use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerPIGEPlugin method eventRoutine.
@Override
public void eventRoutine(ProcessInstanceGenerationEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
SimulationModel model = (SimulationModel) desmojEvent.getModel();
String processId = desmojEvent.getProcessId();
ProcessSimulationComponents desmojObjects = model.getDesmojObjectsMap().get(processId);
ProcessModel processModel = desmojObjects.getProcessModel();
Integer startNodeId;
try {
startNodeId = processModel.getStartNode();
if (desmojObjects.getDistributions().get(startNodeId) == null) {
// no arrival rate defined, check if start event is timer event and use value from there
Map<EventDefinitionType, Map<String, String>> eventDefinitions = processModel.getEventDefinitions().get(startNodeId);
Map<String, String> definitionAttributes = eventDefinitions.get(EventDefinitionType.TIMER);
if (definitionAttributes != null) {
// if start event is timer event
// ISO 8601 duration
String timeDuration = definitionAttributes.get("timeCycle");
if (timeDuration == null) {
String identifier = processModel.getIdentifiers().get(startNodeId);
DebugLogger.log("Timer event " + identifier + " has no timer definition, skip.");
} else // TODO support timeDate and timeDuration attributes?
{
Duration javaDuration = Duration.parse(timeDuration);
long duration = javaDuration.get(ChronoUnit.SECONDS);
TimeUnit unit = TimeUnit.SECONDS;
TimeSpan timeSpan = new TimeSpan(duration, unit);
desmojEvent.setTimeSpanToNextProcessInstance(timeSpan);
}
}
}
} catch (NodeNotFoundException | MultipleStartNodesException | NoStartNodeException e) {
DebugLogger.error(e.getMessage());
DebugLogger.log("Error during instantiation of process model " + processModel.getId() + ".");
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class BPMNTimerTTPlugin method eventRoutine.
@Override
public void eventRoutine(TaskTerminateEvent 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 DataObjectBPMNIntermediateEvent method eventRoutine.
@Override
public void eventRoutine(BPMNIntermediateEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
// int processInstanceId = processInstance.getId();
try {
if (processModel.getDataObjectsGraph().getNodes().containsKey(desmojEvent.getNodeId())) {
Set<Integer> refferingObjects = processModel.getDataObjectsGraph().getTargetObjects(desmojEvent.getNodeId());
Collection<Object> allFields = desmojEvent.getDesmojObjects().getExtensionDistributions().get("dataobject").values();
for (Object fields : allFields) {
Integer i = 0;
while (((Map<String, Map<Integer, DataObjectField>>) fields).values().toArray().length - i != 0) {
DataObjectField field = (DataObjectField) ((Map<String, Map<Integer, DataObjectField>>) fields).values().toArray()[i];
if (refferingObjects.contains(field.getNodeId())) {
// System.out.println(processInstance.getId() + " " + desmojEvent.getDisplayName() + " " + processModel.getDisplayNames().get(field.getNodeId()) + " " + field.getDataDistributionWrapper().getSample());
SimulationModel model = (SimulationModel) desmojEvent.getModel();
Collection<Map<Integer, java.util.List<ProcessNodeInfo>>> allProcesses = model.getProcessNodeInfos().values();
for (Map<Integer, java.util.List<ProcessNodeInfo>> process : allProcesses) {
List<ProcessNodeInfo> currentProcess = process.get(processInstance.getId());
for (ProcessNodeInfo task : currentProcess) {
// System.out.println(processModel.getDisplayNames().get(processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray()[0]) + " " + task.getTaskName());
for (Integer j = 0; j < processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray().length; j++) {
if (task.getId().equals(processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray()[j]) && task.getTransition() == ProcessNodeTransitionType.EVENT_TERMINATE) {
// check all tasks and find the ones that may be looged; already logged ones will get ignored next line
if (!task.getDataObjectField().containsKey(processModel.getDisplayNames().get(field.getNodeId()) + "." + field.getFieldName())) {
// don't log if task already has this field logged
Map<String, Object> fieldSample = new HashMap<String, Object>();
Object currentSample = field.getDataDistributionWrapper().getSample();
// log Value at TaskTerminate
fieldSample.put(processModel.getDisplayNames().get(field.getNodeId()) + "." + field.getFieldName(), currentSample);
task.SetDataObjectField(fieldSample);
// set current DataObjectFieldValue
DataObjectField.addDataObjectValue(processInstance.getId(), fieldSample.keySet().toArray()[0].toString(), currentSample);
}
}
}
}
}
}
i++;
}
}
} else {
// do nothing and continue with the next task because Node has no dataobejcts
}
} catch (ScyllaRuntimeException | ScyllaValidationException | NodeNotFoundException e) {
e.printStackTrace();
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class DataObjectBPMNStartEvent method eventRoutine.
@Override
public void eventRoutine(BPMNStartEvent desmojEvent, ProcessInstance processInstance) throws ScyllaRuntimeException {
ProcessModel processModel = processInstance.getProcessModel();
// int processInstanceId = processInstance.getId();
try {
if (processModel.getDataObjectsGraph().getNodes().containsKey(desmojEvent.getNodeId())) {
Set<Integer> refferingObjects = processModel.getDataObjectsGraph().getTargetObjects(desmojEvent.getNodeId());
Collection<Object> allFields = desmojEvent.getDesmojObjects().getExtensionDistributions().get("dataobject").values();
for (Object fields : allFields) {
Integer i = 0;
while (((Map<String, Map<Integer, DataObjectField>>) fields).values().toArray().length - i != 0) {
DataObjectField field = (DataObjectField) ((Map<String, Map<Integer, DataObjectField>>) fields).values().toArray()[i];
if (refferingObjects.contains(field.getNodeId())) {
// System.out.println(processInstance.getId() + " " + desmojEvent.getDisplayName() + " " + processModel.getDisplayNames().get(field.getNodeId()) + " " + field.getDataDistributionWrapper().getSample());
SimulationModel model = (SimulationModel) desmojEvent.getModel();
Collection<Map<Integer, java.util.List<ProcessNodeInfo>>> allProcesses = model.getProcessNodeInfos().values();
for (Map<Integer, java.util.List<ProcessNodeInfo>> process : allProcesses) {
List<ProcessNodeInfo> currentProcess = process.get(processInstance.getId());
for (ProcessNodeInfo task : currentProcess) {
// System.out.println(processModel.getDisplayNames().get(processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray()[0]) + " " + task.getTaskName());
for (Integer j = 0; j < processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray().length; j++) {
if (task.getId().equals(processModel.getDataObjectsGraph().getSourceObjects(field.getNodeId()).toArray()[j]) && task.getTransition() == ProcessNodeTransitionType.EVENT_TERMINATE) {
// check all tasks and find the ones that may be looged; already logged ones will get ignored next line
if (!task.getDataObjectField().containsKey(processModel.getDisplayNames().get(field.getNodeId()) + "." + field.getFieldName())) {
// don't log if task already has this field logged
Map<String, Object> fieldSample = new HashMap<String, Object>();
Object currentSample = field.getDataDistributionWrapper().getSample();
// log Value at TaskTerminate
fieldSample.put(processModel.getDisplayNames().get(field.getNodeId()) + "." + field.getFieldName(), currentSample);
task.SetDataObjectField(fieldSample);
// set current DataObjectFieldValue
DataObjectField.addDataObjectValue(processInstance.getId(), fieldSample.keySet().toArray()[0].toString(), currentSample);
}
}
}
}
}
}
i++;
}
}
} else {
// do nothing and continue with the next task because Node has no dataobejcts
}
} catch (ScyllaRuntimeException | ScyllaValidationException | NodeNotFoundException e) {
e.printStackTrace();
}
}
use of de.hpi.bpt.scylla.model.process.ProcessModel in project scylla by bptlab.
the class DataObjectDistributionConversionPlugin method convertToDesmoJDistributions.
@SuppressWarnings("unchecked")
@Override
public Map<Integer, Object> convertToDesmoJDistributions(ProcessSimulationComponents pSimComponents) {
SimulationConfiguration simulationConfiguration = pSimComponents.getSimulationConfiguration();
Map<Integer, Object> dataObjects = (Map<Integer, Object>) simulationConfiguration.getExtensionValue(getName(), "dataObjects");
Long randomSeed = simulationConfiguration.getRandomSeed();
ProcessModel processModel = pSimComponents.getProcessModel();
SimulationModel model = pSimComponents.getModel();
boolean showInReport = model.reportIsOn();
boolean showInTrace = model.traceIsOn();
for (Integer nodeId : dataObjects.keySet()) {
Map<String, DataObjectField> dataObjectFields = (Map<String, DataObjectField>) dataObjects.get(nodeId);
String name = processModel.getModelScopeId() + "_" + nodeId.toString();
for (String fieldName : dataObjectFields.keySet()) {
DataObjectField dataObjectField = dataObjectFields.get(fieldName);
DataDistributionWrapper distWrapper = dataObjectField.getDataDistributionWrapper();
Distribution dist = distWrapper.getDistribution();
if (dist == null)
continue;
NumericalDist<?> desmojDist = null;
try {
desmojDist = SimulationUtils.getDistribution(dist, model, name, nodeId, showInReport, showInTrace);
} catch (InstantiationException e) {
DebugLogger.error(e.getMessage());
DebugLogger.error("Instantiation of dmn model failed.");
return null;
}
desmojDist.setSeed(randomSeed);
distWrapper.setDesmojDistribution(desmojDist);
}
}
return dataObjects;
}
Aggregations