use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNEscalationBPMNEEPlugin method eventRoutine.
@Override
public void eventRoutine(BPMNEndEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
SimulationModel model = (SimulationModel) desmojEvent.getModel();
ProcessModel processModel = processInstance.getProcessModel();
int nodeId = desmojEvent.getNodeId();
Map<EventDefinitionType, Map<String, String>> definitions = processModel.getEventDefinitions().get(nodeId);
ProcessSimulationComponents desmojObjects = desmojEvent.getDesmojObjects();
boolean showInTrace = model.traceIsOn();
try {
for (EventDefinitionType definition : definitions.keySet()) {
if (definition == EventDefinitionType.ESCALATION) {
if (processModel.getParent() != null) {
Map<String, String> eventAttributes = processModel.getEventDefinitions().get(nodeId).get(definition);
String escalationRef = eventAttributes.get("escalationRef");
// Map<String, Map<String, String>> escalations =
// model.getCommonProcessElements().getEscalations();
// Map<String, String> escalation = escalations.get("escalationRef");
ProcessSimulationComponents parentDesmojObjects = desmojObjects.getParent();
ProcessModel parentModel = processModel.getParent();
int nodeIdInParent = processModel.getNodeIdInParent();
Integer nextNodeId = null;
// find boundary event of parentModel which has the same escalationRef
List<Integer> referencesToBoundaryEvents = parentModel.getReferencesToBoundaryEvents().get(nodeIdInParent);
for (int nId : referencesToBoundaryEvents) {
Map<EventDefinitionType, Map<String, String>> boundaryEventDefinitions = parentModel.getEventDefinitions().get(nId);
Map<String, String> boundaryEscalationEventDefinition = boundaryEventDefinitions.get(EventDefinitionType.ESCALATION);
if (boundaryEscalationEventDefinition != null) {
if (escalationRef.equals(boundaryEscalationEventDefinition.get("escalationRef"))) {
nextNodeId = nId;
break;
}
}
}
if (nextNodeId == null) {
DebugLogger.error("Could not find referenced escalation " + escalationRef + ".");
SimulationUtils.abort(model, processInstance, nodeId, showInTrace);
return;
}
ProcessInstance parentProcessInstance = processInstance.getParent();
List<ScyllaEvent> events = SimulationUtils.createEventsForNextNode(desmojEvent, parentDesmojObjects, parentProcessInstance, nextNodeId);
TimeSpan timeSpan = new TimeSpan(0);
/**
* first event in the map is the node that comes after the subprocess when normal behavior
* applies, so remove it;
*/
int indexOfTaskTerminateEvent = 0;
desmojEvent.getNextEventMap().remove(indexOfTaskTerminateEvent);
desmojEvent.getTimeSpanToNextEventMap().remove(indexOfTaskTerminateEvent);
for (ScyllaEvent event : events) {
int index = desmojEvent.getNewEventIndex();
desmojEvent.getNextEventMap().put(index, event);
desmojEvent.getTimeSpanToNextEventMap().put(index, timeSpan);
}
processInstance.cancel();
}
}
}
} catch (NodeNotFoundException | ScyllaValidationException e) {
DebugLogger.error(e.getMessage());
e.printStackTrace();
SimulationUtils.abort(model, processInstance, nodeId, showInTrace);
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerBPMNEEPlugin method eventRoutine.
@Override
public void eventRoutine(BPMNEndEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
Map<Integer, ScyllaEvent> nextEvents = desmojEvent.getNextEventMap();
for (int index : nextEvents.keySet()) {
ScyllaEvent event = nextEvents.get(index);
int nextNodeId = event.getNodeId();
TimeSpan timeSpan = BPMNTimerPluginUtils.getTimeSpanUntilNextEvent(processModel, nextNodeId);
if (timeSpan != null) {
desmojEvent.getTimeSpanToNextEventMap().put(index, timeSpan);
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerBPMNEPlugin method eventRoutine.
@Override
public void eventRoutine(BPMNIntermediateEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
Map<Integer, ScyllaEvent> nextEvents = desmojEvent.getNextEventMap();
for (int index : nextEvents.keySet()) {
ScyllaEvent event = nextEvents.get(index);
int nextNodeId = event.getNodeId();
TimeSpan timeSpan = BPMNTimerPluginUtils.getTimeSpanUntilNextEvent(processModel, nextNodeId);
if (timeSpan != null) {
desmojEvent.getTimeSpanToNextEventMap().put(index, timeSpan);
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerBPMNSEPlugin method eventRoutine.
@Override
public void eventRoutine(BPMNStartEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
Map<Integer, ScyllaEvent> nextEvents = desmojEvent.getNextEventMap();
for (int index : nextEvents.keySet()) {
ScyllaEvent event = nextEvents.get(index);
int nextNodeId = event.getNodeId();
TimeSpan timeSpan = BPMNTimerPluginUtils.getTimeSpanUntilNextEvent(processModel, nextNodeId);
if (timeSpan != null) {
desmojEvent.getTimeSpanToNextEventMap().put(index, timeSpan);
}
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerGEPlugin method eventRoutine.
@Override
public void eventRoutine(GatewayEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
Map<Integer, ScyllaEvent> nextEvents = desmojEvent.getNextEventMap();
for (int index : nextEvents.keySet()) {
ScyllaEvent event = nextEvents.get(index);
int nextNodeId = event.getNodeId();
TimeSpan timeSpan = BPMNTimerPluginUtils.getTimeSpanUntilNextEvent(processModel, nextNodeId);
if (timeSpan != null) {
desmojEvent.getTimeSpanToNextEventMap().put(index, timeSpan);
}
}
}
Aggregations