Search in sources :

Example 6 with BpmnParseException

use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.

the class BpmnParse method parseExecutionListener.

/**
 * Parses an {@link ExecutionListener} implementation for the given
 * executionListener element.
 *
 * @param executionListenerElement
 *          the XML element containing the executionListener definition.
 */
public ExecutionListener parseExecutionListener(Element executionListenerElement) {
    ExecutionListener executionListener = null;
    String className = executionListenerElement.attribute(PROPERTYNAME_CLASS);
    String expression = executionListenerElement.attribute(PROPERTYNAME_EXPRESSION);
    String delegateExpression = executionListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
    Element scriptElement = executionListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
    if (className != null) {
        executionListener = new ClassDelegateExecutionListener(className, parseFieldDeclarations(executionListenerElement));
    } else if (expression != null) {
        executionListener = new ExpressionExecutionListener(expressionManager.createExpression(expression));
    } else if (delegateExpression != null) {
        executionListener = new DelegateExpressionExecutionListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(executionListenerElement));
    } else if (scriptElement != null) {
        try {
            ExecutableScript executableScript = parseCamundaScript(scriptElement);
            if (executableScript != null) {
                executionListener = new ScriptExecutionListener(executableScript);
            }
        } catch (BpmnParseException e) {
            addError(e);
        }
    } else {
        addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on executionListener", executionListenerElement);
    }
    return executionListener;
}
Also used : ScriptExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) Element(org.camunda.bpm.engine.impl.util.xml.Element) ClassDelegateExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener) ExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener) ClassDelegateExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener) ScriptExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener) ExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener) DelegateExpressionExecutionListener(org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener)

Example 7 with BpmnParseException

use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.

the class BpmnParse method parseTaskListener.

protected TaskListener parseTaskListener(Element taskListenerElement) {
    TaskListener taskListener = null;
    String className = taskListenerElement.attribute(PROPERTYNAME_CLASS);
    String expression = taskListenerElement.attribute(PROPERTYNAME_EXPRESSION);
    String delegateExpression = taskListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
    Element scriptElement = taskListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
    if (className != null) {
        taskListener = new ClassDelegateTaskListener(className, parseFieldDeclarations(taskListenerElement));
    } else if (expression != null) {
        taskListener = new ExpressionTaskListener(expressionManager.createExpression(expression));
    } else if (delegateExpression != null) {
        taskListener = new DelegateExpressionTaskListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(taskListenerElement));
    } else if (scriptElement != null) {
        try {
            ExecutableScript executableScript = parseCamundaScript(scriptElement);
            if (executableScript != null) {
                taskListener = new ScriptTaskListener(executableScript);
            }
        } catch (BpmnParseException e) {
            addError(e);
        }
    } else {
        addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on taskListener", taskListenerElement);
    }
    return taskListener;
}
Also used : DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) Element(org.camunda.bpm.engine.impl.util.xml.Element) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)

Example 8 with BpmnParseException

use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.

the class BpmnParse method parseProcess.

/**
 * Parses one process (ie anything inside a <process> element).
 *
 * @param processElement
 *          The 'process' element.
 * @return The parsed version of the XML: a {@link ProcessDefinitionImpl}
 *         object.
 */
public ProcessDefinitionEntity parseProcess(Element processElement) {
    // reset all mappings that are related to one process definition
    sequenceFlows = new HashMap<String, TransitionImpl>();
    ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity();
    /*
     * Mapping object model - bpmn xml: processDefinition.id -> generated by
     * processDefinition.key -> bpmn id (required) processDefinition.name ->
     * bpmn name (optional)
     */
    processDefinition.setKey(processElement.attribute("id"));
    processDefinition.setName(processElement.attribute("name"));
    processDefinition.setCategory(rootElement.attribute("targetNamespace"));
    processDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, parseDocumentation(processElement));
    processDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
    processDefinition.setDeploymentId(deployment.getId());
    processDefinition.setProperty(PROPERTYNAME_JOB_PRIORITY, parsePriority(processElement, PROPERTYNAME_JOB_PRIORITY));
    processDefinition.setProperty(PROPERTYNAME_TASK_PRIORITY, parsePriority(processElement, PROPERTYNAME_TASK_PRIORITY));
    processDefinition.setVersionTag(processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "versionTag"));
    try {
        String historyTimeToLive = processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "historyTimeToLive");
        processDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(historyTimeToLive));
    } catch (Exception e) {
        addError(new BpmnParseException(e.getMessage(), processElement, e));
    }
    LOG.parsingElement("process", processDefinition.getKey());
    parseScope(processElement, processDefinition);
    // Parse any laneSets defined for this process
    parseLaneSets(processElement, processDefinition);
    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseProcess(processElement, processDefinition);
    }
    // now we have parsed anything we can validate some stuff
    validateActivities(processDefinition.getActivities());
    // unregister delegates
    for (ActivityImpl activity : processDefinition.getActivities()) {
        activity.setDelegateAsyncAfterUpdate(null);
        activity.setDelegateAsyncBeforeUpdate(null);
    }
    return processDefinition;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) BpmnParseException(org.camunda.bpm.engine.BpmnParseException)

Aggregations

BpmnParseException (org.camunda.bpm.engine.BpmnParseException)8 Element (org.camunda.bpm.engine.impl.util.xml.Element)4 ParameterValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)3 ExecutableScript (org.camunda.bpm.engine.impl.scripting.ExecutableScript)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)1 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 ClassDelegateExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ClassDelegateExecutionListener)1 DelegateExpressionExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.DelegateExpressionExecutionListener)1 ExpressionExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ExpressionExecutionListener)1 ScriptExecutionListener (org.camunda.bpm.engine.impl.bpmn.listener.ScriptExecutionListener)1 BpmnParseUtil.findCamundaExtensionElement (org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseUtil.findCamundaExtensionElement)1 InputParameter (org.camunda.bpm.engine.impl.core.variable.mapping.InputParameter)1 IoMapping (org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping)1 OutputParameter (org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter)1 ListValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.ListValueProvider)1 MapValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.MapValueProvider)1 NullValueProvider (org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider)1