use of de.hpi.bpt.scylla.plugin.dataobject.DataDistributionWrapper in project scylla by bptlab.
the class BatchPluginUtils method getDataViewOfInstance.
private Map<String, Object> getDataViewOfInstance(TaskBeginEvent desmojEvent, ProcessInstance processInstance, BatchActivity batchActivity) {
if (batchActivity.getGroupingCharacteristic().isEmpty()) {
return null;
} else {
// ***********
// get the value of the dataObject
// ***********
ProcessModel processModel = processInstance.getProcessModel();
ProcessSimulationComponents desmojObjects = desmojEvent.getDesmojObjects();
int nodeId = desmojEvent.getNodeId();
boolean showInTrace = desmojEvent.traceIsOn();
SimulationModel model = (SimulationModel) desmojEvent.getModel();
try {
// ***************************
// GET INPUT
// ***************************
// fetch all available data objects
Map<Integer, Object> dataObjects = (Map<Integer, Object>) desmojObjects.getExtensionDistributions().get(DataObjectPluginUtils.PLUGIN_NAME);
Map<String, Object> simulationInput = new HashMap<String, Object>();
// iterate over all available data objects
for (int dataObjectId : dataObjects.keySet()) {
// fetch all data fields
Map<String, DataObjectField> dataObjectFields = (Map<String, DataObjectField>) dataObjects.get(dataObjectId);
String dataObjectName = processModel.getDisplayNames().get(dataObjectId);
for (String fieldName : dataObjectFields.keySet()) {
// create the key by concatenating dataObjectName + fieldName and assure that the first letter is lower case
String key = dataObjectName + "." + fieldName;
// handle the distribution of every data field
DataObjectField dataObjectField = dataObjectFields.get(fieldName);
DataDistributionWrapper distWrapper = dataObjectField.getDataDistributionWrapper();
try {
simulationInput.put(key, distWrapper.getSample());
} catch (ScyllaRuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Map<String, Object> dataView = new HashMap<String, Object>();
for (String dataViewElement : batchActivity.getGroupingCharacteristic()) {
dataView.put(dataViewElement, simulationInput.get(dataViewElement));
}
return dataView;
} catch (ScyllaValidationException e) {
System.err.println(e.getMessage());
e.printStackTrace();
SimulationUtils.abort(model, processInstance, nodeId, showInTrace);
return null;
}
}
}
Aggregations