@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); } }
inputPort.setDepth(depth.intValue());
inputActivityPort.setDepth(inputProcessorPort.getDepth());
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"); iap.setParent(null);
@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 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 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()); }
Activity a = new Activity(); new InputActivityPort(a, "in1"); new InputActivityPort(a, "in2").setDepth(1);