@Override public Set<InputActivityPort> getActivityInputPorts(URI activityType, JsonNode configuration) throws ActivityNotFoundException, ActivityConfigurationException { Set<InputActivityPort> inputPorts = new HashSet<>(); try { for (ActivityInputPort port : getActivityFactory(activityType) .getInputPorts(configuration)) { InputActivityPort inputActivityPort = new InputActivityPort(); inputActivityPort.setName(port.getName()); inputActivityPort.setDepth(port.getDepth()); inputPorts.add(inputActivityPort); } return inputPorts; } catch (org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException e) { throw new ActivityConfigurationException(e); } }
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); } }
ObjectNode portConfig = configResource.objectNode(); InputActivityPort inputPort = new InputActivityPort(); inputPort.setName(getPortElement(portBean, "name", String.class)); inputPort.setParent(activity);
.getByName(toActivityOutput); if (inputActivityPort == null) { inputActivityPort = new InputActivityPort(); inputActivityPort.setName(toActivityOutput); inputActivityPort.setParent(parserState.get()
public Activity makeActivity() { activity = new Activity(); activity.setName("HelloScript"); activity.setType(URI .create("http://ns.taverna.org.uk/2010/activity/beanshell")); personName = new InputActivityPort(activity, "personName"); personName.setDepth(0); hello = new OutputActivityPort(activity, "hello"); hello.setDepth(0); hello.setGranularDepth(0); return activity; }
public void createActivityPortsFromProcessor(Activity activity, Processor processor) { for (InputProcessorPort processorPort : processor.getInputPorts()) new InputActivityPort(activity, processorPort.getName()) .setDepth(processorPort.getDepth()); for (OutputProcessorPort processorPort : processor.getOutputPorts()) { OutputActivityPort activityPort = new OutputActivityPort(activity, processorPort.getName()); activityPort.setDepth(processorPort.getDepth()); activityPort.setGranularDepth(processorPort.getGranularDepth()); } }
protected void parseInputActivityPort( org.apache.taverna.scufl2.xml.InputActivityPort original) { InputActivityPort port = new InputActivityPort(); mapBean(original.getAbout(), port); port.setParent(getParserState().getCurrent(Activity.class)); port.setName(original.getName()); if (original.getPortDepth() != null) port.setDepth(original.getPortDepth().getValue()); }
@Test public void testCompletenessOfDepthSpecifiedIncorrectly() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(new Integer(-3)); iap.setName("fred");
@Test public void testCorrectnessOfDepthSpecifiedIncorrectly() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(new Integer(-3)); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(1, negativeValueProblems.size()); if (!negativeValueProblems.isEmpty()) { NegativeValueProblem problem = negativeValueProblems.iterator().next(); assertEquals(problem.getBean(), iap); assertEquals(problem.getFieldName(), "depth"); assertEquals(problem.getFieldValue(), Integer.valueOf("-3")); } Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); // only done when completeness check }
@Test public void testCompletenessOfSpecifiedBoundActivityPort() { ProcessorInputPortBinding pipb = new ProcessorInputPortBinding(); pipb.setBoundActivityPort(new InputActivityPort()); 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("boundActivityPort")) { problem = true; } } assertFalse(problem); }
@Test public void testCompletenessOfMissingDepth() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(null); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, true, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertFalse(nullFieldProblems.isEmpty()); // depth and parent boolean depthFieldProblem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(iap) && nlp.getFieldName().equals("depth")) { depthFieldProblem = true; } } assertTrue(depthFieldProblem); }
@Test public void testCorrectnessOfOutOfScopeActivityPort1() { ProcessorBinding pb = new ProcessorBinding(); Processor processor = new Processor(); pb.setBoundProcessor(processor); ProcessorInputPortBinding pipb = new ProcessorInputPortBinding(); pipb.setParent(pb); InputActivityPort orphanPort = new InputActivityPort(); pipb.setBoundActivityPort(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("boundActivityPort") && nlp.getValue().equals(orphanPort)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfInScopeActivityPort() { ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); pb.setBoundActivity(activity); ProcessorInputPortBinding pipb = new ProcessorInputPortBinding(); pipb.setParent(pb); InputActivityPort port = new InputActivityPort(); port.setParent(activity); pipb.setBoundActivityPort(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("boundActivityPort") && nlp.getValue().equals(port)) { problem = true; } } assertFalse(problem); }
new InputActivityPort(a, "new1"); new InputActivityPort(a, "new2"); new OutputProcessorPort(p, "new3"); new OutputProcessorPort(p, "new4");
InputActivityPort elsewherePort = new InputActivityPort(); elsewherePort.setParent(otherActivity);
@Test public void testCorrectnessOfMissingDepth() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(null); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); // only done when completeness check }
@Test public void createProcessorFromActivity() throws Exception { Profile profile = new Profile(); Activity a = new Activity(); a.setParent(profile); new InputActivityPort(a, "in1"); new InputActivityPort(a, "in2").setDepth(1); new OutputActivityPort(a, "out1"); new OutputActivityPort(a, "out2").setDepth(0); OutputActivityPort aOut3 = new OutputActivityPort(a, "out3"); aOut3.setDepth(2); aOut3.setGranularDepth(1); ProcessorBinding binding = scufl2Tools.createProcessorAndBindingFromActivity(a); Processor p = binding.getBoundProcessor(); assertEquals(profile, binding.getParent()); assertEquals(2, p.getInputPorts().size()); assertEquals(3, p.getOutputPorts().size()); assertEquals(2, binding.getInputPortBindings().size()); assertEquals(3, binding.getOutputPortBindings().size()); assertEquals(a, binding.getBoundActivity()); assertEquals(p, binding.getBoundProcessor()); }
@Test public void createProcessorPortsFromActivity() throws Exception { Activity a = new Activity(); new InputActivityPort(a, "in1"); new InputActivityPort(a, "in2").setDepth(1);
@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); }
@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); }