@Override public Configuration parseConfiguration(T2FlowParser t2FlowParser, ConfigBean configBean, ParserState parserState) throws ReaderException { StringConstantConfig strConfig = unmarshallConfig(t2FlowParser, configBean, "xstream", StringConstantConfig.class); String value = strConfig.getValue(); if (value == null) throw new ReaderException("String constant configuration has no value set"); Configuration configuration = new Configuration(); ObjectNode json = (ObjectNode) configuration.getJson(); configuration.setType(CONSTANT.resolve("#Config")); json.put("string", value); Activity activity = parserState.getCurrentActivity(); OutputActivityPort valuePort = new OutputActivityPort(activity, VALUE); valuePort.setDepth(0); valuePort.setGranularDepth(0); return configuration; } }
@Override public Set<OutputActivityPort> getActivityOutputPorts(URI activityType, JsonNode configuration) throws ActivityNotFoundException, ActivityConfigurationException { Set<OutputActivityPort> outputPorts = new HashSet<>(); try { for (ActivityOutputPort port : getActivityFactory(activityType) .getOutputPorts(configuration)) { OutputActivityPort outputActivityPort = new OutputActivityPort(); outputActivityPort.setName(port.getName()); outputActivityPort.setDepth(port.getDepth()); outputActivityPort.setGranularDepth(port.getGranularDepth()); outputPorts.add(outputActivityPort); } } catch (org.apache.taverna.workflowmodel.processor.activity.ActivityConfigurationException e) { throw new ActivityConfigurationException(e); } return outputPorts; }
BigInteger.class); if (granularDepth != null) outputPort.setGranularDepth(granularDepth.intValue());
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()); } }
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; }
outputActivityPort.setDepth(outputProcessorPort.getDepth()); if (outputActivityPort.getGranularDepth() == null) outputActivityPort.setGranularDepth(outputProcessorPort .getGranularDepth());
OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(0)); oap.setGranularDepth(new Integer(1)); oap.setName("fred"); oap.setParent(null);
@Test public void testCorrectnessOfGranularDepthSpecifiedIncorrectly() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(new Integer(-2)); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(1, negativeValueProblems.size()); if (!negativeValueProblems.isEmpty()) { NegativeValueProblem problem = negativeValueProblems.iterator().next(); assertEquals(problem.getBean(), oap); assertEquals(problem.getFieldName(), "granularDepth"); assertEquals(problem.getFieldValue(), Integer.valueOf("-2")); } Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(0, nullFieldProblems.size()); // only done when completeness check assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
@Test public void testCorrectnessOfMissingGranularDepth() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(null); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(0, nullFieldProblems.size()); // only done when completeness check assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
protected void parseOutputActivityPort( org.apache.taverna.scufl2.xml.OutputActivityPort original) { OutputActivityPort port = new OutputActivityPort(); mapBean(original.getAbout(), port); port.setParent(getParserState().getCurrent(Activity.class)); port.setName(original.getName()); if (original.getPortDepth() != null) port.setDepth(original.getPortDepth().getValue()); if (original.getGranularPortDepth() != null) port.setGranularDepth(original.getGranularPortDepth().getValue()); }
OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(new Integer(-2)); oap.setName("fred"); oap.setParent(null);
@Test public void testCompletenessOfMissingGranularDepth() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(null); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, true, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(2, nullFieldProblems.size()); // granular depth and parent boolean granularDepthFieldProblem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(oap) && nlp.getFieldName().equals("granularDepth")) { granularDepthFieldProblem = true; } } assertTrue(granularDepthFieldProblem); assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
@Override public void parseScuflObject(Object o) { StringconstantType sc = (StringconstantType) o; Configuration configuration = new Configuration(); configuration.setParent(getParserState().getCurrentProfile()); configuration.setType(CONSTANT.resolve("#Config")); ((ObjectNode) configuration.getJson()).put("string", sc.getValue()); Activity activity = new Activity(); getParserState().setCurrentActivity(activity); activity.setParent(getParserState().getCurrentProfile()); activity.setType(CONSTANT); OutputActivityPort valuePort = new OutputActivityPort(activity, VALUE); valuePort.setDepth(0); valuePort.setGranularDepth(0); configuration.setConfigures(activity); ProcessorBinding pb = new ProcessorBinding(); pb.setParent(getParserState().getCurrentProfile()); pb.setBoundProcessor(getParserState().getCurrentProcessor()); pb.setBoundActivity(activity); } }
@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()); }