use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TimerExecuteNestedActivityJobHandler method dispatchActivityTimeoutIfNeeded.
protected void dispatchActivityTimeoutIfNeeded(JobEntity timerEntity, ExecutionEntity execution, CommandContext commandContext) {
String nestedActivityId = TimerEventHandler.getActivityIdFromConfiguration(timerEntity.getJobHandlerConfiguration());
ActivityImpl boundaryEventActivity = execution.getProcessDefinition().findActivity(nestedActivityId);
ActivityBehavior boundaryActivityBehavior = boundaryEventActivity.getActivityBehavior();
if (boundaryActivityBehavior instanceof BoundaryEventActivityBehavior) {
BoundaryEventActivityBehavior boundaryEventActivityBehavior = (BoundaryEventActivityBehavior) boundaryActivityBehavior;
if (boundaryEventActivityBehavior.isInterrupting()) {
dispatchExecutionTimeOut(timerEntity, execution, commandContext);
}
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class TimerCatchIntermediateEventJobHandler method execute.
public void execute(JobEntity job, String configuration, ExecutionEntity execution, CommandContext commandContext) {
String nestedActivityId = TimerEventHandler.getActivityIdFromConfiguration(configuration);
ActivityImpl intermediateEventActivity = execution.getProcessDefinition().findActivity(nestedActivityId);
if (intermediateEventActivity == null) {
throw new ActivitiException("Error while firing timer: intermediate event activity " + nestedActivityId + " not found");
}
try {
if (commandContext.getEventDispatcher().isEnabled()) {
commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_FIRED, job));
}
if (!execution.getActivity().getId().equals(intermediateEventActivity.getId())) {
execution.setActivity(intermediateEventActivity);
}
execution.signal(null, null);
} catch (RuntimeException e) {
LogMDC.putMDCExecution(execution);
log.error("exception during timer execution", e);
LogMDC.clear();
throw e;
} catch (Exception e) {
LogMDC.putMDCExecution(execution);
log.error("exception during timer execution", e);
LogMDC.clear();
throw new ActivitiException("exception during timer execution: " + e.getMessage(), e);
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class DefaultHistoryManager method recordSubProcessInstanceStart.
/* (non-Javadoc)
* @see org.activiti.engine.impl.history.HistoryManagerInterface#recordSubProcessInstanceStart(org.activiti.engine.impl.persistence.entity.ExecutionEntity, org.activiti.engine.impl.persistence.entity.ExecutionEntity)
*/
@Override
public void recordSubProcessInstanceStart(ExecutionEntity parentExecution, ExecutionEntity subProcessInstance) {
if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstanceEntity historicProcessInstance = new HistoricProcessInstanceEntity((ExecutionEntity) subProcessInstance);
ActivityImpl initialActivity = subProcessInstance.getActivity();
// Fix for ACT-1728: startActivityId not initialized with subprocess-instance
if (historicProcessInstance.getStartActivityId() == null) {
historicProcessInstance.setStartActivityId(subProcessInstance.getProcessDefinition().getInitial().getId());
initialActivity = subProcessInstance.getProcessDefinition().getInitial();
}
getDbSqlSession().insert(historicProcessInstance);
// Fire event
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_PROCESS_INSTANCE_CREATED, historicProcessInstance));
}
HistoricActivityInstanceEntity activitiyInstance = findActivityInstance(parentExecution);
if (activitiyInstance != null) {
activitiyInstance.setCalledProcessInstanceId(subProcessInstance.getProcessInstanceId());
}
// Fix for ACT-1728: start-event not recorded for subprocesses
IdGenerator idGenerator = Context.getProcessEngineConfiguration().getIdGenerator();
// Also record the start-event manually, as there is no "start" activity history listener for this
HistoricActivityInstanceEntity historicActivityInstance = new HistoricActivityInstanceEntity();
historicActivityInstance.setId(idGenerator.getNextId());
historicActivityInstance.setProcessDefinitionId(subProcessInstance.getProcessDefinitionId());
historicActivityInstance.setProcessInstanceId(subProcessInstance.getProcessInstanceId());
historicActivityInstance.setExecutionId(subProcessInstance.getId());
historicActivityInstance.setActivityId(initialActivity.getId());
historicActivityInstance.setActivityName((String) initialActivity.getProperty("name"));
historicActivityInstance.setActivityType((String) initialActivity.getProperty("type"));
Date now = Context.getProcessEngineConfiguration().getClock().getCurrentTime();
historicActivityInstance.setStartTime(now);
getDbSqlSession().insert(historicActivityInstance);
// Fire event
if (config != null && config.getEventDispatcher().isEnabled()) {
config.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.HISTORIC_ACTIVITY_INSTANCE_CREATED, historicActivityInstance));
}
}
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class JobRetryCmd method getCurrentActivity.
private ActivityImpl getCurrentActivity(CommandContext commandContext, JobEntity job) {
String type = job.getJobHandlerType();
ActivityImpl activity = null;
if (TimerExecuteNestedActivityJobHandler.TYPE.equals(type) || TimerCatchIntermediateEventJobHandler.TYPE.equals(type)) {
ExecutionEntity execution = fetchExecutionEntity(commandContext, job.getExecutionId());
if (execution != null) {
activity = execution.getProcessDefinition().findActivity(job.getJobHandlerConfiguration());
}
} else if (TimerStartEventJobHandler.TYPE.equals(type)) {
DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
if (TimerEventHandler.hasRealActivityId(job.getJobHandlerConfiguration())) {
ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());
String activityId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
activity = processDefinition.findActivity(activityId);
} else {
String processId = job.getJobHandlerConfiguration();
if (job instanceof TimerEntity) {
processId = TimerEventHandler.getActivityIdFromConfiguration(job.getJobHandlerConfiguration());
}
ProcessDefinitionEntity processDefinition = null;
if (job.getTenantId() != null && job.getTenantId().length() > 0) {
processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processId, job.getTenantId());
} else {
processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processId);
}
if (processDefinition != null) {
activity = processDefinition.getInitial();
}
}
} else if (AsyncContinuationJobHandler.TYPE.equals(type)) {
ExecutionEntity execution = fetchExecutionEntity(commandContext, job.getExecutionId());
if (execution != null) {
activity = execution.getActivity();
}
} else {
// nop, because activity type is not supported
}
return activity;
}
use of org.activiti.engine.impl.pvm.process.ActivityImpl in project Activiti by Activiti.
the class AbstractEventHandler method dispatchExecutionCancelled.
protected void dispatchExecutionCancelled(EventSubscriptionEntity eventSubscription, ExecutionEntity execution, CommandContext commandContext) {
// subprocesses
for (ExecutionEntity subExecution : execution.getExecutions()) {
dispatchExecutionCancelled(eventSubscription, subExecution, commandContext);
}
// call activities
ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
dispatchExecutionCancelled(eventSubscription, subProcessInstance, commandContext);
}
// activity with message/signal boundary events
ActivityImpl activity = execution.getActivity();
if (activity != null && activity.getActivityBehavior() != null) {
dispatchActivityCancelled(eventSubscription, execution, activity, commandContext);
}
}
Aggregations