@Override
 public boolean canDelete(IDeleteContext context) {
   // Participant bands in a ChoreographyTask only be "deleted" (from the model)
   // if there are no other references to the participant; but they can be "removed"
   // (from the ChoreographyTask's participantRef list) at any time.
   // @see RemoveChoreographyParticipantFeature
   PictogramElement pe = context.getPictogramElement();
   if (ChoreographyUtil.isChoreographyParticipantBand(pe)) {
     int referenceCount = 0;
     Participant participant = BusinessObjectUtil.getFirstElementOfType(pe, Participant.class);
     Definitions definitions = ModelUtil.getDefinitions(participant);
     TreeIterator<EObject> iter = definitions.eAllContents();
     while (iter.hasNext()) {
       EObject o = iter.next();
       for (EReference reference : o.eClass().getEAllReferences()) {
         if (!reference.isContainment() && !(o instanceof DiagramElement)) {
           if (reference.isMany()) {
             List list = (List) o.eGet(reference);
             for (Object referencedObject : list) {
               if (referencedObject == participant) ++referenceCount;
             }
           } else {
             Object referencedObject = o.eGet(reference);
             if (referencedObject == participant) ++referenceCount;
           }
         }
       }
     }
     return referenceCount <= 1;
   }
   return true;
 }
  void createDefinitionsIfMissing() {
    EList<EObject> contents = resource.getContents();

    if (contents.isEmpty() || !(contents.get(0) instanceof DocumentRoot)) {
      TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource);

      if (domain != null) {
        final DocumentRoot docRoot = FACTORY.createDocumentRoot();
        final Definitions definitions = FACTORY.createDefinitions();
        //				definitions.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(definitions, resource);
        Collaboration collaboration = FACTORY.createCollaboration();
        //				collaboration.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(collaboration, resource);
        Participant participant = FACTORY.createParticipant();
        //				participant.setId(EcoreUtil.generateUUID());
        ModelUtil.setID(participant, resource);
        participant.setName("Internal");
        collaboration.getParticipants().add(participant);
        definitions.getRootElements().add(collaboration);

        domain
            .getCommandStack()
            .execute(
                new RecordingCommand(domain) {
                  @Override
                  protected void doExecute() {
                    docRoot.setDefinitions(definitions);
                    resource.getContents().add(docRoot);
                  }
                });
        return;
      }
    }
  }
 // @Test
 // removing until we start supporting global tasks
 public void testManualTaskUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("manualTask.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   GlobalManualTask task = (GlobalManualTask) definitions.getRootElements().get(0);
   assertEquals("pull a lever", task.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testMessageUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("message.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 2);
   assertTrue(definitions.getRootElements().iterator().next() instanceof Message);
   Message msg = (Message) definitions.getRootElements().iterator().next();
   assertEquals("message", msg.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testDataStoreUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("dataStore.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   assertTrue(definitions.getRootElements().iterator().next() instanceof DataStore);
   DataStore da = (DataStore) definitions.getRootElements().iterator().next();
   assertEquals("data store", da.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 // @Test
 // removing until we start supporting global tasks
 public void testSimpleGlobalTaskUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("oneTask.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   assertTrue(definitions.getRootElements().iterator().next() instanceof GlobalTask);
   GlobalTask task = (GlobalTask) definitions.getRootElements().iterator().next();
   assertEquals("oneTask", task.getName());
   assertEquals("my task doc", task.getDocumentation().iterator().next().getText());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testEndEventUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("endEvent.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   EndEvent g = (EndEvent) process.getFlowElements().get(0);
   assertEquals("end event", g.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testDataObjectUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("dataObject.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 2);
   Process process = getRootProcess(definitions);
   assertTrue(process.getFlowElements().iterator().next() instanceof DataObject);
   DataObject da = (DataObject) process.getFlowElements().iterator().next();
   assertEquals("data object", da.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
Ejemplo n.º 9
0
  public static List<EObject> findMessageReferences(Diagram diagram, Message message) {
    List<EObject> result = new ArrayList<EObject>();
    Definitions definitions = ModelUtil.getDefinitions(message);
    TreeIterator<EObject> iter = definitions.eAllContents();
    while (iter.hasNext()) {
      EObject o = iter.next();
      if (o instanceof MessageFlow) {
        if (((MessageFlow) o).getMessageRef() == message) {
          result.add(o);
        }
      }
      if (o instanceof MessageEventDefinition) {
        if (((MessageEventDefinition) o).getMessageRef() == message) {
          result.add(o);
        }
      }
      if (o instanceof Operation) {
        if (((Operation) o).getInMessageRef() == message
            || ((Operation) o).getOutMessageRef() == message) {
          result.add(o);
        }
      }
      if (o instanceof ReceiveTask) {
        if (((ReceiveTask) o).getMessageRef() == message) {
          result.add(o);
        }
      }
      if (o instanceof SendTask) {
        if (((SendTask) o).getMessageRef() == message) {
          result.add(o);
        }
      }
      if (o instanceof CorrelationPropertyRetrievalExpression) {
        if (((CorrelationPropertyRetrievalExpression) o).getMessageRef() == message) {
          result.add(o);
        }
      }
    }

    if (diagram != null) {
      iter = diagram.eResource().getAllContents();
      while (iter.hasNext()) {
        EObject o = iter.next();
        if (o instanceof ContainerShape && !isLabelShape((ContainerShape) o)) {
          if (BusinessObjectUtil.getFirstBaseElement((ContainerShape) o) == message) result.add(o);
        }
      }
    }
    return result;
  }
 // @Test
 // removing until we start supporting global tasks
 public void testScriptTaskUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("scriptTask.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   GlobalScriptTask task = (GlobalScriptTask) definitions.getRootElements().get(0);
   assertEquals("my script", task.getName());
   assertEquals(
       "git status | grep modified | awk '{print $3}' | xargs echo | xargs git add",
       task.getScript());
   assertEquals("bash", task.getScriptLanguage());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testPoolUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("pool.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   assertTrue(definitions.getRootElements().get(0) instanceof Process);
   Process process = getRootProcess(definitions);
   assertEquals("pool", process.getName());
   assertEquals(ProcessType.PRIVATE, process.getProcessType());
   assertTrue(process.isIsClosed());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testLaneUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("pool.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   assertTrue(definitions.getRootElements().get(0) instanceof Process);
   Process process = getRootProcess(definitions);
   assertTrue(process.getLaneSets().size() == 1);
   assertTrue(process.getLaneSets().get(0).getLanes().size() == 1);
   Lane l = process.getLaneSets().get(0).getLanes().get(0);
   assertEquals("my first lane", l.getName());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testStartParallelMultipleEventUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller
               .unmarshall(getTestJsonFile("startParallelMultipleEvent.json"), "")
               .getContents()
               .get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   StartEvent g = (StartEvent) process.getFlowElements().get(0);
   assertEquals("start parallel multiple event", g.getName());
   // TODO multiple event definitions ???
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testSimpleChainUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller
               .unmarshall(getTestJsonFile("startEvent-task-endEvent.json"), "")
               .getContents()
               .get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   assertTrue(process.getFlowElements().size() == 5);
   assertTrue(process.getLaneSets().size() == 1);
   assertTrue(process.getLaneSets().get(0).getLanes().size() == 1);
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 /**
  * @Test this test needs to be revised (the json) public void testGroupUnmarshalling() throws
  * Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions
  * definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("group.json"),
  * "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process
  * process = getRootProcess(definitions); assertTrue(process.getArtifacts().iterator().next()
  * instanceof Group); definitions.eResource().save(System.out, Collections.emptyMap()); }*
  */
 @Test
 public void testTextAnnotationUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller
               .unmarshall(getTestJsonFile("textAnnotation.json"), "")
               .getContents()
               .get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   assertTrue(process.getArtifacts().iterator().next() instanceof TextAnnotation);
   TextAnnotation ta = (TextAnnotation) process.getArtifacts().iterator().next();
   assertEquals("text annotation", ta.getText());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testIntermediateThrowSignalUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller
               .unmarshall(getTestJsonFile("intermediateThrowSignalEvent.json"), "")
               .getContents()
               .get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   ThrowEvent g = (ThrowEvent) process.getFlowElements().get(0);
   assertEquals("throw signal event", g.getName());
   assertTrue(g.getEventDefinitions().iterator().next() instanceof SignalEventDefinition);
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 @Test
 public void testAssociationUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("association.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   Task g = (Task) process.getFlowElements().get(0);
   assertEquals("task", g.getName());
   TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0);
   Association association = (Association) process.getArtifacts().get(1);
   assertEquals(g, association.getSourceRef());
   assertEquals(textA, association.getTargetRef());
   assertEquals(AssociationDirection.NONE, association.getAssociationDirection());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
 private Process getRootProcess(Definitions def) {
   for (RootElement nextRootElement : def.getRootElements()) {
     if (nextRootElement instanceof Process) {
       return (Process) nextRootElement;
     }
   }
   return null;
 }
Ejemplo n.º 19
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;
  }
 @Test
 public void testSequenceFlowUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("sequenceFlow.json"), "").getContents().get(0));
   assertTrue(definitions.getRootElements().size() == 1);
   Process process = getRootProcess(definitions);
   assertTrue(process.getFlowElements().get(0) instanceof Task);
   Task task = (Task) process.getFlowElements().get(0);
   assertEquals("task1", task.getName());
   Task task2 = (Task) process.getFlowElements().get(1);
   assertEquals("task2", task2.getName());
   SequenceFlow flow = (SequenceFlow) process.getFlowElements().get(2);
   assertEquals("seqFlow", flow.getName());
   assertEquals(task, flow.getSourceRef());
   assertEquals(task2, flow.getTargetRef());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
  @Override
  protected List<Object> getModelChildren() {
    List<Object> retList = new ArrayList<Object>();
    FlowElement elem = getFlowElement();

    if (elem instanceof FlowElementsContainer) {
      FlowElementsContainer container = (FlowElementsContainer) elem;
      return getFlowElementsContainerChildren(container);
    } else if (elem instanceof ChoreographyActivity) {
      ChoreographyActivity ca = (ChoreographyActivity) elem;
      retList.addAll(ca.getParticipantRefs());
    } else if (elem instanceof CallActivity) {
      // render a Call Activity with its called element target
      // (a Process or Global Task) as the child node.
      CallableElement target = ((CallActivity) elem).getCalledElementRef();
      if (target != null) {
        retList.add(target);
      }
    } else if (elem instanceof CatchEvent) {
      retList.addAll(((CatchEvent) elem).getEventDefinitions());
      retList.addAll(((CatchEvent) elem).getDataOutputAssociation());
    } else if (elem instanceof ThrowEvent) {
      retList.addAll(((ThrowEvent) elem).getEventDefinitions());
      retList.addAll(((ThrowEvent) elem).getDataInputAssociation());
    }

    if (elem instanceof Activity) {
      // Boundary Events are children nodes of Activities
      Definitions definitions = ModelUtil.getDefinitions(elem);
      if (definitions != null) {
        TreeIterator<EObject> iter = definitions.eAllContents();
        while (iter.hasNext()) {
          EObject o = iter.next();
          if (o instanceof BoundaryEvent && ((BoundaryEvent) o).getAttachedToRef() == elem) {
            retList.add(o);
          }
        }
        retList.addAll(((Activity) elem).getDataInputAssociations());
        retList.addAll(((Activity) elem).getDataOutputAssociations());
      }
    }
    return retList;
  }
Ejemplo n.º 22
0
  private DiagramElementTree findMissingDIElements() {

    DiagramElementTree missing = new DiagramElementTree(null, null);

    // look for any BPMN2 elements that do not have corresponding DI elements
    for (BaseElement be : definitions.getRootElements()) {
      findMissingDIElements(missing, be);
    }

    removeDuplicates(missing.getChildren());
    return missing;
  }
 @Override
 public void delete(IDeleteContext context) {
   Participant participant =
       BusinessObjectUtil.getFirstElementOfType(context.getPictogramElement(), Participant.class);
   Definitions defs = ModelUtil.getDefinitions(participant);
   Process process = participant.getProcessRef();
   if (process != null) {
     BPMNDiagram bpmnDiagram = null;
     if (defs != null) {
       for (BPMNDiagram d : defs.getDiagrams()) {
         BPMNPlane plane = d.getPlane();
         if (plane.getBpmnElement() == process) {
           bpmnDiagram = d;
           break;
         }
       }
     }
     deleteBusinessObject(process);
     if (bpmnDiagram != null) deleteBusinessObject(bpmnDiagram);
   }
   super.delete(context);
 }
Ejemplo n.º 24
0
  /**
   * Check if the given BaseElement has
   *
   * @param baseElement
   * @return
   */
  public static boolean hasBpmnDiagram(BaseElement baseElement) {
    BaseElement process = null;
    if (baseElement instanceof Participant) {
      process = ((Participant) baseElement).getProcessRef();
    } else if (baseElement instanceof CallActivity) {
      CallableElement ce = ((CallActivity) baseElement).getCalledElementRef();
      if (ce instanceof Process) process = (Process) ce;
    }

    if (process != null) {
      baseElement = process;
    }

    try {
      Definitions definitions = ModelUtil.getDefinitions(baseElement);
      for (BPMNDiagram d : definitions.getDiagrams()) {
        if (d.getPlane().getBpmnElement() == baseElement) return true;
      }
    } catch (Exception e) {
    }

    return false;
  }
 @Test
 public void testSimpleDefinitionsUnmarshalling() throws Exception {
   Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
   Definitions definitions =
       ((Definitions)
           unmarshaller.unmarshall(getTestJsonFile("empty.json"), "").getContents().get(0));
   assertEquals("my doc", definitions.getDocumentation().iterator().next().getText());
   assertEquals("http://www.w3.org/1999/XPath", definitions.getExpressionLanguage());
   assertEquals("http://www.omg.org/bpmn20", definitions.getTargetNamespace());
   assertEquals("http://www.w3.org/2001/XMLSchema", definitions.getTypeLanguage());
   assertTrue(definitions.getRootElements().isEmpty());
   definitions.eResource().save(System.out, Collections.emptyMap());
 }
Ejemplo n.º 26
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);
      }
    }
  }
Ejemplo n.º 27
0
  @Override
  protected void findGL(Definitions diagram) {
    StringBuilder temp = new StringBuilder();

    int num = 0;

    for (RootElement rootElement : diagram.getRootElements()) {
      if (rootElement instanceof Process) {
        Process process = (Process) rootElement;
        // System.out.format("Found a process: %s\n", process.getName());

        IDProcess = process.getId();
        for (FlowElement fe : process.getFlowElements()) {
          if (fe instanceof SubProcess) {
            SubProcess sub = (SubProcess) fe;
            // System.out.format("Found a SubProcess: %s\n", sub.getName());
            this.searchSubProcess(sub);
          } else if (fe instanceof IntermediateCatchEvent) {
            IntermediateCatchEvent a = (IntermediateCatchEvent) fe;
            if (a.getName() == null || (a.getName().length() == 0)) {
              num++;

              elementsBPMN.add(fe);
              String name =
                  fe.getName() != null
                      ? fe.getName()
                      : Messages.getString("Generic.LabelEmpty", l); // $NON-NLS-1$
              setElements(fe.getId(), IDProcess, name);
              temp.append(
                  "* name="
                      + name
                      + " ID="
                      + fe.getId() // $NON-NLS-1$ //$NON-NLS-2$
                      + "\n"); //$NON-NLS-1$
            }

          } else if (fe instanceof IntermediateThrowEvent) {
            IntermediateThrowEvent a = (IntermediateThrowEvent) fe;
            if (a.getName() == null || (a.getName().length() == 0)) {
              num++;

              elementsBPMN.add(fe);
              String name =
                  fe.getName() != null
                      ? fe.getName()
                      : Messages.getString("Generic.LabelEmpty", l); // $NON-NLS-1$
              setElements(fe.getId(), IDProcess, name);
              temp.append(
                  "* name="
                      + name
                      + " ID="
                      + fe.getId() // $NON-NLS-1$ //$NON-NLS-2$
                      + "\n"); //$NON-NLS-1$
            }
          }
        }
      }
    }
    if (num > 0) {

      this.Suggestion += Messages.getString("LabelingEvents.SuggestionKO", l); // $NON-NLS-1$
      this.status = false;
    } else {
      this.status = true;
      this.Suggestion += Messages.getString("LabelingEvents.SuggestionOK", l); // $NON-NLS-1$
    }
  }