Java Code Examples for org.camunda.bpm.engine.impl.util.xml.Element#element()

The following examples show how to use org.camunda.bpm.engine.impl.util.xml.Element#element() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectorParseListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
  Element connectorDefinition = findCamundaExtensionElement(serviceTaskElement, "connector");
  if (connectorDefinition != null) {
    Element connectorIdElement = connectorDefinition.element("connectorId");

    String connectorId = null;
    if (connectorIdElement != null)  {
      connectorId = connectorIdElement.getText().trim();
    }
    if (connectorIdElement == null || connectorId.isEmpty()) {
      throw new BpmnParseException("No 'id' defined for connector.", connectorDefinition);
    }

    IoMapping ioMapping = parseInputOutput(connectorDefinition);
    activity.setActivityBehavior(new ServiceTaskConnectorActivityBehavior(connectorId, ioMapping));
  }
}
 
Example 2
Source File: DefaultFormHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void parseConfiguration(Element activityElement, DeploymentEntity deployment, ProcessDefinitionEntity processDefinition, BpmnParse bpmnParse) {
  this.deploymentId = deployment.getId();

  ExpressionManager expressionManager = Context
      .getProcessEngineConfiguration()
      .getExpressionManager();

  Element extensionElement = activityElement.element("extensionElements");
  if (extensionElement != null) {

    // provide support for deprecated form properties
    parseFormProperties(bpmnParse, expressionManager, extensionElement);

    // provide support for new form field metadata
    parseFormData(bpmnParse, expressionManager, extensionElement);
  }
}
 
Example 3
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void parseActivity(Element element, ActivityImpl activity) {

    if (isMultiInstance(activity)) {
      // in case of multi-instance, the extension elements is set according to the async attributes
      // the extension for multi-instance body is set on the element of the activity
      ActivityImpl miBody = activity.getParentFlowScopeActivity();
      if (isAsync(miBody)) {
        setFailedJobRetryTimeCycleValue(element, miBody);
      }
      // the extension for inner activity is set on the multiInstanceLoopCharacteristics element
      if (isAsync(activity)) {
        Element multiInstanceLoopCharacteristics = element.element(MULTI_INSTANCE_LOOP_CHARACTERISTICS);
        setFailedJobRetryTimeCycleValue(multiInstanceLoopCharacteristics, activity);
      }

    } else if (isAsync(activity)) {
      setFailedJobRetryTimeCycleValue(element, activity);
    }
  }
 
Example 4
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void setFailedJobRetryTimeCycleValue(Element element, ActivityImpl activity) {
  String failedJobRetryTimeCycleConfiguration = null;

  Element extensionElements = element.element(EXTENSION_ELEMENTS);
  if (extensionElements != null) {
    Element failedJobRetryTimeCycleElement = extensionElements.elementNS(FOX_ENGINE_NS, FAILED_JOB_RETRY_TIME_CYCLE);
    if (failedJobRetryTimeCycleElement == null) {
      // try to get it from the activiti namespace
      failedJobRetryTimeCycleElement = extensionElements.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, FAILED_JOB_RETRY_TIME_CYCLE);
    }

    if (failedJobRetryTimeCycleElement != null) {
      failedJobRetryTimeCycleConfiguration = failedJobRetryTimeCycleElement.getText();
    }
  }

  if (failedJobRetryTimeCycleConfiguration == null || failedJobRetryTimeCycleConfiguration.isEmpty()) {
    failedJobRetryTimeCycleConfiguration = Context.getProcessEngineConfiguration().getFailedJobRetryTimeCycle();
  }

  if (failedJobRetryTimeCycleConfiguration != null) {
    FailedJobRetryConfiguration configuration = ParseUtil.parseRetryIntervals(failedJobRetryTimeCycleConfiguration);
    activity.getProperties().set(FAILED_JOB_CONFIGURATION, configuration);
  }
}
 
Example 5
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
public void parseSequenceFlowConditionExpression(Element seqFlowElement, TransitionImpl seqFlow) {
    logger.debug("parse sequence flow condition expression,id={}", seqFlow.getId());

    Element conditionExprElement = seqFlowElement.element(CONDITION_EXPRESSION);
    if (conditionExprElement != null) {
        Condition condition = parseConditionExpression(conditionExprElement);
        seqFlow.setProperty(PROPERTYNAME_CONDITION_TEXT,
                translateConditionExpressionElementText(conditionExprElement));
        seqFlow.setProperty(PROPERTYNAME_CONDITION, condition);
    } else {
        tryDeduceConditionExpression(seqFlowElement, seqFlow);
    }
}
 
Example 6
Source File: BpmnParseUtil.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the camunda extension element in the camunda namespace
 * and the given name.
 *
  * @param element the parent element of the extension element
 * @param extensionElementName the name of the extension element to find
 * @return the extension element or null if not found
 */
public static Element findCamundaExtensionElement(Element element, String extensionElementName) {
  Element extensionElements = element.element("extensionElements");
  if(extensionElements != null) {
    return extensionElements.elementNS(BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS, extensionElementName);
  } else {
    return null;
  }
}
 
Example 7
Source File: TestBPMNParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
  // Change activity behavior
  Element compensateEventDefinitionElement = intermediateEventElement.element(COMPENSATE_EVENT_DEFINITION);
  if (compensateEventDefinitionElement != null) {
    final String activityRef = compensateEventDefinitionElement.attribute("activityRef");
    CompensateEventDefinition compensateEventDefinition = new CompensateEventDefinition();
    compensateEventDefinition.setActivityRef(activityRef);
    compensateEventDefinition.setWaitForCompletion(false);

    activity.setActivityBehavior(new TestCompensationEventActivityBehavior(compensateEventDefinition));
  }
}
 
Example 8
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseEndEvent(Element parentElement, ScopeImpl scope, Element endEventElement) {
    ActivityImpl activity = createActivityOnScope(endEventElement, scope);

    Element errorEventDefinition = endEventElement.element(ERROR_EVENT_DEFINITION);
    Element cancelEventDefinition = endEventElement.element(CANCEL_EVENT_DEFINITION);
    Element terminateEventDefinition = endEventElement.element("terminateEventDefinition");
    Element messageEventDefinitionElement = endEventElement.element(MESSAGE_EVENT_DEFINITION);
    Element signalEventDefinition = endEventElement.element(SIGNAL_EVENT_DEFINITION);
    Element compensateEventDefinitionElement = endEventElement.element(COMPENSATE_EVENT_DEFINITION);
    Element escalationEventDefinition = endEventElement.element(ESCALATION_EVENT_DEFINITION);

    if (errorEventDefinition != null) { // error end event
        parseErrorEventDefinition(parentElement, scope, endEventElement, activity, errorEventDefinition);
    } else if (cancelEventDefinition != null) {
        parseCancelEventDefinition(parentElement, scope, endEventElement, activity, cancelEventDefinition);
    } else if (terminateEventDefinition != null) {
        parseTerminateEventDefinition(parentElement, scope, endEventElement, activity, terminateEventDefinition);
    } else if (messageEventDefinitionElement != null) {
        parseMessageEventDefinitionElement(parentElement, scope, endEventElement, activity,
                messageEventDefinitionElement);
    } else if (signalEventDefinition != null) {
        parseSignalEventDefinition(parentElement, scope, endEventElement, activity, signalEventDefinition);
    } else if (compensateEventDefinitionElement != null) {
        parseCompensateEventDefinitionElement(parentElement, scope, endEventElement, activity,
                compensateEventDefinitionElement);
    } else if (escalationEventDefinition != null) {
        parseEscalationEventDefinition(parentElement, scope, endEventElement, activity, escalationEventDefinition);
    } else { // default: none end event
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_NONE);
        activity.setActivityBehavior(new NoneEndEventActivityBehavior());
    }

    if (activity != null) {
        parseActivityInputOutput(endEventElement, activity);
    }

    parseAsynchronousContinuationForActivity(endEventElement, activity);

    parseExecutionListenersOnScope(endEventElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseEndEvent(endEventElement, scope, activity);
    }
}