use of org.activiti.crystalball.simulator.CrystalballException in project Activiti by Activiti.
the class EventLogProcessInstanceCreateTransformer method apply.
@SuppressWarnings({ "unchecked" })
@Override
public SimulationEvent apply(EventLogEntry event) {
if ("PROCESSINSTANCE_START".equals(event.getType())) {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> data;
try {
data = objectMapper.readValue(event.getData(), new TypeReference<HashMap<String, Object>>() {
});
} catch (IOException e) {
throw new CrystalballException("unable to parse JSON string.", e);
}
String processDefinitionId = (String) data.get(Fields.PROCESS_DEFINITION_ID);
Map<String, Object> variableMap = (Map<String, Object>) data.get(Fields.VARIABLES);
String businessKeyValue = (String) data.get(Fields.BUSINESS_KEY);
String processInstanceId = (String) data.get(Fields.PROCESS_INSTANCE_ID);
Map<String, Object> simEventProperties = new HashMap<String, Object>();
simEventProperties.put(processDefinitionIdKey, processDefinitionId);
simEventProperties.put(this.businessKey, businessKeyValue);
simEventProperties.put(variablesKey, variableMap);
simEventProperties.put(PROCESS_INSTANCE_ID, processInstanceId);
return new SimulationEvent.Builder(simulationEventType).priority((int) event.getLogNumber()).properties(simEventProperties).build();
}
return null;
}
use of org.activiti.crystalball.simulator.CrystalballException in project Activiti by Activiti.
the class EventLogUserTaskCompleteTransformer method apply.
@SuppressWarnings("unchecked")
@Override
public SimulationEvent apply(EventLogEntry event) {
if (ActivitiEventType.TASK_COMPLETED.toString().equals(event.getType())) {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> data;
try {
data = objectMapper.readValue(event.getData(), new TypeReference<HashMap<String, Object>>() {
});
} catch (IOException e) {
throw new CrystalballException("unable to parse JSON string.", e);
}
String taskIdValue = (String) data.get(Fields.ACTIVITY_ID);
boolean localScope = false;
Map<String, Object> variableMap = null;
if (data.get(Fields.VARIABLES) != null) {
variableMap = (Map<String, Object>) data.get(Fields.VARIABLES);
} else {
variableMap = (Map<String, Object>) data.get(Fields.LOCAL_VARIABLES);
localScope = true;
}
String taskDefinitionKeyValue = (String) data.get(Fields.TASK_DEFINITION_KEY);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("taskId", taskIdValue);
properties.put(TASK_DEFINITION_KEY, taskDefinitionKeyValue);
properties.put(PROCESS_INSTANCE_ID, event.getProcessInstanceId());
if (variableMap != null) {
properties.put(TASK_VARIABLES, variableMap);
properties.put(VARIABLES_LOCAL_SCOPE, localScope);
}
return new SimulationEvent.Builder(this.simulationEventType).priority((int) event.getLogNumber()).properties(properties).build();
}
return null;
}
Aggregations