Search in sources :

Example 46 with Element

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

the class BpmnParse method parseCollaboration.

/**
 * Parses the collaboration definition defined within the 'definitions' root
 * element and get all participants to lookup their process references during
 * DI parsing.
 */
public void parseCollaboration() {
    Element collaboration = rootElement.element("collaboration");
    if (collaboration != null) {
        for (Element participant : collaboration.elements("participant")) {
            String processRef = participant.attribute("processRef");
            if (processRef != null) {
                ProcessDefinitionImpl procDef = getProcessDefinition(processRef);
                if (procDef != null) {
                    // Set participant process on the procDef, so it can get rendered
                    // later on if needed
                    ParticipantProcess participantProcess = new ParticipantProcess();
                    participantProcess.setId(participant.attribute("id"));
                    participantProcess.setName(participant.attribute("name"));
                    procDef.setParticipantProcess(participantProcess);
                    participantProcesses.put(participantProcess.getId(), processRef);
                }
            }
        }
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 47 with Element

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

the class BpmnParse method parseDIBounds.

protected void parseDIBounds(Element bpmnShapeElement, HasDIBounds target) {
    Element bounds = bpmnShapeElement.elementNS(BPMN_DC_NS, "Bounds");
    if (bounds != null) {
        target.setX(parseDoubleAttribute(bpmnShapeElement, "x", bounds.attribute("x"), true).intValue());
        target.setY(parseDoubleAttribute(bpmnShapeElement, "y", bounds.attribute("y"), true).intValue());
        target.setWidth(parseDoubleAttribute(bpmnShapeElement, "width", bounds.attribute("width"), true).intValue());
        target.setHeight(parseDoubleAttribute(bpmnShapeElement, "height", bounds.attribute("height"), true).intValue());
    } else {
        addError("'Bounds' element is required", bpmnShapeElement);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 48 with Element

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

the class BpmnParse method parseErrors.

public void parseErrors() {
    for (Element errorElement : rootElement.elements("error")) {
        Error error = new Error();
        String id = errorElement.attribute("id");
        if (id == null) {
            addError("'id' is mandatory on error definition", errorElement);
        }
        error.setId(id);
        String errorCode = errorElement.attribute("errorCode");
        if (errorCode != null) {
            error.setErrorCode(errorCode);
        }
        errors.put(id, error);
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 49 with Element

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

the class BpmnParse method parseSignals.

/**
 * Parses the signals of the given definitions file. Signals are not contained
 * within a process element, but they can be referenced from inner process
 * elements.
 */
protected void parseSignals() {
    for (Element signalElement : rootElement.elements("signal")) {
        String id = signalElement.attribute("id");
        String signalName = signalElement.attribute("name");
        for (SignalDefinition signalDefinition : signals.values()) {
            if (signalDefinition.getName().equals(signalName)) {
                addError("duplicate signal name '" + signalName + "'.", signalElement);
            }
        }
        if (id == null) {
            addError("signal must have an id", signalElement);
        } else if (signalName == null) {
            addError("signal with id '" + id + "' has no name", signalElement);
        } else {
            Expression signalExpression = expressionManager.createExpression(signalName);
            SignalDefinition signal = new SignalDefinition();
            signal.setId(this.targetNamespace + ":" + id);
            signal.setExpression(signalExpression);
            this.signals.put(signal.getId(), signal);
        }
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element)

Example 50 with Element

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

the class BpmnParse method parseScriptTaskElement.

/**
 * Returns a {@link ScriptTaskActivityBehavior} for the script task element
 * corresponding to the script source or resource specified.
 *
 * @param scriptTaskElement
 *          the script task element
 * @return the corresponding {@link ScriptTaskActivityBehavior}
 */
protected ScriptTaskActivityBehavior parseScriptTaskElement(Element scriptTaskElement) {
    // determine script language
    String language = scriptTaskElement.attribute("scriptFormat");
    if (language == null) {
        language = ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE;
    }
    String resultVariableName = parseResultVariable(scriptTaskElement);
    // determine script source
    String scriptSource = null;
    Element scriptElement = scriptTaskElement.element("script");
    if (scriptElement != null) {
        scriptSource = scriptElement.getText();
    }
    String scriptResource = scriptTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_RESOURCE);
    try {
        ExecutableScript script = ScriptUtil.getScript(language, scriptSource, scriptResource, expressionManager);
        return new ScriptTaskActivityBehavior(script, resultVariableName);
    } catch (ProcessEngineException e) {
        addError("Unable to process ScriptTask: " + e.getMessage(), scriptElement);
        return null;
    }
}
Also used : Element(org.camunda.bpm.engine.impl.util.xml.Element) ExecutableScript(org.camunda.bpm.engine.impl.scripting.ExecutableScript) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

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