use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class DeleteIdentityLinkForProcessInstanceCmd method execute.
public Void execute(CommandContext commandContext) {
ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
if (processInstance == null) {
throw new ActivitiObjectNotFoundException("Cannot find process instance with id " + processInstanceId, ExecutionEntity.class);
}
processInstance.deleteIdentityLink(userId, groupId, type);
commandContext.getHistoryManager().createProcessInstanceIdentityLinkComment(processInstanceId, userId, groupId, type, false);
return null;
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class TimerExecuteNestedActivityJobHandler method dispatchExecutionTimeOut.
protected void dispatchExecutionTimeOut(JobEntity timerEntity, ExecutionEntity execution, CommandContext commandContext) {
// subprocesses
for (ExecutionEntity subExecution : execution.getExecutions()) {
dispatchExecutionTimeOut(timerEntity, subExecution, commandContext);
}
// call activities
ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
if (subProcessInstance != null) {
dispatchExecutionTimeOut(timerEntity, subProcessInstance, commandContext);
}
// activity with timer boundary event
ActivityImpl activity = execution.getActivity();
if (activity != null && activity.getActivityBehavior() != null) {
dispatchActivityTimeOut(timerEntity, activity, execution, commandContext);
}
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class HasExecutionVariableCmd method execute.
public Boolean execute(CommandContext commandContext) {
if (executionId == null) {
throw new ActivitiIllegalArgumentException("executionId is null");
}
if (variableName == null) {
throw new ActivitiIllegalArgumentException("variableName is null");
}
ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(executionId);
if (execution == null) {
throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class);
}
boolean hasVariable = false;
if (isLocal) {
hasVariable = execution.hasVariableLocal(variableName);
} else {
hasVariable = execution.hasVariable(variableName);
}
return hasVariable;
}
use of org.activiti.engine.impl.persistence.entity.ExecutionEntity 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.persistence.entity.ExecutionEntity in project Activiti by Activiti.
the class StartProcessInstanceByMessageCmd method execute.
public ProcessInstance execute(CommandContext commandContext) {
if (messageName == null) {
throw new ActivitiIllegalArgumentException("Cannot start process instance by message: message name is null");
}
MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionEntityManager().findMessageStartEventSubscriptionByName(messageName, tenantId);
if (messageEventSubscription == null) {
throw new ActivitiObjectNotFoundException("Cannot start process instance by message: no subscription to message with name '" + messageName + "' found.", MessageEventSubscriptionEntity.class);
}
String processDefinitionId = messageEventSubscription.getConfiguration();
if (processDefinitionId == null) {
throw new ActivitiException("Cannot start process instance by message: subscription to message with name '" + messageName + "' is not a message start event.");
}
DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Do not start process a process instance if the process definition is suspended
if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
throw new ActivitiException("Cannot start process instance. Process definition " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
}
ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, startActivity);
if (processVariables != null) {
processInstance.setVariables(processVariables);
}
processInstance.start();
return processInstance;
}
Aggregations