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);
}
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;
}
}
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);
}
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);
}
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();
}
Aggregations