/** * Returns the name of the <code>Workflow</code> to run. If no * <code>Workflow</code> name is set the main <code>Workflow</code> from the * <code>WorkflowBundle</code> will be run. * * @return the <code>Workflow</code> to run */ public String getWorkflowName() { if (workflowName == null && workflowBundle.getMainWorkflow() != null) return workflowBundle.getMainWorkflow().getName(); return workflowName; }
@Override public String getRunName(String runID) throws InvalidRunIdException { WorkflowReport workflowReport = getWorkflowReport(runID); return workflowReport.getSubject().getName() + "_" + ISO_8601.format(workflowReport.getCreatedDate()); }
private int getLongestName(WorkflowReport workflowReport, int level) { int result = 0; result = Math.max(result, getSubject().getName().length() + level); for (ProcessorReport processorReport : workflowReport.getProcessorReports()) { result = Math.max(result, processorReport.getSubject().getName().length()); for (ActivityReport activityReport : processorReport.getActivityReports()) { WorkflowReport nestedWorkflowReport = activityReport.getNestedWorkflowReport(); if (nestedWorkflowReport != null) result = Math.max(result, getLongestName(nestedWorkflowReport, level + 1)); } } return result; }
@Override public String toString() { DateFormat dateFormat = new SimpleDateFormat(dateFormatString); StringBuilder sb = new StringBuilder(); int max = getLongestName(this, 0); spaces(sb, max + 1); sb.append("Status "); sb.append("Queued "); sb.append("Started "); sb.append("Complete "); sb.append("Errors "); sb.append("Started "); sb.append("Finished\n"); sb.append(getSubject().getName()); spaces(sb, max - getSubject().getName().length() + 1); sb.append(getState()); spaces(sb, 10 - getState().name().length()); sb.append("-"); spaces(sb, 9); sb.append("-"); spaces(sb, 9); sb.append("-"); spaces(sb, 9); sb.append("-"); spaces(sb, 9); addDates(sb, getStartedDate(), getCompletedDate(), dateFormat); for (ProcessorReport processorReport : getProcessorReports()) addProcessor(sb, max, 0, processorReport, dateFormat); return sb.toString(); }
@Override public Configuration parseConfiguration(T2FlowParser t2FlowParser, ConfigBean configBean, ParserState parserState) throws ReaderException { DataflowConfig dataflowConfig = unmarshallConfig(t2FlowParser, configBean, "dataflow", DataflowConfig.class); Configuration configuration = new Configuration(); configuration.setType(nestedUri.resolve("#Config")); String wfId = dataflowConfig.getRef(); URI wfUri = WORKFLOW_ROOT.resolve(wfId + "/"); Workflow wf = (Workflow) getUriTools().resolveUri(wfUri, parserState.getCurrentWorkflowBundle()); if (wf == null) throw new ReaderException("Can't find nested workflow with id " + wfId); ObjectNode json = configuration.getJsonAsObjectNode(); json.put("nestedWorkflow", wf.getName()); return configuration; }
/** * Test method for * {@link org.apache.taverna.platform.run.api.RunProfile#RunProfile(org.apache.taverna.scufl2.api.container.WorkflowBundle, org.apache.taverna.scufl2.api.core.Workflow, org.apache.taverna.scufl2.api.profiles.Profile, java.util.Map, org.apache.taverna.reference.ReferenceService, org.apache.taverna.platform.execution.api.ExecutionService)} * . */ @Test public void testRunProfileWorkflowBundleWorkflowProfileMapOfStringT2ReferenceReferenceServiceExecutionService() { runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle); }
@Test public void workflow() throws Exception { Workflow wf = new Workflow(); UUID uuid = UUID.fromString(wf.getName()); assertEquals(4, uuid.version()); }
/** * Test method for * {@link org.apache.taverna.platform.run.api.RunProfile#setWorkflow(org.apache.taverna.scufl2.api.core.Workflow)} * . */ @Test public void testSetWorkflow() { runProfile.setWorkflowName(null); assertNotNull(runProfile.getWorkflowName()); assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName()); runProfile.setWorkflowBundle(new WorkflowBundle()); runProfile.setWorkflowName(null); assertNull(runProfile.getWorkflowName()); runProfile.setWorkflowName(workflow.getName()); assertEquals(workflow.getName(), runProfile.getWorkflowName()); runProfile.setWorkflowName(mainWorkflow.getName()); assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName()); }
} else logger.warning("Can't find bundle URI for workflow document " + wf.getName());
@Test public void readBundleStream() throws Exception { InputStream inputStream = new ByteArrayInputStream( getStructureFormatWorkflowBundle().getBytes("utf-8")); WorkflowBundle wfBundle = bundleIO.readBundle(inputStream, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertEquals("HelloWorld", wfBundle.getName()); assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName()); assertTrue(wfBundle.getMainWorkflow().getProcessors() .containsName("Hello")); }
/** * Test method for * {@link org.apache.taverna.platform.run.api.RunProfile#getWorkflow()}. */ @Test public void testGetWorkflow() { assertNotNull(runProfile.getWorkflowName()); assertEquals(workflow.getName(), runProfile.getWorkflowName()); assertEquals(runProfile.getWorkflowName(), runProfile.getWorkflowName()); runProfile.setWorkflowName(null); assertNotNull(runProfile.getWorkflowName()); assertEquals(mainWorkflow.getName(), runProfile.getWorkflowName()); }
@Test public void awkwardFilenames() throws Exception { workflowBundle.getProfiles().removeByName("tavernaServer"); String funnyName = "Funny_%2f_characters_50%_of the time"; workflowBundle.getMainProfile().setName(funnyName); workflowBundle.getMainWorkflow().setName(funnyName); File bundleFile = tempFile(); bundleIO.writeBundle(workflowBundle, bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); UCFPackage ucfPackage = new UCFPackage(bundleFile); Map<String, ResourceEntry> profiles = ucfPackage.listResources("profile"); assertEquals(2, profiles.size()); assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time.rdf")); assertTrue(profiles.keySet().contains("Funny_%252f_characters_50%25_of%20the%20time/")); Map<String, ResourceEntry> workflows = ucfPackage.listResources("workflow"); assertEquals(1, workflows.size()); assertEquals("Funny_%252f_characters_50%25_of%20the%20time.rdf", workflows.keySet().iterator().next()); // and.. can we read it in again correctly? WorkflowBundle readBundle = bundleIO.readBundle(bundleFile, APPLICATION_VND_TAVERNA_SCUFL2_WORKFLOW_BUNDLE); assertEquals(funnyName, readBundle.getMainProfile().getName()); assertEquals(funnyName, readBundle.getMainWorkflow().getName()); // did the JSON parse back in? JsonNode oldJson = workflowBundle.getMainProfile().getConfigurations().getByName("Hello").getJson(); assertTrue(oldJson.get("script").asText().startsWith("hello")); JsonNode newJson = readBundle.getMainProfile().getConfigurations().getByName("Hello").getJson(); assertTrue(newJson.get("script").asText().startsWith("hello")); assertEquals(oldJson, newJson); }
@Ignore @Test public void getWorkflowBundle() throws Exception { WorkflowBundleIO wfBundleIO = new WorkflowBundleIO(); WorkflowBundle wfBundle = wfBundleIO.createBundle(); String name = wfBundle.getName(); String wfName = wfBundle.getMainWorkflow().getName(); URI id = wfBundle.getIdentifier(); DataBundles.setWorkflowBundle(dataBundle, wfBundle); // Reload the bundle wfBundle = DataBundles.getWorkflowBundle(dataBundle); assertEquals(name, wfBundle.getName()); assertEquals(wfName, wfBundle.getMainWorkflow().getName()); assertEquals(id, wfBundle.getIdentifier()); }
@Test public void readBundleFile() throws Exception { File bundleFile = tempFile(); FileUtils.writeStringToFile(bundleFile, getStructureFormatWorkflowBundle(), UTF_8); WorkflowBundle wfBundle = bundleIO.readBundle(bundleFile, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertEquals("HelloWorld", wfBundle.getName()); assertEquals("HelloWorld", wfBundle.getMainWorkflow().getName()); assertTrue(wfBundle.getMainWorkflow().getProcessors() .containsName("Hello")); }
@Test public void workflows() throws Exception { assertEquals(1, workflowBundle.getWorkflows().size()); Workflow helloWorld = workflowBundle.getWorkflows().getByName( "HelloWorld"); assertEquals("HelloWorld", helloWorld.getName()); assertEquals(workflowBundle.getMainWorkflow(), helloWorld); }
@Test public void cloneWorkflow() throws Exception { Workflow original = originalWfBundle.getMainWorkflow(); assertEquals(originalWfBundle, original.getParent()); Workflow clone = (Workflow) original.clone(); assertNull(clone.getParent()); assertEquals(original.getName(), clone.getName()); assertNotSame(original.getProcessors().getByName("Hello"), clone .getProcessors().getByName("Hello")); assertNotSame(original.getCurrentRevision(), clone.getCurrentRevision()); assertEquals(original.getCurrentRevision(), clone.getCurrentRevision()); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { workflow = new Workflow(); mainWorkflow = new Workflow(); profile = new Profile(); mainProfile = new Profile(); workflowBundle = new WorkflowBundle(); workflowBundle.setMainProfile(mainProfile); workflowBundle.setMainWorkflow(mainWorkflow); executionService = new LocalExecutionService(); executionEnvironment = new LocalExecutionEnvironment(executionService, null, null); dataBundle = DataBundles.createBundle(); runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle); }
@Test public void createBundle() throws Exception { WorkflowBundle wb = bundleIO.createBundle(); assertEquals(wb, wb.getMainWorkflow().getParent()); assertEquals(wb, wb.getMainProfile().getParent()); assertEquals("bundle1", wb.getName()); assertEquals("workflow1", wb.getMainWorkflow().getName()); assertEquals("profile1", wb.getMainProfile().getName()); assertNotNull(wb.getCurrentRevision()); assertNotNull(wb.getMainWorkflow().getCurrentRevision()); assertNotNull(wb.getMainProfile().getCurrentRevision()); }