提交 cb7307f7 编写于 作者: T tijsrademakers

Merge branch 'master' of https://github.com/Activiti/Activiti

/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.cdi.impl.event;
import java.util.HashSet;
import java.util.Set;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BusinessRuleTask;
import org.activiti.bpmn.model.CallActivity;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.bpmn.model.InclusiveGateway;
import org.activiti.bpmn.model.ManualTask;
import org.activiti.bpmn.model.ParallelGateway;
import org.activiti.bpmn.model.ReceiveTask;
import org.activiti.bpmn.model.ScriptTask;
import org.activiti.bpmn.model.SendTask;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.ServiceTask;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.bpmn.model.Task;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.bpmn.model.Transaction;
import org.activiti.bpmn.model.UserTask;
import org.activiti.cdi.BusinessProcessEventType;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.parse.BpmnParseHandler;
/**
* {@link BpmnParseHandler} registering the {@link CdiExecutionListener} for
* distributing execution events using the cdi event infrastructure
*
* @author Daniel Meyer
* @author Joram Barrez
*/
public class CdiEventSupportBpmnParseHandler implements BpmnParseHandler {
protected static final Set<Class<? extends BaseElement>> supportedTypes = new HashSet<Class<? extends BaseElement>>();
static {
supportedTypes.add(StartEvent.class);
supportedTypes.add(EndEvent.class);
supportedTypes.add(ExclusiveGateway.class);
supportedTypes.add(InclusiveGateway.class);
supportedTypes.add(ParallelGateway.class);
supportedTypes.add(ScriptTask.class);
supportedTypes.add(ServiceTask.class);
supportedTypes.add(BusinessRuleTask.class);
supportedTypes.add(Task.class);
supportedTypes.add(ManualTask.class);
supportedTypes.add(UserTask.class);
supportedTypes.add(EndEvent.class);
supportedTypes.add(SubProcess.class);
supportedTypes.add(CallActivity.class);
supportedTypes.add(SendTask.class);
supportedTypes.add(ReceiveTask.class);
supportedTypes.add(EventGateway.class);
supportedTypes.add(Transaction.class);
supportedTypes.add(ThrowEvent.class);
supportedTypes.add(TimerEventDefinition.class);
supportedTypes.add(ErrorEventDefinition.class);
supportedTypes.add(SignalEventDefinition.class);
supportedTypes.add(SequenceFlow.class);
}
public Set<Class< ? extends BaseElement>> getHandledTypes() {
return supportedTypes;
}
public void parse(BpmnParse bpmnParse, BaseElement element) {
if (element instanceof SequenceFlow) {
TransitionImpl transition = bpmnParse.getSequenceFlows().get(element.getId());
transition.addExecutionListener(new CdiExecutionListener(transition.getId()));
} else {
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(element.getId());
if (activity != null) {
addStartEventListener(activity);
addEndEventListener(activity);
}
}
}
protected void addEndEventListener(ActivityImpl activity) {
activity.addExecutionListener(ExecutionListener.EVENTNAME_END, new CdiExecutionListener(activity.getId(), BusinessProcessEventType.END_ACTIVITY));
}
protected void addStartEventListener(ActivityImpl activity) {
activity.addExecutionListener(ExecutionListener.EVENTNAME_START, new CdiExecutionListener(activity.getId(), BusinessProcessEventType.START_ACTIVITY));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.cdi.impl.event;
import org.activiti.bpmn.model.Activity;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.BusinessRuleTask;
import org.activiti.bpmn.model.CallActivity;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.bpmn.model.InclusiveGateway;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.ManualTask;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.MultiInstanceLoopCharacteristics;
import org.activiti.bpmn.model.ParallelGateway;
import org.activiti.bpmn.model.Process;
import org.activiti.bpmn.model.ReceiveTask;
import org.activiti.bpmn.model.ScriptTask;
import org.activiti.bpmn.model.SendTask;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.ServiceTask;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.bpmn.model.Task;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.bpmn.model.Transaction;
import org.activiti.bpmn.model.UserTask;
import org.activiti.cdi.BusinessProcessEventType;
import org.activiti.cdi.impl.event.CdiExecutionListener;
import org.activiti.engine.BpmnParseListener;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.variable.VariableDeclaration;
/**
* {@link BpmnParseListener} registering the {@link CdiExecutionListener} for
* distributing execution events using the cdi event infrastructure
*
* @author Daniel Meyer
*/
public class CdiEventSupportBpmnParseListener implements BpmnParseListener {
protected void addEndEventListener(ActivityImpl activity) {
activity.addExecutionListener(ExecutionListener.EVENTNAME_END, new CdiExecutionListener(activity.getId(), BusinessProcessEventType.END_ACTIVITY));
}
protected void addStartEventListener(ActivityImpl activity) {
activity.addExecutionListener(ExecutionListener.EVENTNAME_START, new CdiExecutionListener(activity.getId(), BusinessProcessEventType.START_ACTIVITY));
}
@Override
public void parseProcess(Process processElement, ProcessDefinitionEntity processDefinition) {
}
@Override
public void parseStartEvent(StartEvent startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
addStartEventListener(startEventActivity);
addEndEventListener(startEventActivity);
}
@Override
public void parseExclusiveGateway(ExclusiveGateway exclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseInclusiveGateway(InclusiveGateway inclusiveGwElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseParallelGateway(ParallelGateway parallelGwElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseScriptTask(ScriptTask scriptTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseServiceTask(ServiceTask serviceTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseBusinessRuleTask(BusinessRuleTask businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseTask(Task taskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseManualTask(ManualTask manualTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseUserTask(UserTask userTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseEndEvent(EndEvent endEventElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseBoundaryTimerEventDefinition(TimerEventDefinition timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) {
addStartEventListener(timerActivity);
addEndEventListener(timerActivity);
}
@Override
public void parseBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseSubProcess(SubProcess subProcessElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseCallActivity(CallActivity callActivityElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) {
}
@Override
public void parseSequenceFlow(SequenceFlow sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
transition.addExecutionListener(new CdiExecutionListener(transition.getId()));
}
@Override
public void parseSendTask(SendTask sendTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseMultiInstanceLoopCharacteristics(Activity activityElement, MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristicsElement, ActivityImpl activity) {
}
@Override
public void parseIntermediateTimerEventDefinition(TimerEventDefinition timerEventDefinition, ActivityImpl timerActivity) {
addStartEventListener(timerActivity);
addEndEventListener(timerActivity);
}
@Override
public void parseReceiveTask(ReceiveTask receiveTaskElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseIntermediateSignalCatchEventDefinition(SignalEventDefinition signalEventDefinition, ActivityImpl signalActivity) {
addStartEventListener(signalActivity);
addEndEventListener(signalActivity);
}
@Override
public void parseBoundarySignalEventDefinition(SignalEventDefinition signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) {
addStartEventListener(signalActivity);
addEndEventListener(signalActivity);
}
@Override
public void parseEventBasedGateway(EventGateway eventBasedGwElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseTransaction(Transaction transactionElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) {
}
@Override
public void parseIntermediateThrowEvent(ThrowEvent intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
addStartEventListener(activity);
addEndEventListener(activity);
}
@Override
public void parseIntermediateCatchEvent(IntermediateCatchEvent intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
}
@Override
public void parseBoundaryEvent(BoundaryEvent boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) {
}
@Override
public void parseIntermediateMessageCatchEventDefinition(MessageEventDefinition messageEventDefinition, ActivityImpl nestedActivity) {
}
@Override
public void parseBoundaryMessageEventDefinition(MessageEventDefinition element, boolean interrupting, ActivityImpl messageActivity) {
}
}
......@@ -12,9 +12,9 @@
<property name="jobExecutorActivate" value="false" />
<property name="mailServerPort" value="5025" />
<property name="customPostBPMNParseListeners">
<property name="postBpmnParseHandlers">
<list>
<bean class="org.activiti.cdi.impl.event.CdiEventSupportBpmnParseListener" />
<bean class="org.activiti.cdi.impl.event.CdiEventSupportBpmnParseHandler" />
</list>
</property>
......
package org.activiti.engine;
import org.activiti.bpmn.model.Activity;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.BusinessRuleTask;
import org.activiti.bpmn.model.CallActivity;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.bpmn.model.InclusiveGateway;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.ManualTask;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.MultiInstanceLoopCharacteristics;
import org.activiti.bpmn.model.ParallelGateway;
import org.activiti.bpmn.model.Process;
import org.activiti.bpmn.model.ReceiveTask;
import org.activiti.bpmn.model.ScriptTask;
import org.activiti.bpmn.model.SendTask;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.ServiceTask;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.bpmn.model.Task;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.bpmn.model.Transaction;
import org.activiti.bpmn.model.UserTask;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.variable.VariableDeclaration;
/**
* Base class for implementing a {@link BpmnParseListener} without being forced to implement
* all methods provided, which makes the implementation more robust to future changes.
*
* @author ruecker
* @author Joram Barrez
*/
public class AbstractBpmnParseListener implements BpmnParseListener {
public void parseProcess(Process process, ProcessDefinitionEntity processDefinition) {
}
public void parseStartEvent(StartEvent startEvent, ScopeImpl scope, ActivityImpl startEventActivity) {
}
public void parseExclusiveGateway(ExclusiveGateway exclusiveGateway, ScopeImpl scope, ActivityImpl activity) {
}
public void parseInclusiveGateway(InclusiveGateway inclusiveGateway, ScopeImpl scope, ActivityImpl activity) {
}
public void parseParallelGateway(ParallelGateway parallelGateway, ScopeImpl scope, ActivityImpl activity) {
}
public void parseScriptTask(ScriptTask scriptTask, ScopeImpl scope, ActivityImpl activity) {
}
public void parseServiceTask(ServiceTask serviceTask, ScopeImpl scope, ActivityImpl activity) {
}
public void parseBusinessRuleTask(BusinessRuleTask businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseTask(Task task, ScopeImpl scope, ActivityImpl activity) {
}
public void parseManualTask(ManualTask manualTask, ScopeImpl scope, ActivityImpl activity) {
}
public void parseUserTask(UserTask userTaskElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseEndEvent(EndEvent endEventElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseBoundaryTimerEventDefinition(TimerEventDefinition timerEventDefinition, boolean interrupting, ActivityImpl timerActivity) {
}
public void parseBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity,
ActivityImpl nestedErrorEventActivity) {
}
public void parseSubProcess(SubProcess subProcess, ScopeImpl scope, ActivityImpl activity) {
}
public void parseCallActivity(CallActivity callActivity, ScopeImpl scope, ActivityImpl activity) {
}
public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity) {
}
public void parseSequenceFlow(SequenceFlow sequenceFlow, ScopeImpl scopeElement, TransitionImpl transition) {
}
public void parseSendTask(SendTask sendTask, ScopeImpl scope, ActivityImpl activity) {
}
public void parseMultiInstanceLoopCharacteristics(Activity modelActivity, MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics,
ActivityImpl activity) {
}
public void parseIntermediateTimerEventDefinition(TimerEventDefinition timerEventDefinition, ActivityImpl timerActivity) {
}
public void parseReceiveTask(ReceiveTask receiveTask, ScopeImpl scope, ActivityImpl activity) {
}
public void parseIntermediateSignalCatchEventDefinition(SignalEventDefinition signalEventDefinition, ActivityImpl signalActivity) {
}
public void parseIntermediateMessageCatchEventDefinition(MessageEventDefinition messageEventDefinition, ActivityImpl nestedActivity) {
}
public void parseBoundarySignalEventDefinition(SignalEventDefinition signalEventDefinition, boolean interrupting, ActivityImpl signalActivity) {
}
public void parseEventBasedGateway(EventGateway eventBasedGateway, ScopeImpl scope, ActivityImpl activity) {
}
public void parseTransaction(Transaction transaction, ScopeImpl scope, ActivityImpl activity) {
}
public void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity) {
}
public void parseIntermediateThrowEvent(ThrowEvent intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
}
public void parseIntermediateCatchEvent(IntermediateCatchEvent intermediateCatchEvent, ScopeImpl scope, ActivityImpl activity) {
}
public void parseBoundaryEvent(BoundaryEvent boundaryEvent, ScopeImpl scopeElement, ActivityImpl nestedActivity) {
}
public void parseBoundaryMessageEventDefinition(MessageEventDefinition messageEventDefinition, boolean interrupting, ActivityImpl messageActivity) {
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.BusinessRuleTask;
import org.activiti.bpmn.model.CallActivity;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.bpmn.model.InclusiveGateway;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.ManualTask;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.MultiInstanceLoopCharacteristics;
import org.activiti.bpmn.model.ParallelGateway;
import org.activiti.bpmn.model.Process;
import org.activiti.bpmn.model.ReceiveTask;
import org.activiti.bpmn.model.ScriptTask;
import org.activiti.bpmn.model.SendTask;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.ServiceTask;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.bpmn.model.Task;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.bpmn.model.Transaction;
import org.activiti.bpmn.model.UserTask;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.impl.util.xml.Element;
import org.activiti.engine.impl.variable.VariableDeclaration;
/**
* Listener which can be registered within the engine to receive events during parsing (and
* maybe influence ist). Instead of implementing this interface you might consider to extend
* the {@link AbstractBpmnParseListener}, which contains an empty implementation for all methods
* and makes your implementation easier and more robust to future changes.
*
* Instances of this interface can be injected into the {@link ProcessEngineConfigurationImpl}
* using the pre/postPastListeners lists.
*
* @author Tom Baeyens
* @author Falko Menge
* @author Joram Barrez
*/
public interface BpmnParseListener {
void parseProcess(Process process, ProcessDefinitionEntity processDefinition);
void parseStartEvent(StartEvent startEvent, ScopeImpl scope, ActivityImpl startEventActivity);
void parseExclusiveGateway(ExclusiveGateway exclusiveGateway, ScopeImpl scope, ActivityImpl activity);
void parseInclusiveGateway(InclusiveGateway inclusiveGateway, ScopeImpl scope, ActivityImpl activity);
void parseParallelGateway(ParallelGateway parallelGateway, ScopeImpl scope, ActivityImpl activity);
void parseScriptTask(ScriptTask scriptTask, ScopeImpl scope, ActivityImpl activity);
void parseServiceTask(ServiceTask serviceTask, ScopeImpl scope, ActivityImpl activity);
void parseBusinessRuleTask(BusinessRuleTask businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity);
void parseTask(Task task, ScopeImpl scope, ActivityImpl activity);
void parseManualTask(ManualTask manualTask, ScopeImpl scope, ActivityImpl activity);
void parseUserTask(UserTask userTaskElement, ScopeImpl scope, ActivityImpl activity);
void parseEndEvent(EndEvent endEventElement, ScopeImpl scope, ActivityImpl activity);
void parseBoundaryTimerEventDefinition(TimerEventDefinition timerEventDefinition, boolean interrupting, ActivityImpl timerActivity);
void parseBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity);
void parseSubProcess(SubProcess subProcess, ScopeImpl scope, ActivityImpl activity);
void parseCallActivity(CallActivity callActivity, ScopeImpl scope, ActivityImpl activity);
void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity);
void parseSequenceFlow(SequenceFlow sequenceFlow, ScopeImpl scopeElement, TransitionImpl transition);
void parseSendTask(SendTask sendTask, ScopeImpl scope, ActivityImpl activity);
void parseMultiInstanceLoopCharacteristics(org.activiti.bpmn.model.Activity modelActivity, MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics, ActivityImpl activity);
void parseIntermediateTimerEventDefinition(TimerEventDefinition timerEventDefinition, ActivityImpl timerActivity);
void parseReceiveTask(ReceiveTask receiveTask, ScopeImpl scope, ActivityImpl activity);
void parseIntermediateSignalCatchEventDefinition(SignalEventDefinition signalEventDefinition, ActivityImpl signalActivity);
void parseIntermediateMessageCatchEventDefinition(MessageEventDefinition messageEventDefinition, ActivityImpl nestedActivity);
void parseBoundarySignalEventDefinition(SignalEventDefinition signalEventDefinition, boolean interrupting, ActivityImpl signalActivity);
void parseEventBasedGateway(EventGateway eventBasedGateway, ScopeImpl scope, ActivityImpl activity);
void parseTransaction(Transaction transaction, ScopeImpl scope, ActivityImpl activity);
void parseCompensateEventDefinition(Element compensateEventDefinition, ActivityImpl compensationActivity);
void parseIntermediateThrowEvent(ThrowEvent intermediateEventElement, ScopeImpl scope, ActivityImpl activity);
void parseIntermediateCatchEvent(IntermediateCatchEvent intermediateCatchEvent, ScopeImpl scope, ActivityImpl activity);
void parseBoundaryEvent(BoundaryEvent boundaryEvent, ScopeImpl scopeElement, ActivityImpl nestedActivity);
void parseBoundaryMessageEventDefinition(MessageEventDefinition messageEventDefinition, boolean interrupting, ActivityImpl messageActivity);
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.engine.parse.BpmnParseHandler;
import org.slf4j.Logger;
/**
* @author Joram Barrez
*/
public class BpmnParseHandlers {
private static final Logger LOGGER = org.slf4j.LoggerFactory.getLogger(BpmnParseHandlers.class);
protected Map<Class<? extends BaseElement>, List<BpmnParseHandler>> parseHandlers;
public BpmnParseHandlers() {
this.parseHandlers = new HashMap<Class<? extends BaseElement>, List<BpmnParseHandler>>();
}
public List<BpmnParseHandler> getHandlersFor(Class<? extends BaseElement> clazz) {
return parseHandlers.get(clazz);
}
public void addHandlers(List<BpmnParseHandler> bpmnParseHandlers) {
for (BpmnParseHandler bpmnParseHandler : bpmnParseHandlers) {
addHandler(bpmnParseHandler);
}
}
public void addHandler(BpmnParseHandler bpmnParseHandler) {
for (Class<? extends BaseElement> type : bpmnParseHandler.getHandledTypes()) {
List<BpmnParseHandler> handlers = parseHandlers.get(type);
if (handlers == null) {
handlers = new ArrayList<BpmnParseHandler>();
parseHandlers.put(type, handlers);
}
handlers.add(bpmnParseHandler);
}
}
public void parse(BpmnParse bpmnParse, BaseElement element) {
if (element instanceof FlowElement) {
bpmnParse.setCurrentFlowElement((FlowElement) element);
}
// Execute parse handlers
List<BpmnParseHandler> handlers = parseHandlers.get(element.getClass());
if (handlers == null) {
LOGGER.warn("Could not find matching parse handler for + " + element.getId() + " this is likely a bug.");
} else {
for (BpmnParseHandler handler : handlers) {
handler.parse(bpmnParse, element);
}
}
}
}
......@@ -12,10 +12,6 @@
*/
package org.activiti.engine.impl.bpmn.parser;
import java.util.ArrayList;
import java.util.List;
import org.activiti.engine.BpmnParseListener;
import org.activiti.engine.impl.bpmn.parser.factory.ActivityBehaviorFactory;
import org.activiti.engine.impl.bpmn.parser.factory.ListenerFactory;
import org.activiti.engine.impl.cfg.BpmnParseFactory;
......@@ -74,7 +70,7 @@ public class BpmnParser extends Parser {
protected ActivityBehaviorFactory activityBehaviorFactory;
protected ListenerFactory listenerFactory;
protected BpmnParseFactory bpmnParseFactory;
protected List<BpmnParseListener> parseListeners = new ArrayList<BpmnParseListener>();
protected BpmnParseHandlers bpmnParserHandlers;
/**
* Creates a new {@link BpmnParse} instance that can be used
......@@ -116,11 +112,12 @@ public class BpmnParser extends Parser {
this.expressionManager = expressionManager;
}
public List<BpmnParseListener> getParseListeners() {
return parseListeners;
public BpmnParseHandlers getBpmnParserHandlers() {
return bpmnParserHandlers;
}
public void setParseListeners(List<BpmnParseListener> parseListeners) {
this.parseListeners = parseListeners;
public void setBpmnParserHandlers(BpmnParseHandlers bpmnParserHandlers) {
this.bpmnParserHandlers = bpmnParserHandlers;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.Activity;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.bpmn.model.MultiInstanceLoopCharacteristics;
import org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public abstract class AbstractActivityBpmnParseHandler<T extends FlowNode> extends AbstractFlowNodeBpmnParseHandler<T> {
@Override
public void parse(BpmnParse bpmnParse, BaseElement element) {
super.parse(bpmnParse, element);
if (element instanceof Activity
&& ((Activity) element).getLoopCharacteristics() != null) {
createMultiInstanceLoopCharacteristics(bpmnParse, (Activity) element);
}
}
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, org.activiti.bpmn.model.Activity modelActivity) {
MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
// Activity Behavior
MultiInstanceActivityBehavior miActivityBehavior = null;
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
if (activity == null) {
bpmnParse.getBpmnModel().addProblem("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found", modelActivity);
}
if (loopCharacteristics.isSequential()) {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(
activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
} else {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(
activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
}
// ActivityImpl settings
activity.setScope(true);
activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
activity.setActivityBehavior(miActivityBehavior);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
// loopcardinality
if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
}
// completion condition
if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
}
// activiti:collection
if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
if (loopCharacteristics.getInputDataItem().contains("{")) {
miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
} else {
miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
}
}
// activiti:elementVariable
if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
}
// Validation
if (miActivityBehavior.getLoopCardinalityExpression() == null && miActivityBehavior.getCollectionExpression() == null
&& miActivityBehavior.getCollectionVariable() == null) {
bpmnModel.addProblem("Either loopCardinality or loopDataInputRef/activiti:collection must been set.", loopCharacteristics);
}
// Validation
if (miActivityBehavior.getCollectionExpression() == null && miActivityBehavior.getCollectionVariable() == null
&& miActivityBehavior.getCollectionElementVariable() != null) {
bpmnModel.addProblem("LoopDataInputRef/activiti:collection must be set when using inputDataItem or activiti:elementVariable.", loopCharacteristics);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.activiti.bpmn.model.ActivitiListener;
import org.activiti.bpmn.model.Activity;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.Gateway;
import org.activiti.bpmn.model.ImplementationType;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.activiti.engine.parse.BpmnParseHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Doccen: do not use, only for internal usage
* (or we must extract a second subclass).
*
* @author Joram Barrez
*/
public abstract class AbstractBpmnParseHandler<T extends BaseElement> implements BpmnParseHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractBpmnParseHandler.class);
public static final String PROPERTYNAME_IS_FOR_COMPENSATION = "isForCompensation";
public static final String PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION = "eventDefinitions";
public static final String PROPERTYNAME_ERROR_EVENT_DEFINITIONS = "errorEventDefinitions";
public static final String PROPERTYNAME_TIMER_DECLARATION = "timerDeclarations";
public Set<Class< ? extends BaseElement>> getHandledTypes() {
Set<Class< ? extends BaseElement>> types = new HashSet<Class<? extends BaseElement>>();
types.add(getHandledType());
return types;
}
protected Class<? extends BaseElement> getHandledType() {
// Subclasses should override
return null;
}
@SuppressWarnings("unchecked")
public void parse(BpmnParse bpmnParse, BaseElement element) {
T baseElement = (T) element;
executeParse(bpmnParse, baseElement);
}
protected abstract void executeParse(BpmnParse bpmnParse, T element);
protected ActivityImpl findActivity(BpmnParse bpmnParse, String id) {
return bpmnParse.getCurrentScope().findActivity(id);
}
public ActivityImpl createActivityOnCurrentScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName) {
return createActivityOnScope(bpmnParse, flowElement, xmlLocalName, bpmnParse.getCurrentScope());
}
public ActivityImpl createActivityOnScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName, ScopeImpl scopeElement) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Parsing activity {}", flowElement.getId());
}
ActivityImpl activity = scopeElement.createActivity(flowElement.getId());
bpmnParse.setCurrentActivity(activity);
activity.setProperty("name", flowElement.getName());
activity.setProperty("documentation", flowElement.getDocumentation());
if (flowElement instanceof Activity) {
Activity modelActivity = (Activity) flowElement;
activity.setProperty("default", modelActivity.getDefaultFlow());
if(modelActivity.isForCompensation()) {
activity.setProperty(PROPERTYNAME_IS_FOR_COMPENSATION, true);
}
} else if (flowElement instanceof Gateway) {
activity.setProperty("default", ((Gateway) flowElement).getDefaultFlow());
}
activity.setProperty("type", xmlLocalName);
return activity;
}
protected void createExecutionListenersOnScope(BpmnParse bpmnParse, List<ActivitiListener> activitiListenerList, ScopeImpl scope) {
for (ActivitiListener activitiListener : activitiListenerList) {
scope.addExecutionListener(activitiListener.getEvent(), createExecutionListener(bpmnParse, activitiListener));
}
}
protected void createExecutionListenersOnTransition(BpmnParse bpmnParse, List<ActivitiListener> activitiListenerList, TransitionImpl transition) {
for (ActivitiListener activitiListener : activitiListenerList) {
transition.addExecutionListener(createExecutionListener(bpmnParse, activitiListener));
}
}
protected ExecutionListener createExecutionListener(BpmnParse bpmnParse, ActivitiListener activitiListener) {
ExecutionListener executionListener = null;
if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
executionListener = bpmnParse.getListenerFactory().createClassDelegateExecutionListener(activitiListener);
} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
executionListener = bpmnParse.getListenerFactory().createExpressionExecutionListener(activitiListener);
} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
executionListener = bpmnParse.getListenerFactory().createDelegateExpressionExecutionListener(activitiListener);
}
return executionListener;
}
@SuppressWarnings("unchecked")
protected void addEventSubscriptionDeclaration(BpmnParse bpmnParse, EventSubscriptionDeclaration subscription, EventDefinition parsedEventDefinition, ScopeImpl scope) {
List<EventSubscriptionDeclaration> eventDefinitions = (List<EventSubscriptionDeclaration>) scope.getProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION);
if(eventDefinitions == null) {
eventDefinitions = new ArrayList<EventSubscriptionDeclaration>();
scope.setProperty(PROPERTYNAME_EVENT_SUBSCRIPTION_DECLARATION, eventDefinitions);
} else {
// if this is a message event, validate that it is the only one with the provided name for this scope
if(subscription.getEventType().equals("message")) {
for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) {
if(eventDefinition.getEventType().equals("message")
&& eventDefinition.getEventName().equals(subscription.getEventName())
&& eventDefinition.isStartEvent() == subscription.isStartEvent()) {
bpmnParse.getBpmnModel().addProblem("Cannot have more than one message event subscription with name '" + subscription.getEventName() +
"' for scope '"+scope.getId()+"'", parsedEventDefinition);
}
}
}
}
eventDefinitions.add(subscription);
}
protected String getPrecedingEventBasedGateway(BpmnParse bpmnParse, IntermediateCatchEvent event) {
String eventBasedGatewayId = null;
for (SequenceFlow sequenceFlow : event.getIncomingFlows()) {
FlowElement sourceElement = bpmnParse.getBpmnModel().getFlowElement(sequenceFlow.getSourceRef());
if (sourceElement instanceof EventGateway) {
eventBasedGatewayId = sourceElement.getId();
break;
}
}
return eventBasedGatewayId;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.List;
import org.activiti.bpmn.model.FieldExtension;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.bpmn.model.Task;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
/**
* @author Joram Barrez
*/
public abstract class AbstractExternalInvocationBpmnParseHandler<T extends FlowNode> extends AbstractActivityBpmnParseHandler<T> {
protected void validateFieldDeclarationsForEmail(BpmnParse bpmnParse, Task task, List<FieldExtension> fieldExtensions) {
boolean toDefined = false;
boolean textOrHtmlDefined = false;
for (FieldExtension fieldExtension : fieldExtensions) {
if (fieldExtension.getFieldName().equals("to")) {
toDefined = true;
}
if (fieldExtension.getFieldName().equals("html")) {
textOrHtmlDefined = true;
}
if (fieldExtension.getFieldName().equals("text")) {
textOrHtmlDefined = true;
}
}
if (!toDefined) {
bpmnParse.getBpmnModel().addProblem("No recipient is defined on the mail activity", task);
}
if (!textOrHtmlDefined) {
bpmnParse.getBpmnModel().addProblem("Text or html field should be provided", task);
}
}
protected void validateFieldDeclarationsForShell(BpmnParse bpmnParse, Task task, List<FieldExtension> fieldExtensions) {
boolean shellCommandDefined = false;
for (FieldExtension fieldExtension : fieldExtensions) {
String fieldName = fieldExtension.getFieldName();
String fieldValue = fieldExtension.getStringValue();
shellCommandDefined |= fieldName.equals("command");
if ((fieldName.equals("wait") || fieldName.equals("redirectError") || fieldName.equals("cleanEnv")) && !fieldValue.toLowerCase().equals("true")
&& !fieldValue.toLowerCase().equals("false")) {
bpmnParse.getBpmnModel().addProblem("undefined value for shell " + fieldName + " parameter :" + fieldValue.toString() + ".", task);
}
}
if (!shellCommandDefined) {
bpmnParse.getBpmnModel().addProblem("No shell command is defined on the shell activity", task);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
/**
* @author Joram Barrez
*/
public abstract class AbstractFlowNodeBpmnParseHandler<T extends FlowNode> extends AbstractBpmnParseHandler<T> {
@Override
public void parse(BpmnParse bpmnParse, BaseElement element) {
super.parse(bpmnParse, element);
createExecutionListenersOnScope(bpmnParse, ((FlowNode) element).getExecutionListeners(), findActivity(bpmnParse, element.getId()));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.CancelEventDefinition;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class BoundaryEventParseHandler extends AbstractBpmnParseHandler<BoundaryEvent> {
public Class< ? extends BaseElement> getHandledType() {
return BoundaryEvent.class;
}
protected void executeParse(BpmnParse bpmnParse, BoundaryEvent boundaryEvent) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
ActivityImpl parentActivity = findActivity(bpmnParse, boundaryEvent.getAttachedToRefId());
if (parentActivity == null) {
bpmnModel.addProblem("Invalid reference in boundary event. Make sure that the referenced activity is defined in the same scope as the boundary event", boundaryEvent);
return;
}
ActivityImpl nestedActivity = createActivityOnScope(bpmnParse, boundaryEvent, BpmnXMLConstants.ELEMENT_EVENT_BOUNDARY, parentActivity);
bpmnParse.setCurrentActivity(nestedActivity);
EventDefinition eventDefinition = null;
if (boundaryEvent.getEventDefinitions().size() > 0) {
eventDefinition = boundaryEvent.getEventDefinitions().get(0);
}
if (eventDefinition instanceof TimerEventDefinition
|| eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition
|| eventDefinition instanceof SignalEventDefinition
|| eventDefinition instanceof CancelEventDefinition
|| eventDefinition instanceof MessageEventDefinition
|| eventDefinition instanceof org.activiti.bpmn.model.CompensateEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else {
bpmnModel.addProblem("Unsupported boundary event type", boundaryEvent);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BusinessRuleTask;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class BusinessRuleParseHandler extends AbstractActivityBpmnParseHandler<BusinessRuleTask> {
public Class< ? extends BaseElement> getHandledType() {
return BusinessRuleTask.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, BusinessRuleTask businessRuleTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, businessRuleTask, BpmnXMLConstants.ELEMENT_TASK_BUSINESSRULE);
activity.setAsync(businessRuleTask.isAsynchronous());
activity.setExclusive(!businessRuleTask.isNotExclusive());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBusinessRuleTaskActivityBehavior(businessRuleTask));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.CallActivity;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class CallActivityParseHandler extends AbstractActivityBpmnParseHandler<CallActivity> {
public Class< ? extends BaseElement> getHandledType() {
return CallActivity.class;
}
protected void executeParse(BpmnParse bpmnParse, CallActivity callActivity) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, callActivity, BpmnXMLConstants.ELEMENT_CALL_ACTIVITY);
activity.setScope(true);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCallActivityBehavior(callActivity));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.CancelEventDefinition;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class CancelEventDefinitionParseHandler extends AbstractBpmnParseHandler<CancelEventDefinition> {
public Class< ? extends BaseElement> getHandledType() {
return CancelEventDefinition.class;
}
protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
ActivityImpl activity = bpmnParse.getCurrentActivity();
activity.setProperty("type", "cancelBoundaryCatch");
ActivityImpl parent = (ActivityImpl) activity.getParent();
if (!parent.getProperty("type").equals("transaction")) {
bpmnModel.addProblem("boundary event with cancelEventDefinition only supported on transaction subprocesses.", cancelEventDefinition);
}
for (ActivityImpl child : parent.getActivities()) {
if (child.getProperty("type").equals("cancelBoundaryCatch") && child != activity) {
bpmnModel.addProblem("multiple boundary events with cancelEventDefinition not supported on same transaction subprocess.", cancelEventDefinition);
}
}
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelBoundaryEventActivityBehavior(cancelEventDefinition));
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.CompensateEventDefinition;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class CompensateEventDefinitionParseHandler extends AbstractBpmnParseHandler<CompensateEventDefinition> {
public Class< ? extends BaseElement> getHandledType() {
return CompensateEventDefinition.class;
}
protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) {
ScopeImpl scope = bpmnParse.getCurrentScope();
if(StringUtils.isNotEmpty(eventDefinition.getActivityRef())) {
if(scope.findActivity(eventDefinition.getActivityRef()) == null) {
bpmnParse.getBpmnModel().addProblem("Invalid attribute value for 'activityRef': no activity with id '" + eventDefinition.getActivityRef() +
"' in current scope " + scope.getId(), eventDefinition);
}
}
org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition compensateEventDefinition =
new org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition();
compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef());
compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion());
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), compensateEventDefinition));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
activity.setProperty("type", "compensationBoundaryCatch");
ScopeImpl parent = activity.getParent();
for (ActivityImpl child : parent.getActivities()) {
if (child.getProperty("type").equals("compensationBoundaryCatch") && child != activity ) {
bpmnParse.getBpmnModel().addProblem("multiple boundary events with compensateEventDefinition not supported on same activity.", eventDefinition);
}
}
} else {
// What to do?
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.CancelEventDefinition;
import org.activiti.bpmn.model.EndEvent;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.TerminateEventDefinition;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class EndEventParseHandler extends AbstractActivityBpmnParseHandler<EndEvent> {
public Class< ? extends BaseElement> getHandledType() {
return EndEvent.class;
}
protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) {
ActivityImpl endEventActivity = createActivityOnCurrentScope(bpmnParse, endEvent, BpmnXMLConstants.ELEMENT_EVENT_END);
EventDefinition eventDefinition = null;
if (endEvent.getEventDefinitions().size() > 0) {
eventDefinition = endEvent.getEventDefinitions().get(0);
}
// Error end event
if (eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition) {
org.activiti.bpmn.model.ErrorEventDefinition errorDefinition = (org.activiti.bpmn.model.ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode());
if (StringUtils.isEmpty(errorCode)) {
bpmnParse.getBpmnModel().addProblem("errorCode is required for an error event", errorDefinition);
}
endEventActivity.setProperty("type", "errorEndEvent");
errorDefinition.setErrorCode(errorCode);
}
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition));
// Cancel end event
} else if (eventDefinition instanceof CancelEventDefinition) {
ScopeImpl scope = bpmnParse.getCurrentScope();
if (scope.getProperty("type")==null || !scope.getProperty("type").equals("transaction")) {
bpmnParse.getBpmnModel().addProblem("end event with cancelEventDefinition only supported inside transaction subprocess", endEvent);
} else {
endEventActivity.setProperty("type", "cancelEndEvent");
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent));
}
// Terminate end event
} else if (eventDefinition instanceof TerminateEventDefinition) {
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent));
// None end event
} else if (eventDefinition == null) {
endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent));
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.ErrorEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class ErrorEventDefinitionParseHandler extends AbstractBpmnParseHandler<ErrorEventDefinition> {
public static final String PROPERTYNAME_INITIAL = "initial";
public Class< ? extends BaseElement> getHandledType() {
return ErrorEventDefinition.class;
}
protected void executeParse(BpmnParse bpmnParse, ErrorEventDefinition eventDefinition) {
org.activiti.bpmn.model.ErrorEventDefinition modelErrorEvent = (org.activiti.bpmn.model.ErrorEventDefinition) eventDefinition;
if (bpmnParse.getBpmnModel().containsErrorRef(modelErrorEvent.getErrorCode())) {
String errorCode = bpmnParse.getBpmnModel().getErrors().get(modelErrorEvent.getErrorCode());
if (StringUtils.isEmpty(errorCode)) {
bpmnParse.getBpmnModel().addProblem("errorCode is required for an error event", eventDefinition);
}
modelErrorEvent.setErrorCode(errorCode);
}
ScopeImpl scope = bpmnParse.getCurrentScope();
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
scope.setProperty(PROPERTYNAME_INITIAL, activity);
// the scope of the event subscription is the parent of the event
// subprocess (subscription must be created when parent is initialized)
ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
createErrorStartEventDefinition(modelErrorEvent, activity, catchingScope);
} else {
bpmnParse.getBpmnModel().addProblem("multiple start events not supported for subprocess", bpmnParse.getCurrentSubProcess());
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = true; // non-interrupting not yet supported
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
ActivityImpl parentActivity = scope.findActivity(boundaryEvent.getAttachedToRefId());
createBoundaryErrorEventDefinition(modelErrorEvent, interrupting, parentActivity, activity);
}
}
protected void createErrorStartEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition errorEventDefinition, ActivityImpl startEventActivity, ScopeImpl scope) {
org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(startEventActivity.getId());
if (StringUtils.isNotEmpty(errorEventDefinition.getErrorCode())) {
definition.setErrorCode(errorEventDefinition.getErrorCode());
}
definition.setPrecedence(10);
addErrorEventDefinition(definition, scope);
}
public void createBoundaryErrorEventDefinition(org.activiti.bpmn.model.ErrorEventDefinition errorEventDefinition, boolean interrupting,
ActivityImpl activity, ActivityImpl nestedErrorEventActivity) {
nestedErrorEventActivity.setProperty("type", "boundaryError");
ScopeImpl catchingScope = nestedErrorEventActivity.getParent();
((ActivityImpl) catchingScope).setScope(true);
org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition =
new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(nestedErrorEventActivity.getId());
definition.setErrorCode(errorEventDefinition.getErrorCode());
addErrorEventDefinition(definition, catchingScope);
}
@SuppressWarnings("unchecked")
protected void addErrorEventDefinition(org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition errorEventDefinition, ScopeImpl catchingScope) {
List<org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition> errorEventDefinitions =
(List<org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition>) catchingScope.getProperty(PROPERTYNAME_ERROR_EVENT_DEFINITIONS);
if(errorEventDefinitions == null) {
errorEventDefinitions = new ArrayList<org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition>();
catchingScope.setProperty(PROPERTYNAME_ERROR_EVENT_DEFINITIONS, errorEventDefinitions);
}
errorEventDefinitions.add(errorEventDefinition);
Collections.sort(errorEventDefinitions, org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition.comparator);
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.EventGateway;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class EventBasedGatewayParseHandler extends AbstractActivityBpmnParseHandler<EventGateway> {
public Class< ? extends BaseElement> getHandledType() {
return EventGateway.class;
}
protected void executeParse(BpmnParse bpmnParse, EventGateway gateway) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_EVENT);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createEventBasedGatewayActivityBehavior(gateway));
activity.setScope(true);
// find all outgoing sequence flows
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
for (SequenceFlow sequenceFlow : gateway.getOutgoingFlows()) {
FlowElement flowElement = bpmnModel.getFlowElement(sequenceFlow.getTargetRef());
if (flowElement != null && flowElement instanceof IntermediateCatchEvent == false) {
bpmnModel.addProblem("Event based gateway can only be connected to elements of type intermediateCatchEvent.", flowElement);
}
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.ExclusiveGateway;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class ExclusiveGatewayParseHandler extends AbstractActivityBpmnParseHandler<ExclusiveGateway> {
public Class< ? extends BaseElement> getHandledType() {
return ExclusiveGateway.class;
}
protected void executeParse(BpmnParse bpmnParse, ExclusiveGateway gateway) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_EXCLUSIVE);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createExclusiveGatewayActivityBehavior(gateway));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.InclusiveGateway;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class InclusiveGatewayParseHandler extends AbstractActivityBpmnParseHandler<InclusiveGateway> {
public Class< ? extends BaseElement> getHandledType() {
return InclusiveGateway.class;
}
protected void executeParse(BpmnParse bpmnParse, InclusiveGateway gateway) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_INCLUSIVE);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createInclusiveGatewayActivityBehavior(gateway));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
/**
* @author Joram Barrez
*/
public class IntermediateCatchEventParseHandler extends AbstractActivityBpmnParseHandler<IntermediateCatchEvent> {
public Class< ? extends BaseElement> getHandledType() {
return IntermediateCatchEvent.class;
}
protected void executeParse(BpmnParse bpmnParse, IntermediateCatchEvent event) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
ActivityImpl nestedActivity = null;
EventDefinition eventDefinition = null;
if (event.getEventDefinitions().size() > 0) {
eventDefinition = event.getEventDefinitions().get(0);
}
if (eventDefinition == null) {
bpmnModel.addProblem("No event definition for intermediate catch event " + event.getId(), event);
nestedActivity = createActivityOnCurrentScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH);
} else {
ScopeImpl scope = bpmnParse.getCurrentScope();
String eventBasedGatewayId = getPrecedingEventBasedGateway(bpmnParse, event);
if (eventBasedGatewayId != null) {
ActivityImpl gatewayActivity = scope.findActivity(eventBasedGatewayId);
nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, gatewayActivity);
} else {
nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, scope);
}
// Catch event behavior is the same for all types
nestedActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchEventActivityBehavior(event));
if (eventDefinition instanceof TimerEventDefinition
|| eventDefinition instanceof SignalEventDefinition
|| eventDefinition instanceof MessageEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else {
bpmnModel.addProblem("Unsupported intermediate catch event type.", event);
}
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class IntermediateThrowEventParseHandler extends AbstractActivityBpmnParseHandler<ThrowEvent> {
public Class< ? extends BaseElement> getHandledType() {
return ThrowEvent.class;
}
protected void executeParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
ActivityImpl nestedActivityImpl = createActivityOnCurrentScope(bpmnParse, intermediateEvent, BpmnXMLConstants.ELEMENT_EVENT_THROW);
EventDefinition eventDefinition = null;
if (intermediateEvent.getEventDefinitions().size() > 0) {
eventDefinition = intermediateEvent.getEventDefinitions().get(0);
}
if (eventDefinition instanceof SignalEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else if (eventDefinition instanceof org.activiti.bpmn.model.CompensateEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else if (eventDefinition == null) {
nestedActivityImpl.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowNoneEventActivityBehavior(intermediateEvent));
} else {
bpmnModel.addProblem("Unsupported intermediate throw event type " + eventDefinition, intermediateEvent);
}
}
protected CompensateEventDefinition createCompensateEventDefinition(BpmnParse bpmnParse, org.activiti.bpmn.model.CompensateEventDefinition eventDefinition, ScopeImpl scopeElement) {
if(StringUtils.isNotEmpty(eventDefinition.getActivityRef())) {
if(scopeElement.findActivity(eventDefinition.getActivityRef()) == null) {
bpmnParse.getBpmnModel().addProblem("Invalid attribute value for 'activityRef': no activity with id '" + eventDefinition.getActivityRef() +
"' in current scope " + scopeElement.getId(), eventDefinition);
}
}
CompensateEventDefinition compensateEventDefinition = new CompensateEventDefinition();
compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef());
compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion());
return compensateEventDefinition;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.ManualTask;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class ManualTaskParseHandler extends AbstractActivityBpmnParseHandler<ManualTask> {
public Class< ? extends BaseElement> getHandledType() {
return ManualTask.class;
}
protected void executeParse(BpmnParse bpmnParse, ManualTask manualTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, manualTask, BpmnXMLConstants.ELEMENT_TASK_MANUAL);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createManualTaskActivityBehavior(manualTask));
activity.setAsync(manualTask.isAsynchronous());
activity.setExclusive(!manualTask.isNotExclusive());
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class MessageEventDefinitionParseHandler extends AbstractBpmnParseHandler<MessageEventDefinition> {
public Class< ? extends BaseElement> getHandledType() {
return MessageEventDefinition.class;
}
protected void executeParse(BpmnParse bpmnParse, MessageEventDefinition messageDefinition) {
if (bpmnParse.getBpmnModel().containsMessageId(messageDefinition.getMessageRef())) {
String messageName = bpmnParse.getBpmnModel().getMessage(messageDefinition.getMessageRef()).getName();
if (StringUtils.isEmpty(messageName)) {
bpmnParse.getBpmnModel().addProblem("messageName is required for a message event", messageDefinition);
}
messageDefinition.setMessageRef(messageName);
}
EventSubscriptionDeclaration eventSubscription = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
ScopeImpl scope = bpmnParse.getCurrentScope();
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent && bpmnParse.getCurrentSubProcess() != null) {
// the scope of the event subscription is the parent of the event
// subprocess (subscription must be created when parent is initialized)
ScopeImpl catchingScope = ((ActivityImpl) scope).getParent();
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
eventSubscriptionDeclaration.setActivityId(activity.getId());
eventSubscriptionDeclaration.setStartEvent(false);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, catchingScope);
} else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
activity.setProperty("type", "messageStartEvent");
eventSubscription.setStartEvent(true);
eventSubscription.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, bpmnParse.getCurrentProcessDefinition());
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
activity.setProperty("type", "intermediateMessageCatch");
if(getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
eventSubscription.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity.getParent());
} else {
activity.setScope(true);
addEventSubscriptionDeclaration(bpmnParse, eventSubscription, messageDefinition, activity);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
activity.setProperty("type", "boundaryMessage");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(messageDefinition.getMessageRef(), "message");
eventSubscriptionDeclaration.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, messageDefinition, activity.getParent());
if (activity.getParent() instanceof ActivityImpl) {
((ActivityImpl) activity.getParent()).setScope(true);
}
}
else {
// What to do here?
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.ParallelGateway;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class ParallelGatewayParseHandler extends AbstractActivityBpmnParseHandler<ParallelGateway> {
public Class< ? extends BaseElement> getHandledType() {
return ParallelGateway.class;
}
protected void executeParse(BpmnParse bpmnParse, ParallelGateway gateway) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createParallelGatewayActivityBehavior(gateway));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.HashMap;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.Process;
import org.activiti.engine.impl.bpmn.data.IOSpecification;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.task.TaskDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Joram Barrez
*/
public class ProcessParseHandler extends AbstractBpmnParseHandler<Process> {
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessParseHandler.class);
public static final String PROPERTYNAME_DOCUMENTATION = "documentation";
public Class< ? extends BaseElement> getHandledType() {
return Process.class;
}
protected void executeParse(BpmnParse bpmnParse, Process process) {
if (process.isExecutable() == false) {
LOGGER.info("Ignoring non-executable process with id='" + process.getId() + "'. Set the attribute isExecutable=\"true\" to deploy this process.");
} else {
bpmnParse.getProcessDefinitions().add(transformProcess(bpmnParse, process));
}
}
protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) {
ProcessDefinitionEntity currentProcessDefinition = new ProcessDefinitionEntity();
bpmnParse.setCurrentProcessDefinition(currentProcessDefinition);
/*
* Mapping object model - bpmn xml: processDefinition.id -> generated by
* activiti engine processDefinition.key -> bpmn id (required)
* processDefinition.name -> bpmn name (optional)
*/
currentProcessDefinition.setKey(process.getId());
currentProcessDefinition.setName(process.getName());
currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace());
currentProcessDefinition.setDescription(process.getDocumentation());
currentProcessDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, process.getDocumentation()); // Kept for backwards compatibility. See ACT-1020
currentProcessDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId());
createExecutionListenersOnScope(bpmnParse, process.getExecutionListeners(), currentProcessDefinition);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
for (String candidateUser : process.getCandidateStarterUsers()) {
currentProcessDefinition.addCandidateStarterUserIdExpression(expressionManager.createExpression(candidateUser));
}
for (String candidateGroup : process.getCandidateStarterGroups()) {
currentProcessDefinition.addCandidateStarterGroupIdExpression(expressionManager.createExpression(candidateGroup));
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey());
}
bpmnParse.setCurrentScope(currentProcessDefinition);
bpmnParse.processFlowElements(process.getFlowElements());
bpmnParse.processArtifacts(process.getArtifacts(), currentProcessDefinition);
bpmnParse.removeCurrentScope();
if (process.getIoSpecification() != null) {
IOSpecification ioSpecification = bpmnParse.createIOSpecification(process.getIoSpecification());
currentProcessDefinition.setIoSpecification(ioSpecification);
}
return currentProcessDefinition;
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.ReceiveTask;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class ReceiveTaskParseHandler extends AbstractActivityBpmnParseHandler<ReceiveTask> {
public Class< ? extends BaseElement> getHandledType() {
return ReceiveTask.class;
}
protected void executeParse(BpmnParse bpmnParse, ReceiveTask receiveTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, receiveTask, BpmnXMLConstants.ELEMENT_TASK_RECEIVE);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createReceiveTaskActivityBehavior(receiveTask));
activity.setAsync(receiveTask.isAsynchronous());
activity.setExclusive(!receiveTask.isNotExclusive());
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.ScriptTask;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class ScriptTaskParseHandler extends AbstractActivityBpmnParseHandler<ScriptTask> {
public Class< ? extends BaseElement> getHandledType() {
return ScriptTask.class;
}
protected void executeParse(BpmnParse bpmnParse, ScriptTask scriptTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, scriptTask, BpmnXMLConstants.ELEMENT_TASK_SCRIPT);
activity.setAsync(scriptTask.isAsynchronous());
activity.setExclusive(!scriptTask.isNotExclusive());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createScriptTaskActivityBehavior(scriptTask));
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.DataAssociation;
import org.activiti.bpmn.model.ImplementationType;
import org.activiti.bpmn.model.SendTask;
import org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior;
import org.activiti.engine.impl.bpmn.data.AbstractDataAssociation;
import org.activiti.engine.impl.bpmn.data.IOSpecification;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.bpmn.webservice.Operation;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class SendTaskParseHandler extends AbstractExternalInvocationBpmnParseHandler<SendTask> {
public Class< ? extends BaseElement> getHandledType() {
return SendTask.class;
}
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, sendTask, BpmnXMLConstants.ELEMENT_TASK_SEND);
activity.setAsync(sendTask.isAsynchronous());
activity.setExclusive(!sendTask.isNotExclusive());
// for e-mail
if (StringUtils.isNotEmpty(sendTask.getType())) {
if (sendTask.getType().equalsIgnoreCase("mail")) {
validateFieldDeclarationsForEmail(bpmnParse, sendTask, sendTask.getFieldExtensions());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
} else if (sendTask.getType().equalsIgnoreCase("mule")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
} else {
bpmnParse.getBpmnModel().addProblem("Invalid usage of type attribute: '" + sendTask.getType() + "'.", sendTask);
}
// for web service
} else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) &&
StringUtils.isNotEmpty(sendTask.getOperationRef())) {
if (!bpmnParse.getOperations().containsKey(sendTask.getOperationRef())) {
bpmnParse.getBpmnModel().addProblem(sendTask.getOperationRef() + " does not exist", sendTask);
} else {
WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask);
Operation operation = bpmnParse.getOperations().get(sendTask.getOperationRef());
webServiceActivityBehavior.setOperation(operation);
if (sendTask.getIoSpecification() != null) {
IOSpecification ioSpecification = bpmnParse.createIOSpecification(sendTask.getIoSpecification());
webServiceActivityBehavior.setIoSpecification(ioSpecification);
}
for (DataAssociation dataAssociationElement : sendTask.getDataInputAssociations()) {
AbstractDataAssociation dataAssociation = bpmnParse.createDataInputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
}
for (DataAssociation dataAssociationElement : sendTask.getDataOutputAssociations()) {
AbstractDataAssociation dataAssociation = bpmnParse.createDataOutputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
}
activity.setActivityBehavior(webServiceActivityBehavior);
}
} else {
bpmnParse.getBpmnModel().addProblem("One of the attributes 'type' or 'operation' is mandatory on sendTask.", sendTask);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Condition;
import org.activiti.engine.impl.bpmn.behavior.EventBasedGatewayActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.el.UelExpressionCondition;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.activiti.engine.impl.pvm.process.TransitionImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class SequenceFlowParseHandler extends AbstractBpmnParseHandler<SequenceFlow> {
public static final String PROPERTYNAME_CONDITION = "condition";
public static final String PROPERTYNAME_CONDITION_TEXT = "conditionText";
public Class< ? extends BaseElement> getHandledType() {
return SequenceFlow.class;
}
protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
ScopeImpl scope = bpmnParse.getCurrentScope();
// Implicit check: sequence flow cannot cross (sub) process boundaries: we
// don't do a processDefinition.findActivity here
ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef());
ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef());
if (sourceActivity == null) {
bpmnModel.addProblem("Invalid source '" + sequenceFlow.getSourceRef() + "' of sequence flow '" + sequenceFlow.getId() + "'", sequenceFlow);
} else if (destinationActivity == null) {
throw new ActivitiException("Invalid destination '" + sequenceFlow.getTargetRef() + "' of sequence flow '" + sequenceFlow.getId() + "'");
} else if (!(sourceActivity.getActivityBehavior() instanceof EventBasedGatewayActivityBehavior)
&& destinationActivity.getActivityBehavior() instanceof IntermediateCatchEventActivityBehavior && (destinationActivity.getParentActivity() != null)
&& (destinationActivity.getParentActivity().getActivityBehavior() instanceof EventBasedGatewayActivityBehavior)) {
bpmnModel.addProblem("Invalid incoming sequenceflow " + sequenceFlow.getId() + " for intermediateCatchEvent with id '" + destinationActivity.getId()
+ "' connected to an event-based gateway.", sequenceFlow);
} else {
TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId());
bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition);
transition.setProperty("name", sequenceFlow.getName());
transition.setProperty("documentation", sequenceFlow.getDocumentation());
transition.setDestination(destinationActivity);
if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
Condition expressionCondition = new UelExpressionCondition(bpmnParse.getExpressionManager().createExpression(sequenceFlow.getConditionExpression()));
transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression());
transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition);
}
createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.DataAssociation;
import org.activiti.bpmn.model.ImplementationType;
import org.activiti.bpmn.model.ServiceTask;
import org.activiti.engine.impl.bpmn.behavior.WebServiceActivityBehavior;
import org.activiti.engine.impl.bpmn.data.AbstractDataAssociation;
import org.activiti.engine.impl.bpmn.data.IOSpecification;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class ServiceTaskParseHandler extends AbstractExternalInvocationBpmnParseHandler<ServiceTask> {
public Class< ? extends BaseElement> getHandledType() {
return ServiceTask.class;
}
protected void executeParse(BpmnParse bpmnParse, ServiceTask serviceTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, serviceTask, BpmnXMLConstants.ELEMENT_TASK_SERVICE);
activity.setAsync(serviceTask.isAsynchronous());
activity.setExclusive(!serviceTask.isNotExclusive());
// Email, Mule and Shell service tasks
if (StringUtils.isNotEmpty(serviceTask.getType())) {
if (serviceTask.getType().equalsIgnoreCase("mail")) {
validateFieldDeclarationsForEmail(bpmnParse, serviceTask, serviceTask.getFieldExtensions());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(serviceTask));
} else if (serviceTask.getType().equalsIgnoreCase("mule")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(serviceTask, bpmnParse.getBpmnModel()));
} else if (serviceTask.getType().equalsIgnoreCase("shell")) {
validateFieldDeclarationsForShell(bpmnParse, serviceTask, serviceTask.getFieldExtensions());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createShellActivityBehavior(serviceTask));
} else {
bpmnParse.getBpmnModel().addProblem("Invalid usage of type attribute: '" + serviceTask.getType() + "'.", serviceTask);
}
// activiti:class
} else if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createClassDelegateServiceTask(serviceTask));
// activiti:delegateExpression
} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskDelegateExpressionActivityBehavior(serviceTask));
// activiti:expression
} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskExpressionActivityBehavior(serviceTask));
// Webservice
} else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(serviceTask.getImplementationType()) &&
StringUtils.isNotEmpty(serviceTask.getOperationRef())) {
if (!bpmnParse.getOperations().containsKey(serviceTask.getOperationRef())) {
bpmnParse.getBpmnModel().addProblem(serviceTask.getOperationRef() + " does not exist", serviceTask);
} else {
WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(serviceTask);
webServiceActivityBehavior.setOperation(bpmnParse.getOperations().get(serviceTask.getOperationRef()));
if (serviceTask.getIoSpecification() != null) {
IOSpecification ioSpecification = bpmnParse.createIOSpecification(serviceTask.getIoSpecification());
webServiceActivityBehavior.setIoSpecification(ioSpecification);
}
for (DataAssociation dataAssociationElement : serviceTask.getDataInputAssociations()) {
AbstractDataAssociation dataAssociation = bpmnParse.createDataInputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
}
for (DataAssociation dataAssociationElement : serviceTask.getDataOutputAssociations()) {
AbstractDataAssociation dataAssociation = bpmnParse.createDataOutputAssociation(dataAssociationElement);
webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
}
activity.setActivityBehavior(webServiceActivityBehavior);
}
} else {
bpmnParse.getBpmnModel().addProblem("One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask.", serviceTask);
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.ThrowEvent;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class SignalEventDefinitionParseHandler extends AbstractBpmnParseHandler<SignalEventDefinition> {
public Class< ? extends BaseElement> getHandledType() {
return SignalEventDefinition.class;
}
protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDefinition) {
if (bpmnParse.getBpmnModel().containsSignalId(signalDefinition.getSignalRef())) {
String signalName = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef()).getName();
if (StringUtils.isEmpty(signalName)) {
bpmnParse.getBpmnModel().addProblem("signalName is required for a signal event", signalDefinition);
}
signalDefinition.setSignalRef(signalName);
}
ActivityImpl activity = bpmnParse.getCurrentActivity();
if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setActivityId(activity.getId());
eventSubscriptionDeclaration.setStartEvent(false);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, bpmnParse.getCurrentScope());
} else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent){
activity.setProperty("type", "intermediateSignalCatch");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
eventSubscriptionDeclaration.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
} else {
activity.setScope(true);
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity);
}
} else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
activity.setProperty("type", "intermediateSignalThrow");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setAsync(signalDefinition.isAsync());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), eventSubscriptionDeclaration));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
boolean interrupting = boundaryEvent.isCancelActivity();
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
activity.setProperty("type", "boundarySignal");
EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
eventSubscriptionDeclaration.setActivityId(activity.getId());
addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
if (activity.getParent() instanceof ActivityImpl) {
((ActivityImpl) activity.getParent()).setScope(true);
}
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.MessageEventDefinition;
import org.activiti.bpmn.model.SignalEventDefinition;
import org.activiti.bpmn.model.StartEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.form.DefaultStartFormHandler;
import org.activiti.engine.impl.form.StartFormHandler;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang.StringUtils;
/**
* @author Joram Barrez
*/
public class StartEventParseHandler extends AbstractActivityBpmnParseHandler<StartEvent> {
public static final String PROPERTYNAME_INITIATOR_VARIABLE_NAME = "initiatorVariableName";
public static final String PROPERTYNAME_INITIAL = "initial";
@Override
public Class< ? extends BaseElement> getHandledType() {
return StartEvent.class;
}
@Override
protected void executeParse(BpmnParse bpmnParse, StartEvent startEvent) {
ActivityImpl startEventActivity = createActivityOnCurrentScope(bpmnParse, startEvent, BpmnXMLConstants.ELEMENT_EVENT_START);
ScopeImpl scope = bpmnParse.getCurrentScope();
if (scope instanceof ProcessDefinitionEntity) {
createProcessDefinitionStartEvent(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope);
selectInitial(bpmnParse, startEventActivity, startEvent, (ProcessDefinitionEntity) scope);
createStartFormHandlers(bpmnParse, startEvent, (ProcessDefinitionEntity) scope);
} else {
createScopeStartEvent(bpmnParse, startEventActivity, startEvent);
}
}
protected void selectInitial(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
if (processDefinition.getInitial() == null) {
processDefinition.setInitial(startEventActivity);
} else {
// validate that there is s single none start event / timer start event:
if (startEventActivity.getProperty("type").equals("messageStartEvent") == false) {
String currentInitialType = (String) processDefinition.getInitial().getProperty("type");
if (currentInitialType.equals("messageStartEvent")) {
processDefinition.setInitial(startEventActivity);
} else {
bpmnParse.getBpmnModel().addProblem("multiple none start events or timer start events not supported on process definition.", startEvent);
}
}
}
}
protected void createStartFormHandlers(BpmnParse bpmnParse, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
if (processDefinition.getInitial() != null) {
if (startEvent.getId().equals(processDefinition.getInitial().getId())) {
StartFormHandler startFormHandler = new DefaultStartFormHandler();
startFormHandler.parseConfiguration(startEvent.getFormProperties(), startEvent.getFormKey(), bpmnParse.getDeployment(), processDefinition);
processDefinition.setStartFormHandler(startFormHandler);
}
}
}
protected void createProcessDefinitionStartEvent(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent, ProcessDefinitionEntity processDefinition) {
if (StringUtils.isNotEmpty(startEvent.getInitiator())) {
processDefinition.setProperty(PROPERTYNAME_INITIATOR_VARIABLE_NAME, startEvent.getInitiator());
}
// all start events share the same behavior:
startEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneStartEventActivityBehavior(startEvent));
if (startEvent.getEventDefinitions().size() > 0) {
EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof MessageEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else {
bpmnParse.getBpmnModel().addProblem("Unsupported event definition on start event", eventDefinition);
}
}
}
protected void createScopeStartEvent(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent) {
ScopeImpl scope = bpmnParse.getCurrentScope();
Object triggeredByEvent = scope.getProperty("triggeredByEvent");
boolean isTriggeredByEvent = triggeredByEvent != null && ((Boolean) triggeredByEvent == true);
if (isTriggeredByEvent) { // event subprocess
// all start events of an event subprocess share common behavior
EventSubProcessStartEventActivityBehavior activityBehavior =
bpmnParse.getActivityBehaviorFactory().createEventSubProcessStartEventActivityBehavior(startEvent, startEventActivity.getId());
startEventActivity.setActivityBehavior(activityBehavior);
if (startEvent.getEventDefinitions().size() > 0) {
EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
if (eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition
|| eventDefinition instanceof MessageEventDefinition
|| eventDefinition instanceof SignalEventDefinition) {
bpmnParse.getBpmnParserHandlers().parse(bpmnParse, eventDefinition);
} else {
bpmnParse.getBpmnModel().addProblem("start event of event subprocess must be of type 'error', 'message' or 'signal' ", startEvent);
}
}
} else { // "regular" subprocess
if(startEvent.getEventDefinitions().size() > 0) {
bpmnParse.getBpmnModel().addProblem("event definitions only allowed on start event if subprocess is an event subprocess", startEvent);
}
if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
scope.setProperty(PROPERTYNAME_INITIAL, startEventActivity);
startEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneStartEventActivityBehavior(startEvent));
} else {
bpmnParse.getBpmnModel().addProblem("multiple start events not supported for subprocess", bpmnParse.getCurrentSubProcess());
}
}
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.HashSet;
import java.util.Set;
import org.activiti.bpmn.constants.BpmnXMLConstants;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.EventSubProcess;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.engine.impl.bpmn.data.IOSpecification;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.pvm.process.ActivityImpl;
/**
* @author Joram Barrez
*/
public class SubProcessParseHandler extends AbstractActivityBpmnParseHandler<SubProcess> {
protected static Set<Class<? extends BaseElement>> supportedTypes = new HashSet<Class<? extends BaseElement>>();
static {
supportedTypes.add(SubProcess.class);
supportedTypes.add(EventSubProcess.class);
}
public Set<Class< ? extends BaseElement>> getHandledTypes() {
return supportedTypes;
}
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {
ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope());
activity.setAsync(subProcess.isAsynchronous());
activity.setExclusive(!subProcess.isNotExclusive());
boolean triggeredByEvent = false;
if (subProcess instanceof EventSubProcess) {
triggeredByEvent = true;
}
activity.setProperty("triggeredByEvent", triggeredByEvent);
// event subprocesses are not scopes
activity.setScope(!triggeredByEvent);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess));
bpmnParse.setCurrentScope(activity);
bpmnParse.setCurrentSubProcess(subProcess);
bpmnParse.processFlowElements(subProcess.getFlowElements());
bpmnParse.processArtifacts(subProcess.getArtifacts(), activity);
bpmnParse.removeCurrentScope();
bpmnParse.removeCurrentSubProcess();
if (subProcess.getIoSpecification() != null) {
IOSpecification ioSpecification = bpmnParse.createIOSpecification(subProcess.getIoSpecification());
activity.setIoSpecification(ioSpecification);
}
}
}
......@@ -47,7 +47,6 @@ import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
import org.activiti.engine.impl.pvm.runtime.OutgoingExecution;
import org.activiti.engine.impl.pvm.runtime.StartingExecution;
import org.activiti.engine.impl.util.BitMaskUtil;
import org.activiti.engine.impl.variable.VariableDeclaration;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.Job;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -281,13 +280,6 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
ScopeImpl scope = getScope();
ensureParentInitialized();
List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
if (variableDeclarations!=null) {
for (VariableDeclaration variableDeclaration : variableDeclarations) {
variableDeclaration.initialize(this, parent);
}
}
// initialize the lists of referenced objects (prevents db queries)
variableInstances = new HashMap<String, VariableInstanceEntity>();
eventSubscriptions = new ArrayList<EventSubscriptionEntity>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册