use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class BatchPluginUtils method logTaskEventForNonResponsiblePI.
// If the execution type is parallel this makes the entry for the not really simulated process instances for tasks
void logTaskEventForNonResponsiblePI(TaskEvent event, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
ProcessModel processModel = processInstance.getProcessModel();
int parentNodeId = processModel.getNodeIdInParent();
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
if (cluster != null && cluster.getBatchActivity().getExecutionType().equals(BatchClusterExecutionType.PARALLEL)) {
SimulationModel model = (SimulationModel) event.getModel();
long timestamp = Math.round(model.presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
String taskName = event.getDisplayName();
int nodeId = event.getNodeId();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
String source = event.getSource();
ProcessNodeTransitionType transition;
Set<String> resources = new HashSet<String>();
if (event instanceof TaskEnableEvent) {
transition = ProcessNodeTransitionType.ENABLE;
} else if (event instanceof TaskBeginEvent) {
transition = ProcessNodeTransitionType.BEGIN;
Set<ResourceObject> resourceObjects = processInstance.getAssignedResources().get(source).getResourceObjects();
for (ResourceObject res : resourceObjects) {
String resourceName = res.getResourceType() + "_" + res.getId();
resources.add(resourceName);
}
tasksAndResources.put(source, resources);
} else if (event instanceof TaskCancelEvent) {
transition = ProcessNodeTransitionType.CANCEL;
resources = tasksAndResources.get(source);
tasksAndResources.remove(source);
} else if (event instanceof TaskTerminateEvent) {
transition = ProcessNodeTransitionType.TERMINATE;
resources = tasksAndResources.get(source);
tasksAndResources.remove(source);
} else {
throw new ScyllaRuntimeException("Task event type not supported.");
}
int sourceSuffix = 0;
List<ProcessInstance> processInstances = cluster.getProcessInstances();
for (ProcessInstance pi : processInstances) {
if (!processInstance.getParent().equals(pi)) {
// the source attribute comes from an event, but we did not really simulate the events for the
// non-responsible process instances, so we mock a source attribute value
String mockSource = source + "##" + ++sourceSuffix;
ProcessNodeInfo info;
info = new ProcessNodeInfo(nodeId, processScopeNodeId, mockSource, timestamp, taskName, resources, transition);
model.addNodeInfo(processModel, pi, info);
}
}
}
}
}
use of de.hpi.bpt.scylla.logger.ProcessNodeInfo in project scylla by bptlab.
the class BatchPluginUtils method logBPMNEventForNonResponsiblePI.
// If the execution type is parallel this makes the entry for the not really simulated process instances for events
void logBPMNEventForNonResponsiblePI(BPMNEvent event, ProcessInstance processInstance) {
ProcessInstance parentProcessInstance = processInstance.getParent();
if (parentProcessInstance != null) {
ProcessModel processModel = processInstance.getProcessModel();
int parentNodeId = processModel.getNodeIdInParent();
BatchPluginUtils pluginInstance = BatchPluginUtils.getInstance();
BatchCluster cluster = pluginInstance.getRunningCluster(parentProcessInstance, parentNodeId);
if (cluster != null && cluster.hasExecutionType(BatchClusterExecutionType.PARALLEL)) {
SimulationModel model = (SimulationModel) event.getModel();
long timestamp = Math.round(model.presentTime().getTimeRounded(DateTimeUtils.getReferenceTimeUnit()));
Set<String> resources = new HashSet<String>();
String taskName = event.getDisplayName();
int nodeId = event.getNodeId();
String processScopeNodeId = SimulationUtils.getProcessScopeNodeId(processModel, nodeId);
String source = event.getSource();
int sourceSuffix = 0;
List<ProcessInstance> processInstances = cluster.getProcessInstances();
for (ProcessInstance pi : processInstances) {
if (!processInstance.getParent().equals(pi)) {
// the source attribute comes from an event, but we did not really simulate the events for the
// non-responsible process instances, so we mock a source attribute value
String mockSource = source + "##" + ++sourceSuffix;
ProcessNodeInfo info;
info = new ProcessNodeInfo(nodeId, processScopeNodeId, mockSource, timestamp, taskName, resources, ProcessNodeTransitionType.EVENT_BEGIN);
model.addNodeInfo(processModel, pi, info);
info = new ProcessNodeInfo(nodeId, processScopeNodeId, mockSource, timestamp, taskName, resources, ProcessNodeTransitionType.EVENT_TERMINATE);
model.addNodeInfo(processModel, pi, info);
}
}
}
}
}
Aggregations