public static void writeMultiInstance(Activity activity, XMLStreamWriter xtw) throws Exception {
    if (activity.getLoopCharacteristics() != null) {
      MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics();
      if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())
          || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())
          || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) {

        xtw.writeStartElement(ELEMENT_MULTIINSTANCE);
        BpmnXMLUtil.writeDefaultAttribute(
            ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL,
            String.valueOf(multiInstanceObject.isSequential()).toLowerCase(),
            xtw);
        if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) {
          BpmnXMLUtil.writeQualifiedAttribute(
              ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw);
        }
        if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) {
          BpmnXMLUtil.writeQualifiedAttribute(
              ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw);
        }
        if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) {
          xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY);
          xtw.writeCharacters(multiInstanceObject.getLoopCardinality());
          xtw.writeEndElement();
        }
        if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) {
          xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION);
          xtw.writeCharacters(multiInstanceObject.getCompletionCondition());
          xtw.writeEndElement();
        }
        xtw.writeEndElement();
      }
    }
  }
  protected void createDataAssociation(
      DataAssociation dataAssociation, boolean incoming, Activity activity) {
    String sourceRef = null;
    String targetRef = null;
    if (incoming) {
      sourceRef = dataAssociation.getSourceRef();
      targetRef = activity.getId();

    } else {
      sourceRef = activity.getId();
      targetRef = dataAssociation.getTargetRef();
    }

    ObjectNode flowNode =
        BpmnJsonConverterUtil.createChildShape(
            dataAssociation.getId(), STENCIL_DATA_ASSOCIATION, 172, 212, 128, 212);
    ArrayNode dockersArrayNode = objectMapper.createArrayNode();
    ObjectNode dockNode = objectMapper.createObjectNode();

    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sourceRef).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sourceRef).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);

    if (model.getFlowLocationGraphicInfo(dataAssociation.getId()).size() > 2) {
      for (int i = 1;
          i < model.getFlowLocationGraphicInfo(dataAssociation.getId()).size() - 1;
          i++) {
        GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(dataAssociation.getId()).get(i);
        dockNode = objectMapper.createObjectNode();
        dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX());
        dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY());
        dockersArrayNode.add(dockNode);
      }
    }

    dockNode = objectMapper.createObjectNode();
    dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(targetRef).getWidth() / 2.0);
    dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(targetRef).getHeight() / 2.0);
    dockersArrayNode.add(dockNode);
    flowNode.put("dockers", dockersArrayNode);
    ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
    outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(targetRef));
    flowNode.put("outgoing", outgoingArrayNode);
    flowNode.put("target", BpmnJsonConverterUtil.createResourceNode(targetRef));

    ObjectNode propertiesNode = objectMapper.createObjectNode();
    propertiesNode.put(PROPERTY_OVERRIDE_ID, dataAssociation.getId());

    flowNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
    shapesArrayNode.add(flowNode);
  }
Ejemplo n.º 3
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);
     }
   }
 }
  protected void processDataStoreReferences(
      FlowElementsContainer container, String dataStoreReferenceId, ArrayNode outgoingArrayNode) {
    for (FlowElement flowElement : container.getFlowElements()) {
      if (flowElement instanceof Activity) {
        Activity activity = (Activity) flowElement;

        if (CollectionUtils.isNotEmpty(activity.getDataInputAssociations())) {
          for (DataAssociation dataAssociation : activity.getDataInputAssociations()) {
            if (dataStoreReferenceId.equals(dataAssociation.getSourceRef())) {
              outgoingArrayNode.add(
                  BpmnJsonConverterUtil.createResourceNode(dataAssociation.getId()));
            }
          }
        }

      } else if (flowElement instanceof SubProcess) {
        processDataStoreReferences(
            (SubProcess) flowElement, dataStoreReferenceId, outgoingArrayNode);
      }
    }
  }
  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};
  }
Ejemplo n.º 6
0
  public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model)
      throws Exception {

    /*if (parentElement instanceof ServiceTask == false && parentElement instanceof SendTask == false &&
        parentElement instanceof SubProcess == false && parentElement instanceof Process == false) return;
    */

    if (parentElement instanceof Activity == false && parentElement instanceof Process == false)
      return;
    IOSpecification ioSpecification = new IOSpecification();
    BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
    boolean readyWithIOSpecification = false;
    System.out.println("IOSPEC PARSE " + parentElement);
    try {
      while (readyWithIOSpecification == false && xtr.hasNext()) {
        xtr.next();
        if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
          inputParser.parseChildElement(xtr, ioSpecification, model);

        } else if (xtr.isStartElement()
            && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
          outputParser.parseChildElement(xtr, ioSpecification, model);

        } else if (xtr.isStartElement()
            && ELEMENT_DATA_INPUTSET.equalsIgnoreCase(xtr.getLocalName())) {
          inputSetParser.parseChildElement(xtr, ioSpecification, model);

        } else if (xtr.isStartElement()
            && ELEMENT_DATA_OUTPUTSET.equalsIgnoreCase(xtr.getLocalName())) {
          outputsetParser.parseChildElement(xtr, ioSpecification, model);

        } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
          readyWithIOSpecification = true;
        }
      }
    } catch (Exception e) {
      LOGGER.warn("Error parsing ioSpecification child elements", e);
    }

    if (parentElement instanceof Process) {
      ((Process) parentElement).setIoSpecification(ioSpecification);
    } else {
      ((Activity) parentElement).setIoSpecification(ioSpecification);
    }
  }
  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);
  }
  public void convertToBpmnModel(
      JsonNode elementNode,
      JsonNode modelNode,
      ActivityProcessor processor,
      BaseElement parentElement,
      Map<String, JsonNode> shapeMap,
      BpmnModel bpmnModel) {

    this.processor = processor;
    this.model = bpmnModel;

    BaseElement baseElement = convertJsonToElement(elementNode, modelNode, shapeMap);
    baseElement.setId(BpmnJsonConverterUtil.getElementId(elementNode));

    if (baseElement instanceof FlowElement) {
      FlowElement flowElement = (FlowElement) baseElement;
      flowElement.setName(getPropertyValueAsString(PROPERTY_NAME, elementNode));
      flowElement.setDocumentation(getPropertyValueAsString(PROPERTY_DOCUMENTATION, elementNode));

      BpmnJsonConverterUtil.convertJsonToListeners(elementNode, flowElement);

      if (baseElement instanceof Activity) {
        Activity activity = (Activity) baseElement;
        activity.setAsynchronous(getPropertyValueAsBoolean(PROPERTY_ASYNCHRONOUS, elementNode));
        activity.setNotExclusive(!getPropertyValueAsBoolean(PROPERTY_EXCLUSIVE, elementNode));

        String multiInstanceType =
            getPropertyValueAsString(PROPERTY_MULTIINSTANCE_TYPE, elementNode);
        String multiInstanceCardinality =
            getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CARDINALITY, elementNode);
        String multiInstanceCollection =
            getPropertyValueAsString(PROPERTY_MULTIINSTANCE_COLLECTION, elementNode);
        String multiInstanceCondition =
            getPropertyValueAsString(PROPERTY_MULTIINSTANCE_CONDITION, elementNode);

        if (StringUtils.isNotEmpty(multiInstanceType)
            && "none".equalsIgnoreCase(multiInstanceType) == false) {

          String multiInstanceVariable =
              getPropertyValueAsString(PROPERTY_MULTIINSTANCE_VARIABLE, elementNode);

          MultiInstanceLoopCharacteristics multiInstanceObject =
              new MultiInstanceLoopCharacteristics();
          if ("sequential".equalsIgnoreCase(multiInstanceType)) {
            multiInstanceObject.setSequential(true);
          } else {
            multiInstanceObject.setSequential(false);
          }
          multiInstanceObject.setLoopCardinality(multiInstanceCardinality);
          multiInstanceObject.setInputDataItem(multiInstanceCollection);
          multiInstanceObject.setElementVariable(multiInstanceVariable);
          multiInstanceObject.setCompletionCondition(multiInstanceCondition);
          activity.setLoopCharacteristics(multiInstanceObject);
        }

      } else if (baseElement instanceof Gateway) {
        JsonNode flowOrderNode = getProperty(PROPERTY_SEQUENCEFLOW_ORDER, elementNode);
        if (flowOrderNode != null) {
          flowOrderNode = BpmnJsonConverterUtil.validateIfNodeIsTextual(flowOrderNode);
          JsonNode orderArray = flowOrderNode.get("sequenceFlowOrder");
          if (orderArray != null && orderArray.size() > 0) {
            for (JsonNode orderNode : orderArray) {
              ExtensionElement orderElement = new ExtensionElement();
              orderElement.setName("EDITOR_FLOW_ORDER");
              orderElement.setElementText(orderNode.asText());
              flowElement.addExtensionElement(orderElement);
            }
          }
        }
      }
    }

    if (baseElement instanceof FlowElement) {
      FlowElement flowElement = (FlowElement) baseElement;
      if (flowElement instanceof SequenceFlow) {
        ExtensionElement idExtensionElement = new ExtensionElement();
        idExtensionElement.setName("EDITOR_RESOURCEID");
        idExtensionElement.setElementText(elementNode.get(EDITOR_SHAPE_ID).asText());
        flowElement.addExtensionElement(idExtensionElement);
      }

      if (parentElement instanceof Process) {
        ((Process) parentElement).addFlowElement(flowElement);

      } else if (parentElement instanceof SubProcess) {
        ((SubProcess) parentElement).addFlowElement(flowElement);

      } else if (parentElement instanceof Lane) {
        Lane lane = (Lane) parentElement;
        lane.getFlowReferences().add(flowElement.getId());
        lane.getParentProcess().addFlowElement(flowElement);
      }

    } else if (baseElement instanceof Artifact) {
      Artifact artifact = (Artifact) baseElement;
      if (parentElement instanceof Process) {
        ((Process) parentElement).addArtifact(artifact);

      } else if (parentElement instanceof SubProcess) {
        ((SubProcess) parentElement).addArtifact(artifact);

      } else if (parentElement instanceof Lane) {
        Lane lane = (Lane) parentElement;
        lane.getFlowReferences().add(artifact.getId());
        lane.getParentProcess().addArtifact(artifact);
      }
    }
  }
Ejemplo n.º 9
0
  public void convertToBpmnModel(
      XMLStreamReader xtr,
      BpmnModel model,
      Process activeProcess,
      List<SubProcess> activeSubProcessList)
      throws Exception {

    String elementId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
    String elementName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
    boolean async = parseAsync(xtr);
    boolean notExclusive = parseNotExclusive(xtr);
    String defaultFlow = xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT);
    boolean isForCompensation = parseForCompensation(xtr);

    BaseElement parsedElement = convertXMLToElement(xtr, model);

    if (parsedElement instanceof Artifact) {
      Artifact currentArtifact = (Artifact) parsedElement;
      currentArtifact.setId(elementId);

      if (isInSubProcess(activeSubProcessList)) {
        final SubProcess currentSubProcess =
            activeSubProcessList.get(activeSubProcessList.size() - 2);
        currentSubProcess.addArtifact(currentArtifact);

      } else {
        activeProcess.addArtifact(currentArtifact);
      }
    }

    if (parsedElement instanceof FlowElement) {

      FlowElement currentFlowElement = (FlowElement) parsedElement;
      currentFlowElement.setId(elementId);
      currentFlowElement.setName(elementName);

      if (currentFlowElement instanceof Activity) {

        Activity activity = (Activity) currentFlowElement;
        activity.setAsynchronous(async);
        activity.setNotExclusive(notExclusive);
        activity.setForCompensation(isForCompensation);
        if (StringUtils.isNotEmpty(defaultFlow)) {
          activity.setDefaultFlow(defaultFlow);
        }
      }

      if (currentFlowElement instanceof Gateway) {
        Gateway gateway = (Gateway) currentFlowElement;
        if (StringUtils.isNotEmpty(defaultFlow)) {
          gateway.setDefaultFlow(defaultFlow);
        }

        gateway.setAsynchronous(async);
        gateway.setNotExclusive(notExclusive);
      }

      if (currentFlowElement instanceof DataObject) {
        if (activeSubProcessList.size() > 0) {
          activeSubProcessList
              .get(activeSubProcessList.size() - 1)
              .getDataObjects()
              .add((ValuedDataObject) parsedElement);
        } else {
          activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
        }
      }

      if (activeSubProcessList.size() > 0) {
        activeSubProcessList
            .get(activeSubProcessList.size() - 1)
            .addFlowElement(currentFlowElement);
      } else {
        activeProcess.addFlowElement(currentFlowElement);
      }
    }
  }
Ejemplo n.º 10
0
  public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model)
      throws Exception {
    xtw.writeStartElement(getXMLElementName());
    boolean didWriteExtensionStartElement = false;
    writeDefaultAttribute(ATTRIBUTE_ID, baseElement.getId(), xtw);
    if (baseElement instanceof FlowElement) {
      writeDefaultAttribute(ATTRIBUTE_NAME, ((FlowElement) baseElement).getName(), xtw);
    }

    if (baseElement instanceof Activity) {
      final Activity activity = (Activity) baseElement;
      if (activity.isAsynchronous()) {
        writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
        if (activity.isNotExclusive()) {
          writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
        }
      }
      if (StringUtils.isNotEmpty(activity.getDefaultFlow())) {
        FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow());
        if (defaultFlowElement != null && defaultFlowElement instanceof SequenceFlow) {
          writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw);
        }
      }
    }

    if (baseElement instanceof Gateway) {
      final Gateway gateway = (Gateway) baseElement;
      if (gateway.isAsynchronous()) {
        writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
        if (gateway.isNotExclusive()) {
          writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
        }
      }
      if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
        FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
        if (defaultFlowElement != null && defaultFlowElement instanceof SequenceFlow) {
          writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
        }
      }
    }

    writeAdditionalAttributes(baseElement, model, xtw);

    if (baseElement instanceof FlowElement) {
      final FlowElement flowElement = (FlowElement) baseElement;
      if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {

        xtw.writeStartElement(ELEMENT_DOCUMENTATION);
        xtw.writeCharacters(flowElement.getDocumentation());
        xtw.writeEndElement();
      }
    }

    didWriteExtensionStartElement =
        writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement =
        BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, xtw);

    if (didWriteExtensionStartElement) {
      xtw.writeEndElement();
    }

    if (baseElement instanceof Activity) {
      final Activity activity = (Activity) baseElement;
      MultiInstanceExport.writeMultiInstance(activity, xtw);
    }

    writeAdditionalChildElements(baseElement, model, xtw);

    xtw.writeEndElement();
  }
Ejemplo n.º 11
0
  public void convertToXML(XMLStreamWriter xtw, FlowElement flowElement) throws Exception {
    xtw.writeStartElement(getXMLElementName());
    didWriteExtensionStartElement = false;
    writeDefaultAttribute(ATTRIBUTE_ID, flowElement.getId(), xtw);
    writeDefaultAttribute(ATTRIBUTE_NAME, flowElement.getName(), xtw);

    if (flowElement instanceof Activity) {
      Activity activity = (Activity) flowElement;
      if (activity.isAsynchronous()) {
        writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
      }
      if (activity.isNotExclusive()) {
        writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
      }
      writeDefaultAttribute(ATTRIBUTE_ACTIVITY_DEFAULT, activity.getDefaultFlow(), xtw);
    }

    writeAdditionalAttributes(flowElement, xtw);
    if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {

      xtw.writeStartElement(ELEMENT_DOCUMENTATION);
      xtw.writeCharacters(flowElement.getDocumentation());
      xtw.writeEndElement();
    }
    writeAdditionalChildElements(flowElement, xtw);

    writeListeners(flowElement, xtw);

    if (didWriteExtensionStartElement) {
      xtw.writeEndElement();
    }

    if (flowElement instanceof Activity) {
      Activity activity = (Activity) flowElement;
      if (activity.getLoopCharacteristics() != null) {
        MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics();
        if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())
            || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())
            || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) {

          xtw.writeStartElement(ELEMENT_MULTIINSTANCE);
          writeDefaultAttribute(
              ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL,
              String.valueOf(multiInstanceObject.isSequential()).toLowerCase(),
              xtw);
          if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) {
            writeQualifiedAttribute(
                ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw);
          }
          if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) {
            writeQualifiedAttribute(
                ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw);
          }
          if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) {
            xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY);
            xtw.writeCharacters(multiInstanceObject.getLoopCardinality());
            xtw.writeEndElement();
          }
          if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) {
            xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION);
            xtw.writeCharacters(multiInstanceObject.getCompletionCondition());
            xtw.writeEndElement();
          }
          xtw.writeEndElement();
        }
      }
    }

    xtw.writeEndElement();
  }