Java Code Examples for org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#setActivityBehavior()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#setActivityBehavior() . 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: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void parseMessageEventDefinitionElement(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element messageEventDefinitionElement) {
    if (isServiceTaskLike(messageEventDefinitionElement)) {

        // CAM-436 same behaviour as service task
        ActivityImpl act = parseServiceTaskLike(ActivityTypes.END_EVENT_MESSAGE, messageEventDefinitionElement,
                scope);
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_MESSAGE);
        activity.setActivityBehavior(act.getActivityBehavior());
        scope.getActivities().remove(act);
    } else {
        // default to non behavior if no service task
        // properties have been specified
        activity.setActivityBehavior(new IntermediateThrowNoneEventActivityBehavior());
    }
}
 
Example 2
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void parseErrorEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element errorEventDefinition) {
    String errorRef = errorEventDefinition.attribute("errorRef");

    if (errorRef == null || "".equals(errorRef)) {
        errorRef = DEFAULT_ERROR_ID;
    }

    org.camunda.bpm.engine.impl.bpmn.parser.Error error = errors.get(errorRef);
    if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) {
        error.setErrorCode(DEFAULT_ERROR_CODE);
    }
    if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) {
        addError(
                "'errorCode' is mandatory on errors referenced by throwing error event definitions, but the error '"
                        + error.getId() + "' does not define one.",
                errorEventDefinition);
    }
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_ERROR);
    if (error != null) {
        activity.setActivityBehavior(new ErrorEndEventActivityBehavior(error.getErrorCode()));
    } else {
        activity.setActivityBehavior(new ErrorEndEventActivityBehavior(errorRef));
    }

}
 
Example 3
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 4
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseServiceTaskLikeAttributesDelegateExpression(String elementName, Element serviceTaskElement,
        ScopeImpl scope, ActivityImpl activity, String delegateExpression, String resultVariableName) {
    if (resultVariableName != null) {
        addError(PREFIX_ERROR_MSG_VARIABLE_NAME + elementName + " elements using 'delegateExpression'",
                serviceTaskElement);
    }
    activity.setActivityBehavior(new ServiceTaskDelegateExpressionActivityBehavior(
            expressionManager.createExpression(delegateExpression), parseFieldDeclarations(serviceTaskElement)));
}
 
Example 5
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseServiceTaskLikeAttributesClassName(String elementName, Element serviceTaskElement,
        ScopeImpl scope, ActivityImpl activity, String className, String resultVariableName) {
    if (resultVariableName != null) {
        addError(PREFIX_ERROR_MSG_VARIABLE_NAME + elementName + " elements using 'class'", serviceTaskElement);
    }
    activity.setActivityBehavior(
            new ClassDelegateActivityBehavior(className, parseFieldDeclarations(serviceTaskElement)));
}
 
Example 6
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseEscalationEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element escalationEventDefinition) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_ESCALATION);

    Escalation escalation = findEscalationForEscalationEventDefinition(escalationEventDefinition);
    if (escalation != null && escalation.getEscalationCode() == null) {
        addError("escalation end event must have an 'escalationCode'", escalationEventDefinition);
    }
    activity.setActivityBehavior(new ThrowEscalationEventActivityBehavior(escalation));
}
 
Example 7
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseCompensateEventDefinitionElement(Element parentElement, ScopeImpl scope,
        Element endEventElement, ActivityImpl activity, Element compensateEventDefinitionElement) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_COMPENSATION);
    CompensateEventDefinition compensateEventDefinition = parseThrowCompensateEventDefinition(
            compensateEventDefinitionElement, scope);
    activity.setActivityBehavior(new CompensationEventActivityBehavior(compensateEventDefinition));
    activity.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
    activity.setScope(true);
}
 
Example 8
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseCancelEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element cancelEventDefinition) {
    if (scope.getProperty(BpmnProperties.TYPE.getName()) == null
            || !scope.getProperty(BpmnProperties.TYPE.getName()).equals("transaction")) {
        addError("end event with cancelEventDefinition only supported inside transaction subprocess",
                cancelEventDefinition);
    } else {
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_CANCEL);
        activity.setActivityBehavior(new CancelEndEventActivityBehavior());
        activity.setActivityStartBehavior(ActivityStartBehavior.INTERRUPT_FLOW_SCOPE);
        activity.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
        activity.setScope(true);
    }
}
 
Example 9
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 10
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
public ActivityImpl parseServiceTaskLike(String elementName, Element serviceTaskElement, ScopeImpl scope) {
    logger.debug("parse service task like element,elementName={}", elementName);

    ActivityImpl activity = createActivityOnScope(serviceTaskElement, scope);

    String type = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, TYPE);
    String className = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_CLASS);
    String expression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_EXPRESSION);
    String delegateExpression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS,
            PROPERTYNAME_DELEGATE_EXPRESSION);
    String resultVariableName = parseResultVariable(serviceTaskElement);

    parseAsynchronousContinuationForActivity(serviceTaskElement, activity);

    parseServiceTaskLikeAttributes(elementName, serviceTaskElement, scope, activity, type, className, expression,
            delegateExpression, resultVariableName);

    parseExecutionListenersOnScope(serviceTaskElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseServiceTask(serviceTaskElement, scope, activity);
    }

    if (activity.getActivityBehavior() == null) {
        String defaultDelegateExpression = "${taskDispatcher}";
        if (resultVariableName != null) {
            addError(PREFIX_ERROR_MSG_VARIABLE_NAME + elementName + " elements using 'delegateExpression'",
                    serviceTaskElement);
        }

        activity.setActivityBehavior(new ServiceTaskDelegateExpressionActivityBehavior(
                expressionManager.createExpression(defaultDelegateExpression),
                parseFieldDeclarations(serviceTaskElement)));
    }

    // activity behavior could be set by a listener (e.g. connector); thus,
    // check is after listener invocation
    if (activity.getActivityBehavior() == null) {
        addError("One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on "
                + elementName + ".", serviceTaskElement);
    }

    return activity;
}
 
Example 11
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseServiceTaskLikeAttributesExpression(String elementName, Element serviceTaskElement,
        ScopeImpl scope, ActivityImpl activity, String expression, String resultVariableName) {
    activity.setActivityBehavior(new ServiceTaskExpressionActivityBehavior(
            expressionManager.createExpression(expression), resultVariableName));
}
 
Example 12
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);
    }
}
 
Example 13
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseSignalEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element signalEventDefinition) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_SIGNAL);
    EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinition, true);
    activity.setActivityBehavior(new ThrowSignalEventActivityBehavior(signalDefinition));
}
 
Example 14
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseTerminateEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element terminateEventDefinition) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_TERMINATE);
    activity.setActivityBehavior(new TerminateEndEventActivityBehavior());
    activity.setActivityStartBehavior(ActivityStartBehavior.INTERRUPT_FLOW_SCOPE);
}
 
Example 15
Source File: TestBPMNParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
  // Change activity behavior
  startEventActivity.setActivityBehavior(new TestNoneStartEventActivityBehavior());
}
 
Example 16
Source File: TestBPMNParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity) {
  // Change activity behavior
  activity.setActivityBehavior(new TestNoneEndEventActivityBehavior());
}