Search in sources :

Example 6 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class BpmnParse method parseEndEvents.

/**
 * Parses the end events of a certain level in the process (process,
 * subprocess or another scope).
 *
 * @param parentElement
 *          The 'parent' element that contains the end events (process,
 *          subprocess).
 * @param scope
 *          The {@link ScopeImpl} to which the end events must be added.
 */
public void parseEndEvents(Element parentElement, ScopeImpl scope) {
    for (Element endEventElement : parentElement.elements("endEvent")) {
        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
            String errorRef = errorEventDefinition.attribute("errorRef");
            if (errorRef == null || "".equals(errorRef)) {
                addError("'errorRef' attribute is mandatory on error end event", errorEventDefinition);
            } else {
                Error error = errors.get(errorRef);
                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));
                }
            }
        } else if (cancelEventDefinition != null) {
            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);
            }
        } else if (terminateEventDefinition != null) {
            activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_TERMINATE);
            activity.setActivityBehavior(new TerminateEndEventActivityBehavior());
            activity.setActivityStartBehavior(ActivityStartBehavior.INTERRUPT_FLOW_SCOPE);
        } else if (messageEventDefinitionElement != null) {
            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());
            }
        } else if (signalEventDefinition != null) {
            activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_SIGNAL);
            EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinition, true);
            activity.setActivityBehavior(new ThrowSignalEventActivityBehavior(signalDefinition));
        } else if (compensateEventDefinitionElement != null) {
            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);
        } else if (escalationEventDefinition != null) {
            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));
        } 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);
        for (BpmnParseListener parseListener : parseListeners) {
            parseListener.parseEndEvent(endEventElement, scope, activity);
        }
        parseExecutionListenersOnScope(endEventElement, activity);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 7 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class BpmnParse method parseIntermediateThrowEvent.

public ActivityImpl parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scopeElement) {
    Element signalEventDefinitionElement = intermediateEventElement.element(SIGNAL_EVENT_DEFINITION);
    Element compensateEventDefinitionElement = intermediateEventElement.element(COMPENSATE_EVENT_DEFINITION);
    Element linkEventDefinitionElement = intermediateEventElement.element(LINK_EVENT_DEFINITION);
    Element messageEventDefinitionElement = intermediateEventElement.element(MESSAGE_EVENT_DEFINITION);
    Element escalationEventDefinition = intermediateEventElement.element(ESCALATION_EVENT_DEFINITION);
    // event (event target)
    if (linkEventDefinitionElement != null) {
        String linkName = linkEventDefinitionElement.attribute("name");
        String elementId = intermediateEventElement.attribute("id");
        // now we remember the link in order to replace the sequence flow later on
        eventLinkSources.put(elementId, linkName);
        // and done - no activity created
        return null;
    }
    ActivityImpl nestedActivityImpl = createActivityOnScope(intermediateEventElement, scopeElement);
    ActivityBehavior activityBehavior = null;
    parseAsynchronousContinuationForActivity(intermediateEventElement, nestedActivityImpl);
    if (signalEventDefinitionElement != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_SIGNAL_THROW);
        EventSubscriptionDeclaration signalDefinition = parseSignalEventDefinition(signalEventDefinitionElement, true);
        activityBehavior = new ThrowSignalEventActivityBehavior(signalDefinition);
    } else if (compensateEventDefinitionElement != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_COMPENSATION_THROW);
        CompensateEventDefinition compensateEventDefinition = parseThrowCompensateEventDefinition(compensateEventDefinitionElement, scopeElement);
        activityBehavior = new CompensationEventActivityBehavior(compensateEventDefinition);
        nestedActivityImpl.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
        nestedActivityImpl.setScope(true);
    } else if (messageEventDefinitionElement != null) {
        if (isServiceTaskLike(messageEventDefinitionElement)) {
            // CAM-436 same behavior as service task
            nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW);
            activityBehavior = parseServiceTaskLike(ActivityTypes.INTERMEDIATE_EVENT_MESSAGE_THROW, messageEventDefinitionElement, scopeElement).getActivityBehavior();
        } else {
            // default to non behavior if no service task
            // properties have been specified
            nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
            activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
        }
    } else if (escalationEventDefinition != null) {
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW);
        Escalation escalation = findEscalationForEscalationEventDefinition(escalationEventDefinition);
        if (escalation != null && escalation.getEscalationCode() == null) {
            addError("throwing escalation event must have an 'escalationCode'", escalationEventDefinition);
        }
        activityBehavior = new ThrowEscalationEventActivityBehavior(escalation);
    } else {
        // None intermediate event
        nestedActivityImpl.getProperties().set(BpmnProperties.TYPE, ActivityTypes.INTERMEDIATE_EVENT_NONE_THROW);
        activityBehavior = new IntermediateThrowNoneEventActivityBehavior();
    }
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseIntermediateThrowEvent(intermediateEventElement, scopeElement, nestedActivityImpl);
    }
    nestedActivityImpl.setActivityBehavior(activityBehavior);
    parseExecutionListenersOnScope(intermediateEventElement, nestedActivityImpl);
    return nestedActivityImpl;
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)

Example 8 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class BpmnParse method parseCompensationHandlerForCompensationBoundaryEvent.

protected ActivityImpl parseCompensationHandlerForCompensationBoundaryEvent(ScopeImpl parentScope, ActivityImpl sourceActivity, String targetRef, Map<String, Element> compensationHandlers) {
    Element compensationHandler = compensationHandlers.get(targetRef);
    ActivityImpl eventScope = (ActivityImpl) sourceActivity.getEventScope();
    ActivityImpl compensationHandlerActivity = null;
    if (eventScope.isMultiInstance()) {
        ScopeImpl miBody = eventScope.getFlowScope();
        compensationHandlerActivity = parseActivity(compensationHandler, null, miBody);
    } else {
        compensationHandlerActivity = parseActivity(compensationHandler, null, parentScope);
    }
    compensationHandlerActivity.getProperties().set(BpmnProperties.COMPENSATION_BOUNDARY_EVENT, sourceActivity);
    return compensationHandlerActivity;
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 9 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class BpmnParse method parseBoundaryTimerEventDefinition.

/**
 * Parses a boundary timer event. The end-result will be that the given nested
 * activity will get the appropriate {@link ActivityBehavior}.
 *
 * @param timerEventDefinition
 *          The XML element corresponding with the timer event details
 * @param interrupting
 *          Indicates whether this timer is interrupting.
 * @param boundaryActivity
 *          The activity which maps to the structure of the timer event on the
 *          boundary of another activity. Note that this is NOT the activity
 *          onto which the boundary event is attached, but a nested activity
 *          inside this activity, specifically created for this event.
 */
public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting, ActivityImpl boundaryActivity) {
    boundaryActivity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.BOUNDARY_TIMER);
    TimerDeclarationImpl timerDeclaration = parseTimer(timerEventDefinition, boundaryActivity, TimerExecuteNestedActivityJobHandler.TYPE);
    // ACT-1427
    if (interrupting) {
        timerDeclaration.setInterruptingTimer(true);
        Element timeCycleElement = timerEventDefinition.element("timeCycle");
        if (timeCycleElement != null) {
            addTimeCycleWarning(timeCycleElement, "cancelling boundary");
        }
    }
    addTimerDeclaration(boundaryActivity.getEventScope(), timerDeclaration);
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseBoundaryTimerEventDefinition(timerEventDefinition, interrupting, boundaryActivity);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 10 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.

the class BpmnParse method parseProcessDefinitions.

/**
 * Parses all the process definitions defined within the 'definitions' root
 * element.
 */
public void parseProcessDefinitions() {
    for (Element processElement : rootElement.elements("process")) {
        boolean isExecutable = !deployment.isNew();
        String isExecutableStr = processElement.attribute("isExecutable");
        if (isExecutableStr != null) {
            isExecutable = Boolean.parseBoolean(isExecutableStr);
            if (!isExecutable) {
                LOG.ignoringNonExecutableProcess(processElement.attribute("id"));
            }
        } else {
            LOG.missingIsExecutableAttribute(processElement.attribute("id"));
        }
        // Only process executable processes
        if (isExecutable) {
            processDefinitions.add(parseProcess(processElement));
        }
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Aggregations

Element (org.camunda.bpm.engine.impl.util.xml.Element)60 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 BpmnParseException (org.camunda.bpm.engine.BpmnParseException)4 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)4 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)3 ProcessEngineXml (org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml)2 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)2 Condition (org.camunda.bpm.engine.impl.Condition)2 IoMapping (org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping)2 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)2 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)2 ScriptCondition (org.camunda.bpm.engine.impl.scripting.ScriptCondition)2 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)2 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)2 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)2 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)2 LinkedHashMap (java.util.LinkedHashMap)1 TreeMap (java.util.TreeMap)1 ProcessArchiveXml (org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml)1