Exemplo n.º 1
0
 private int createMissingDIElementChildren(
     DiagramElementTreeNode node, int x, int y, List<BaseElement> created) {
   for (DiagramElementTreeNode childNode : node.getChildren()) {
     if (childNode.getChecked()) {
       BPMNShape bpmnShape = createMissingDIElement(childNode, x, y, created);
       if (bpmnShape != null) {
         y += bpmnShape.getBounds().getHeight() + 10;
       }
     }
   }
   return y;
 }
Exemplo n.º 2
0
  private int findMissingDIElements(
      DiagramElementTreeNode missing, LaneSet laneSet, List<FlowElement> laneElements) {
    int added = 0;
    if (laneSet != null) {
      for (Lane lane : laneSet.getLanes()) {
        // create the missing tree node for this Lane's container
        // this is either a FlowElementsContainer or another Lane
        BaseElement container = (BaseElement) lane.eContainer().eContainer();
        DiagramElementTreeNode containerNode = missing.getChild(container);
        if (containerNode == null) containerNode = missing.addChild(container);
        DiagramElementTreeNode parentNode = containerNode.addChild(lane);

        for (FlowNode fn : lane.getFlowNodeRefs()) {
          if (isMissingDIElement(fn)) {
            parentNode.addChild(fn);
            laneElements.add(fn);
            ++added;
          }
        }
        added += findMissingDIElements(parentNode, lane.getChildLaneSet(), laneElements);

        if (added == 0) {
          containerNode.removeChild(lane);
          missing.removeChild(container);
        }
      }
    }
    return added;
  }
Exemplo n.º 3
0
  private void removeDuplicates(List<DiagramElementTreeNode> children) {
    List<DiagramElementTreeNode> duplicates = new ArrayList<DiagramElementTreeNode>();
    for (DiagramElementTreeNode node : children) {
      if (node.hasChildren()) removeDuplicates(node.getChildren());

      BaseElement be = node.getBaseElement();
      if (be instanceof Collaboration) {
        Collaboration c = (Collaboration) be;
        for (Participant p : c.getParticipants()) {
          for (DiagramElementTreeNode n : children) {
            if (n.getBaseElement() == p.getProcessRef()) {
              duplicates.add(n);
            }
          }
        }
      } else if (be instanceof ChoreographyActivity) {
        ChoreographyActivity c = (ChoreographyActivity) be;
        for (Participant p : c.getParticipantRefs()) {
          for (DiagramElementTreeNode n : children) {
            if (n.getBaseElement() == p) {
              duplicates.add(n);
            }
          }
        }
      }
    }
    if (!duplicates.isEmpty()) children.removeAll(duplicates);
  }
Exemplo n.º 4
0
  private void createMissingDIElements(DiagramElementTree missing) {

    // look for any BPMN2 elements that do not have corresponding DI elements
    // and create DI elements for them. First, handle the BPMNShape objects:
    int x = 102400;
    int y = 0;
    List<BaseElement> shapes = new ArrayList<BaseElement>();
    for (DiagramElementTreeNode node : missing.getChildren()) {
      if (node.getChecked()) {
        BPMNShape bpmnShape = createMissingDIElement(node, x, y, shapes);
        if (bpmnShape != null) {
          y += bpmnShape.getBounds().getHeight() + 10;
        }
      }
    }

    // Next create the BPMNEdge objects. At this point, all of the source
    // and target elements for the connections should already exist, so
    // we don't have to worry about that.
    List<BaseElement> connections = new ArrayList<BaseElement>();
    for (BaseElement be : shapes) {
      if (be instanceof FlowNode) {
        FlowNode flowNode = (FlowNode) be;
        // find the BPMNDiagram that contains this flow node
        BPMNDiagram bpmnDiagram = createDIDiagram(flowNode);

        for (SequenceFlow sf : flowNode.getIncoming()) {
          if (!connections.contains(sf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, sf);
            if (bpmnEdge != null) connections.add(sf);
          }
        }

        for (SequenceFlow sf : flowNode.getOutgoing()) {
          if (!connections.contains(sf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, sf);
            if (bpmnEdge != null) connections.add(sf);
          }
        }
      } else if (be instanceof ConversationNode) {
        ConversationNode convNode = (ConversationNode) be;
        BPMNDiagram bpmnDiagram = createDIDiagram(convNode);
        for (MessageFlow mf : convNode.getMessageFlowRefs()) {
          if (!connections.contains(mf)) {
            BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, mf);
            if (bpmnEdge != null) connections.add(mf);
          }
        }
      }
    }
    // Finally, Associations are RootElements and since we only include shapes
    // in the missing elements tree, we'll have to revisit all of the RootElements
    TreeIterator<EObject> iter = definitions.eAllContents();
    while (iter.hasNext()) {
      EObject o = iter.next();
      if (o instanceof Association) {
        Association assoc = (Association) o;
        BPMNDiagram bpmnDiagram = createDIDiagram(assoc);
        BPMNEdge bpmnEdge = createDIEdge(bpmnDiagram, assoc);
        if (bpmnEdge != null) connections.add(assoc);
      }
    }
  }
Exemplo n.º 5
0
  private BPMNShape createMissingDIElement(
      DiagramElementTreeNode node, int x, int y, List<BaseElement> created) {
    BaseElement element = node.getBaseElement();
    BPMNShape bpmnShape = null;
    BPMNDiagram bpmnDiagram = createDIDiagram(element);

    if (element instanceof Lane) {
      Lane lane = (Lane) element;
      bpmnShape = createDIShape(bpmnDiagram, lane, x, y);
      node.setBpmnShape(bpmnShape);

      y = createMissingDIElementChildren(node, x, y, created);
      created.add(lane);
    } else if (element instanceof FlowElementsContainer) {
      FlowElementsContainer container = (FlowElementsContainer) element;

      if (container instanceof SubProcess || container instanceof SubChoreography) {
        bpmnShape = createDIShape(bpmnDiagram, container, x, y);
        node.setBpmnShape(bpmnShape);
        created.add(container);
      }

      y = createMissingDIElementChildren(node, x, y, created);
    } else if (element instanceof Collaboration) {
      y = createMissingDIElementChildren(node, x, y, created);
    } else if (element instanceof Artifact) {
      bpmnShape = createDIShape(bpmnDiagram, element, x, y);
      node.setBpmnShape(bpmnShape);
      created.add(element);
    } else if (element instanceof Participant) {
      boolean doImport = true;
      if (node.getParent().getBaseElement() instanceof ChoreographyActivity) {
        // this is a Participant Band in a Choreography Activity
        doImport = false;
      }

      bpmnShape = createDIShape(bpmnDiagram, element, x, y, doImport);
      node.setBpmnShape(bpmnShape);
      created.add(element);
      if (!doImport) {
        ChoreographyActivity ca = (ChoreographyActivity) node.getParent().getBaseElement();
        bpmnShape.setChoreographyActivityShape(node.getParent().getBpmnShape());
        if (ca.getParticipantRefs().get(0) == element)
          bpmnShape.setParticipantBandKind(ParticipantBandKind.TOP_INITIATING);
        else bpmnShape.setParticipantBandKind(ParticipantBandKind.BOTTOM_NON_INITIATING);
      }
      createMissingDIElementChildren(node, x, y, created);
    } else if (element instanceof ConversationNode) {
      bpmnShape = createDIShape(bpmnDiagram, element, x, y);
      node.setBpmnShape(bpmnShape);
      created.add(element);
    } else if (element instanceof FlowNode) {
      boolean doImport = !(element instanceof ChoreographyActivity);
      bpmnShape = createDIShape(bpmnDiagram, element, x, y, doImport);
      node.setBpmnShape(bpmnShape);
      created.add(element);
      y = createMissingDIElementChildren(node, x, y, created);
      if (!doImport) importer.importShape(bpmnShape);
    } else if (isDataElement(element)) {
      bpmnShape = createDIShape(bpmnDiagram, element, x, y);
      node.setBpmnShape(bpmnShape);
      created.add(element);
    }
    return bpmnShape;
  }
Exemplo n.º 6
0
  private void findMissingDIElements(DiagramElementTreeNode missing, BaseElement be) {
    if (be instanceof FlowElementsContainer) {
      // handles Process/SubProcess and Choreography/SubChoreography
      FlowElementsContainer container = (FlowElementsContainer) be;
      DiagramElementTreeNode parentNode = null;

      List<FlowElement> laneElements = new ArrayList<FlowElement>();
      for (LaneSet laneSet : container.getLaneSets()) {
        findMissingDIElements(missing, laneSet, laneElements);
      }

      for (FlowElement fe : container.getFlowElements()) {
        if (isMissingDIElement(fe) && !laneElements.contains(fe)) {
          if (fe instanceof SequenceFlow || fe instanceof DataObject || fe instanceof DataStore)
            continue;
          if (parentNode == null) parentNode = missing.addChild(container);
          parentNode.addChild(fe);
          if (fe instanceof FlowElementsContainer || fe instanceof ChoreographyActivity) {
            findMissingDIElements(parentNode, fe);
          }
        }
      }
      List<Artifact> artifacts = getArtifacts(container);
      if (artifacts != null) {
        for (Artifact a : artifacts) {
          if (isMissingDIElement(a) && !(a instanceof Association)) {
            if (parentNode == null) parentNode = missing.addChild(container);
            parentNode.addChild(a);
          }
        }
      }
    }

    // Choreography inherits both Collaboration and FlowElementsContainer
    if (be instanceof Collaboration) {
      // also handle Choreography
      Collaboration container = (Collaboration) be;
      DiagramElementTreeNode parentNode = null;
      for (Artifact a : container.getArtifacts()) {
        if (isMissingDIElement(a) && !(a instanceof Association)) {
          if (parentNode == null) parentNode = missing.addChild(container);
          parentNode.addChild(a);
        }
      }
      for (Participant p : container.getParticipants()) {
        boolean isParticipantBand = false;
        if (p.eContainer() instanceof Choreography) {
          // this may be a Choreography Activity Participant band
          Choreography choreography = (Choreography) p.eContainer();
          for (FlowElement fe : choreography.getFlowElements()) {
            if (fe instanceof ChoreographyActivity) {
              if (((ChoreographyActivity) fe).getParticipantRefs().contains(p)) {
                isParticipantBand = true;
                break;
              }
            }
          }
        }
        if (isMissingDIElement(p)
            && p.getProcessRef() != null
            && isMissingDIElement(p.getProcessRef())
            && !isParticipantBand) {
          if (parentNode == null) parentNode = missing.addChild(container);
          parentNode.addChild(p);
        }
      }
      for (ConversationNode c : container.getConversations()) {
        if (isMissingDIElement(c)) {
          if (parentNode == null) parentNode = missing.addChild(container);
          parentNode.addChild(c);
        }
      }
    } else if (be instanceof Participant) {
      Participant container = (Participant) be;
      if (container.getProcessRef() != null) {
        DiagramElementTreeNode parentNode = missing.addChild(container);
        parentNode.addChild(container.getProcessRef());
      }
    } else if (be instanceof ChoreographyActivity) {
      ChoreographyActivity container = (ChoreographyActivity) be;
      DiagramElementTreeNode parentNode = null;
      for (Participant p : container.getParticipantRefs()) {
        if (isMissingDIElement(p)) {
          if (parentNode == null) parentNode = missing.addChild(container);
          DiagramElementTreeNode child = parentNode.addChild(p);
          if (p.getProcessRef() != null) findMissingDIElements(child, p.getProcessRef());
        }
      }
    } else if (isDataElement(be)) {
      if (isMissingDIElement(be)) {
        missing.addChild(be);
      }
    }
  }