Search in sources :

Example 1 with DeploymentEntityManager

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

the class DeploymentManager method removeDeployment.

public void removeDeployment(String deploymentId, boolean cascade) {
    DeploymentEntityManager deploymentEntityManager = Context.getCommandContext().getDeploymentEntityManager();
    DeploymentEntity deployment = deploymentEntityManager.findDeploymentById(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(Context.getCommandContext()).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());
    }
}
Also used : DeploymentEntityManager(org.activiti.engine.impl.persistence.entity.DeploymentEntityManager) DeploymentEntity(org.activiti.engine.impl.persistence.entity.DeploymentEntity) ProcessDefinitionQueryImpl(org.activiti.engine.impl.ProcessDefinitionQueryImpl) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ActivitiEventDispatcher(org.activiti.engine.delegate.event.ActivitiEventDispatcher)

Aggregations

ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 ActivitiEventDispatcher (org.activiti.engine.delegate.event.ActivitiEventDispatcher)1 ProcessDefinitionQueryImpl (org.activiti.engine.impl.ProcessDefinitionQueryImpl)1 DeploymentEntity (org.activiti.engine.impl.persistence.entity.DeploymentEntity)1 DeploymentEntityManager (org.activiti.engine.impl.persistence.entity.DeploymentEntityManager)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1