Search in sources :

Example 1 with BpmnParseException

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

the class BpmnParseUtil method parseInputParameterElement.

/**
 * Parses a input parameter and adds it to the {@link IoMapping}.
 *
 * @param inputParameterElement the input parameter element
 * @param ioMapping the mapping to add the element
 * @throws BpmnParseException if the input parameter element is malformed
 */
public static void parseInputParameterElement(Element inputParameterElement, IoMapping ioMapping) {
    String nameAttribute = inputParameterElement.attribute("name");
    if (nameAttribute == null || nameAttribute.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'name' for inputParameter", inputParameterElement);
    }
    ParameterValueProvider valueProvider = parseNestedParamValueProvider(inputParameterElement);
    // add parameter
    ioMapping.addInputParameter(new InputParameter(nameAttribute, valueProvider));
}
Also used : BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider) InputParameter(org.camunda.bpm.engine.impl.core.variable.mapping.InputParameter)

Example 2 with BpmnParseException

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

the class BpmnParseUtil method parseCamundaScript.

/**
 * Parses a camunda script element.
 *
 * @param scriptElement the script element ot parse
 * @return the generated executable script
 * @throws BpmnParseException if the a attribute is missing or the script cannot be processed
 */
public static ExecutableScript parseCamundaScript(Element scriptElement) {
    String scriptLanguage = scriptElement.attribute("scriptFormat");
    if (scriptLanguage == null || scriptLanguage.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'scriptFormatAttribute' for 'script' element", scriptElement);
    } else {
        String scriptResource = scriptElement.attribute("resource");
        String scriptSource = scriptElement.getText();
        try {
            return ScriptUtil.getScript(scriptLanguage, scriptSource, scriptResource, getExpressionManager());
        } catch (ProcessEngineException e) {
            throw new BpmnParseException("Unable to process script", scriptElement, e);
        }
    }
}
Also used : BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 3 with BpmnParseException

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

the class BpmnParseUtil method parseOutputParameterElement.

/**
 * Parses a output parameter and adds it to the {@link IoMapping}.
 *
 * @param outputParameterElement the output parameter element
 * @param ioMapping the mapping to add the element
 * @throws BpmnParseException if the output parameter element is malformed
 */
public static void parseOutputParameterElement(Element outputParameterElement, IoMapping ioMapping) {
    String nameAttribute = outputParameterElement.attribute("name");
    if (nameAttribute == null || nameAttribute.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'name' for outputParameter", outputParameterElement);
    }
    ParameterValueProvider valueProvider = parseNestedParamValueProvider(outputParameterElement);
    // add parameter
    ioMapping.addOutputParameter(new OutputParameter(nameAttribute, valueProvider));
}
Also used : OutputParameter(org.camunda.bpm.engine.impl.core.variable.mapping.OutputParameter) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) ParameterValueProvider(org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider)

Example 4 with BpmnParseException

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

the class ConnectorParseListener method parseServiceTask.

@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));
    }
}
Also used : IoMapping(org.camunda.bpm.engine.impl.core.variable.mapping.IoMapping) BpmnParseException(org.camunda.bpm.engine.BpmnParseException) BpmnParseUtil.findCamundaExtensionElement(org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseUtil.findCamundaExtensionElement) Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 5 with BpmnParseException

use of org.camunda.bpm.engine.BpmnParseException 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)

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