Search in sources :

Example 6 with ProcessDefinitionImpl

use of org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl in project Activiti by Activiti.

the class SetProcessDefinitionVersionCmd method execute.

public Void execute(CommandContext commandContext) {
    // check that the new process definition is just another version of the same
    // process definition that the process instance is using
    ExecutionEntityManager executionManager = commandContext.getExecutionEntityManager();
    ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
    if (processInstance == null) {
        throw new ActivitiObjectNotFoundException("No process instance found for id = '" + processInstanceId + "'.", ProcessInstance.class);
    } else if (!processInstance.isProcessInstanceType()) {
        throw new ActivitiIllegalArgumentException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id.");
    }
    ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();
    DeploymentManager deploymentCache = commandContext.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinitionEntity currentProcessDefinition;
    if (currentProcessDefinitionImpl instanceof ProcessDefinitionEntity) {
        currentProcessDefinition = (ProcessDefinitionEntity) currentProcessDefinitionImpl;
    } else {
        currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.getId());
    }
    ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyAndVersion(currentProcessDefinition.getKey(), processDefinitionVersion);
    validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);
    // switch the historic process instance to the new process definition version
    commandContext.getHistoryManager().recordProcessDefinitionChange(processInstanceId, newProcessDefinition.getId());
    // switch all sub-executions of the process instance to the new process definition version
    List<ExecutionEntity> childExecutions = executionManager.findChildExecutionsByProcessInstanceId(processInstanceId);
    for (ExecutionEntity executionEntity : childExecutions) {
        validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
    }
    return null;
}
Also used : ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) 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) ExecutionEntityManager(org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)

Example 7 with ProcessDefinitionImpl

use of org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl in project Activiti by Activiti.

the class AddListenerUserTaskParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
    super.executeParse(bpmnParse, userTask);
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
    ActivityImpl activity = processDefinition.findActivity(userTask.getId());
    SimulatorParserUtils.setSimulationBehavior(scope, userTask);
    UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activity.getActivityBehavior();
    userTaskActivity.getTaskDefinition().addTaskListener(eventName, taskListener);
}
Also used : ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl)

Example 8 with ProcessDefinitionImpl

use of org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl in project Activiti by Activiti.

the class SimulatorParserUtils method setSimulationBehavior.

static void setSimulationBehavior(ScopeImpl scope, BaseElement baseElement) {
    String behaviorClassName = getBehaviorClassName(baseElement);
    if (behaviorClassName != null) {
        ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
        ActivityImpl activity = processDefinition.findActivity(baseElement.getId());
        LOG.debug("Scripting task [" + activity.getId() + "] setting behavior to [" + behaviorClassName + "]");
        try {
            @SuppressWarnings("unchecked") Class<AbstractSimulationActivityBehavior> behaviorClass = (Class<AbstractSimulationActivityBehavior>) Class.forName(behaviorClassName);
            Constructor<AbstractSimulationActivityBehavior> constructor = behaviorClass.getDeclaredConstructor(ScopeImpl.class, ActivityImpl.class);
            activity.setActivityBehavior(constructor.newInstance(scope, activity));
        } catch (Throwable t) {
            LOG.error("unable to set simulation behavior class[" + behaviorClassName + "]", t);
            throw new ActivitiException("unable to set simulation behavior class[" + behaviorClassName + "]");
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) AbstractSimulationActivityBehavior(org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior)

Example 9 with ProcessDefinitionImpl

use of org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl in project Activiti by Activiti.

the class AtomicOperationProcessStartInitial method eventNotificationsCompleted.

@Override
protected void eventNotificationsCompleted(InterpretableExecution execution) {
    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
    StartingExecution startingExecution = execution.getStartingExecution();
    if (activity == startingExecution.getInitial()) {
        execution.disposeStartingExecution();
        execution.performOperation(ACTIVITY_EXECUTE);
    } else {
        List<ActivityImpl> initialActivityStack = processDefinition.getInitialActivityStack(startingExecution.getInitial());
        int index = initialActivityStack.indexOf(activity);
        activity = initialActivityStack.get(index + 1);
        InterpretableExecution executionToUse = null;
        if (activity.isScope()) {
            executionToUse = (InterpretableExecution) execution.getExecutions().get(0);
        } else {
            executionToUse = execution;
        }
        executionToUse.setActivity(activity);
        executionToUse.performOperation(PROCESS_START_INITIAL);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)

Aggregations

ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)9 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)6 ActivitiException (org.activiti.engine.ActivitiException)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 PvmProcessDefinition (org.activiti.engine.impl.pvm.PvmProcessDefinition)2 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)2 ArrayList (java.util.ArrayList)1 AbstractSimulationActivityBehavior (org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 RepositoryService (org.activiti.engine.RepositoryService)1 UserTaskActivityBehavior (org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior)1 DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)1 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)1 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)1 ProcessDefinitionBuilder (org.activiti.engine.impl.pvm.ProcessDefinitionBuilder)1 PvmExecution (org.activiti.engine.impl.pvm.PvmExecution)1 PvmProcessInstance (org.activiti.engine.impl.pvm.PvmProcessInstance)1 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1