public File(String name, Type type, Format format, Bioformat bioformat, URI uri, String path, String checksum, String creationDate, String modificationDate, String description, FileStatus status, boolean external, long size, Software software, Experiment experiment, List<Sample> samples, Job job, List<RelatedFile> relatedFiles, FileIndex index, int release, List<AnnotationSet> annotationSets, Map<String, Object> stats, Map<String, Object> attributes) { this.id = StringUtils.isNotEmpty(path) ? StringUtils.replace(path, "/", ":") : path; this.name = name; this.type = type; this.format = format; this.bioformat = bioformat; this.uri = uri; this.path = path; this.checksum = checksum; this.creationDate = creationDate; this.modificationDate = modificationDate; this.description = description; this.status = status; this.release = release; this.external = external; this.size = size; this.software = software; this.experiment = experiment; this.samples = samples; this.tags = Collections.emptyList(); this.job = job; this.relatedFiles = relatedFiles; this.index = index != null ? index : new FileIndex(); this.annotationSets = annotationSets; this.stats = stats; this.attributes = attributes; }
public File(String name, Type type, Format format, Bioformat bioformat, String path, String description, FileStatus status, long size, int release) { this(name, type, format, bioformat, null, path, null, TimeUtils.getTime(), TimeUtils.getTime(), description, status, false, size, null, new Experiment(), Collections.emptyList(), new Job(), Collections.emptyList(), new FileIndex(), release, Collections.emptyList(), Collections.emptyMap(), Collections.emptyMap()); }
public File(Type type, Format format, Bioformat bioformat, String path, String description, FileStatus status, long size, List<Sample> samples, long jobId, Software software, Map<String, Object> stats, Map<String, Object> attributes) { this("", type, format, bioformat, null, path, null, TimeUtils.getTime(), TimeUtils.getTime(), description, status, false, size, software, new Experiment(), samples, new Job().setUid(jobId), Collections.emptyList(), new FileIndex(), -1, Collections.emptyList(), stats, attributes); }
file.setIndex(new FileIndex("", "", new FileIndex.IndexStatus(Status.READY, ""), -1, Collections.emptyMap())); file.setSamples(samples);
public static File create(String resourceName, boolean indexed) throws IOException, CatalogException { File file; URI uri = getResourceUri(resourceName); file = fileMetadataReader.create(studyId, uri, "data/vcfs/", "", true, null, sessionId).first(); catalogFileUtils.upload(uri, file, null, sessionId, false, false, true, false, Long.MAX_VALUE); if (indexed) { FileIndex fileIndex = new FileIndex("user", "today", new FileIndex.IndexStatus(FileIndex.IndexStatus.READY), 1234, Collections.emptyMap()); catalogManager.getFileManager().setFileIndex(studyId, file.getPath(), fileIndex, sessionId); indexedFiles.add((int) file.getUid()); List<String> samples = catalogManager.getCohortManager().getSamples(studyId, cohortId, null, sessionId).getResult().stream().map(Sample::getId).collect(Collectors.toList()); samples.addAll(file.getSamples().stream().map(Sample::getId).collect(Collectors.toList())); catalogManager.getCohortManager().update(studyId, cohortId, new ObjectMap(CohortDBAdaptor.QueryParams.SAMPLES.key(), samples), true, null, sessionId); } return catalogManager.getFileManager().get(studyId, file.getId(), null, sessionId).first(); }
if (!status.equals(FileIndex.IndexStatus.READY)) { final FileIndex index; index = file.getIndex() == null ? new FileIndex() : file.getIndex(); if (index.getStatus() == null) { index.setStatus(new FileIndex.IndexStatus()); index = file.getIndex() == null ? new FileIndex() : file.getIndex(); String prevStatus = index.getStatus().getName(); String newStatus;
public QueryResult<FileIndex> updateFileIndexStatus(File file, String newStatus, String message, Integer release, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); Long studyId = file.getStudyUid(); authorizationManager.checkFilePermission(studyId, file.getUid(), userId, FileAclEntry.FilePermissions.WRITE); FileIndex index = file.getIndex(); if (index != null) { if (!FileIndex.IndexStatus.isValid(newStatus)) { throw new CatalogException("The status " + newStatus + " is not a valid status."); } else { index.setStatus(new FileIndex.IndexStatus(newStatus, message)); } } else { index = new FileIndex(userId, TimeUtils.getTime(), new FileIndex.IndexStatus(newStatus), -1, new ObjectMap()); } if (release != null) { if (newStatus.equals(FileIndex.IndexStatus.READY)) { index.setRelease(release); } } ObjectMap params = new ObjectMap(FileDBAdaptor.QueryParams.INDEX.key(), index); fileDBAdaptor.update(file.getUid(), params, QueryOptions.empty()); auditManager.recordUpdate(AuditRecord.Resource.file, file.getUid(), userId, params, null, null); return new QueryResult<>("Update file index", 0, 1, 1, "", "", Arrays.asList(index)); }