public DeploymentEntity getDeployment() { String deploymentId = getProcessDefinition().getDeploymentId(); DeploymentEntity deployment = Context.getCommandContext().getDeploymentEntityManager().findById(deploymentId); return deployment; } }
public InputStream execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("deploymentId is null"); } if (resourceName == null) { throw new ActivitiIllegalArgumentException("resourceName is null"); } ResourceEntity resource = commandContext.getResourceEntityManager().findResourceByDeploymentIdAndResourceName(deploymentId, resourceName); if (resource == null) { if (commandContext.getDeploymentEntityManager().findById(deploymentId) == null) { throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class); } else { throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class); } } return new ByteArrayInputStream(resource.getBytes()); }
/** * Resolving the process definition will fetch the BPMN 2.0, parse it and store the {@link BpmnModel} in memory. */ public ProcessDefinitionCacheEntry resolveProcessDefinition(ProcessDefinition processDefinition) { String processDefinitionId = processDefinition.getId(); String deploymentId = processDefinition.getDeploymentId(); ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.get(processDefinitionId); if (cachedProcessDefinition == null) { CommandContext commandContext = Context.getCommandContext(); DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId); deployment.setNew(false); deploy(deployment, null); cachedProcessDefinition = processDefinitionCache.get(processDefinitionId); if (cachedProcessDefinition == null) { throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache"); } } return cachedProcessDefinition; }
public Void execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("Deployment id is null"); } DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class); } // Update category deployment.setKey(key); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment)); } return null; }
public Void execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("Deployment id is null"); } DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class); } // Update category deployment.setCategory(category); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment)); } return null; }
public void removeDeployment(String deploymentId, boolean cascade) { DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", DeploymentEntity.class); } // Remove any process definition from the cache List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ActivitiEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher(); for (ProcessDefinition processDefinition : processDefinitions) { // Since all process definitions are deleted by a single query, we should dispatch the events in this loop if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, processDefinition)); } } // Delete data deploymentEntityManager.deleteDeployment(deploymentId, cascade); // Since we use a delete by query, delete-events are not automatically dispatched if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, deployment)); } for (ProcessDefinition processDefinition : processDefinitions) { processDefinitionCache.remove(processDefinition.getId()); } }
DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("Could not find deployment with id " + deploymentId, Deployment.class);
public DeploymentEntity getDeployment() { String deploymentId = getProcessDefinition().getDeploymentId(); DeploymentEntity deployment = Context.getCommandContext().getDeploymentEntityManager().findById(deploymentId); return deployment; } }
public InputStream execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("deploymentId is null"); } if (resourceName == null) { throw new ActivitiIllegalArgumentException("resourceName is null"); } ResourceEntity resource = commandContext.getResourceEntityManager().findResourceByDeploymentIdAndResourceName(deploymentId, resourceName); if (resource == null) { if (commandContext.getDeploymentEntityManager().findById(deploymentId) == null) { throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class); } else { throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class); } } return new ByteArrayInputStream(resource.getBytes()); }
public static StartFormHandler getStartFormHandler(CommandContext commandContext, ProcessDefinition processDefinition) { StartFormHandler startFormHandler = new DefaultStartFormHandler(); org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId()); FlowElement initialFlowElement = process.getInitialFlowElement(); if (initialFlowElement instanceof StartEvent) { StartEvent startEvent = (StartEvent) initialFlowElement; List<FormProperty> formProperties = startEvent.getFormProperties(); String formKey = startEvent.getFormKey(); DeploymentEntity deploymentEntity = commandContext.getDeploymentEntityManager().findById(processDefinition.getDeploymentId()); startFormHandler.parseConfiguration(formProperties, formKey, deploymentEntity, processDefinition); return startFormHandler; } return null; }
public static TaskFormHandler getTaskFormHandlder(String processDefinitionId, String taskId) { org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId); FlowElement flowElement = process.getFlowElement(taskId, true); if (flowElement instanceof UserTask) { UserTask userTask = (UserTask) flowElement; ProcessDefinition processDefinitionEntity = ProcessDefinitionUtil.getProcessDefinition(processDefinitionId); DeploymentEntity deploymentEntity = Context.getProcessEngineConfiguration() .getDeploymentEntityManager().findById(processDefinitionEntity.getDeploymentId()); TaskFormHandler taskFormHandler = new DefaultTaskFormHandler(); taskFormHandler.parseConfiguration(userTask.getFormProperties(), userTask.getFormKey(), deploymentEntity, processDefinitionEntity); return taskFormHandler; } return null; }
public Void execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("Deployment id is null"); } DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class); } if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(deployment.getEngineVersion())) { return null; } // Update category deployment.setKey(key); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment)); } return null; }
public Void execute(CommandContext commandContext) { if (deploymentId == null) { throw new ActivitiIllegalArgumentException("Deployment id is null"); } DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class); } if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(deployment.getEngineVersion())) { commandContext.getProcessEngineConfiguration().getActiviti5CompatibilityHandler().setDeploymentCategory(deploymentId, category); } // Update category deployment.setCategory(category); if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment)); } return null; }
public static KnowledgeBase findKnowledgeBaseByDeploymentId(String deploymentId) { DeploymentCache<Object> knowledgeBaseCache = Context.getProcessEngineConfiguration().getDeploymentManager().getKnowledgeBaseCache(); KnowledgeBase knowledgeBase = (KnowledgeBase) knowledgeBaseCache.get(deploymentId); if (knowledgeBase == null) { DeploymentEntity deployment = Context.getCommandContext().getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("no deployment with id " + deploymentId, Deployment.class); } Context.getProcessEngineConfiguration().getDeploymentManager().deploy(deployment); knowledgeBase = (KnowledgeBase) knowledgeBaseCache.get(deploymentId); if (knowledgeBase == null) { throw new ActivitiException("deployment " + deploymentId + " doesn't contain any rules"); } } return knowledgeBase; } }
/** * Resolving the process definition will fetch the BPMN 2.0, parse it and store the {@link BpmnModel} in memory. */ public ProcessDefinitionCacheEntry resolveProcessDefinition(ProcessDefinition processDefinition) { String processDefinitionId = processDefinition.getId(); String deploymentId = processDefinition.getDeploymentId(); ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.get(processDefinitionId); if (cachedProcessDefinition == null) { CommandContext commandContext = Context.getCommandContext(); if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && Activiti5Util.isActiviti5ProcessDefinition(Context.getCommandContext(), processDefinition)) { return Activiti5Util.getActiviti5CompatibilityHandler().resolveProcessDefinition(processDefinition); } DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId); deployment.setNew(false); deploy(deployment, null); cachedProcessDefinition = processDefinitionCache.get(processDefinitionId); if (cachedProcessDefinition == null) { throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache"); } } return cachedProcessDefinition; }
public void removeDeployment(String deploymentId, boolean cascade) { DeploymentEntity deployment = deploymentEntityManager.findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", DeploymentEntity.class); } if (processEngineConfiguration.isActiviti5CompatibilityEnabled() && Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(deployment.getEngineVersion())) { processEngineConfiguration.getActiviti5CompatibilityHandler().deleteDeployment(deploymentId, cascade); return; } // Remove any process definition from the cache List<ProcessDefinition> processDefinitions = new ProcessDefinitionQueryImpl().deploymentId(deploymentId).list(); ActivitiEventDispatcher eventDispatcher = Context.getProcessEngineConfiguration().getEventDispatcher(); for (ProcessDefinition processDefinition : processDefinitions) { // Since all process definitions are deleted by a single query, we should dispatch the events in this loop if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, processDefinition)); } } // Delete data deploymentEntityManager.deleteDeployment(deploymentId, cascade); // Since we use a delete by query, delete-events are not automatically dispatched if (eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, deployment)); } for (ProcessDefinition processDefinition : processDefinitions) { processDefinitionCache.remove(processDefinition.getId()); } }
DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId); if (deployment == null) { throw new ActivitiObjectNotFoundException("Could not find deployment with id " + deploymentId, Deployment.class);