public boolean doTypeCheck() throws IterationTypeMismatchException { if (inputs.size() == 0) { // Arguable, but technically a merge with no inputs is valid, it may // make more sense to throw an exception here though as it has no // actual meaning. return true; } // Return false if we have unbound input ports or bound ports where the // resolved depth hasn't been calculated yet for (MergeInputPort ip : inputs) { if (ip.getIncomingLink() == null || ip.getIncomingLink().getResolvedDepth() == -1) { return false; } } // Got all input ports, now scan for input depths int inputDepth = inputs.get(0).getIncomingLink().getResolvedDepth(); for (MergeInputPort ip : inputs) { if (ip.getIncomingLink().getResolvedDepth() != inputDepth) { throw new IterationTypeMismatchException(); } } // Got to here so all the input resolved depths match, push depth+1 to // all outgoing links and return true for (DatalinkImpl dli : output.outgoingLinks) { dli.setResolvedDepth(inputDepth+1); } return true; } }
public boolean doTypeCheck() throws IterationTypeMismatchException { if (inputs.size() == 0) { // Arguable, but technically a merge with no inputs is valid, it may // make more sense to throw an exception here though as it has no // actual meaning. return true; } // Return false if we have unbound input ports or bound ports where the // resolved depth hasn't been calculated yet for (MergeInputPort ip : inputs) { if (ip.getIncomingLink() == null || ip.getIncomingLink().getResolvedDepth() == -1) { return false; } } // Got all input ports, now scan for input depths int inputDepth = inputs.get(0).getIncomingLink().getResolvedDepth(); for (MergeInputPort ip : inputs) { if (ip.getIncomingLink().getResolvedDepth() != inputDepth) { throw new IterationTypeMismatchException(); } } // Got to here so all the input resolved depths match, push depth+1 to // all outgoing links and return true for (DatalinkImpl dli : output.outgoingLinks) { dli.setResolvedDepth(inputDepth+1); } return true; } }
if (ip.getIncomingLink() == null || ip.getIncomingLink().getResolvedDepth() == -1) { return false; if (ip.getIncomingLink().getResolvedDepth() != inputDepth) { throw new IterationTypeMismatchException();
public MergeConfigurationView(Merge merge){ super((Frame)null, "Merge Configuration", true); this.merge = merge; // Ordered list of merge's input ports inputPortsList = new ArrayList<MergeInputPort>(merge.getInputPorts()); // Generate labels for the input ports (label displays a link from a workflow entity // towards the merge's input port) labelListModel = new DefaultListModel(); String maxLabel = "Order of incoming links (entity.port -> merge):"+"Push"; for (MergeInputPort mergeInputPort : inputPortsList){ EventForwardingOutputPort sourcePort = mergeInputPort.getIncomingLink().getSource(); // Get the name TokenProcessingEntity (Processor or another Merge or Dataflow) and // its port that contains the source EventForwardingOutputPort Dataflow workflow = FileManager.getInstance().getCurrentDataflow(); TokenProcessingEntity entity = Tools.getTokenProcessingEntityWithEventForwardingOutputPort(sourcePort, workflow); if (entity != null){ String link = entity.getLocalName() + "." + sourcePort.getName() + " -> " + merge.getLocalName(); if (link.length() > maxLabel.length()) maxLabel = link; labelListModel.addElement(link); } } initComponents(); }
public void actionPerformed(ActionEvent e) { try { List<? extends MergeInputPort> inputPorts = merge.getInputPorts(); EventForwardingOutputPort outputPort = merge.getOutputPort(); List<Edit<?>> editList = new ArrayList<Edit<?>>(); for (MergeInputPort inputPort : inputPorts) { Datalink datalink = inputPort.getIncomingLink(); if (datalink != null) { editList.add(Tools.getDisconnectDatalinkAndRemovePortsEdit(datalink)); } } for (Datalink datalink : outputPort.getOutgoingLinks()) { editList.add(Tools.getDisconnectDatalinkAndRemovePortsEdit(datalink)); } if (editList.isEmpty()) { editManager.doDataflowEdit(dataflow, edits.getRemoveMergeEdit(dataflow, merge)); } else { editList.add(edits.getRemoveMergeEdit(dataflow, merge)); editManager.doDataflowEdit(dataflow, new CompoundEdit(editList)); } dataflowSelectionModel.removeSelection(merge); } catch (EditException e1) { logger.debug("Delete merge failed", e1); } }
EventForwardingOutputPort sourcePort = mergeInputPort.getIncomingLink().getSource();
@Test public void redo() throws Exception { Edit<Merge> theEdit = new ConnectMergedDatalinkEdit(merge,sourcePort,sinkPort); theEdit.doEdit(); theEdit.undo(); theEdit.doEdit(); assertEquals(1,merge.getInputPorts().size()); assertTrue(merge.getInputPorts().get(0) instanceof MergeInputPort); assertSame(sourcePort,merge.getInputPorts().get(0).getIncomingLink().getSource()); assertEquals(1,merge.getOutputPort().getOutgoingLinks().size()); assertSame(sinkPort,merge.getOutputPort().getOutgoingLinks().toArray(new Datalink[]{})[0].getSink()); assertEquals(1,sourcePort.getOutgoingLinks().size()); assertTrue(sourcePort.getOutgoingLinks().toArray(new Datalink[]{})[0].getSink() instanceof MergeInputPort); assertTrue(sinkPort.getIncomingLink().getSource() instanceof MergeOutputPort); assertSame(merge.getInputPorts().get(0),sourcePort.getOutgoingLinks().toArray(new Datalink[]{})[0].getSink()); assertSame(sinkPort.getIncomingLink().getSource(),merge.getOutputPort()); }
assertTrue(merge.getInputPorts().get(0) instanceof MergeInputPort); assertEquals("source_port_tomerge",merge.getInputPorts().get(0).getName()); assertSame(sourcePort,merge.getInputPorts().get(0).getIncomingLink().getSource()); assertTrue(merge.getInputPorts().get(1) instanceof MergeInputPort); assertEquals("source_port2_tomerge",merge.getInputPorts().get(1).getName()); assertSame(sourcePort2,merge.getInputPorts().get(1).getIncomingLink().getSource());