Esempio n. 1
0
        /// <summary>
        /// Resolving the process definition will fetch the BPMN 2.0, parse it and store the <seealso cref="BpmnModel"/> in memory.
        /// </summary>
        public virtual ProcessDefinitionCacheEntry ResolveProcessDefinition(IProcessDefinition processDefinition)
        {
            string processDefinitionId = processDefinition.Id;
            string deploymentId        = processDefinition.DeploymentId;

            ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.Get(processDefinitionId);

            if (cachedProcessDefinition == null)
            {
                IDeploymentEntity deployment = deploymentEntityManager.FindById <IDeploymentEntity>(new KeyValuePair <string, object>("id", deploymentId));
                deployment.New = false;
                Deploy(deployment, null);
                cachedProcessDefinition = processDefinitionCache.Get(processDefinitionId);

                if (cachedProcessDefinition == null)
                {
                    throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
                }
            }
            return(cachedProcessDefinition);
        }
Esempio n. 2
0
        public virtual IProcessDefinition FindDeployedProcessDefinitionById(string processDefinitionId)
        {
            if (string.IsNullOrWhiteSpace(processDefinitionId))
            {
                throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
            }

            // first try the cache
            ProcessDefinitionCacheEntry cacheEntry        = processDefinitionCache.Get(processDefinitionId);
            IProcessDefinition          processDefinition = cacheEntry?.ProcessDefinition;

            if (processDefinition == null)
            {
                processDefinition = processDefinitionEntityManager.FindById <IProcessDefinitionEntity>(new KeyValuePair <string, object>("processDefinitionId", processDefinitionId));
                if (processDefinition == null)
                {
                    throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", typeof(IProcessDefinition));
                }
                processDefinition = ResolveProcessDefinition(processDefinition).ProcessDefinition;
            }
            return(processDefinition);
        }