Exemple #1
0
        public virtual void logJobDefinitionOperation(string operation, string jobDefinitionId, string processDefinitionId, string processDefinitionKey, PropertyChange propertyChange)
        {
            if (UserOperationLogEnabled)
            {
                UserOperationLogContext             context      = new UserOperationLogContext();
                UserOperationLogContextEntryBuilder entryBuilder = UserOperationLogContextEntryBuilder.entry(operation, EntityTypes.JOB_DEFINITION).jobDefinitionId(jobDefinitionId).processDefinitionId(processDefinitionId).processDefinitionKey(processDefinitionKey).propertyChanges(propertyChange).category(org.camunda.bpm.engine.history.UserOperationLogEntry_Fields.CATEGORY_OPERATOR);

                if (!string.ReferenceEquals(jobDefinitionId, null))
                {
                    JobDefinitionEntity jobDefinition = JobDefinitionManager.findById(jobDefinitionId);
                    // Backward compatibility
                    if (jobDefinition != null)
                    {
                        entryBuilder.inContextOf(jobDefinition);
                    }
                }
                else if (!string.ReferenceEquals(processDefinitionId, null))
                {
                    ProcessDefinitionEntity definition = ProcessDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
                    // Backward compatibility
                    if (definition != null)
                    {
                        entryBuilder.inContextOf(definition);
                    }
                }

                context.addEntry(entryBuilder.create());

                fireUserOperationLog(context);
            }
        }
Exemple #2
0
        /// <summary>
        /// Deletes the given process definition from the database and cache.
        /// If cascadeToHistory and cascadeToInstances is set to true it deletes
        /// the history and the process instances.
        ///
        /// *Note*: If more than one process definition, from one deployment, is deleted in
        /// a single transaction and the cascadeToHistory and cascadeToInstances flag was set to true it
        /// can cause a dirty deployment cache. The process instances of ALL process definitions must be deleted,
        /// before every process definition can be deleted! In such cases the cascadeToInstances flag
        /// have to set to false!
        ///
        /// On deletion of all process instances, the task listeners will be deleted as well.
        /// Deletion of tasks and listeners needs the redeployment of deployments.
        /// It can cause to problems if is done sequential with the deletion of process definition
        /// in a single transaction.
        ///
        /// *For example*:
        /// Deployment contains two process definition. First process definition
        /// and instances will be removed, also cleared from the cache.
        /// Second process definition will be removed and his instances.
        /// Deletion of instances will cause redeployment this deploys again
        /// first into the cache. Only the second will be removed from cache and
        /// first remains in the cache after the deletion process.
        /// </summary>
        /// <param name="processDefinition"> the process definition which should be deleted </param>
        /// <param name="processDefinitionId"> the id of the process definition </param>
        /// <param name="cascadeToHistory"> if true the history will deleted as well </param>
        /// <param name="cascadeToInstances"> if true the process instances are deleted as well </param>
        /// <param name="skipCustomListeners"> if true skips the custom listeners on deletion of instances </param>
        /// <param name="skipIoMappings"> specifies whether input/output mappings for tasks should be invoked </param>
        public virtual void deleteProcessDefinition(ProcessDefinition processDefinition, string processDefinitionId, bool cascadeToHistory, bool cascadeToInstances, bool skipCustomListeners, bool skipIoMappings)
        {
            if (cascadeToHistory)
            {
                cascadeDeleteHistoryForProcessDefinition(processDefinitionId);
                if (cascadeToInstances)
                {
                    cascadeDeleteProcessInstancesForProcessDefinition(processDefinitionId, skipCustomListeners, skipIoMappings);
                }
            }
            else
            {
                ProcessInstanceQueryImpl procInstQuery = (new ProcessInstanceQueryImpl()).processDefinitionId(processDefinitionId);
                long processInstanceCount = ProcessInstanceManager.findProcessInstanceCountByQueryCriteria(procInstQuery);
                if (processInstanceCount != 0)
                {
                    throw LOG.deleteProcessDefinitionWithProcessInstancesException(processDefinitionId, processInstanceCount);
                }
            }

            // remove related authorization parameters in IdentityLink table
            IdentityLinkManager.deleteIdentityLinksByProcDef(processDefinitionId);

            // remove timer start events:
            deleteTimerStartEventsForProcessDefinition(processDefinition);

            //delete process definition from database
            DbEntityManager.delete(typeof(ProcessDefinitionEntity), "deleteProcessDefinitionsById", processDefinitionId);

            // remove process definition from cache:
            Context.ProcessEngineConfiguration.DeploymentCache.removeProcessDefinition(processDefinitionId);

            deleteSubscriptionsForProcessDefinition(processDefinitionId);

            // delete job definitions
            JobDefinitionManager.deleteJobDefinitionsByProcessDefinitionId(processDefinition.Id);
        }