public void removePortsBindingForUnknownPorts(ProcessorBinding binding) { // First, remove ports no longer owned by processor Iterator<ProcessorInputPortBinding> inputBindings = binding .getInputPortBindings().iterator(); Activity activity = binding.getBoundActivity(); Processor processor = binding.getBoundProcessor(); for (ProcessorInputPortBinding ip : iterable(inputBindings)) { if (!activity.getInputPorts().contains(ip.getBoundActivityPort())) { inputBindings.remove(); continue; } if (!processor.getInputPorts().contains(ip.getBoundProcessorPort())) { inputBindings.remove(); continue; } } Iterator<ProcessorOutputPortBinding> outputBindings = binding .getOutputPortBindings().iterator(); for (ProcessorOutputPortBinding op : iterable(outputBindings)) { if (!activity.getOutputPorts().contains(op.getBoundActivityPort())) { outputBindings.remove(); continue; } if (!processor.getOutputPorts() .contains(op.getBoundProcessorPort())) { outputBindings.remove(); continue; } } }
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; }
@Override protected void cloneInto(WorkflowBean clone, Cloning cloning) { super.cloneInto(clone, cloning); ProcessorBinding cloneBinding = (ProcessorBinding) clone; cloneBinding.setActivityPosition(getActivityPosition()); cloneBinding.setBoundProcessor(cloning .cloneOrOriginal(getBoundProcessor())); cloneBinding.setBoundActivity(cloning .cloneOrOriginal(getBoundActivity())); } }
@Override public String toString() { return getClass().getSimpleName() + " " + getBoundProcessor() + " " + getBoundActivity(); }
@Test public void testCompletenessOfSpecifiedBoundProcessor() { ProcessorBinding pb = new ProcessorBinding(); pb.setBoundProcessor(new Processor()); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor")) { problem = true; } } assertFalse(problem); }
@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); }
private void processorBinding(ProcessorBinding node) { processorBindingElem = objectFactory.createProcessorBinding(); processorBindingElem.setAbout(uri(node)); processorBindingElem.setName(node.getName()); processorBindingElem.setBindActivity(resource(uri(node .getBoundActivity()))); processorBindingElem.setBindProcessor(resource(uri(node .getBoundProcessor()))); if (node.getActivityPosition() != null) { ActivityPosition value = new ActivityPosition(); value.setDatatype(value.getDatatype()); value.setValue(node.getActivityPosition()); processorBindingElem.setActivityPosition(value); } profileElem.getProcessorBinding().add(resource(uri(node))); doc.getAny().add(processorBindingElem); }
@Test public void testCompletenessOfSpecifiedBoundActivity() { ProcessorBinding pb = new ProcessorBinding(); pb.setBoundActivity(new Activity()); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity")) { problem = true; } } assertFalse(problem); }
Activity boundActivity = profile.getActivities().getByName( parseName(scanner)); processorBinding.setBoundActivity(boundActivity); return; default: Processor boundProcessor = wf.getProcessors().getByName( wfProcName[1]); processorBinding.setBoundProcessor(boundProcessor); return; default: if (level == Level.InputPortBindings) { InputProcessorPort processorPort = processorBinding .getBoundProcessor().getInputPorts() .getByName(firstLink); InputActivityPort activityPort = processorBinding .getBoundActivity().getInputPorts() .getByName(secondLink); new ProcessorInputPortBinding(processorBinding, } else { OutputActivityPort activityPort = processorBinding .getBoundActivity().getOutputPorts() .getByName(firstLink); OutputProcessorPort processorPort = processorBinding .getBoundProcessor().getOutputPorts() .getByName(secondLink); new ProcessorOutputPortBinding(processorBinding,
@Test public void testCorrectnessOfValidActivityPosition() { ProcessorBinding pb = new ProcessorBinding(); Integer activityPosition = Integer.valueOf(3); pb.setActivityPosition(activityPosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); }
@Override public boolean accept(Visitor visitor) { if (visitor.visitEnter(this)) { List<Iterable<? extends WorkflowBean>> children = new ArrayList<>(); if (getInputPortBindings() != null) children.add(getInputPortBindings()); if (getOutputPortBindings() != null) children.add(getOutputPortBindings()); outer: for (Iterable<? extends WorkflowBean> it : children) for (WorkflowBean bean : it) if (!bean.accept(visitor)) break outer; } return visitor.visitLeave(this); }
/** * Get the activity bound to this processor in the given profile. * * @param profile * The profile to search within. * @return The activity. * @throws IllegalStateException * If there are more than one activity for the processor. * @throws IndexOutOfBoundsException * If there aren't any activities for the processor. * @see #getBinding(Profile) * @see Scufl2Tools#processorBindingForProcessor(Processor,Profile) */ public Activity getActivity(Profile profile) { return getBinding(profile).getBoundActivity(); }
@Test public void testCompletenessOfMissingBoundProcessor() { ProcessorBinding pb = new ProcessorBinding(); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertFalse(nullFieldProblems.isEmpty()); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor")) { problem = true; } } assertTrue(problem); }
private void parseProcessorBinding(Scanner scanner) { level = Level.ProcessorBinding; processorBinding = new ProcessorBinding(); String bindingName = parseName(scanner); processorBinding.setName(bindingName); profile.getProcessorBindings().add(processorBinding); }
@Override public void setParent(ProcessorBinding parent) { if (this.parent != null && this.parent != parent) this.parent.getInputPortBindings().remove(this); this.parent = parent; if (parent != null) parent.getInputPortBindings().add(this); }
@Override public void setParent(ProcessorBinding parent) { if (this.parent != null && this.parent != parent) this.parent.getOutputPortBindings().remove(this); this.parent = parent; if (parent != null) parent.getOutputPortBindings().add(this); }
@Test public void testCorrectnessOfMissingInputPortBindings() { ProcessorBinding pb = new ProcessorBinding(); pb.setInputPortBindings(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); }
@Test public void testCorrectnessOfMissingOutputPortBindings() { ProcessorBinding pb = new ProcessorBinding(); pb.setOutputPortBindings(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); }
public List<ProcessorBinding> processorBindingsForProcessor( Processor processor, Profile profile) { List<ProcessorBinding> bindings = new ArrayList<>(); for (ProcessorBinding pb : profile.getProcessorBindings()) if (pb.getBoundProcessor().equals(processor)) bindings.add(pb); Collections.sort(bindings, new BindingComparator()); return bindings; }