use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseLanes.
protected void parseLanes(Element laneSetElement, LaneSet laneSet) {
List<Element> lanes = laneSetElement.elements("lane");
if (lanes != null && lanes.size() > 0) {
for (Element laneElement : lanes) {
// Parse basic attributes
Lane lane = new Lane();
lane.setId(laneElement.attribute("id"));
lane.setName(laneElement.attribute("name"));
// Parse ID's of flow-nodes that live inside this lane
List<Element> flowNodeElements = laneElement.elements("flowNodeRef");
if (flowNodeElements != null && flowNodeElements.size() > 0) {
for (Element flowNodeElement : flowNodeElements) {
lane.getFlowNodeIds().add(flowNodeElement.getText());
}
}
laneSet.addLane(lane);
}
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseBPMNEdge.
public void parseBPMNEdge(Element bpmnEdgeElement) {
String sequenceFlowId = bpmnEdgeElement.attribute("bpmnElement");
if (sequenceFlowId != null && !"".equals(sequenceFlowId)) {
if (sequenceFlows != null && sequenceFlows.containsKey(sequenceFlowId)) {
TransitionImpl sequenceFlow = sequenceFlows.get(sequenceFlowId);
List<Element> waypointElements = bpmnEdgeElement.elementsNS(OMG_DI_NS, "waypoint");
if (waypointElements.size() >= 2) {
List<Integer> waypoints = new ArrayList<Integer>();
for (Element waypointElement : waypointElements) {
waypoints.add(parseDoubleAttribute(waypointElement, "x", waypointElement.attribute("x"), true).intValue());
waypoints.add(parseDoubleAttribute(waypointElement, "y", waypointElement.attribute("y"), true).intValue());
}
sequenceFlow.setWaypoints(waypoints);
} else {
addError("Minimum 2 waypoint elements must be definted for a 'BPMNEdge'", bpmnEdgeElement);
}
} else if (!elementIds.contains(sequenceFlowId)) {
// it might not be a
// sequenceFlow but it
// might still
// reference
// 'something'
addError("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + sequenceFlowId + "not found", bpmnEdgeElement);
}
} else {
addError("'bpmnElement' attribute is required on BPMNEdge", bpmnEdgeElement);
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseMessages.
/**
* Parses the messages of the given definitions file. Messages are not
* contained within a process element, but they can be referenced from inner
* process elements.
*/
public void parseMessages() {
for (Element messageElement : rootElement.elements("message")) {
String id = messageElement.attribute("id");
String messageName = messageElement.attribute("name");
Expression messageExpression = null;
if (messageName != null) {
messageExpression = expressionManager.createExpression(messageName);
}
MessageDefinition messageDefinition = new MessageDefinition(this.targetNamespace + ":" + id, messageExpression);
this.messages.put(messageDefinition.getId(), messageDefinition);
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseSequenceFlow.
/**
* Parses all sequence flow of a scope.
*
* @param processElement
* The 'process' element wherein the sequence flow are defined.
* @param scope
* The scope to which the sequence flow must be added.
* @param compensationHandlers
*/
public void parseSequenceFlow(Element processElement, ScopeImpl scope, Map<String, Element> compensationHandlers) {
for (Element sequenceFlowElement : processElement.elements("sequenceFlow")) {
String id = sequenceFlowElement.attribute("id");
String sourceRef = sequenceFlowElement.attribute("sourceRef");
String destinationRef = sequenceFlowElement.attribute("targetRef");
// to target the catching link event (event target) here:
if (eventLinkSources.containsKey(destinationRef)) {
String linkName = eventLinkSources.get(destinationRef);
destinationRef = eventLinkTargets.get(linkName);
if (destinationRef == null) {
addError("sequence flow points to link event source with name '" + linkName + "' but no event target with that name exists. Most probably your link events are not configured correctly.", sequenceFlowElement);
// we cannot do anything useful now
return;
}
// Reminder: Maybe we should log a warning if we use intermediate link
// events which are not used?
// e.g. we have a catching event without the corresponding throwing one.
// not done for the moment as it does not break executability
}
// Implicit check: sequence flow cannot cross (sub) process boundaries: we
// don't do a processDefinition.findActivity here
ActivityImpl sourceActivity = scope.findActivityAtLevelOfSubprocess(sourceRef);
ActivityImpl destinationActivity = scope.findActivityAtLevelOfSubprocess(destinationRef);
if ((sourceActivity == null && compensationHandlers.containsKey(sourceRef)) || (sourceActivity != null && sourceActivity.isCompensationHandler())) {
addError("Invalid outgoing sequence flow of compensation activity '" + sourceRef + "'. A compensation activity should not have an incoming or outgoing sequence flow.", sequenceFlowElement);
} else if ((destinationActivity == null && compensationHandlers.containsKey(destinationRef)) || (destinationActivity != null && destinationActivity.isCompensationHandler())) {
addError("Invalid incoming sequence flow of compensation activity '" + destinationRef + "'. A compensation activity should not have an incoming or outgoing sequence flow.", sequenceFlowElement);
} else if (sourceActivity == null) {
addError("Invalid source '" + sourceRef + "' of sequence flow '" + id + "'", sequenceFlowElement);
} else if (destinationActivity == null) {
addError("Invalid destination '" + destinationRef + "' of sequence flow '" + id + "'", sequenceFlowElement);
} else if (sourceActivity.getActivityBehavior() instanceof EventBasedGatewayActivityBehavior) {
// ignore
} else if (destinationActivity.getActivityBehavior() instanceof IntermediateCatchEventActivityBehavior && (destinationActivity.getEventScope() != null) && (destinationActivity.getEventScope().getActivityBehavior() instanceof EventBasedGatewayActivityBehavior)) {
addError("Invalid incoming sequenceflow for intermediateCatchEvent with id '" + destinationActivity.getId() + "' connected to an event-based gateway.", sequenceFlowElement);
} else if (sourceActivity.getActivityBehavior() instanceof SubProcessActivityBehavior && sourceActivity.isTriggeredByEvent()) {
addError("Invalid outgoing sequence flow of event subprocess", sequenceFlowElement);
} else if (destinationActivity.getActivityBehavior() instanceof SubProcessActivityBehavior && destinationActivity.isTriggeredByEvent()) {
addError("Invalid incoming sequence flow of event subprocess", sequenceFlowElement);
} else {
if (getMultiInstanceScope(sourceActivity) != null) {
sourceActivity = getMultiInstanceScope(sourceActivity);
}
if (getMultiInstanceScope(destinationActivity) != null) {
destinationActivity = getMultiInstanceScope(destinationActivity);
}
TransitionImpl transition = sourceActivity.createOutgoingTransition(id);
sequenceFlows.put(id, transition);
transition.setProperty("name", sequenceFlowElement.attribute("name"));
transition.setProperty("documentation", parseDocumentation(sequenceFlowElement));
transition.setDestination(destinationActivity);
parseSequenceFlowConditionExpression(sequenceFlowElement, transition);
parseExecutionListenersOnTransition(sequenceFlowElement, transition);
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseSequenceFlow(sequenceFlowElement, scope, transition);
}
}
}
}
use of org.camunda.bpm.engine.impl.util.xml.Element in project camunda-bpm-platform by camunda.
the class BpmnParse method parseStartFormHandlers.
protected void parseStartFormHandlers(List<Element> startEventElements, ProcessDefinitionEntity processDefinition) {
if (processDefinition.getInitial() != null) {
for (Element startEventElement : startEventElements) {
if (startEventElement.attribute("id").equals(processDefinition.getInitial().getId())) {
StartFormHandler startFormHandler;
String startFormHandlerClassName = startEventElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "formHandlerClass");
if (startFormHandlerClassName != null) {
startFormHandler = (StartFormHandler) ReflectUtil.instantiate(startFormHandlerClassName);
} else {
startFormHandler = new DefaultStartFormHandler();
}
startFormHandler.parseConfiguration(startEventElement, deployment, processDefinition, this);
processDefinition.setStartFormHandler(new DelegateStartFormHandler(startFormHandler, deployment));
}
}
}
}
Aggregations