ObjectNode portConfig = configResource.objectNode(); InputActivityPort inputPort = new InputActivityPort(); inputPort.setName(getPortElement(portBean, "name", String.class)); inputPort.setParent(activity); inputPort.setDepth(depth.intValue()); portConfig.put("name", inputPort.getName()); portConfig.put("depth", inputPort.getDepth());
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()); }
@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 inputActivityPort(InputActivityPort node) { org.apache.taverna.scufl2.xml.InputActivityPort inputActivityPort = objectFactory .createInputActivityPort(); inputActivityPort.setAbout(uri(node)); inputActivityPort.setName(node.getName()); inputActivityPort.setPortDepth(portDepth(node.getDepth())); org.apache.taverna.scufl2.xml.Activity.InputActivityPort wrapper = objectFactory .createActivityInputActivityPort(); wrapper.setInputActivityPort(inputActivityPort); activity.getInputActivityPort().add(wrapper); }
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()); } }
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); } }
@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); }
assertEquals(expectedInputs, concatAct.getInputPorts().getNames()); InputActivityPort s1 = concatAct.getInputPorts().getByName("string1"); assertEquals(0, s1.getDepth().intValue()); InputActivityPort s2 = concatAct.getInputPorts().getByName("string2"); assertEquals(0, s2.getDepth().intValue()); InputActivityPort inputList = echoAct.getInputPorts().getByName( "inputlist"); assertEquals(1, inputList.getDepth().intValue());
public void bindActivityToProcessorByMatchingPorts(ProcessorBinding binding) { Activity activity = binding.getBoundActivity(); Processor processor = binding.getBoundProcessor(); for (InputActivityPort activityPort : activity.getInputPorts()) { InputProcessorPort processorPort = processor.getInputPorts() .getByName(activityPort.getName()); if (processorPort != null && processorPortBindingInternalInBinding(processorPort, binding) == null) new ProcessorInputPortBinding(binding, processorPort, activityPort); } for (OutputProcessorPort processorPort : processor.getOutputPorts()) { OutputActivityPort activityPort = activity.getOutputPorts() .getByName(processorPort.getName()); if (activityPort != null && processorPortBindingInternalInBinding(activityPort, binding) == null) new ProcessorOutputPortBinding(binding, activityPort, processorPort); } }
/** * Constructs an <code>InputPort</code> for the specified * <code>Activity</code> with the specified name. * <p> * The <code>InputPort</code> is added to the <code>Activity</code> (if the * <code>Activity</code> is not <code>null</code>). * * @param activity * the <code>Activity</code> to add this <code>Port</code> to. * Can be <code>null</code> * @param name * the name of the <code>Port</code>. <strong>Must not</strong> * be <code>null</code> or an empty String. */ public InputActivityPort(Activity activity, String name) { super(name); setParent(activity); }
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()); } }
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; }
@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); }
InputActivityPort elsewherePort = new InputActivityPort(); elsewherePort.setParent(otherActivity);
for (ProcessorInputPortBinding ip : pb.getInputPortBindings()) links.add("'" + escapeName(ip.getBoundProcessorPort().getName()) + "' -> '" + escapeName(ip.getBoundActivityPort().getName()) + "'"); Collections.sort(links); if (!links.isEmpty()) {
private void createDefaultProcessorBinding() { Processor p = parserState.get().getCurrentProcessor(); Activity a = parserState.get().getCurrentActivity(); ProcessorBinding pb = new ProcessorBinding(); pb.setParent(parserState.get().getCurrentProfile()); pb.setActivityPosition(0); pb.setBoundProcessor(p); pb.setBoundActivity(a); for (InputActivityPort iap : a.getInputPorts()) { InputProcessorPort ipp = findOrCreateProcessorInputPort(p, iap.getName(), iap.getDepth()); ProcessorInputPortBinding portBinding = new ProcessorInputPortBinding(); portBinding.setParent(pb); portBinding.setBoundActivityPort(iap); portBinding.setBoundProcessorPort(ipp); } for (OutputActivityPort oap : a.getOutputPorts()) { OutputProcessorPort opp = findOrCreateProcessorOutputPort(p, oap.getName(), oap.getDepth(), oap.getGranularDepth()); ProcessorOutputPortBinding portBinding = new ProcessorOutputPortBinding(); portBinding.setParent(pb); portBinding.setBoundActivityPort(oap); portBinding.setBoundProcessorPort(opp); } }
@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 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); }
.getByName(toActivityOutput); if (inputActivityPort == null) { inputActivityPort = new InputActivityPort(); inputActivityPort.setName(toActivityOutput); inputActivityPort.setParent(parserState.get() .getCurrentActivity()); parserState.get().getCurrentActivity().getInputPorts() if (inputActivityPort.getDepth() == null) inputActivityPort.setDepth(inputProcessorPort.getDepth());