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); }
@Override public QueryResult<Job> insert(Job job, long studyId, QueryOptions options) throws CatalogDBException { long startTime = startQuery(); this.dbAdaptorFactory.getCatalogStudyDBAdaptor().checkId(studyId); List<Bson> filterList = new ArrayList<>(); filterList.add(Filters.eq(QueryParams.ID.key(), job.getId())); filterList.add(Filters.eq(PRIVATE_STUDY_ID, studyId)); filterList.add(Filters.eq(QueryParams.STATUS_NAME.key(), Status.READY)); Bson bson = Filters.and(filterList); QueryResult<Long> count = jobCollection.count(bson); if (count.getResult().get(0) > 0) { throw new CatalogDBException("Job { id: '" + job.getId() + "'} already exists."); } long jobId = getNewId(); job.setUid(jobId); job.setStudyUid(studyId); if (StringUtils.isEmpty(job.getUuid())) { job.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.JOB)); } Document jobObject = jobConverter.convertToStorageType(job); if (StringUtils.isNotEmpty(job.getCreationDate())) { jobObject.put(PRIVATE_CREATION_DATE, TimeUtils.toDate(job.getCreationDate())); } else { jobObject.put(PRIVATE_CREATION_DATE, TimeUtils.getDate()); } jobObject.put(PERMISSION_RULES_APPLIED, Collections.emptyList()); jobCollection.insert(jobObject, null); //TODO: Check results.get(0).getN() != 0 return endQuery("Create Job", startTime, get(jobId, filterOptions(options, FILTER_ROUTE_JOBS))); }