Search in sources :

Example 1 with IncidentContext

use of org.camunda.bpm.engine.impl.incident.IncidentContext in project camunda-bpm-platform by camunda.

the class ExternalTaskEntity method createIncidentContext.

protected IncidentContext createIncidentContext() {
    IncidentContext context = new IncidentContext();
    context.setProcessDefinitionId(processDefinitionId);
    context.setExecutionId(executionId);
    context.setActivityId(activityId);
    context.setTenantId(tenantId);
    context.setConfiguration(id);
    return context;
}
Also used : IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext)

Example 2 with IncidentContext

use of org.camunda.bpm.engine.impl.incident.IncidentContext in project camunda-bpm-platform by camunda.

the class JobEntity method removeFailedJobIncident.

protected void removeFailedJobIncident(boolean incidentResolved) {
    IncidentHandler handler = Context.getProcessEngineConfiguration().getIncidentHandler(Incident.FAILED_JOB_HANDLER_TYPE);
    IncidentContext incidentContext = createIncidentContext();
    if (incidentResolved) {
        handler.resolveIncident(incidentContext);
    } else {
        handler.deleteIncident(incidentContext);
    }
}
Also used : IncidentHandler(org.camunda.bpm.engine.impl.incident.IncidentHandler) IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext)

Example 3 with IncidentContext

use of org.camunda.bpm.engine.impl.incident.IncidentContext in project camunda-bpm-platform by camunda.

the class JobEntity method createFailedJobIncident.

protected void createFailedJobIncident() {
    final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    if (processEngineConfiguration.isCreateIncidentOnFailedJobEnabled()) {
        String incidentHandlerType = Incident.FAILED_JOB_HANDLER_TYPE;
        // make sure job has an ID set:
        if (id == null) {
            id = processEngineConfiguration.getIdGenerator().getNextId();
        } else {
            // check whether there exists already an incident
            // for this job
            List<Incident> failedJobIncidents = Context.getCommandContext().getIncidentManager().findIncidentByConfigurationAndIncidentType(id, incidentHandlerType);
            if (!failedJobIncidents.isEmpty()) {
                return;
            }
        }
        IncidentContext incidentContext = createIncidentContext();
        incidentContext.setActivityId(getActivityId());
        processEngineConfiguration.getIncidentHandler(incidentHandlerType).handleIncident(incidentContext, exceptionMessage);
    }
}
Also used : IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext) Incident(org.camunda.bpm.engine.runtime.Incident) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)

Example 4 with IncidentContext

use of org.camunda.bpm.engine.impl.incident.IncidentContext in project camunda-bpm-platform by camunda.

the class JobEntity method createIncidentContext.

protected IncidentContext createIncidentContext() {
    IncidentContext incidentContext = new IncidentContext();
    incidentContext.setProcessDefinitionId(processDefinitionId);
    incidentContext.setExecutionId(executionId);
    incidentContext.setTenantId(tenantId);
    incidentContext.setConfiguration(id);
    incidentContext.setJobDefinitionId(jobDefinitionId);
    return incidentContext;
}
Also used : IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext)

Example 5 with IncidentContext

use of org.camunda.bpm.engine.impl.incident.IncidentContext in project camunda-bpm-platform by camunda.

the class ExecutionCachedEntityStateTest method testProcessInstanceIncident.

@Deployment
public void testProcessInstanceIncident() {
    runtimeService.startProcessInstanceByKey("testProcess");
    ExecutionEntity processInstance = (ExecutionEntity) runtimeService.createProcessInstanceQuery().singleResult();
    assertEquals(0, processInstance.getCachedEntityStateRaw());
    final ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
    assertEquals(0, execution.getCachedEntityStateRaw());
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            IncidentContext incidentContext = new IncidentContext();
            incidentContext.setExecutionId(execution.getId());
            IncidentEntity.createAndInsertIncident("foo", incidentContext, null);
            return null;
        }
    });
    ExecutionEntity execution2 = (ExecutionEntity) runtimeService.createExecutionQuery().activityId("task").singleResult();
    assertEquals(BitMaskUtil.getMaskForBit(ExecutionEntity.INCIDENT_STATE_BIT), execution2.getCachedEntityStateRaw());
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

IncidentContext (org.camunda.bpm.engine.impl.incident.IncidentContext)8 IncidentHandler (org.camunda.bpm.engine.impl.incident.IncidentHandler)3 DefaultIncidentHandler (org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler)2 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 Deployment (org.camunda.bpm.engine.test.Deployment)2 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)1 IncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity)1 Incident (org.camunda.bpm.engine.runtime.Incident)1