Search in sources :

Example 46 with ExecutionEntity

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;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 47 with ExecutionEntity

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);
    }
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 48 with ExecutionEntity

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;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 49 with ExecutionEntity

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;
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) TimerEntity(org.activiti.engine.impl.persistence.entity.TimerEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 50 with ExecutionEntity

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;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) MessageEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity)

Aggregations

ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)58 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)15 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)15 ActivitiException (org.activiti.engine.ActivitiException)12 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)11 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)8 HashMap (java.util.HashMap)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 CompensateEventSubscriptionEntity (org.activiti.engine.impl.persistence.entity.CompensateEventSubscriptionEntity)5 Deployment (org.activiti.engine.test.Deployment)5 ArrayList (java.util.ArrayList)4 DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)4 AttachmentEntity (org.activiti.engine.impl.persistence.entity.AttachmentEntity)3 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)3 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)3 List (java.util.List)2 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)2