Search in sources :

Example 11 with ExecutionEntity

use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.

the class SubmitStartFormCmd method execute.

protected ProcessInstance execute(CommandContext commandContext, ProcessDefinitionEntity processDefinition) {
    ExecutionEntity processInstance = null;
    if (businessKey != null) {
        processInstance = processDefinition.createProcessInstance(businessKey);
    } else {
        processInstance = processDefinition.createProcessInstance();
    }
    commandContext.getHistoryManager().reportFormPropertiesSubmitted(processInstance, properties, null);
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    startFormHandler.submitFormProperties(properties, processInstance);
    processInstance.start();
    return processInstance;
}
Also used : StartFormHandler(org.activiti.engine.impl.form.StartFormHandler) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity)

Example 12 with ExecutionEntity

use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.

the class AbstractSetProcessInstanceStateCmd method execute.

public Void execute(CommandContext commandContext) {
    if (executionId == null) {
        throw new ActivitiIllegalArgumentException("ProcessInstanceId cannot be null.");
    }
    ExecutionEntity executionEntity = commandContext.getExecutionEntityManager().findExecutionById(executionId);
    if (executionEntity == null) {
        throw new ActivitiObjectNotFoundException("Cannot find processInstance for id '" + executionId + "'.", Execution.class);
    }
    if (!executionEntity.isProcessInstanceType()) {
        throw new ActivitiException("Cannot set suspension state for execution '" + executionId + "': not a process instance.");
    }
    SuspensionStateUtil.setSuspensionState(executionEntity, getNewState());
    // All child executions are suspended
    List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByProcessInstanceId(executionId);
    for (ExecutionEntity childExecution : childExecutions) {
        if (!childExecution.getId().equals(executionId)) {
            SuspensionStateUtil.setSuspensionState(childExecution, getNewState());
        }
    }
    // All tasks are suspended
    List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByProcessInstanceId(executionId);
    for (TaskEntity taskEntity : tasks) {
        SuspensionStateUtil.setSuspensionState(taskEntity, getNewState());
    }
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 13 with ExecutionEntity

use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.

the class SaveAttachmentCmd method execute.

public Object execute(CommandContext commandContext) {
    AttachmentEntity updateAttachment = commandContext.getDbSqlSession().selectById(AttachmentEntity.class, attachment.getId());
    updateAttachment.setName(attachment.getName());
    updateAttachment.setDescription(attachment.getDescription());
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        // Forced to fetch the process-instance to associate the right process definition
        String processDefinitionId = null;
        String processInstanceId = updateAttachment.getProcessInstanceId();
        if (updateAttachment.getProcessInstanceId() != null) {
            ExecutionEntity process = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
            if (process != null) {
                processDefinitionId = process.getProcessDefinitionId();
            }
        }
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, attachment, processInstanceId, processInstanceId, processDefinitionId));
    }
    return null;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) AttachmentEntity(org.activiti.engine.impl.persistence.entity.AttachmentEntity)

Example 14 with ExecutionEntity

use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.

the class SetProcessInstanceNameCmd method execute.

@Override
public Void execute(CommandContext commandContext) {
    if (processInstanceId == null) {
        throw new ActivitiIllegalArgumentException("processInstanceId is null");
    }
    ExecutionEntity execution = commandContext.getExecutionEntityManager().findExecutionById(processInstanceId);
    if (execution == null) {
        throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist", ProcessInstance.class);
    }
    if (!execution.isProcessInstanceType()) {
        throw new ActivitiObjectNotFoundException("process instance " + processInstanceId + " doesn't exist, the given ID references an execution, though", ProcessInstance.class);
    }
    if (execution.isSuspended()) {
        throw new ActivitiException("process instance " + processInstanceId + " is suspended, cannot set name");
    }
    // Actually set the name
    execution.setName(name);
    // Record the change in history
    commandContext.getHistoryManager().recordProcessInstanceNameChange(processInstanceId, name);
    return null;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 15 with ExecutionEntity

use of org.activiti.engine.impl.persistence.entity.ExecutionEntity in project Activiti by Activiti.

the class TimerStartEventJobHandler method startProcessInstanceWithInitialActivity.

protected void startProcessInstanceWithInitialActivity(JobEntity job, String configuration, DeploymentManager deploymentManager, CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());
    String activityId = getActivityIdFromConfiguration(configuration);
    ActivityImpl startActivity = processDefinition.findActivity(activityId);
    if (!deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        dispatchTimerFiredEvent(job, commandContext);
        ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
        processInstance.start();
    } else {
        log.debug("Ignoring timer of suspended process definition {}", processDefinition.getId());
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

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