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 void addEventProperties(Event event, ObjectNode propertiesNode) {
    List<EventDefinition> eventDefinitions = event.getEventDefinitions();
    if (eventDefinitions.size() == 1) {

      EventDefinition eventDefinition = eventDefinitions.get(0);
      if (eventDefinition instanceof ErrorEventDefinition) {
        ErrorEventDefinition errorDefinition = (ErrorEventDefinition) eventDefinition;
        if (StringUtils.isNotEmpty(errorDefinition.getErrorCode())) {
          propertiesNode.put(PROPERTY_ERRORREF, errorDefinition.getErrorCode());
        }

      } else if (eventDefinition instanceof SignalEventDefinition) {
        SignalEventDefinition signalDefinition = (SignalEventDefinition) eventDefinition;
        if (StringUtils.isNotEmpty(signalDefinition.getSignalRef())) {
          propertiesNode.put(PROPERTY_SIGNALREF, signalDefinition.getSignalRef());
        }

      } else if (eventDefinition instanceof MessageEventDefinition) {
        MessageEventDefinition messageDefinition = (MessageEventDefinition) eventDefinition;
        if (StringUtils.isNotEmpty(messageDefinition.getMessageRef())) {
          propertiesNode.put(PROPERTY_MESSAGEREF, messageDefinition.getMessageRef());
        }

      } else if (eventDefinition instanceof TimerEventDefinition) {
        TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
        if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
          propertiesNode.put(PROPERTY_TIMER_DURATON, timerDefinition.getTimeDuration());
        }
        if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
          propertiesNode.put(PROPERTY_TIMER_CYCLE, timerDefinition.getTimeCycle());
        }
        if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
          propertiesNode.put(PROPERTY_TIMER_DATE, timerDefinition.getTimeDate());
        }
        if (StringUtils.isNotEmpty(timerDefinition.getEndDate())) {
          propertiesNode.put(PROPERTY_TIMER_CYCLE_END_DATE, timerDefinition.getEndDate());
        }
      } else if (eventDefinition instanceof TerminateEventDefinition) {
        TerminateEventDefinition terminateEventDefinition =
            (TerminateEventDefinition) eventDefinition;
        propertiesNode.put(PROPERTY_TERMINATE_ALL, terminateEventDefinition.isTerminateAll());
      }
    }
  }
Exemplo n.º 3
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();
 }
 protected void convertJsonToErrorDefinition(JsonNode objectNode, Event event) {
   String errorRef = getPropertyValueAsString(PROPERTY_ERRORREF, objectNode);
   ErrorEventDefinition eventDefinition = new ErrorEventDefinition();
   eventDefinition.setErrorCode(errorRef);
   event.getEventDefinitions().add(eventDefinition);
 }
 protected void writeErrorDefinition(ErrorEventDefinition errorDefinition, XMLStreamWriter xtw)
     throws Exception {
   xtw.writeStartElement(ELEMENT_EVENT_ERRORDEFINITION);
   writeDefaultAttribute(ATTRIBUTE_ERROR_REF, errorDefinition.getErrorCode(), xtw);
   xtw.writeEndElement();
 }
 public ErrorEndEventActivityBehavior createErrorEndEventActivityBehavior(
     EndEvent endEvent, ErrorEventDefinition errorEventDefinition) {
   return new ErrorEndEventActivityBehavior(errorEventDefinition.getErrorCode());
 }