use of org.camunda.bpm.engine.BpmnParseException 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.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParse method parseTaskListener.
protected TaskListener parseTaskListener(Element taskListenerElement) {
TaskListener taskListener = null;
String className = taskListenerElement.attribute(PROPERTYNAME_CLASS);
String expression = taskListenerElement.attribute(PROPERTYNAME_EXPRESSION);
String delegateExpression = taskListenerElement.attribute(PROPERTYNAME_DELEGATE_EXPRESSION);
Element scriptElement = taskListenerElement.elementNS(CAMUNDA_BPMN_EXTENSIONS_NS, "script");
if (className != null) {
taskListener = new ClassDelegateTaskListener(className, parseFieldDeclarations(taskListenerElement));
} else if (expression != null) {
taskListener = new ExpressionTaskListener(expressionManager.createExpression(expression));
} else if (delegateExpression != null) {
taskListener = new DelegateExpressionTaskListener(expressionManager.createExpression(delegateExpression), parseFieldDeclarations(taskListenerElement));
} else if (scriptElement != null) {
try {
ExecutableScript executableScript = parseCamundaScript(scriptElement);
if (executableScript != null) {
taskListener = new ScriptTaskListener(executableScript);
}
} catch (BpmnParseException e) {
addError(e);
}
} else {
addError("Element 'class', 'expression', 'delegateExpression' or 'script' is mandatory on taskListener", taskListenerElement);
}
return taskListener;
}
use of org.camunda.bpm.engine.BpmnParseException in project camunda-bpm-platform by camunda.
the class BpmnParse method parseProcess.
/**
* Parses one process (ie anything inside a <process> element).
*
* @param processElement
* The 'process' element.
* @return The parsed version of the XML: a {@link ProcessDefinitionImpl}
* object.
*/
public ProcessDefinitionEntity parseProcess(Element processElement) {
// reset all mappings that are related to one process definition
sequenceFlows = new HashMap<String, TransitionImpl>();
ProcessDefinitionEntity processDefinition = new ProcessDefinitionEntity();
/*
* Mapping object model - bpmn xml: processDefinition.id -> generated by
* processDefinition.key -> bpmn id (required) processDefinition.name ->
* bpmn name (optional)
*/
processDefinition.setKey(processElement.attribute("id"));
processDefinition.setName(processElement.attribute("name"));
processDefinition.setCategory(rootElement.attribute("targetNamespace"));
processDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, parseDocumentation(processElement));
processDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
processDefinition.setDeploymentId(deployment.getId());
processDefinition.setProperty(PROPERTYNAME_JOB_PRIORITY, parsePriority(processElement, PROPERTYNAME_JOB_PRIORITY));
processDefinition.setProperty(PROPERTYNAME_TASK_PRIORITY, parsePriority(processElement, PROPERTYNAME_TASK_PRIORITY));
processDefinition.setVersionTag(processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "versionTag"));
try {
String historyTimeToLive = processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "historyTimeToLive");
processDefinition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(historyTimeToLive));
} catch (Exception e) {
addError(new BpmnParseException(e.getMessage(), processElement, e));
}
LOG.parsingElement("process", processDefinition.getKey());
parseScope(processElement, processDefinition);
// Parse any laneSets defined for this process
parseLaneSets(processElement, processDefinition);
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseProcess(processElement, processDefinition);
}
// now we have parsed anything we can validate some stuff
validateActivities(processDefinition.getActivities());
// unregister delegates
for (ActivityImpl activity : processDefinition.getActivities()) {
activity.setDelegateAsyncAfterUpdate(null);
activity.setDelegateAsyncBeforeUpdate(null);
}
return processDefinition;
}
Aggregations