use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class ProcessesXmlParse method parseProcessArchive.
/**
* parse a <code><process-archive .../></code> element and add it to the list of parsed elements
*/
protected void parseProcessArchive(Element element, List<ProcessArchiveXml> parsedProcessArchives) {
ProcessArchiveXmlImpl processArchive = new ProcessArchiveXmlImpl();
processArchive.setName(element.attribute(NAME));
processArchive.setTenantId(element.attribute(TENANT_ID));
List<String> processResourceNames = new ArrayList<String>();
Map<String, String> properties = new HashMap<String, String>();
for (Element childElement : element.elements()) {
if (PROCESS_ENGINE.equals(childElement.getTagName())) {
processArchive.setProcessEngineName(childElement.getText());
} else if (PROCESS.equals(childElement.getTagName()) || RESOURCE.equals(childElement.getTagName())) {
processResourceNames.add(childElement.getText());
} else if (PROPERTIES.equals(childElement.getTagName())) {
parseProperties(childElement, properties);
}
}
// set properties
processArchive.setProperties(properties);
// add collected resource names.
processArchive.setProcessResourceNames(processResourceNames);
// add process archive to list of parsed archives.
parsedProcessArchives.add(processArchive);
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseTaskListeners.
protected void parseTaskListeners(Element userTaskElement, TaskDefinition taskDefinition) {
Element extentionsElement = userTaskElement.element("extensionElements");
if (extentionsElement != null) {
List<Element> taskListenerElements = extentionsElement.elementsNS(CAMUNDA_BPMN_EXTENSIONS_NS, "taskListener");
for (Element taskListenerElement : taskListenerElements) {
String eventName = taskListenerElement.attribute("event");
if (eventName != null) {
if (TaskListener.EVENTNAME_CREATE.equals(eventName) || TaskListener.EVENTNAME_ASSIGNMENT.equals(eventName) || TaskListener.EVENTNAME_COMPLETE.equals(eventName) || TaskListener.EVENTNAME_DELETE.equals(eventName)) {
TaskListener taskListener = parseTaskListener(taskListenerElement);
taskDefinition.addTaskListener(eventName, taskListener);
} else {
addError("Attribute 'event' must be one of {create|assignment|complete|delete}", userTaskElement);
}
} else {
addError("Attribute 'event' is mandatory on taskListener", userTaskElement);
}
}
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseLaneSets.
protected void parseLaneSets(Element parentElement, ProcessDefinitionEntity processDefinition) {
List<Element> laneSets = parentElement.elements("laneSet");
if (laneSets != null && laneSets.size() > 0) {
for (Element laneSetElement : laneSets) {
LaneSet newLaneSet = new LaneSet();
newLaneSet.setId(laneSetElement.attribute("id"));
newLaneSet.setName(laneSetElement.attribute("name"));
parseLanes(laneSetElement, newLaneSet);
// Finally, add the set
processDefinition.addLaneSet(newLaneSet);
}
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseScopeStartEvent.
protected void parseScopeStartEvent(ActivityImpl startEventActivity, Element startEventElement, Element parentElement, ActivityImpl scopeActivity) {
Properties scopeProperties = scopeActivity.getProperties();
// set this as the scope's initial
if (!scopeProperties.contains(BpmnProperties.INITIAL_ACTIVITY)) {
scopeProperties.set(BpmnProperties.INITIAL_ACTIVITY, startEventActivity);
} else {
addError("multiple start events not supported for subprocess", startEventElement);
}
Element errorEventDefinition = startEventElement.element(ERROR_EVENT_DEFINITION);
Element messageEventDefinition = startEventElement.element(MESSAGE_EVENT_DEFINITION);
Element signalEventDefinition = startEventElement.element(SIGNAL_EVENT_DEFINITION);
Element timerEventDefinition = startEventElement.element(TIMER_EVENT_DEFINITION);
Element compensateEventDefinition = startEventElement.element(COMPENSATE_EVENT_DEFINITION);
Element escalationEventDefinitionElement = startEventElement.element(ESCALATION_EVENT_DEFINITION);
Element conditionalEventDefinitionElement = startEventElement.element(CONDITIONAL_EVENT_DEFINITION);
if (scopeActivity.isTriggeredByEvent()) {
// event subprocess
EventSubProcessStartEventActivityBehavior behavior = new EventSubProcessStartEventActivityBehavior();
// parse isInterrupting
String isInterruptingAttr = startEventElement.attribute(INTERRUPTING);
boolean isInterrupting = isInterruptingAttr.equalsIgnoreCase(TRUE);
if (isInterrupting) {
scopeActivity.setActivityStartBehavior(ActivityStartBehavior.INTERRUPT_EVENT_SCOPE);
} else {
scopeActivity.setActivityStartBehavior(ActivityStartBehavior.CONCURRENT_IN_FLOW_SCOPE);
}
// the event scope of the start event is the flow scope of the event subprocess
startEventActivity.setEventScope(scopeActivity.getFlowScope());
if (errorEventDefinition != null) {
if (!isInterrupting) {
addError("error start event of event subprocess must be interrupting", startEventElement);
}
parseErrorStartEventDefinition(errorEventDefinition, startEventActivity);
} else if (messageEventDefinition != null) {
startEventActivity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.START_EVENT_MESSAGE);
EventSubscriptionDeclaration messageStartEventSubscriptionDeclaration = parseMessageEventDefinition(messageEventDefinition);
parseEventDefinitionForSubprocess(messageStartEventSubscriptionDeclaration, startEventActivity, messageEventDefinition);
} else if (signalEventDefinition != null) {
startEventActivity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.START_EVENT_SIGNAL);
EventSubscriptionDeclaration eventSubscriptionDeclaration = parseSignalEventDefinition(signalEventDefinition, false);
parseEventDefinitionForSubprocess(eventSubscriptionDeclaration, startEventActivity, signalEventDefinition);
} else if (timerEventDefinition != null) {
parseTimerStartEventDefinitionForEventSubprocess(timerEventDefinition, startEventActivity, isInterrupting);
} else if (compensateEventDefinition != null) {
parseCompensationEventSubprocess(startEventActivity, startEventElement, scopeActivity, compensateEventDefinition);
} else if (escalationEventDefinitionElement != null) {
startEventActivity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.START_EVENT_ESCALATION);
EscalationEventDefinition escalationEventDefinition = createEscalationEventDefinitionForEscalationHandler(escalationEventDefinitionElement, scopeActivity, isInterrupting);
addEscalationEventDefinition(startEventActivity.getEventScope(), escalationEventDefinition, escalationEventDefinitionElement);
} else if (conditionalEventDefinitionElement != null) {
final ConditionalEventDefinition conditionalEventDef = parseConditionalStartEventForEventSubprocess(conditionalEventDefinitionElement, startEventActivity, isInterrupting);
behavior = new EventSubProcessStartConditionalEventActivityBehavior(conditionalEventDef);
} else {
addError("start event of event subprocess must be of type 'error', 'message', 'timer', 'signal', 'compensation' or 'escalation'", startEventElement);
}
startEventActivity.setActivityBehavior(behavior);
} else {
// "regular" subprocess
Element conditionalEventDefinition = startEventElement.element(CONDITIONAL_EVENT_DEFINITION);
if (conditionalEventDefinition != null) {
addError("conditionalEventDefinition is not allowed on start event within a subprocess", conditionalEventDefinition);
}
if (timerEventDefinition != null) {
addError("timerEventDefinition is not allowed on start event within a subprocess", timerEventDefinition);
}
if (escalationEventDefinitionElement != null) {
addError("escalationEventDefinition is not allowed on start event within a subprocess", escalationEventDefinitionElement);
}
if (compensateEventDefinition != null) {
addError("compensateEventDefinition is not allowed on start event within a subprocess", compensateEventDefinition);
}
if (errorEventDefinition != null) {
addError("errorEventDefinition only allowed on start event if subprocess is an event subprocess", errorEventDefinition);
}
if (messageEventDefinition != null) {
addError("messageEventDefinition only allowed on start event if subprocess is an event subprocess", messageEventDefinition);
}
if (signalEventDefinition != null) {
addError("signalEventDefintion only allowed on start event if subprocess is an event subprocess", messageEventDefinition);
}
startEventActivity.setActivityBehavior(new NoneStartEventActivityBehavior());
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseMultiInstanceLoopCharacteristics.
/**
* Parses loopCharacteristics (standardLoop/Multi-instance) of an activity, if
* any is defined.
*/
public ScopeImpl parseMultiInstanceLoopCharacteristics(Element activityElement, ScopeImpl scope) {
Element miLoopCharacteristics = activityElement.element("multiInstanceLoopCharacteristics");
if (miLoopCharacteristics == null) {
return null;
} else {
String id = activityElement.attribute("id");
LOG.parsingElement("mi body for activity", id);
id = getIdForMiBody(id);
ActivityImpl miBodyScope = scope.createActivity(id);
setActivityAsyncDelegates(miBodyScope);
miBodyScope.setProperty(PROPERTYNAME_TYPE, ActivityTypes.MULTI_INSTANCE_BODY);
miBodyScope.setScope(true);
boolean isSequential = parseBooleanAttribute(miLoopCharacteristics.attribute("isSequential"), false);
MultiInstanceActivityBehavior behavior = null;
if (isSequential) {
behavior = new SequentialMultiInstanceActivityBehavior();
} else {
behavior = new ParallelMultiInstanceActivityBehavior();
}
miBodyScope.setActivityBehavior(behavior);
// loopCardinality
Element loopCardinality = miLoopCharacteristics.element("loopCardinality");
if (loopCardinality != null) {
String loopCardinalityText = loopCardinality.getText();
if (loopCardinalityText == null || "".equals(loopCardinalityText)) {
addError("loopCardinality must be defined for a multiInstanceLoopCharacteristics definition ", miLoopCharacteristics);
}
behavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCardinalityText));
}
// completionCondition
Element completionCondition = miLoopCharacteristics.element("completionCondition");
if (completionCondition != null) {
String completionConditionText = completionCondition.getText();
behavior.setCompletionConditionExpression(expressionManager.createExpression(completionConditionText));
}
// activiti:collection
String collection = miLoopCharacteristics.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "collection");
if (collection != null) {
if (collection.contains("{")) {
behavior.setCollectionExpression(expressionManager.createExpression(collection));
} else {
behavior.setCollectionVariable(collection);
}
}
// loopDataInputRef
Element loopDataInputRef = miLoopCharacteristics.element("loopDataInputRef");
if (loopDataInputRef != null) {
String loopDataInputRefText = loopDataInputRef.getText();
if (loopDataInputRefText != null) {
if (loopDataInputRefText.contains("{")) {
behavior.setCollectionExpression(expressionManager.createExpression(loopDataInputRefText));
} else {
behavior.setCollectionVariable(loopDataInputRefText);
}
}
}
// activiti:elementVariable
String elementVariable = miLoopCharacteristics.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "elementVariable");
if (elementVariable != null) {
behavior.setCollectionElementVariable(elementVariable);
}
// dataInputItem
Element inputDataItem = miLoopCharacteristics.element("inputDataItem");
if (inputDataItem != null) {
String inputDataItemName = inputDataItem.attribute("name");
behavior.setCollectionElementVariable(inputDataItemName);
}
// Validation
if (behavior.getLoopCardinalityExpression() == null && behavior.getCollectionExpression() == null && behavior.getCollectionVariable() == null) {
addError("Either loopCardinality or loopDataInputRef/activiti:collection must been set", miLoopCharacteristics);
}
// Validation
if (behavior.getCollectionExpression() == null && behavior.getCollectionVariable() == null && behavior.getCollectionElementVariable() != null) {
addError("LoopDataInputRef/activiti:collection must be set when using inputDataItem or activiti:elementVariable", miLoopCharacteristics);
}
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseMultiInstanceLoopCharacteristics(activityElement, miLoopCharacteristics, miBodyScope);
}
return miBodyScope;
}
}
Aggregations