Ejemplo n.º 1
0
  protected void writeMessageDefinition(
      Event parentEvent,
      MessageEventDefinition messageDefinition,
      BpmnModel model,
      XMLStreamWriter xtw)
      throws Exception {
    xtw.writeStartElement(ELEMENT_EVENT_MESSAGEDEFINITION);

    String messageRef = messageDefinition.getMessageRef();
    if (StringUtils.isNotEmpty(messageRef)) {
      // remove the namespace from the message id if set
      if (messageRef.startsWith(model.getTargetNamespace())) {
        messageRef = messageRef.replace(model.getTargetNamespace(), "");
        messageRef = messageRef.replaceFirst(":", "");
      } else {
        for (String prefix : model.getNamespaces().keySet()) {
          String namespace = model.getNamespace(prefix);
          if (messageRef.startsWith(namespace)) {
            messageRef = messageRef.replace(model.getTargetNamespace(), "");
            messageRef = prefix + messageRef;
          }
        }
      }
    }
    writeDefaultAttribute(ATTRIBUTE_MESSAGE_REF, messageRef, xtw);
    boolean didWriteExtensionStartElement =
        BpmnXMLUtil.writeExtensionElements(messageDefinition, false, xtw);
    if (didWriteExtensionStartElement) {
      xtw.writeEndElement();
    }
    xtw.writeEndElement();
  }
Ejemplo n.º 2
0
  protected void writeTimerDefinition(
      Event parentEvent, TimerEventDefinition timerDefinition, XMLStreamWriter xtw)
      throws Exception {
    xtw.writeStartElement(ELEMENT_EVENT_TIMERDEFINITION);
    boolean didWriteExtensionStartElement =
        BpmnXMLUtil.writeExtensionElements(timerDefinition, false, xtw);
    if (didWriteExtensionStartElement) {
      xtw.writeEndElement();
    }
    if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
      xtw.writeStartElement(ATTRIBUTE_TIMER_DATE);
      xtw.writeCharacters(timerDefinition.getTimeDate());
      xtw.writeEndElement();

    } else if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
      xtw.writeStartElement(ATTRIBUTE_TIMER_CYCLE);
      xtw.writeCharacters(timerDefinition.getTimeCycle());
      xtw.writeEndElement();

    } else if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
      xtw.writeStartElement(ATTRIBUTE_TIMER_DURATION);
      xtw.writeCharacters(timerDefinition.getTimeDuration());
      xtw.writeEndElement();
    }

    xtw.writeEndElement();
  }
Ejemplo n.º 3
0
 protected void writeTerminateDefinition(
     Event parentEvent, TerminateEventDefinition terminateDefinition, XMLStreamWriter xtw)
     throws Exception {
   xtw.writeStartElement(ELEMENT_EVENT_TERMINATEDEFINITION);
   boolean didWriteExtensionStartElement =
       BpmnXMLUtil.writeExtensionElements(terminateDefinition, false, xtw);
   if (didWriteExtensionStartElement) {
     xtw.writeEndElement();
   }
   xtw.writeEndElement();
 }
Ejemplo n.º 4
0
 protected void writeErrorDefinition(
     Event parentEvent, ErrorEventDefinition errorDefinition, XMLStreamWriter xtw)
     throws Exception {
   xtw.writeStartElement(ELEMENT_EVENT_ERRORDEFINITION);
   writeDefaultAttribute(ATTRIBUTE_ERROR_REF, errorDefinition.getErrorCode(), xtw);
   boolean didWriteExtensionStartElement =
       BpmnXMLUtil.writeExtensionElements(errorDefinition, false, xtw);
   if (didWriteExtensionStartElement) {
     xtw.writeEndElement();
   }
   xtw.writeEndElement();
 }
Ejemplo n.º 5
0
 protected void writeSignalDefinition(
     Event parentEvent, SignalEventDefinition signalDefinition, XMLStreamWriter xtw)
     throws Exception {
   xtw.writeStartElement(ELEMENT_EVENT_SIGNALDEFINITION);
   writeDefaultAttribute(ATTRIBUTE_SIGNAL_REF, signalDefinition.getSignalRef(), xtw);
   if (parentEvent instanceof ThrowEvent && signalDefinition.isAsync()) {
     BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, "true", xtw);
   }
   boolean didWriteExtensionStartElement =
       BpmnXMLUtil.writeExtensionElements(signalDefinition, false, xtw);
   if (didWriteExtensionStartElement) {
     xtw.writeEndElement();
   }
   xtw.writeEndElement();
 }
Ejemplo n.º 6
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.º 7
0
  @SuppressWarnings("unchecked")
  public static void writeProcess(Process process, XMLStreamWriter xtw) throws Exception {
    // start process element
    xtw.writeStartElement(ELEMENT_PROCESS);
    xtw.writeAttribute(ATTRIBUTE_ID, process.getId());

    if (StringUtils.isNotEmpty(process.getName())) {
      xtw.writeAttribute(ATTRIBUTE_NAME, process.getName());
    }

    xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable()));
    xtw.writeAttribute("isClosed", Boolean.toString(process.isClosed()));
    if (StringUtils.isNotEmpty(process.getProcessType())) {
      xtw.writeAttribute("processType", process.getProcessType());
    }

    if (process.getCandidateStarterUsers().size() > 0) {
      xtw.writeAttribute(
          ACTIVITI_EXTENSIONS_PREFIX,
          ACTIVITI_EXTENSIONS_NAMESPACE,
          ATTRIBUTE_PROCESS_CANDIDATE_USERS,
          BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers()));
    }

    if (process.getCandidateStarterGroups().size() > 0) {
      xtw.writeAttribute(
          ACTIVITI_EXTENSIONS_PREFIX,
          ACTIVITI_EXTENSIONS_NAMESPACE,
          ATTRIBUTE_PROCESS_CANDIDATE_GROUPS,
          BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups()));
    }

    // write custom attributes
    BpmnXMLUtil.writeCustomAttributes(
        process.getAttributes().values(), xtw, defaultProcessAttributes);

    if (!process.getDocumentations().isEmpty()) {
      for (Documentation documentation : process.getDocumentations()) {
        xtw.writeStartElement(ELEMENT_DOCUMENTATION);
        if (StringUtils.isNotEmpty(documentation.getId())) {
          writeDefaultAttribute(ATTRIBUTE_ID, documentation.getId(), xtw);
        }
        if (StringUtils.isNotEmpty(documentation.getTextFormat())) {
          writeDefaultAttribute(ATTRIBUTE_TEXTFORMAT, documentation.getTextFormat(), xtw);
        }
        if (StringUtils.isNotEmpty(documentation.getText())) {
          xtw.writeCData(documentation.getText());
        }
        xtw.writeEndElement();
      }
    }

    boolean didWriteExtensionStartElement =
        ActivitiListenerExport.writeListeners(process, false, xtw);
    didWriteExtensionStartElement =
        BpmnXMLUtil.writeExtensionElements(process, didWriteExtensionStartElement, xtw);

    if (didWriteExtensionStartElement) {
      // closing extensions element
      xtw.writeEndElement();
    }
    if (process.getIoSpecification() != null) {
      BpmnXMLUtil.writeIOSpecification(process.getIoSpecification(), xtw);
    }

    LaneExport.writeLanes(process, xtw);
  }