use of io.takari.bpm.model.SourceAwareProcessDefinition in project concord by walmartlabs.
the class DefaultElementEventProcessor method process.
@Override
public void process(ElementEvent event, EventParamsBuilder builder, Predicate<AbstractElement> filter) throws ExecutionException {
ProcessDefinition pd = processDefinitionProvider.getById(event.getProcessDefinitionId());
if (pd == null) {
throw new RuntimeException("Process definition not found: " + event.getProcessDefinitionId());
}
if (!(pd instanceof SourceAwareProcessDefinition)) {
return;
}
Map<String, SourceMap> sourceMaps = ((SourceAwareProcessDefinition) pd).getSourceMaps();
SourceMap source = sourceMaps.get(event.getElementId());
if (source == null) {
return;
}
AbstractElement element = ProcessDefinitionUtils.findElement(pd, event.getElementId());
if (filter != null && !filter.test(element)) {
return;
}
try {
Map<String, Object> e = new HashMap<>();
e.put("processDefinitionId", event.getProcessDefinitionId());
e.put("elementId", event.getElementId());
e.put("line", source.getLine());
e.put("column", source.getColumn());
e.put("description", source.getDescription());
e.putAll(builder.build(element));
ProcessEventRequest req = new ProcessEventRequest();
// TODO should it be in the constants?
req.setEventType("ELEMENT");
req.setData(e);
req.setEventDate(Instant.now().atOffset(ZoneOffset.UTC));
ProcessEventsApi client = new ProcessEventsApi(apiClientFactory.create(ApiClientConfiguration.builder().sessionToken(event.getSessionToken()).txId(UUID.fromString(event.getInstanceId())).build()));
client.event(UUID.fromString(event.getInstanceId()), req);
} catch (Exception e) {
log.warn("process ['{}'] -> transfer error: {}", event.getInstanceId(), e.getMessage());
}
}
Aggregations