예제 #1
0
        public virtual object  Execute(ICommandContext commandContext)
        {
            if (string.IsNullOrWhiteSpace(processDefinitionId))
            {
                throw new ActivitiIllegalArgumentException("Process definition id is null");
            }

            IProcessDefinitionEntity processDefinition = commandContext.ProcessDefinitionEntityManager.FindById <IProcessDefinitionEntity>(processDefinitionId);

            if (processDefinition == null)
            {
                throw new ActivitiObjectNotFoundException("No process definition found for id = '" + processDefinitionId + "'", typeof(IProcessDefinition));
            }

            // Update category
            processDefinition.Category = category;

            // Remove process definition from cache, it will be refetched later
            IDeploymentCache <ProcessDefinitionCacheEntry> processDefinitionCache = commandContext.ProcessEngineConfiguration.ProcessDefinitionCache;

            if (processDefinitionCache != null)
            {
                processDefinitionCache.Remove(processDefinitionId);
            }

            if (commandContext.EventDispatcher.Enabled)
            {
                commandContext.EventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_UPDATED, processDefinition));
            }

            return(null);
        }
예제 #2
0
        public virtual void RemoveDeployment(string deploymentId, bool cascade)
        {
            IDeploymentEntity deployment = deploymentEntityManager.FindById <IDeploymentEntity>(new KeyValuePair <string, object>("id", deploymentId));

            if (deployment == null)
            {
                throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", typeof(IDeploymentEntity));
            }

            // Remove any process definition from the cache
            IList <IProcessDefinition> processDefinitions = (new ProcessDefinitionQueryImpl()).SetDeploymentId(deploymentId).List();
            IActivitiEventDispatcher   eventDispatcher    = Context.ProcessEngineConfiguration.EventDispatcher;

            foreach (IProcessDefinition processDefinition in processDefinitions)
            {
                // Since all process definitions are deleted by a single query, we should dispatch the events in this loop
                if (eventDispatcher.Enabled)
                {
                    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.Enabled)
            {
                eventDispatcher.DispatchEvent(ActivitiEventBuilder.CreateEntityEvent(ActivitiEventType.ENTITY_DELETED, deployment));
            }

            foreach (IProcessDefinition processDefinition in processDefinitions)
            {
                processDefinitionCache.Remove(processDefinition.Id);
            }
        }