Ejemplo n.º 1
0
  private BPMNDiagram createDIDiagram(BaseElement bpmnElement) {

    BPMNDiagram bpmnDiagram = DIUtils.findBPMNDiagram(bpmnElement, true);

    // if this container does not have a BPMNDiagram, create one
    if (bpmnElement instanceof Process) {
      if (bpmnDiagram == null) {
        // unless this Process is referenced by a Pool
        for (Collaboration c :
            ModelUtil.getAllObjectsOfType(bpmnElement.eResource(), Collaboration.class)) {
          for (Participant p : c.getParticipants()) {
            if (!ModelUtil.isParticipantBand(p)) {
              if (p.getProcessRef() == bpmnElement) {
                bpmnDiagram = DIUtils.findBPMNDiagram(p, true);
                break;
              }
            }
          }
          if (bpmnDiagram != null) break;
        }
      } else {
        // Always create a new BPMNDiagram if this Process is being referenced by a Participant Band
        //				for (Collaboration c : ModelUtil.getAllObjectsOfType(bpmnElement.eResource(),
        // Collaboration.class)) {
        //					for (Participant p : c.getParticipants()) {
        //						if (ModelUtil.isParticipantBand(p)) {
        //							if (p.getProcessRef() == bpmnElement) {
        //								bpmnDiagram = null;
        //								break;
        //							}
        //						}
        //					}
        //					if (bpmnDiagram==null)
        //						break;
        //				}
      }
    }

    if (bpmnDiagram == null) {
      FlowElementsContainer container = getRootElementContainer(bpmnElement);
      if (container == null) {
        diagnostics.add(IStatus.ERROR, bpmnElement, Messages.DIGenerator_No_Diagram);
        return this.bpmnDiagram;
      }
      BPMNPlane plane = BpmnDiFactory.eINSTANCE.createBPMNPlane();
      plane.setBpmnElement(container);

      bpmnDiagram = BpmnDiFactory.eINSTANCE.createBPMNDiagram();
      bpmnDiagram.setName(ExtendedPropertiesProvider.getTextValue(container));
      bpmnDiagram.setPlane(plane);

      definitions.getDiagrams().add(bpmnDiagram);
    }

    return bpmnDiagram;
  }