protected internal virtual IList <IProcessDefinitionEntity> FindProcessDefinition(ICommandContext commandContext)
        {
            // If process definition is already provided (eg. when command is called through the DeployCmd)
            // we don't need to do an extra database fetch and we can simply return it, wrapped in a list
            if (processDefinitionEntity != null)
            {
                return(new List <IProcessDefinitionEntity>(new IProcessDefinitionEntity[] { processDefinitionEntity }));
            }

            // Validation of input parameters
            if (string.IsNullOrWhiteSpace(processDefinitionId) && string.IsNullOrWhiteSpace(processDefinitionKey))
            {
                throw new ActivitiIllegalArgumentException("Process definition id or key cannot be null");
            }

            IList <IProcessDefinitionEntity> processDefinitionEntities = new List <IProcessDefinitionEntity>();
            IProcessDefinitionEntityManager  processDefinitionManager  = commandContext.ProcessDefinitionEntityManager;

            if (!string.IsNullOrWhiteSpace(processDefinitionId))
            {
                IProcessDefinitionEntity processDefinitionEntity = processDefinitionManager.FindById <IProcessDefinitionEntity>(new KeyValuePair <string, object>("id", processDefinitionId));
                if (processDefinitionEntity == null)
                {
                    throw new ActivitiObjectNotFoundException("Cannot find process definition for id '" + processDefinitionId + "'", typeof(IProcessDefinition));
                }
                processDefinitionEntities.Add(processDefinitionEntity);
            }
            else
            {
                IProcessDefinitionQuery query = new ProcessDefinitionQueryImpl(commandContext).SetProcessDefinitionKey(processDefinitionKey);

                if (tenantId is null || ProcessEngineConfiguration.NO_TENANT_ID.Equals(tenantId))
                {
                    query.SetProcessDefinitionWithoutTenantId();
                }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves each process definition.  It is assumed that the deployment is new, the definitions
        /// have never been saved before, and that they have all their values properly set up.
        /// </summary>
        protected internal virtual void PersistProcessDefinitionsAndAuthorizations(ParsedDeployment parsedDeployment)
        {
            ICommandContext commandContext = Context.CommandContext;
            IProcessDefinitionEntityManager processDefinitionManager = commandContext.ProcessDefinitionEntityManager;

            foreach (IProcessDefinitionEntity processDefinition in parsedDeployment.AllProcessDefinitions)
            {
                processDefinitionManager.Insert(processDefinition, false);
                bpmnDeploymentHelper.AddAuthorizationsForNewProcessDefinition(parsedDeployment.GetProcessModelForProcessDefinition(processDefinition), processDefinition);
            }
        }
Ejemplo n.º 3
0
        public static IProcessDefinitionEntity GetProcessDefinitionFromDatabase(string processDefinitionId)
        {
            IProcessDefinitionEntityManager processDefinitionEntityManager = Context.ProcessEngineConfiguration.ProcessDefinitionEntityManager;
            IProcessDefinitionEntity        processDefinition = processDefinitionEntityManager.FindById <IProcessDefinitionEntity>(new KeyValuePair <string, object>("processDefinitionId", processDefinitionId));

            if (processDefinition == null)
            {
                throw new ActivitiException("No process definition found with id " + processDefinitionId);
            }

            return(processDefinition);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the most recent persisted process definition that matches this one for tenant and key.
        /// If none is found, returns null.  This method assumes that the tenant and key are properly
        /// set on the process definition entity.
        /// </summary>
        public virtual IProcessDefinitionEntity GetMostRecentVersionOfProcessDefinition(IProcessDefinitionEntity processDefinition)
        {
            string key      = processDefinition.Key;
            string tenantId = processDefinition.TenantId;
            IProcessDefinitionEntityManager processDefinitionManager = Context.CommandContext.ProcessEngineConfiguration.ProcessDefinitionEntityManager;

            IProcessDefinitionEntity existingDefinition;

            if (!(tenantId is null) && !tenantId.Equals(ProcessEngineConfiguration.NO_TENANT_ID))
            {
                existingDefinition = processDefinitionManager.FindLatestProcessDefinitionByKeyAndTenantId(key, tenantId);
            }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the persisted version of the already-deployed process definition.  Note that this is
        /// different from <seealso cref="#getMostRecentVersionOfProcessDefinition"/> as it looks specifically for
        /// a process definition that is already persisted and attached to a particular deployment,
        /// rather than the latest version across all deployments.
        /// </summary>
        public virtual IProcessDefinitionEntity GetPersistedInstanceOfProcessDefinition(IProcessDefinitionEntity processDefinition)
        {
            string deploymentId = processDefinition.DeploymentId;

            if (string.IsNullOrWhiteSpace(processDefinition.DeploymentId))
            {
                throw new InvalidOperationException("Provided process definition must have a deployment id.");
            }

            IProcessDefinitionEntityManager processDefinitionManager = Context.CommandContext.ProcessEngineConfiguration.ProcessDefinitionEntityManager;
            IProcessDefinitionEntity        persistedProcessDefinition;

            if (processDefinition.TenantId is null || ProcessEngineConfiguration.NO_TENANT_ID.Equals(processDefinition.TenantId))
            {
                persistedProcessDefinition = processDefinitionManager.FindProcessDefinitionByDeploymentAndKey(deploymentId, processDefinition.Key);
            }