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><process-application ... /></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);
}
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();
}
}
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;
}
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);
}
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;
}
Aggregations