use of org.activiti.crystalball.simulator.SimulationEvent 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;
}
use of org.activiti.crystalball.simulator.SimulationEvent in project Activiti by Activiti.
the class AcquireJobNotificationEventHandler method init.
@Override
public void init() {
log.info(jobExecutor.getName() + " starting to acquire jobs");
jobExecutor.start();
SimulationEvent event = new SimulationEvent.Builder(SimulationEvent.TYPE_ACQUIRE_JOB_NOTIFICATION_EVENT).simulationTime(SimulationRunContext.getClock().getCurrentTime().getTime()).property(((SimulationDefaultJobExecutor) jobExecutor).getAcquireJobsRunnable()).build();
SimulationRunContext.getEventCalendar().addEvent(event);
}
use of org.activiti.crystalball.simulator.SimulationEvent in project Activiti by Activiti.
the class StartReplayProcessEventHandler method init.
@Override
public void init() {
SimulationEvent toReplayStartEvent = findProcessInstanceStartEvent();
SimulationEvent startEvent = new SimulationEvent.Builder(eventTypeToSchedule).properties(toReplayStartEvent.getProperties()).build();
// add start process event
SimulationRunContext.getEventCalendar().addEvent(startEvent);
}
use of org.activiti.crystalball.simulator.SimulationEvent in project Activiti by Activiti.
the class ReplayEventLogTest method getTransformers.
private static List<Function<EventLogEntry, SimulationEvent>> getTransformers() {
List<Function<EventLogEntry, SimulationEvent>> transformers = new ArrayList<Function<EventLogEntry, SimulationEvent>>();
transformers.add(new EventLogProcessInstanceCreateTransformer(PROCESS_INSTANCE_START_EVENT_TYPE, PROCESS_DEFINITION_ID_KEY, BUSINESS_KEY, VARIABLES_KEY));
transformers.add(new EventLogUserTaskCompleteTransformer(USER_TASK_COMPLETED_EVENT_TYPE));
return transformers;
}
use of org.activiti.crystalball.simulator.SimulationEvent in project Activiti by Activiti.
the class ReplayRunTest method getTransformers.
private static List<Function<ActivitiEvent, SimulationEvent>> getTransformers() {
List<Function<ActivitiEvent, SimulationEvent>> transformers = new ArrayList<Function<ActivitiEvent, SimulationEvent>>();
transformers.add(new ProcessInstanceCreateTransformer(PROCESS_INSTANCE_START_EVENT_TYPE, PROCESS_DEFINITION_ID_KEY, BUSINESS_KEY, VARIABLES_KEY));
transformers.add(new UserTaskCompleteTransformer(USER_TASK_COMPLETED_EVENT_TYPE));
return transformers;
}
Aggregations