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);
}
}
}
}
}
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);
}
}
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);
}
}
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);
}
}
}
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;
}
}
Aggregations