use of org.activiti.engine.impl.persistence.entity.DeploymentEntity 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());
}
}
use of org.activiti.engine.impl.persistence.entity.DeploymentEntity in project Activiti by Activiti.
the class RulesHelper method findKnowledgeBaseByDeploymentId.
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().findDeploymentById(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;
}
use of org.activiti.engine.impl.persistence.entity.DeploymentEntity in project Activiti by Activiti.
the class ChangeDeploymentTenantIdCmd method execute.
public Void execute(CommandContext commandContext) {
if (deploymentId == null) {
throw new ActivitiIllegalArgumentException("deploymentId is null");
}
// Update all entities
DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId);
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find deployment with id " + deploymentId, Deployment.class);
}
String oldTenantId = deployment.getTenantId();
deployment.setTenantId(newTenantId);
// Doing process instances, executions and tasks with direct SQL updates (otherwise would not be performant)
commandContext.getProcessDefinitionEntityManager().updateProcessDefinitionTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getExecutionEntityManager().updateExecutionTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getTaskEntityManager().updateTaskTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getEventSubscriptionEntityManager().updateEventSubscriptionTenantId(oldTenantId, newTenantId);
// Doing process definitions in memory, cause we need to clear the process definition cache
List<ProcessDefinition> processDefinitions = commandContext.getDbSqlSession().createProcessDefinitionQuery().deploymentId(deploymentId).list();
for (ProcessDefinition processDefinition : processDefinitions) {
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().remove(processDefinition.getId());
}
// Clear process definition cache
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().clear();
return null;
}
use of org.activiti.engine.impl.persistence.entity.DeploymentEntity in project Activiti by Activiti.
the class DeployCmd method execute.
public Deployment execute(CommandContext commandContext) {
DeploymentEntity deployment = deploymentBuilder.getDeployment();
deployment.setDeploymentTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
if (deploymentBuilder.isDuplicateFilterEnabled()) {
List<Deployment> existingDeployments = new ArrayList<Deployment>();
if (deployment.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(deployment.getTenantId())) {
DeploymentEntity existingDeployment = commandContext.getDeploymentEntityManager().findLatestDeploymentByName(deployment.getName());
if (existingDeployment != null) {
existingDeployments.add(existingDeployment);
}
} else {
List<Deployment> deploymentList = commandContext.getProcessEngineConfiguration().getRepositoryService().createDeploymentQuery().deploymentName(deployment.getName()).deploymentTenantId(deployment.getTenantId()).orderByDeploymentId().desc().list();
if (!deploymentList.isEmpty()) {
existingDeployments.addAll(deploymentList);
}
}
DeploymentEntity existingDeployment = null;
if (!existingDeployments.isEmpty()) {
existingDeployment = (DeploymentEntity) existingDeployments.get(0);
}
if ((existingDeployment != null) && !deploymentsDiffer(deployment, existingDeployment)) {
return existingDeployment;
}
}
deployment.setNew(true);
// Save the data
commandContext.getDeploymentEntityManager().insertDeployment(deployment);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, deployment));
}
// Deployment settings
Map<String, Object> deploymentSettings = new HashMap<String, Object>();
deploymentSettings.put(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED, deploymentBuilder.isBpmn20XsdValidationEnabled());
deploymentSettings.put(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED, deploymentBuilder.isProcessValidationEnabled());
// Actually deploy
commandContext.getProcessEngineConfiguration().getDeploymentManager().deploy(deployment, deploymentSettings);
if (deploymentBuilder.getProcessDefinitionsActivationDate() != null) {
scheduleProcessDefinitionActivation(commandContext, deployment);
}
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, deployment));
}
return deployment;
}
use of org.activiti.engine.impl.persistence.entity.DeploymentEntity in project Activiti by Activiti.
the class DeploymentManager method resolveProcessDefinition.
public ProcessDefinitionEntity resolveProcessDefinition(ProcessDefinitionEntity processDefinition) {
String processDefinitionId = processDefinition.getId();
String deploymentId = processDefinition.getDeploymentId();
processDefinition = processDefinitionCache.get(processDefinitionId);
if (processDefinition == null) {
DeploymentEntity deployment = Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(deploymentId);
deployment.setNew(false);
deploy(deployment, null);
processDefinition = processDefinitionCache.get(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
}
}
return processDefinition;
}
Aggregations