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 static String getUniqueMergeInputPortName(Merge merge, String name, int count) { String uniqueName = name + count; for (MergeInputPort mergeInputPort : merge.getInputPorts()) { if (mergeInputPort.getName().equals(uniqueName)) { return getUniqueMergeInputPortName(merge, name, ++count); } } return uniqueName; }
private void transferMerge(List<Edit<?>> editList, Map<Object, Object> oldNewMapping, Dataflow nestedDataflow, Merge merge) throws EditException { editList.add(edits.getRemoveMergeEdit(currentDataflow, merge)); Merge newMerge = edits.createMerge(nestedDataflow); edits.getAddMergeEdit(nestedDataflow, newMerge).doEdit(); oldNewMapping.put(merge, newMerge); for (MergeInputPort mip : merge.getInputPorts()) { MergeInputPort newMip = edits.createMergeInputPort(newMerge, mip.getName(), mip.getDepth()); edits.getAddMergeInputPortEdit(newMerge, newMip).doEdit(); oldNewMapping.put(mip, newMip); } oldNewMapping.put(merge.getOutputPort(), newMerge.getOutputPort()); }
assertEquals(1,merge.getInputPorts().size()); assertTrue(merge.getInputPorts().get(0) instanceof MergeInputPort); assertEquals("source_port_tomerge",merge.getInputPorts().get(0).getName()); assertSame(sourcePort,merge.getInputPorts().get(0).getIncomingLink().getSource()); assertEquals(2,merge.getInputPorts().size()); assertTrue(merge.getInputPorts().get(1) instanceof MergeInputPort); assertEquals("source_port2_tomerge",merge.getInputPorts().get(1).getName()); assertSame(sourcePort2,merge.getInputPorts().get(1).getIncomingLink().getSource());
Merge merge = ((MergeInputPort) sink).getMerge(); queue.add(merge);
private void considerNearestDownstream(TokenProcessingEntity investigate) { if (investigate instanceof Processor) for (Condition condition : ((Processor) investigate) .getControlledPreconditionList()) considerInclusion(condition.getTarget()); for (EventForwardingOutputPort outputPort : investigate .getOutputPorts()) for (Datalink datalink : outputPort.getOutgoingLinks()) { EventHandlingInputPort sink = datalink.getSink(); if (sink instanceof ProcessorInputPort) considerInclusion(((ProcessorInputPort) sink) .getProcessor()); else if (sink instanceof MergeInputPort) considerInclusion(((MergeInputPort) sink).getMerge()); // The merge it self doesn't count as a processor else { // Ignore dataflow ports } } }
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 static String getUniqueMergeInputPortName(Merge merge, String name, int count) { String uniqueName = name + count; for (MergeInputPort mergeInputPort : merge.getInputPorts()) { if (mergeInputPort.getName().equals(uniqueName)) { return getUniqueMergeInputPortName(merge, name, ++count); } } return uniqueName; }
if (ip.getIncomingLink() == null || ip.getIncomingLink().getResolvedDepth() == -1) { return false; if (ip.getIncomingLink().getResolvedDepth() != inputDepth) { throw new IterationTypeMismatchException();
@Override public void refreshView() { mergeView = new JPanel(); mergeView.setLayout(new BoxLayout(mergeView, BoxLayout.PAGE_AXIS)); mergeView.setBorder(new EmptyBorder(5, 5, 5, 5)); mergeView.add(new JLabel("Merge: " + merge.getLocalName())); mergeView.add(Box.createRigidArea(new Dimension(0,5))); mergeView.add(new JLabel("Inputs: ")); for (MergeInputPort mergeInputPort : merge.getInputPorts()) { mergeView.add(new JLabel(mergeInputPort.getName())); } mergeView.add(Box.createRigidArea(new Dimension(0,5))); mergeView.add(new JLabel("Outputs: ")); mergeView.add(new JLabel(merge.getOutputPort().getName())); } }
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); } }
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(); }
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()); }