Search in sources :

Example 1 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class NeedsActiveProcessDefinitionCmd method execute.

public T execute(CommandContext commandContext) {
    DeploymentManager deploymentManager = commandContext.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinitionEntity processDefinition = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
    if (deploymentManager.isProcessDefinitionSuspended(processDefinitionId)) {
        throw new ActivitiException("Cannot execute operation because process definition '" + processDefinition.getName() + "' (id=" + processDefinition.getId() + ") is supended");
    }
    return execute(commandContext, processDefinition);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class CallActivityBehavior method execute.

public void execute(ActivityExecution execution) throws Exception {
    String processDefinitonKey = this.processDefinitonKey;
    if (processDefinitionExpression != null) {
        processDefinitonKey = (String) processDefinitionExpression.getValue(execution);
    }
    DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager();
    ProcessDefinitionEntity processDefinition = null;
    if (execution.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(execution.getTenantId())) {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKey(processDefinitonKey);
    } else {
        processDefinition = deploymentManager.findDeployedLatestProcessDefinitionByKeyAndTenantId(processDefinitonKey, execution.getTenantId());
    }
    // Do not start 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");
    }
    PvmProcessInstance subProcessInstance = execution.createSubProcessInstance(processDefinition);
    if (inheritVariables) {
        Map<String, Object> variables = execution.getVariables();
        for (Map.Entry<String, Object> entry : variables.entrySet()) {
            subProcessInstance.setVariable(entry.getKey(), entry.getValue());
        }
    }
    // copy process variables
    for (AbstractDataAssociation dataInputAssociation : dataInputAssociations) {
        Object value = null;
        if (dataInputAssociation.getSourceExpression() != null) {
            value = dataInputAssociation.getSourceExpression().getValue(execution);
        } else {
            value = execution.getVariable(dataInputAssociation.getSource());
        }
        subProcessInstance.setVariable(dataInputAssociation.getTarget(), value);
    }
    try {
        subProcessInstance.start();
    } catch (Exception e) {
        if (!ErrorPropagation.mapException(e, execution, mapExceptions, true))
            throw e;
    }
}
Also used : PvmProcessInstance(org.activiti.engine.impl.pvm.PvmProcessInstance) ActivitiException(org.activiti.engine.ActivitiException) AbstractDataAssociation(org.activiti.engine.impl.bpmn.data.AbstractDataAssociation) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) Map(java.util.Map) ActivitiException(org.activiti.engine.ActivitiException)

Example 3 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class IntegrationContextBuilderTest method setUp.

@BeforeEach
public void setUp() {
    initMocks(this);
    ProcessEngineConfigurationImpl processEngineConfiguration = mock(ProcessEngineConfigurationImpl.class);
    Context.setProcessEngineConfiguration(processEngineConfiguration);
    DeploymentManager deploymentManager = mock(DeploymentManager.class);
    ProcessDefinition processDefinition = mock(ProcessDefinition.class);
    given(processEngineConfiguration.getDeploymentManager()).willReturn(deploymentManager);
    given(deploymentManager.findDeployedProcessDefinitionById(PROCESS_DEFINITION_ID)).willReturn(processDefinition);
    given(processDefinition.getId()).willReturn(PROCESS_DEFINITION_ID);
    given(processDefinition.getKey()).willReturn(PROCESS_DEFINITION_KEY);
    given(processDefinition.getVersion()).willReturn(PROCESS_DEFINITION_VERSION);
}
Also used : DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class CachingAndArtifactsManager method addDefinitionInfoToCache.

protected void addDefinitionInfoToCache(ProcessDefinitionEntity processDefinition, ProcessEngineConfigurationImpl processEngineConfiguration, CommandContext commandContext) {
    if (!processEngineConfiguration.isEnableProcessDefinitionInfoCache()) {
        return;
    }
    DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager();
    ProcessDefinitionInfoEntityManager definitionInfoEntityManager = commandContext.getProcessDefinitionInfoEntityManager();
    ObjectMapper objectMapper = commandContext.getProcessEngineConfiguration().getObjectMapper();
    ProcessDefinitionInfoEntity definitionInfoEntity = definitionInfoEntityManager.findProcessDefinitionInfoByProcessDefinitionId(processDefinition.getId());
    ObjectNode infoNode = null;
    if (definitionInfoEntity != null && definitionInfoEntity.getInfoJsonId() != null) {
        byte[] infoBytes = definitionInfoEntityManager.findInfoJsonById(definitionInfoEntity.getInfoJsonId());
        if (infoBytes != null) {
            try {
                infoNode = (ObjectNode) objectMapper.readTree(infoBytes);
            } catch (Exception e) {
                throw new ActivitiException("Error deserializing json info for process definition " + processDefinition.getId());
            }
        }
    }
    ProcessDefinitionInfoCacheObject definitionCacheObject = new ProcessDefinitionInfoCacheObject();
    if (definitionInfoEntity == null) {
        definitionCacheObject.setRevision(0);
    } else {
        definitionCacheObject.setId(definitionInfoEntity.getId());
        definitionCacheObject.setRevision(definitionInfoEntity.getRevision());
    }
    if (infoNode == null) {
        infoNode = objectMapper.createObjectNode();
    }
    definitionCacheObject.setInfoNode(infoNode);
    deploymentManager.getProcessDefinitionInfoCache().add(processDefinition.getId(), definitionCacheObject);
}
Also used : ProcessDefinitionInfoEntityManager(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager) ActivitiException(org.activiti.engine.ActivitiException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinitionInfoEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionInfoCacheObject(org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)

Example 5 with DeploymentManager

use of org.activiti.engine.impl.persistence.deploy.DeploymentManager in project Activiti by Activiti.

the class ProcessDefinitionUtil method getBpmnModel.

public static BpmnModel getBpmnModel(String processDefinitionId) {
    DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager();
    // This will check the cache in the findDeployedProcessDefinitionById and resolveProcessDefinition method
    ProcessDefinition processDefinitionEntity = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
    return deploymentManager.resolveProcessDefinition(processDefinitionEntity).getBpmnModel();
}
Also used : DeploymentManager(org.activiti.engine.impl.persistence.deploy.DeploymentManager) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Aggregations

DeploymentManager (org.activiti.engine.impl.persistence.deploy.DeploymentManager)15 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)8 ActivitiException (org.activiti.engine.ActivitiException)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)3 ProcessDefinitionInfoCacheObject (org.activiti.engine.impl.persistence.deploy.ProcessDefinitionInfoCacheObject)3 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)2 ProcessDefinitionInfoEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntity)2 ProcessDefinitionInfoEntityManager (org.activiti.engine.impl.persistence.entity.ProcessDefinitionInfoEntityManager)2 ProcessDefinitionRetriever (org.activiti.engine.impl.util.ProcessDefinitionRetriever)2 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 Map (java.util.Map)1 AbstractDataAssociation (org.activiti.engine.impl.bpmn.data.AbstractDataAssociation)1 BpmnDeployer (org.activiti.engine.impl.bpmn.deployer.BpmnDeployer)1 ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)1 Deployer (org.activiti.engine.impl.persistence.deploy.Deployer)1 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)1