@SuppressWarnings("boxing") protected Set<OutputProcessorPort> parseProcessorOutputPorts( Processor newProc, GranularDepthPorts origPorts) { Set<OutputProcessorPort> newPorts = new HashSet<>(); for (GranularDepthPort origPort : origPorts.getPort()) { OutputProcessorPort newPort = new OutputProcessorPort(newProc, origPort.getName()); newPort.setDepth(origPort.getDepth().intValue()); newPort.setGranularDepth(origPort.getGranularDepth().intValue()); newPorts.add(newPort); } return newPorts; }
private OutputProcessorPort findOrCreateProcessorOutputPort(Processor p, String name, Integer depth, Integer granularDepth) { OutputProcessorPort port = p.getOutputPorts().getByName(name); if (port == null) { port = new OutputProcessorPort(); port.setParent(p); port.setName(name); port.setDepth(depth); port.setGranularDepth(granularDepth); } return port; }
private void parsePort(Scanner scanner, String next) throws ReaderException { boolean in = next.equals("In"); String portName = parseName(scanner); switch (level) { case Workflow: if (in) new InputWorkflowPort(workflow, portName); else new OutputWorkflowPort(workflow, portName); break; case Processor: if (in) new InputProcessorPort(processor, portName); else new OutputProcessorPort(processor, portName); break; case Activity: if (in) new InputActivityPort(activity, portName); else new OutputActivityPort(activity, portName); break; default: throw new ReaderException("Unexpected " + next + " at level " + level); } }
public Processor createConstant(Workflow workflow, Profile profile, String name) { Processor processor = new Processor(null, name); workflow.getProcessors().addWithUniqueName(processor); processor.setParent(workflow); OutputProcessorPort valuePort = new OutputProcessorPort(processor, CONSTANT_VALUE_PORT); valuePort.setDepth(0); valuePort.setGranularDepth(0); Activity activity = createActivityFromProcessor(processor, profile); activity.setType(CONSTANT); createConfigurationFor(activity, CONSTANT_CONFIG); return processor; }
public void createProcessorPortsFromActivity(Processor processor, Activity activity) { for (InputActivityPort activityPort : activity.getInputPorts()) new InputProcessorPort(processor, activityPort.getName()) .setDepth(activityPort.getDepth()); for (OutputActivityPort activityPort : activity.getOutputPorts()) { OutputProcessorPort procPort = new OutputProcessorPort(processor, activityPort.getName()); procPort.setDepth(activityPort.getDepth()); procPort.setGranularDepth(activityPort.getGranularDepth()); } }
protected void processorOutputProcessorPort( org.apache.taverna.scufl2.xml.OutputProcessorPort original) { org.apache.taverna.scufl2.api.port.OutputProcessorPort port = new org.apache.taverna.scufl2.api.port.OutputProcessorPort(); port.setName(original.getName()); if (original.getPortDepth() != null) port.setDepth(original.getPortDepth().getValue()); if (original.getGranularPortDepth() != null) port.setGranularDepth(original.getGranularPortDepth().getValue()); port.setParent(getParserState().getCurrent( org.apache.taverna.scufl2.api.core.Processor.class)); mapBean(getParserState().getCurrentBase().resolve(original.getAbout()), port); }
@Test public void testCompletenessOfSpecifiedBoundProcessorPort() { ProcessorOutputPortBinding pipb = new ProcessorOutputPortBinding(); pipb.setBoundProcessorPort(new OutputProcessorPort()); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pipb, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(pipb) && nlp.getFieldName().equals("boundProcessorPort")) { problem = true; } } assertFalse(problem); }
new InputProcessorPort(p, "in1"); new InputProcessorPort(p, "in2"); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2"); Profile profile = new Profile(); Activity a = scufl2Tools.createActivityFromProcessor(p, profile); new InputActivityPort(a, "new1"); new InputActivityPort(a, "new2"); new OutputProcessorPort(p, "new3"); new OutputProcessorPort(p, "new4"); new OutputActivityPort(a, "new4"); new OutputActivityPort(a, "new5");
public Processor makeProcessor() { processor = new Processor(workflow, "Hello"); processorName = new InputProcessorPort(processor, "name"); processorName.setDepth(0); processorGreeting = new OutputProcessorPort(processor, "greeting"); processorGreeting.setDepth(0); processorGreeting.setGranularDepth(0); // FIXME: Should not need to make default iteration stack makeIterationStrategyStack(processorName).setParent(processor); return processor; }
@Test public void testCorrectnessOfOutOfScopeProcessorPort1() { ProcessorBinding pb = new ProcessorBinding(); Processor processor = new Processor(); pb.setBoundProcessor(processor); ProcessorOutputPortBinding pipb = new ProcessorOutputPortBinding(); pipb.setParent(pb); OutputProcessorPort orphanPort = new OutputProcessorPort(); pipb.setBoundProcessorPort(orphanPort); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pipb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pipb) && nlp.getFieldName().equals("boundProcessorPort") && nlp.getValue().equals(orphanPort)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfInScopeProcessorPort() { ProcessorBinding pb = new ProcessorBinding(); Processor processor = new Processor(); pb.setBoundProcessor(processor); ProcessorOutputPortBinding pipb = new ProcessorOutputPortBinding(); pipb.setParent(pb); OutputProcessorPort port = new OutputProcessorPort(); port.setParent(processor); pipb.setBoundProcessorPort(port); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pipb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pipb) && nlp.getFieldName().equals("boundProcessorPort") && nlp.getValue().equals(port)) { problem = true; } } assertFalse(problem); }
@Test public void createActivityFromProcessor() throws Exception { Processor p = new Processor(); new InputProcessorPort(p, "in1"); new InputProcessorPort(p, "in2").setDepth(1); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(0); OutputProcessorPort pOut3 = new OutputProcessorPort(p, "out3"); pOut3.setDepth(2); pOut3.setGranularDepth(1); Profile profile = new Profile(); Activity a = scufl2Tools.createActivityFromProcessor(p, profile); assertEquals(profile, a.getParent()); ProcessorBinding binding = scufl2Tools.processorBindingForProcessor(p, profile); assertEquals(2, a.getInputPorts().size()); assertEquals(3, a.getOutputPorts().size()); assertEquals(2, binding.getInputPortBindings().size()); assertEquals(3, binding.getOutputPortBindings().size()); assertEquals(a, binding.getBoundActivity()); assertEquals(p, binding.getBoundProcessor()); }
OutputProcessorPort elsewherePort = new OutputProcessorPort(); elsewherePort.setParent(otherProcessor);
p2.setParent(w); OutputProcessorPort opp = new OutputProcessorPort(); opp.setParent(p2);
@Test public void createActivityPortsFromProcessorWithOverwrite() throws Exception { Processor p = new Processor(); new InputProcessorPort(p, "in1"); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(1); Activity a = new Activity(); new InputActivityPort(a, "other"); OutputActivityPort toBeOverWritten = new OutputActivityPort(a, "out1"); toBeOverWritten.setDepth(1); assertEquals(a, toBeOverWritten.getParent()); scufl2Tools.createActivityPortsFromProcessor(a, p); // Still there assertNotNull(a.getInputPorts().getByName("other")); // but out1 has been overwritten OutputActivityPort aOut1 = a.getOutputPorts().getByName("out1"); assertNull(aOut1.getDepth()); assertNotSame(toBeOverWritten, aOut1); }
p2.setParent(otherWorkflow); OutputProcessorPort opp = new OutputProcessorPort(); opp.setParent(p2);
@Test public void testSimpleIteration() { WorkflowBundle wb = new WorkflowBundle(); Workflow w = new Workflow(); wb.setMainWorkflow(w); InputWorkflowPort a = new InputWorkflowPort(w, "a"); a.setDepth(1); Processor p = new Processor(w, "p"); InputProcessorPort ipp = new InputProcessorPort(p, "in"); ipp.setDepth(0); OutputProcessorPort opp = new OutputProcessorPort(p, "out"); opp.setDepth(3); DataLink inLink = new DataLink(w, a, ipp); IterationStrategyStack iss = new IterationStrategyStack(p); CrossProduct cp = new CrossProduct(); iss.add(cp); PortNode portNode = new PortNode(cp, ipp); portNode.setDesiredDepth(0); StructuralValidator sv = new StructuralValidator(); ReportStructuralValidationListener l = new ReportStructuralValidationListener(); sv.checkStructure(wb, l); ValidatorState vs = sv.getValidatorState(); assertEquals(0, l.getIncompleteWorkflows().size()); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(a)); assertEquals(Integer.valueOf(1), vs.getDataLinkResolvedDepth(inLink)); assertEquals(Integer.valueOf(1), vs.getPortResolvedDepth(ipp)); assertEquals(Integer.valueOf(4), vs.getPortResolvedDepth(opp)); }
new InputProcessorPort(p, "in2").setDepth(1); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(0); OutputProcessorPort pOut3 = new OutputProcessorPort(p, "out3"); pOut3.setDepth(2); pOut3.setGranularDepth(1);
@Test public void testInScopeProcessorPorts() { Workflow w = new Workflow(); DataLink dataLink = new DataLink(); dataLink.setParent(w); Processor p1 = new Processor(); p1.setParent(w); InputProcessorPort ipp = new InputProcessorPort(); ipp.setParent(p1); Processor p2 = new Processor(); p2.setParent(w); OutputProcessorPort opp = new OutputProcessorPort(); opp.setParent(p2); dataLink.setReceivesFrom(opp); dataLink.setSendsTo(ipp); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dataLink, true, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertEquals(Collections.EMPTY_SET, outOfScopeValueProblems); }
@Test public void createProcessorPortsFromActivityWithOverwrite() throws Exception { Activity a = new Activity(); new InputActivityPort(a, "in1"); new OutputActivityPort(a, "out1"); new OutputActivityPort(a, "out2").setDepth(1); Processor p = new Processor(); new InputProcessorPort(p, "other"); OutputProcessorPort toBeOverWritten = new OutputProcessorPort(p, "out1"); toBeOverWritten.setDepth(1); assertEquals(p, toBeOverWritten.getParent()); scufl2Tools.createProcessorPortsFromActivity(p, a); // Still there assertNotNull(p.getInputPorts().getByName("other")); // but out1 has been overwritten OutputProcessorPort pOut1 = p.getOutputPorts().getByName("out1"); assertNull(pOut1.getDepth()); assertNotSame(toBeOverWritten, pOut1); }