Search in sources :

Example 1 with AbstractElement

use of io.takari.bpm.model.AbstractElement in project concord by walmartlabs.

the class YamlGroupConverter method convert.

@Override
public Chunk convert(ConverterContext ctx, YamlGroup s) throws YamlConverterException {
    Chunk c = new Chunk();
    // create a subprocess
    Chunk sub = ctx.convert(s.getSteps());
    List<AbstractElement> l = ctx.wrapAsProcess(sub);
    // add the subprocess
    String id = ctx.nextId();
    c.addElement(new SubProcess(id, l));
    c.addOutput(id);
    c.addSourceMap(id, toSourceMap(s, "Group of steps"));
    // keep the subprocess' source map
    c.addSourceMaps(sub.getSourceMap());
    applyErrorBlock(ctx, c, id, s.getOptions());
    return c;
}
Also used : SubProcess(io.takari.bpm.model.SubProcess) AbstractElement(io.takari.bpm.model.AbstractElement)

Example 2 with AbstractElement

use of io.takari.bpm.model.AbstractElement 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());
    }
}
Also used : AbstractElement(io.takari.bpm.model.AbstractElement) HashMap(java.util.HashMap) SourceAwareProcessDefinition(io.takari.bpm.model.SourceAwareProcessDefinition) ProcessDefinition(io.takari.bpm.model.ProcessDefinition) ExecutionException(io.takari.bpm.api.ExecutionException) ProcessEventRequest(com.walmartlabs.concord.client.ProcessEventRequest) SourceMap(io.takari.bpm.model.SourceMap) SourceAwareProcessDefinition(io.takari.bpm.model.SourceAwareProcessDefinition) ProcessEventsApi(com.walmartlabs.concord.client.ProcessEventsApi)

Aggregations

AbstractElement (io.takari.bpm.model.AbstractElement)2 ProcessEventRequest (com.walmartlabs.concord.client.ProcessEventRequest)1 ProcessEventsApi (com.walmartlabs.concord.client.ProcessEventsApi)1 ExecutionException (io.takari.bpm.api.ExecutionException)1 ProcessDefinition (io.takari.bpm.model.ProcessDefinition)1 SourceAwareProcessDefinition (io.takari.bpm.model.SourceAwareProcessDefinition)1 SourceMap (io.takari.bpm.model.SourceMap)1 SubProcess (io.takari.bpm.model.SubProcess)1 HashMap (java.util.HashMap)1