コード例 #1
0
  @Test
  @DiagramResource("org/camunda/bpm/modeler/test/ui/change/ChangeSupportTest.testBase.bpmn")
  public void testListElementRemove() {
    final Process process1 = findBusinessObjectById(diagram, "Process_1", Process.class);
    final ServiceTask serviceTask1 =
        findBusinessObjectById(diagram, "ServiceTask_1", ServiceTask.class);

    FeatureChangeFilter filter = new FeatureChangeFilter(process1, FLOW_ELEMENTS_FEATURE);
    CustomResourceSetListener listener = new CustomResourceSetListener(process1, filter);
    listener.register();

    // assert that task is member of collection
    assertThat(process1.getFlowElements()).contains(serviceTask1);

    transactionalExecute(
        new RecordingCommand(editingDomain) {

          @Override
          protected void doExecute() {
            process1.getFlowElements().remove(serviceTask1);
          }
        });

    assertThat(listener.getCapturedEvents()).hasSize(1);
  }
コード例 #2
0
 public void laneToTop(Lane lane) {
   LaneSet laneSet = FACTORY.createLaneSet();
   //		laneSet.setId(EcoreUtil.generateUUID());
   ModelUtil.setID(laneSet, resource);
   laneSet.getLanes().add(lane);
   Process process = getOrCreateProcess(getInternalParticipant());
   process.getLaneSets().add(laneSet);
 }
コード例 #3
0
 private InputOutputSpecification getOrCreateIOSpecification(Object target) {
   Process process = getOrCreateProcess(getParticipant(target));
   if (process.getIoSpecification() == null) {
     InputOutputSpecification ioSpec = FACTORY.createInputOutputSpecification();
     //			ioSpec.setId(EcoreUtil.generateUUID());
     ModelUtil.setID(ioSpec, resource);
     process.setIoSpecification(ioSpec);
   }
   return process.getIoSpecification();
 }
コード例 #4
0
 public Process getOrCreateProcess(Participant participant) {
   if (participant.getProcessRef() == null) {
     Process process = FACTORY.createProcess();
     //			process.setId(EcoreUtil.generateUUID());
     ModelUtil.setID(process, resource);
     process.setName("Process for " + participant.getName());
     getDefinitions().getRootElements().add(process);
     participant.setProcessRef(process);
   }
   return participant.getProcessRef();
 }
コード例 #5
0
 @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());
 }
コード例 #6
0
 @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());
 }
コード例 #7
0
 @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());
 }
コード例 #8
0
 @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());
 }
コード例 #9
0
 @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());
 }
コード例 #10
0
 /**
  * @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());
 }
コード例 #11
0
 @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());
 }
コード例 #12
0
 @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());
 }
コード例 #13
0
 @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());
 }
コード例 #14
0
 @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());
 }
  private void modifyModelStructure(IMoveShapeContext context) {
    Lane movedLane = getMovedLane(context);
    Participant sourceParticipant =
        (Participant) getBusinessObjectForPictogramElement(context.getSourceContainer());
    Participant internalParticipant = null;

    try {
      ModelHandler handler = ModelHandler.getInstance(getDiagram());
      internalParticipant = handler.getInternalParticipant();
      handler.moveLane(movedLane, internalParticipant);
    } catch (IOException e) {
      Activator.logError(e);
    }

    LaneSet laneSet = null;
    for (LaneSet set : sourceParticipant.getProcessRef().getLaneSets()) {
      if (set.getLanes().contains(movedLane)) {
        laneSet = set;
        break;
      }
    }

    if (laneSet != null) {
      laneSet.getLanes().remove(movedLane);
      if (laneSet.getLanes().isEmpty()) {
        sourceParticipant.getProcessRef().getLaneSets().remove(laneSet);
      }

      Process process = internalParticipant.getProcessRef();
      if (process.getLaneSets().isEmpty()) {
        LaneSet createLaneSet = ModelHandler.FACTORY.createLaneSet();
        //				createLaneSet.setId(EcoreUtil.generateUUID());
        process.getLaneSets().add(createLaneSet);
        ModelUtil.setID(createLaneSet);
      }
      process.getLaneSets().get(0).getLanes().add(movedLane);
    }
  }
  private void modifyModelStructure(IMoveShapeContext context) {
    Lane movedLane = getMovedLane(context);
    Process sourceProcess = getProcess(context.getSourceContainer());
    Process targetProcess = getProcess(context.getTargetContainer());
    moveLane(movedLane, sourceProcess, targetProcess);

    for (LaneSet laneSet : sourceProcess.getLaneSets()) {
      if (laneSet.getLanes().contains(movedLane)) {
        laneSet.getLanes().remove(movedLane);
        if (laneSet.getLanes().isEmpty()) {
          sourceProcess.getLaneSets().remove(laneSet);
        }

        if (targetProcess.getLaneSets().isEmpty()) {
          LaneSet newLaneSet = createLaneSet();
          targetProcess.getLaneSets().add(newLaneSet);
        }
        targetProcess.getLaneSets().get(0).getLanes().add(movedLane);
        break;
      }
    }
  }
コード例 #17
0
 /**
  * @param <A>
  * @param target object that this artifact is being added to
  * @param artifact artifact to be added
  * @return
  */
 public <T extends Artifact> T addArtifact(Object target, T artifact) {
   Process process = getOrCreateProcess(getParticipant(target));
   process.getArtifacts().add(artifact);
   return artifact;
 }
コード例 #18
0
ファイル: LabelingEvents.java プロジェクト: MDEGroup/learnpad
  @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$
    }
  }