public ProcessorBinding bindActivityToProcessorByMatchingPorts( Activity activity, Processor processor) { ProcessorBinding binding = new ProcessorBinding(); binding.setParent(activity.getParent()); binding.setBoundActivity(activity); binding.setBoundProcessor(processor); bindActivityToProcessorByMatchingPorts(binding); return binding; }
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); } }
public Profile makeMainProfile() { Profile profile = new Profile(); profile.setName("tavernaWorkbench"); // FIXME: Can't set dc:creator/date/description // FIXME: Can't create recommendsEnvironment/requiresEnvironment makeActivity().setParent(profile); makeConfiguration().setParent(profile); makeProcessorBinding().setParent(profile); // profile.setProfilePosition(0); return profile; }
@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 testCorrectnessOfOutOfScopeBoundActivity() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity orphanActivity = new Activity(); pb.setBoundActivity(orphanActivity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(orphanActivity)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor1() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Processor orphanProcessor = new Processor(); pb.setBoundProcessor(orphanProcessor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(orphanProcessor)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor2() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfInScopeBoundActivity1() { // Test when in same profile WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); activity.setParent(profile); pb.setBoundActivity(activity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(activity)) { problem = true; } } assertFalse(problem); }
@Test public void testCorrectnessOfInScopeBoundProcessor() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); w.setParent(wb); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); // assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertFalse(problem); }
@Test public void testCorrectnessOfInScopeBoundActivity2() { // Test when in same profile WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Profile otherProfile = new Profile(); otherProfile.setParent(wb); Activity activity = new Activity(); activity.setParent(otherProfile); pb.setBoundActivity(activity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(activity)) { problem = true; } } assertFalse(problem); } }
protected void parseProcessorBinding( org.apache.taverna.scufl2.xml.ProcessorBinding original) throws ReaderException { org.apache.taverna.scufl2.api.profiles.ProcessorBinding binding = new org.apache.taverna.scufl2.api.profiles.ProcessorBinding(); binding.setParent(getParserState().getCurrent( org.apache.taverna.scufl2.api.profiles.Profile.class)); mapBean(original.getAbout(), binding); getParserState().push(binding); if (original.getName() != null) binding.setName(original.getName()); if (original.getActivityPosition() != null) binding.setActivityPosition(original.getActivityPosition() .getValue()); URI processorUri = resolve(original.getBindProcessor().getResource()); URI activityUri = resolve(original.getBindActivity().getResource()); binding.setBoundProcessor((Processor) resolveBeanUri(processorUri)); binding.setBoundActivity((Activity) resolveBeanUri(activityUri)); for (InputPortBinding inputPortBinding : original.getInputPortBinding()) parseInputPortBinding(inputPortBinding.getInputPortBinding()); for (OutputPortBinding outputPortBinding : original .getOutputPortBinding()) parseOutputPortBinding(outputPortBinding.getOutputPortBinding()); getParserState().pop(); }