Search in sources :

Example 6 with IncidentContext

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

the class ExecutionCachedEntityStateTest method testExecutionIncidentParallel.

@Deployment
public void testExecutionIncidentParallel() {
    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)

Example 7 with IncidentContext

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

the class PvmExecutionImpl method resolveIncident.

/**
 * Resolves an incident with given id.
 *
 * @param incidentId
 */
@Override
public void resolveIncident(final String incidentId) {
    IncidentEntity incident = (IncidentEntity) Context.getCommandContext().getIncidentManager().findIncidentById(incidentId);
    IncidentHandler incidentHandler = findIncidentHandler(incident.getIncidentType());
    if (incidentHandler == null) {
        incidentHandler = new DefaultIncidentHandler(incident.getIncidentType());
    }
    IncidentContext incidentContext = new IncidentContext(incident);
    incidentHandler.resolveIncident(incidentContext);
}
Also used : IncidentHandler(org.camunda.bpm.engine.impl.incident.IncidentHandler) DefaultIncidentHandler(org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler) DefaultIncidentHandler(org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler) IncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity) IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext)

Example 8 with IncidentContext

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

the class PvmExecutionImpl method createIncident.

public Incident createIncident(String incidentType, String configuration, String message) {
    IncidentContext incidentContext = new IncidentContext();
    incidentContext.setTenantId(this.getTenantId());
    incidentContext.setProcessDefinitionId(this.getProcessDefinitionId());
    incidentContext.setExecutionId(this.getId());
    incidentContext.setActivityId(this.getActivityId());
    incidentContext.setConfiguration(configuration);
    IncidentHandler incidentHandler = findIncidentHandler(incidentType);
    if (incidentHandler == null) {
        incidentHandler = new DefaultIncidentHandler(incidentType);
    }
    return incidentHandler.handleIncident(incidentContext, message);
}
Also used : IncidentHandler(org.camunda.bpm.engine.impl.incident.IncidentHandler) DefaultIncidentHandler(org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler) DefaultIncidentHandler(org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler) IncidentContext(org.camunda.bpm.engine.impl.incident.IncidentContext)

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