Search in sources :

Example 1 with FlowableProcessCancelledEventImpl

use of org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl in project petals-se-flowable by petalslink.

the class ProcessInstanceCanceledEventListener method createLogData.

@Override
protected AbstractFlowLogData createLogData(final FlowableEvent event) {
    if (event instanceof FlowableProcessCancelledEventImpl) {
        final FlowableProcessCancelledEventImpl eventImpl = (FlowableProcessCancelledEventImpl) event;
        final String processInstanceId = eventImpl.getProcessInstanceId();
        this.log.fine("The process instance '" + processInstanceId + "' is canceled.");
        final HistoricProcessInstanceQuery processQuery = this.historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables();
        final HistoricProcessInstance processResult = processQuery.singleResult();
        final Map<String, Object> processVariables = processResult.getProcessVariables();
        final String flowInstanceId = (String) processVariables.get(VAR_PETALS_FLOW_INSTANCE_ID);
        final String flowStepId = (String) processVariables.get(VAR_PETALS_FLOW_STEP_ID);
        if (this.isFlowTracingEnabled(processVariables)) {
            return new ProcessInstanceFlowStepFailureLogData(flowInstanceId, flowStepId, eventImpl.getCause().toString());
        } else {
            return null;
        }
    } else {
        this.log.warning("Unexpected event implementation: " + event.getClass().getName());
        return null;
    }
}
Also used : FlowableProcessCancelledEventImpl(org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl) HistoricProcessInstanceQuery(org.flowable.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.flowable.engine.history.HistoricProcessInstance) ProcessInstanceFlowStepFailureLogData(org.ow2.petals.flowable.monitoring.ProcessInstanceFlowStepFailureLogData)

Aggregations

FlowableProcessCancelledEventImpl (org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl)1 HistoricProcessInstance (org.flowable.engine.history.HistoricProcessInstance)1 HistoricProcessInstanceQuery (org.flowable.engine.history.HistoricProcessInstanceQuery)1 ProcessInstanceFlowStepFailureLogData (org.ow2.petals.flowable.monitoring.ProcessInstanceFlowStepFailureLogData)1