@Deprecated public QueryResult<Job> create(long studyId, String name, String toolName, String description, String executor, Map<String, String> params, String commandLine, URI tmpOutDirUri, long outDirId, List<File> inputFiles, List<File> outputFiles, Map<String, Object> attributes, Map<String, Object> resourceManagerAttributes, Job.JobStatus status, long startTime, long endTime, QueryOptions options, String sessionId) throws CatalogException { Job job = new Job(-1, null, name, "", toolName, null, "", description, startTime, endTime, executor, "", commandLine, false, status, -1, new File().setUid(outDirId), inputFiles, outputFiles, Collections.emptyList(), params, -1, attributes, resourceManagerAttributes); return create(String.valueOf(studyId), job, options, sessionId); }
@Test public void getJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); job = catalogJobDBAdaptor.get(jobId, null).first(); System.out.println(job); try { catalogJobDBAdaptor.get(-1, null); fail("error: expected exception"); } catch (CatalogDBException e) { System.out.println("correct exception: " + e); } }
@Test public void updateInputAndOutputFiles() throws Exception { Job job = new Job() .setOutDir(new File().setUid(5)) .setStatus(new Job.JobStatus()); long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); job.setName("jobName1"); QueryResult<Job> insert = catalogJobDBAdaptor.insert(job, studyId, null); List<File> fileInput = Arrays.asList( new File().setUid(5L).setName("file1").setStatus(new File.FileStatus()), new File().setUid(6L).setName("file2").setStatus(new File.FileStatus()), new File().setUid(7L).setName("file3").setStatus(new File.FileStatus()) ); List<File> fileOutput = Arrays.asList( new File().setUid(15L).setName("file1").setStatus(new File.FileStatus()), new File().setUid(16L).setName("file2").setStatus(new File.FileStatus()), new File().setUid(17L).setName("file3").setStatus(new File.FileStatus()) ); ObjectMap params = new ObjectMap() .append(JobDBAdaptor.QueryParams.INPUT.key(), fileInput) .append(JobDBAdaptor.QueryParams.OUTPUT.key(), fileOutput); QueryResult<Job> update = catalogJobDBAdaptor.update(insert.first().getUid(), params, QueryOptions.empty()); assertEquals(3, update.first().getInput().size()); assertEquals(3, update.first().getOutput().size()); assertTrue(Arrays.asList(5L, 6L, 7L).containsAll(update.first().getInput().stream().map(File::getUid).collect(Collectors.toList()))); assertTrue(Arrays.asList(15L, 16L, 17L) .containsAll(update.first().getOutput().stream().map(File::getUid).collect(Collectors.toList()))); }
@Test public void deleteJobTest() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job job = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = job.getUid(); assertEquals(Job.JobStatus.PREPARED, job.getStatus().getName()); catalogJobDBAdaptor.delete(jobId); thrown.expect(CatalogDBException.class); thrown.expectMessage("not exist"); catalogJobDBAdaptor.get(jobId, QueryOptions.empty()); }
file.setUid(newFileId); file.setStudyUid(studyId); if (StringUtils.isEmpty(file.getUuid())) {
File file = new File("name", File.Type.FILE, File.Format.BAM, File.Bioformat.MICROARRAY_EXPRESSION_ONECHANNEL_AGILENT, "test/base", "convertorTest", new File.FileStatus("READY"), 1111L, 2); file.setUid(111).setSamples(Arrays.asList(new Sample().setId("1"), new Sample().setId("2"))) .setSoftware(new Software().setName("Software")); file.setAnnotationSets(AnnotationHelper.createAnnotation());
@Test public void SetVisitedJob() throws CatalogException { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Job jobBefore = catalogJobDBAdaptor.insert(new Job("name", user3.getId(), "", "", "", new File().setUid(4), Collections.emptyList(), 1), studyId, null).first(); long jobId = jobBefore.getUid(); assertTrue(!jobBefore.isVisited()); ObjectMap params = new ObjectMap(JobDBAdaptor.QueryParams.VISITED.key(), true); catalogJobDBAdaptor.update(jobBefore.getUid(), params, QueryOptions.empty()); Job jobAfter = catalogJobDBAdaptor.get(jobId, null).first(); assertTrue(jobAfter.isVisited()); }