private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("start1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof StartEvent);
    assertEquals("start1", flowElement.getId());

    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    assertEquals("userTask1", flowElement.getId());
    UserTask userTask = (UserTask) flowElement;
    assertTrue(userTask.getCandidateUsers().size() == 1);
    assertTrue(userTask.getCandidateGroups().size() == 1);
    assertTrue(userTask.getFormProperties().size() == 2);

    flowElement = model.getMainProcess().getFlowElement("subprocess1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SubProcess);
    assertEquals("subprocess1", flowElement.getId());
    SubProcess subProcess = (SubProcess) flowElement;
    assertTrue(subProcess.getFlowElements().size() == 5);

    flowElement = model.getMainProcess().getFlowElement("boundaryEvent1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof BoundaryEvent);
    assertEquals("boundaryEvent1", flowElement.getId());
    BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
    assertNotNull(boundaryEvent.getAttachedToRef());
    assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId());
    assertEquals(1, boundaryEvent.getEventDefinitions().size());
    assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
  }
Beispiel #2
0
 private void processFlowElements(
     Collection<FlowElement> flowElementList, BaseElement parentScope) {
   for (FlowElement flowElement : flowElementList) {
     if (flowElement instanceof SequenceFlow) {
       SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
       FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
       if (sourceNode != null) {
         sourceNode.getOutgoingFlows().add(sequenceFlow);
       }
       FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
       if (targetNode != null) {
         targetNode.getIncomingFlows().add(sequenceFlow);
       }
     } else if (flowElement instanceof BoundaryEvent) {
       BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
       FlowElement attachedToElement =
           getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
       if (attachedToElement != null) {
         boundaryEvent.setAttachedToRef((Activity) attachedToElement);
         ((Activity) attachedToElement).getBoundaryEvents().add(boundaryEvent);
       }
     } else if (flowElement instanceof SubProcess) {
       SubProcess subProcess = (SubProcess) flowElement;
       processFlowElements(subProcess.getFlowElements(), subProcess);
     }
   }
 }
  @Override
  public void refresh() {
    cancelActivityCombo.removeFocusListener(listener);
    messageCombo.removeFocusListener(listener);

    PictogramElement pe = getSelectedPictogramElement();
    if (pe != null) {
      Object bo = getBusinessObject(pe);
      if (bo == null) return;

      final Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
      if (model == null) {
        return;
      }

      boolean cancelActivity = ((BoundaryEvent) bo).isCancelActivity();
      if (cancelActivity == false) {
        cancelActivityCombo.select(1);
      } else {
        cancelActivityCombo.select(0);
      }

      String messageRef = null;
      if (bo instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bo;
        if (boundaryEvent.getEventDefinitions().get(0) != null) {
          MessageEventDefinition messageDefinition =
              (MessageEventDefinition) boundaryEvent.getEventDefinitions().get(0);
          if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
            messageRef = messageDefinition.getMessageRef();
          }
        }
      }

      String[] items = new String[model.getBpmnModel().getMessages().size() + 1];
      items[0] = "";
      int counter = 1;
      int selectedCounter = 0;
      for (Message message : model.getBpmnModel().getMessages()) {
        items[counter] = message.getId() + " / " + message.getName();
        if (message.getId().equals(messageRef)) {
          selectedCounter = counter;
        }
        counter++;
      }

      messageCombo.setItems(items);
      messageCombo.select(selectedCounter);
    }
    cancelActivityCombo.addFocusListener(listener);
    messageCombo.addFocusListener(listener);
  }
  protected void convertElementToJson(ObjectNode propertiesNode, FlowElement flowElement) {
    BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
    ArrayNode dockersArrayNode = objectMapper.createArrayNode();
    ObjectNode dockNode = objectMapper.createObjectNode();
    GraphicInfo graphicInfo = model.getGraphicInfo(boundaryEvent.getId());
    GraphicInfo parentGraphicInfo = model.getGraphicInfo(boundaryEvent.getAttachedToRef().getId());
    dockNode.put(EDITOR_BOUNDS_X, graphicInfo.x + graphicInfo.width - parentGraphicInfo.x);
    dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.y - parentGraphicInfo.y);
    dockersArrayNode.add(dockNode);
    flowElementNode.put("dockers", dockersArrayNode);

    addEventProperties(boundaryEvent, propertiesNode);
  }
  public Object[] create(ICreateContext context) {
    BoundaryEvent boundaryEvent = new BoundaryEvent();
    CompensateEventDefinition compensateEvent = new CompensateEventDefinition();
    boundaryEvent.getEventDefinitions().add(compensateEvent);

    Object parentObject = getBusinessObjectForPictogramElement(context.getTargetContainer());
    ((Activity) parentObject).getBoundaryEvents().add(boundaryEvent);
    boundaryEvent.setAttachedToRef((Activity) parentObject);

    addObjectToContainer(context, boundaryEvent, "Compensate");

    // return newly created business object(s)
    return new Object[] {boundaryEvent};
  }
  private void validateModel(BpmnModel model) {

    BoundaryEvent errorElement =
        (BoundaryEvent) model.getMainProcess().getFlowElement("errorEvent");
    ErrorEventDefinition errorEvent = (ErrorEventDefinition) extractEventDefinition(errorElement);
    assertTrue(errorElement.isCancelActivity()); // always true
    assertEquals("errorRef", errorEvent.getErrorCode());

    BoundaryEvent signalElement =
        (BoundaryEvent) model.getMainProcess().getFlowElement("signalEvent");
    SignalEventDefinition signalEvent =
        (SignalEventDefinition) extractEventDefinition(signalElement);
    assertFalse(signalElement.isCancelActivity());
    assertEquals("signalRef", signalEvent.getSignalRef());

    BoundaryEvent messageElement =
        (BoundaryEvent) model.getMainProcess().getFlowElement("messageEvent");
    MessageEventDefinition messageEvent =
        (MessageEventDefinition) extractEventDefinition(messageElement);
    assertFalse(messageElement.isCancelActivity());
    assertEquals("messageRef", messageEvent.getMessageRef());

    BoundaryEvent timerElement =
        (BoundaryEvent) model.getMainProcess().getFlowElement("timerEvent");
    TimerEventDefinition timerEvent = (TimerEventDefinition) extractEventDefinition(timerElement);
    assertFalse(timerElement.isCancelActivity());
    assertEquals("PT5M", timerEvent.getTimeDuration());
  }
 protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode) {
   BoundaryEvent boundaryEvent = new BoundaryEvent();
   String stencilId = BpmnJsonConverterUtil.getStencilId(elementNode);
   if (STENCIL_EVENT_BOUNDARY_TIMER.equals(stencilId)) {
     convertJsonToTimerDefinition(elementNode, boundaryEvent);
   } else if (STENCIL_EVENT_BOUNDARY_ERROR.equals(stencilId)) {
     convertJsonToErrorDefinition(elementNode, boundaryEvent);
   } else if (STENCIL_EVENT_BOUNDARY_SIGNAL.equals(stencilId)) {
     convertJsonToSignalDefinition(elementNode, boundaryEvent);
   }
   boundaryEvent.setAttachedToRefId(
       lookForAttachedRef(
           elementNode.get(EDITOR_SHAPE_ID).asText(), modelNode.get(EDITOR_CHILD_SHAPES)));
   return boundaryEvent;
 }
  protected String getStencilId(FlowElement flowElement) {
    BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
    List<EventDefinition> eventDefinitions = boundaryEvent.getEventDefinitions();
    if (eventDefinitions.size() != 1) {
      // return timer event as default;
      return STENCIL_EVENT_BOUNDARY_TIMER;
    }

    EventDefinition eventDefinition = eventDefinitions.get(0);
    if (eventDefinition instanceof ErrorEventDefinition) {
      return STENCIL_EVENT_BOUNDARY_ERROR;
    } else if (eventDefinition instanceof SignalEventDefinition) {
      return STENCIL_EVENT_BOUNDARY_SIGNAL;
    } else {
      return STENCIL_EVENT_BOUNDARY_TIMER;
    }
  }
  public void convertToJson(
      BaseElement baseElement,
      ActivityProcessor processor,
      BpmnModel model,
      FlowElementsContainer container,
      ArrayNode shapesArrayNode,
      double subProcessX,
      double subProcessY) {

    this.model = model;
    this.processor = processor;
    this.subProcessX = subProcessX;
    this.subProcessY = subProcessY;
    this.shapesArrayNode = shapesArrayNode;
    GraphicInfo graphicInfo = model.getGraphicInfo(baseElement.getId());

    String stencilId = null;
    if (baseElement instanceof ServiceTask) {
      ServiceTask serviceTask = (ServiceTask) baseElement;
      if ("mail".equalsIgnoreCase(serviceTask.getType())) {
        stencilId = STENCIL_TASK_MAIL;
      } else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
        stencilId = STENCIL_TASK_CAMEL;
      } else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
        stencilId = STENCIL_TASK_MULE;
      } else {
        stencilId = getStencilId(baseElement);
      }
    } else {
      stencilId = getStencilId(baseElement);
    }

    flowElementNode =
        BpmnJsonConverterUtil.createChildShape(
            baseElement.getId(),
            stencilId,
            graphicInfo.getX() - subProcessX + graphicInfo.getWidth(),
            graphicInfo.getY() - subProcessY + graphicInfo.getHeight(),
            graphicInfo.getX() - subProcessX,
            graphicInfo.getY() - subProcessY);
    shapesArrayNode.add(flowElementNode);
    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, baseElement.getId());

    if (baseElement instanceof FlowElement) {
      FlowElement flowElement = (FlowElement) baseElement;
      if (StringUtils.isNotEmpty(flowElement.getName())) {
        propertiesNode.put(PROPERTY_NAME, flowElement.getName());
      }

      if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
        propertiesNode.put(PROPERTY_DOCUMENTATION, flowElement.getDocumentation());
      }
    }

    convertElementToJson(propertiesNode, baseElement);

    flowElementNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();

    if (baseElement instanceof FlowNode) {
      FlowNode flowNode = (FlowNode) baseElement;
      for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
        outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getId()));
      }

      for (MessageFlow messageFlow : model.getMessageFlows().values()) {
        if (messageFlow.getSourceRef().equals(flowNode.getId())) {
          outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(messageFlow.getId()));
        }
      }
    }

    if (baseElement instanceof Activity) {

      Activity activity = (Activity) baseElement;
      for (BoundaryEvent boundaryEvent : activity.getBoundaryEvents()) {
        outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(boundaryEvent.getId()));
      }

      propertiesNode.put(PROPERTY_ASYNCHRONOUS, activity.isAsynchronous());
      propertiesNode.put(PROPERTY_EXCLUSIVE, !activity.isNotExclusive());

      if (activity.getLoopCharacteristics() != null) {
        MultiInstanceLoopCharacteristics loopDef = activity.getLoopCharacteristics();
        if (StringUtils.isNotEmpty(loopDef.getLoopCardinality())
            || StringUtils.isNotEmpty(loopDef.getInputDataItem())
            || StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {

          if (loopDef.isSequential() == false) {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Parallel");
          } else {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_TYPE, "Sequential");
          }

          if (StringUtils.isNotEmpty(loopDef.getLoopCardinality())) {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_CARDINALITY, loopDef.getLoopCardinality());
          }
          if (StringUtils.isNotEmpty(loopDef.getInputDataItem())) {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_COLLECTION, loopDef.getInputDataItem());
          }
          if (StringUtils.isNotEmpty(loopDef.getElementVariable())) {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_VARIABLE, loopDef.getElementVariable());
          }
          if (StringUtils.isNotEmpty(loopDef.getCompletionCondition())) {
            propertiesNode.put(PROPERTY_MULTIINSTANCE_CONDITION, loopDef.getCompletionCondition());
          }
        }
      }

      if (activity instanceof UserTask) {
        BpmnJsonConverterUtil.convertListenersToJson(
            ((UserTask) activity).getTaskListeners(), false, propertiesNode);
      }

      BpmnJsonConverterUtil.convertListenersToJson(
          activity.getExecutionListeners(), true, propertiesNode);

      if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
        for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
          if (model.getFlowElement(dataAssociation.getSourceRef()) != null) {
            createDataAssociation(dataAssociation, true, activity);
          }
        }
      }

      if (CollectionUtils.isNotEmpty(activity.getDataOutputAssociations())) {
        for (DataAssociation dataAssociation : activity.getDataOutputAssociations()) {
          if (model.getFlowElement(dataAssociation.getTargetRef()) != null) {
            createDataAssociation(dataAssociation, false, activity);
            outgoingArrayNode.add(
                BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
          }
        }
      }
    }

    for (Artifact artifact : container.getArtifacts()) {
      if (artifact instanceof Association) {
        Association association = (Association) artifact;
        if (StringUtils.isNotEmpty(association.getSourceRef())
            && association.getSourceRef().equals(baseElement.getId())) {
          outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(association.getId()));
        }
      }
    }

    if (baseElement instanceof DataStoreReference) {
      for (Process process : model.getProcesses()) {
        processDataStoreReferences(process, baseElement.getId(), outgoingArrayNode);
      }
    }

    flowElementNode.put("outgoing", outgoingArrayNode);
  }
  private void drawFlowElements(
      Collection<FlowElement> elementList,
      Map<String, GraphicInfo> locationMap,
      ContainerShape parentShape,
      Process process) {

    final IFeatureProvider featureProvider = getDiagramTypeProvider().getFeatureProvider();

    List<FlowElement> noDIList = new ArrayList<FlowElement>();
    for (FlowElement flowElement : elementList) {

      if (flowElement instanceof SequenceFlow) {
        continue;
      }

      AddContext context = new AddContext(new AreaContext(), flowElement);
      IAddFeature addFeature = featureProvider.getAddFeature(context);

      if (addFeature == null) {
        System.out.println("Element not supported: " + flowElement);
        return;
      }

      GraphicInfo graphicInfo = locationMap.get(flowElement.getId());
      if (graphicInfo == null) {

        noDIList.add(flowElement);

      } else {

        context.setNewObject(flowElement);
        context.setSize((int) graphicInfo.getWidth(), (int) graphicInfo.getHeight());

        ContainerShape parentContainer = null;
        if (parentShape instanceof Diagram) {
          parentContainer = getParentContainer(flowElement.getId(), process, (Diagram) parentShape);
        } else {
          parentContainer = parentShape;
        }

        context.setTargetContainer(parentContainer);
        if (parentContainer instanceof Diagram == false) {
          Point location = getLocation(parentContainer);
          context.setLocation(
              (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y);
        } else {
          context.setLocation((int) graphicInfo.getX(), (int) graphicInfo.getY());
        }

        if (flowElement instanceof ServiceTask) {

          ServiceTask serviceTask = (ServiceTask) flowElement;

          if (serviceTask.isExtended()) {

            CustomServiceTask targetTask = findCustomServiceTask(serviceTask);

            if (targetTask != null) {

              for (FieldExtension field : serviceTask.getFieldExtensions()) {
                CustomProperty customFieldProperty = new CustomProperty();
                customFieldProperty.setName(field.getFieldName());
                if (StringUtils.isNotEmpty(field.getExpression())) {
                  customFieldProperty.setSimpleValue(field.getExpression());
                } else {
                  customFieldProperty.setSimpleValue(field.getStringValue());
                }
                serviceTask.getCustomProperties().add(customFieldProperty);
              }

              serviceTask.getFieldExtensions().clear();
            }
          }
        }

        if (flowElement instanceof BoundaryEvent) {
          BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
          if (boundaryEvent.getAttachedToRef() != null) {
            ContainerShape container =
                (ContainerShape)
                    featureProvider.getPictogramElementForBusinessObject(
                        boundaryEvent.getAttachedToRef());

            if (container != null) {
              AddContext boundaryContext = new AddContext(new AreaContext(), boundaryEvent);
              boundaryContext.setTargetContainer(container);
              Point location = getLocation(container);
              boundaryContext.setLocation(
                  (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y);

              if (addFeature.canAdd(boundaryContext)) {
                PictogramElement newBoundaryContainer = addFeature.add(boundaryContext);
                // featureProvider.link(newBoundaryContainer, new Object[] { boundaryEvent });
              }
            }
          }
        } else if (addFeature.canAdd(context)) {
          PictogramElement newContainer = addFeature.add(context);
          featureProvider.link(newContainer, new Object[] {flowElement});

          if (flowElement instanceof SubProcess) {
            drawFlowElements(
                ((SubProcess) flowElement).getFlowElements(),
                locationMap,
                (ContainerShape) newContainer,
                process);
          }
        }
      }
    }

    for (FlowElement flowElement : noDIList) {
      if (flowElement instanceof BoundaryEvent) {
        ((BoundaryEvent) flowElement).getAttachedToRef().getBoundaryEvents().remove(flowElement);
      } else {
        elementList.remove(flowElement);
      }
    }
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  protected void drawFlowElements(
      Collection<FlowElement> elementList,
      Map<String, GraphicInfo> locationMap,
      ContainerShape parentShape,
      Process process) {

    final IFeatureProvider featureProvider = getDiagramTypeProvider().getFeatureProvider();

    List<FlowElement> noDIList = new ArrayList<FlowElement>();
    for (FlowElement flowElement : elementList) {

      if (flowElement instanceof SequenceFlow) {
        continue;
      }

      AddContext context = new AddContext(new AreaContext(), flowElement);
      IAddFeature addFeature = featureProvider.getAddFeature(context);

      if (addFeature == null) {
        System.out.println("Element not supported: " + flowElement);
        return;
      }

      GraphicInfo graphicInfo = locationMap.get(flowElement.getId());
      if (graphicInfo == null) {

        noDIList.add(flowElement);

      } else {

        context.setNewObject(flowElement);
        context.setSize((int) graphicInfo.getWidth(), (int) graphicInfo.getHeight());
        ContainerShape parentContainer = null;
        if (parentShape instanceof Diagram) {
          parentContainer = getParentContainer(flowElement.getId(), process, (Diagram) parentShape);
        } else {
          parentContainer = parentShape;
        }

        context.setTargetContainer(parentContainer);
        if (parentContainer instanceof Diagram == false) {
          Point location = getLocation(parentContainer);
          context.setLocation(
              (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y);
        } else {
          context.setLocation((int) graphicInfo.getX(), (int) graphicInfo.getY());
        }

        if (flowElement instanceof ServiceTask) {

          ServiceTask serviceTask = (ServiceTask) flowElement;

          if (serviceTask.isExtended()) {

            CustomServiceTask targetTask = findCustomServiceTask(serviceTask);

            if (targetTask != null) {

              for (FieldExtension field : serviceTask.getFieldExtensions()) {
                CustomProperty customFieldProperty = new CustomProperty();
                customFieldProperty.setName(field.getFieldName());
                if (StringUtils.isNotEmpty(field.getExpression())) {
                  customFieldProperty.setSimpleValue(field.getExpression());
                } else {
                  customFieldProperty.setSimpleValue(field.getStringValue());
                }
                serviceTask.getCustomProperties().add(customFieldProperty);
              }

              serviceTask.getFieldExtensions().clear();
            }
          }

        } else if (flowElement instanceof UserTask) {

          UserTask userTask = (UserTask) flowElement;

          if (userTask.isExtended()) {

            CustomUserTask targetTask = findCustomUserTask(userTask);

            if (targetTask != null) {

              final List<Class<CustomUserTask>> classHierarchy =
                  new ArrayList<Class<CustomUserTask>>();
              final List<String> fieldInfoObjects = new ArrayList<String>();

              Class clazz = targetTask.getClass();
              classHierarchy.add(clazz);

              boolean hierarchyOpen = true;
              while (hierarchyOpen) {
                clazz = clazz.getSuperclass();
                if (CustomUserTask.class.isAssignableFrom(clazz)) {
                  classHierarchy.add(clazz);
                } else {
                  hierarchyOpen = false;
                }
              }

              for (final Class<CustomUserTask> currentClass : classHierarchy) {
                for (final Field field : currentClass.getDeclaredFields()) {
                  if (field.isAnnotationPresent(Property.class)) {
                    fieldInfoObjects.add(field.getName());
                  }
                }
              }

              for (String fieldName : userTask.getExtensionElements().keySet()) {
                if (fieldInfoObjects.contains(fieldName)) {
                  CustomProperty customFieldProperty = new CustomProperty();
                  customFieldProperty.setName(fieldName);
                  customFieldProperty.setSimpleValue(
                      userTask.getExtensionElements().get(fieldName).get(0).getElementText());
                  userTask.getCustomProperties().add(customFieldProperty);
                }
              }

              for (String fieldName : fieldInfoObjects) {
                userTask.getExtensionElements().remove(fieldName);
              }
            }
          }
        }

        if (flowElement instanceof BoundaryEvent) {
          BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
          if (boundaryEvent.getAttachedToRef() != null) {
            ContainerShape container =
                (ContainerShape)
                    featureProvider.getPictogramElementForBusinessObject(
                        boundaryEvent.getAttachedToRef());

            if (container != null) {
              AddContext boundaryContext = new AddContext(new AreaContext(), boundaryEvent);
              boundaryContext.setTargetContainer(container);
              Point location = getLocation(container);
              boundaryContext.setLocation(
                  (int) graphicInfo.getX() - location.x, (int) graphicInfo.getY() - location.y);

              if (addFeature.canAdd(boundaryContext)) {
                addFeature.add(boundaryContext);
              }
            }
          }
        } else if (addFeature.canAdd(context)) {
          PictogramElement newContainer = addFeature.add(context);
          featureProvider.link(newContainer, new Object[] {flowElement});

          if (flowElement instanceof SubProcess) {
            drawFlowElements(
                ((SubProcess) flowElement).getFlowElements(),
                locationMap,
                (ContainerShape) newContainer,
                process);
          }
        }
      }
    }

    for (FlowElement flowElement : noDIList) {
      if (flowElement instanceof BoundaryEvent) {
        ((BoundaryEvent) flowElement).getAttachedToRef().getBoundaryEvents().remove(flowElement);
      } else {
        // do not remove Data Objects
        if (flowElement instanceof DataObject == false) {
          elementList.remove(flowElement);
        }
      }
    }
  }