Search in sources :

Example 36 with Element

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

the class ProcessesXmlParse method parseRootElement.

/**
 * we know this is a <code>&lt;process-application ... /&gt;</code> structure.
 */
@Override
protected void parseRootElement() {
    List<ProcessEngineXml> processEngines = new ArrayList<ProcessEngineXml>();
    List<ProcessArchiveXml> processArchives = new ArrayList<ProcessArchiveXml>();
    for (Element element : rootElement.elements()) {
        if (PROCESS_ENGINE.equals(element.getTagName())) {
            parseProcessEngine(element, processEngines);
        } else if (PROCESS_ARCHIVE.equals(element.getTagName())) {
            parseProcessArchive(element, processArchives);
        }
    }
    processesXml = new ProcessesXmlImpl(processEngines, processArchives);
}
Also used : ProcessEngineXml(org.camunda.bpm.container.impl.metadata.spi.ProcessEngineXml) ProcessArchiveXml(org.camunda.bpm.application.impl.metadata.spi.ProcessArchiveXml) Element(org.camunda.bpm.engine.impl.util.xml.Element) ArrayList(java.util.ArrayList)

Example 37 with Element

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

the class BpmnParseUtil method parseParamValueProvider.

/**
 * @throws BpmnParseException if the parameter is invalid
 */
protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) {
    // LIST
    if ("list".equals(parameterElement.getTagName())) {
        List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>();
        for (Element element : parameterElement.elements()) {
            // parse nested provider
            providerList.add(parseParamValueProvider(element));
        }
        return new ListValueProvider(providerList);
    }
    // MAP
    if ("map".equals(parameterElement.getTagName())) {
        TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>();
        for (Element entryElement : parameterElement.elements("entry")) {
            // entry must provide key
            String keyAttribute = entryElement.attribute("key");
            if (keyAttribute == null || keyAttribute.isEmpty()) {
                throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
            }
            // parse nested provider
            providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement));
        }
        return new MapValueProvider(providerMap);
    }
    // SCRIPT
    if ("script".equals(parameterElement.getTagName())) {
        ExecutableScript executableScript = parseCamundaScript(parameterElement);
        if (executableScript != null) {
            return new ScriptValueProvider(executableScript);
        } else {
            return new NullValueProvider();
        }
    }
    String textContent = parameterElement.getText().trim();
    if (!textContent.isEmpty()) {
        // EL
        return new ElValueProvider(getExpressionManager().createExpression(textContent));
    } else {
        // NULL value
        return new NullValueProvider();
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) ArrayList(java.util.ArrayList) ElValueProvider(org.camunda.bpm.engine.impl.el.ElValueProvider) ScriptValueProvider(org.camunda.bpm.engine.impl.scripting.ScriptValueProvider) TreeMap(java.util.TreeMap) MapValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.MapValueProvider) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) ListValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ListValueProvider) NullValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.NullValueProvider) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript)

Example 38 with Element

use of org.camunda.bpm.engine.impl.util.xml.Element 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 39 with Element

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

the class BpmnParse method parseDocumentation.

public String parseDocumentation(Element element) {
    List<Element> docElements = element.elements("documentation");
    List<String> docStrings = new ArrayList<String>();
    for (Element e : docElements) {
        docStrings.add(e.getText());
    }
    return parseDocumentation(docStrings);
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 40 with Element

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

the class BpmnParse method parseConditionalEventDefinition.

/**
 * Parses the given element and returns an ConditionalEventDefinition object.
 *
 * @param element the XML element which contains the conditional event information
 * @param conditionalActivity the conditional event activity
 * @return the conditional event definition which was parsed
 */
protected ConditionalEventDefinition parseConditionalEventDefinition(Element element, ActivityImpl conditionalActivity) {
    ConditionalEventDefinition conditionalEventDefinition = null;
    Element conditionExprElement = element.element(CONDITION);
    if (conditionExprElement != null) {
        Condition condition = parseConditionExpression(conditionExprElement);
        conditionalEventDefinition = new ConditionalEventDefinition(condition, conditionalActivity);
        String expression = conditionExprElement.getText().trim();
        conditionalEventDefinition.setConditionAsString(expression);
        conditionalActivity.getProcessDefinition().getProperties().set(BpmnProperties.HAS_CONDITIONAL_EVENTS, true);
        final String variableName = element.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "variableName");
        conditionalEventDefinition.setVariableName(variableName);
        final String variableEvents = element.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "variableEvents");
        final List<String> variableEventsList = parseCommaSeparatedList(variableEvents);
        conditionalEventDefinition.setVariableEvents(new HashSet<String>(variableEventsList));
        for (String variableEvent : variableEventsList) {
            if (!VARIABLE_EVENTS.contains(variableEvent)) {
                addWarning("Variable event: " + variableEvent + " is not valid. Possible variable change events are: " + Arrays.toString(VARIABLE_EVENTS.toArray()), element);
            }
        }
    } else {
        addError("Conditional event must contain an expression for evaluation.", element);
    }
    return conditionalEventDefinition;
}
Also used : ScriptCondition(org.camunda.bpm.engine.impl.scripting.ScriptCondition) Condition(org.camunda.bpm.engine.impl.Condition) 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