private void makeProfile(ScuflType wf) { Profile profile = new Profile(SCUFL + "-" + wf.getVersion()); profile.setParent(parserState.get().getCurrentWorkflowBundle()); parserState.get().getCurrentWorkflowBundle().setMainProfile(profile); parserState.get().setCurrentProfile(profile); }
protected void makeProfile(org.apache.taverna.scufl2.xml.t2flow.jaxb.Workflow wf) { // TODO: What should the default be? Should there be one? Who knows Profile profile = new Profile( wf.getProducedBy() == null ? DEFAULT_PRODUCED_BY : wf.getProducedBy()); profile.setParent(parserState.get().getCurrentWorkflowBundle()); parserState.get().getCurrentWorkflowBundle().setMainProfile(profile); parserState.get().setCurrentProfile(profile); }
protected void parseProfile(Profile original, URI profileUri) { org.apache.taverna.scufl2.api.profiles.Profile p = new org.apache.taverna.scufl2.api.profiles.Profile(); p.setParent(getParserState().getCurrent(WorkflowBundle.class)); getParserState().push(p); if (original.getAbout() != null) { URI about = getParserState().getCurrentBase().resolve( original.getAbout()); mapBean(about, p); } else mapBean(profileUri, p); if (original.getName() != null) p.setName(original.getName()); // Note - we'll pop() in profileSecond() instead }
public WorkflowBundle makeWorkflowBundle() { // Based on // uk.org.taverna.scufl2.scufl2-usecases/src/main/resources/workflows/example/workflowBundle.rdf workflowBundle = new WorkflowBundle(); workflowBundle.setName("HelloWorld"); // NOTE: setSameBaseAs should only be called when loading a workflow // bundle // which already has an ID workflowBundle .setGlobalBaseURI(URI .create("http://ns.taverna.org.uk/2010/workflowBundle/28f7c554-4f35-401f-b34b-516e9a0ef731/")); Workflow workflow = makeMainWorkflow(); workflow.setParent(workflowBundle); workflowBundle.setMainWorkflow(workflow); Profile profile = makeMainProfile(); profile.setParent(workflowBundle); workflowBundle.setMainProfile(profile); Profile secondaryProfile = makeSecondaryProfile(); secondaryProfile.setParent(workflowBundle); Scufl2Tools scufl2Tools = new Scufl2Tools(); scufl2Tools.setParents(workflowBundle); return workflowBundle; }
@Test public void testCorrectnessOfInScopeBoundActivity2() { // Test when in same profile WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Profile otherProfile = new Profile(); otherProfile.setParent(wb); Activity activity = new Activity(); activity.setParent(otherProfile); pb.setBoundActivity(activity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(activity)) { problem = true; } } assertFalse(problem); } }
@Test public void testCorrectnessOfOutOfScopeBoundActivity() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity orphanActivity = new Activity(); pb.setBoundActivity(orphanActivity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(orphanActivity)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor1() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Processor orphanProcessor = new Processor(); pb.setBoundProcessor(orphanProcessor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(orphanProcessor)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor2() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertTrue(problem); }
profile.setParent(wb); profile.newRevision();
@Test public void testCorrectnessOfInScopeBoundActivity1() { // Test when in same profile WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); activity.setParent(profile); pb.setBoundActivity(activity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(activity)) { problem = true; } } assertFalse(problem); }
@Test public void testCorrectnessOfInScopeBoundProcessor() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); w.setParent(wb); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); // assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertFalse(problem); }
@Ignore @Test public void writeBundleFileSetParents() throws Exception { File bundleFile = tempFile(); // Deliberately orphan a profile and a processor Profile profile = wfBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); wfBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); bundleIO.writeBundle(wfBundle, bundleFile, TEXT_VND_TAVERNA_SCUFL2_STRUCTURE); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); String bundleTxt = FileUtils.readFileToString(bundleFile, UTF_8); assertTrue(bundleTxt.contains("Processor 'Hello'")); assertTrue(bundleTxt.contains("Profile 'tavernaWorkbench'")); }
/** * Similar bug to {@link DataLinkCompareTest#dataLinkNotAddedTwice()} */ @Test public void configurationNotAddedTwice() throws Exception { Configuration c1a = new Configuration("c1"); Profile p1 = new Profile("p1"); p1.getConfigurations().add(c1a); c1a.setParent(p1); p1.getConfigurations().add(c1a); Configuration c1b = new Configuration("c1"); Profile p2 = new Profile("p2"); p2.getConfigurations().add(c1b); c1b.setParent(p2); p2.getConfigurations().add(c1b); WorkflowBundle bundle = new WorkflowBundle(); p1.setParent(bundle); p2.setParent(bundle); new Scufl2Tools().setParents(bundle); assertEquals(1, p1.getConfigurations().size()); assertEquals(1, p2.getConfigurations().size()); }
@Test public void setParents() throws Exception { // Deliberately orphan a profile and a processor Profile profile = workflowBundle.getProfiles().getByName("tavernaWorkbench"); profile.setParent(null); workflowBundle.getProfiles().add(profile); processor.setParent(null); workflow.getProcessors().add(processor); assertNull(processor.getParent()); assertNull(profile.getParent()); scufl2Tools.setParents(workflowBundle); assertNotNull(processor.getParent()); assertNotNull(profile.getParent()); }