コード例 #1
0
 protected internal virtual void Validate()
 {
     EnsureUtil.EnsureOnlyOneNotNull("Authorization must either have a 'userId' or a 'groupId'.", Authorization.UserId,
                                     Authorization.GroupId);
     EnsureUtil.EnsureNotNull("Authorization 'resourceType' cannot be null.", "authorization.getResource()",
                              Authorization.GetResource());
 }
コード例 #2
0
        public virtual IProcessInstanceWithVariables ExecuteWithVariablesInReturn(bool skipCustomListeners, bool skipIoMappings)
        {
            EnsureUtil.EnsureOnlyOneNotNull("either process definition id or key must be set", ProcessDefinitionId, ProcessDefinitionKey);

            if (IsTenantIdSet && !ReferenceEquals(ProcessDefinitionId, null))
            {
                throw Log.ExceptionStartProcessInstanceByIdAndTenantId();
            }

            ICommand <IProcessInstanceWithVariables> command;

            if (ModificationBuilder.ModificationOperations.Count == 0)
            {
                if (skipCustomListeners || skipIoMappings)
                {
                    throw Log.ExceptionStartProcessInstanceAtStartActivityAndSkipListenersOrMapping();
                }
                // start at the default start activity
                command = new StartProcessInstanceCmd(this);
            }
            else
            {
                // start at any activity using the instructions
                ModificationBuilder.SkipCustomListeners = skipCustomListeners;
                ModificationBuilder.SkipIoMappings      = skipIoMappings;

                command = new StartProcessInstanceAtActivitiesCmd(this);
            }

            return(_commandExecutor.Execute(command));
        }
コード例 #3
0
 public InstantiationStack(IList <IPvmActivity> activities, IPvmActivity targetActivity,
                           IPvmTransition targetTransition)
 {
     EnsureUtil.EnsureOnlyOneNotNull("target must be either a transition or an activity", targetActivity,
                                     targetTransition);
     this.Activities = activities;
     // TODO: make this a subclass that contains targetActivity and targetTransition?!
     this.TargetActivity   = targetActivity;
     this.TargetTransition = targetTransition;
 }
コード例 #4
0
        public virtual IDmnDecisionResult Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureOnlyOneNotNull("either decision definition id or key must be set", DecisionDefinitionId,
                                            DecisionDefinitionKey);

            var decisionDefinition = GetDecisionDefinition(commandContext);

            foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
            {
                checker.CheckEvaluateDecision(decisionDefinition);
            }

            return(DoEvaluateDecision(decisionDefinition, Variables));
        }
コード例 #5
0
        protected internal virtual void ValidateParameters()
        {
            EnsureUtil.EnsureOnlyOneNotNull(
                "Need to specify either a process instance id, a process definition id or a process definition key.",
                ProcessInstanceId, ProcessDefinitionId, ProcessDefinitionKey);

            if (ProcessDefinitionTenantIdSet &&
                (!ReferenceEquals(ProcessInstanceId, null) || !ReferenceEquals(ProcessDefinitionId, null)))
            {
                //throw LOG.exceptionUpdateSuspensionStateForTenantOnlyByProcessDefinitionKey();
            }

            EnsureUtil.EnsureNotNull("commandExecutor", CommandExecutor);
        }
コード例 #6
0
        /// <summary>
        /// 查询已部署的流程定义
        /// </summary>
        /// <param name="commandContext"></param>
        /// <returns></returns>
        public virtual ProcessDefinitionEntity Execute(CommandContext commandContext)
        {
            EnsureUtil.EnsureOnlyOneNotNull("either process definition id or key must be set", ProcessDefinitionId,
                                            ProcessDefinitionKey);

            var processDefinition = Find(commandContext);

            if (CheckReadPermission)
            {
                foreach (var checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
                {
                    checker.CheckReadProcessDefinition(processDefinition);
                }
            }

            return(processDefinition);
        }
コード例 #7
0
        public virtual void DeleteHistoricDetailsByProcessCaseInstanceId(string historicProcessInstanceId, string historicCaseInstanceId)
        {
            EnsureUtil.EnsureOnlyOneNotNull("Only the process instance or case instance id should be set", historicProcessInstanceId, historicCaseInstanceId);
            if (HistoryEnabled)
            {
                // delete entries in DB
                IList <IHistoricDetail> historicDetails;
                if (historicProcessInstanceId != null)
                {
                    historicDetails = FindHistoricDetailsByProcessInstanceId(historicProcessInstanceId);
                }
                else
                {
                    historicDetails = FindHistoricDetailsByCaseInstanceId(historicCaseInstanceId);
                }
                if (historicDetails != null)
                {
                    foreach (IHistoricDetail historicDetail in historicDetails)
                    {
                        if (historicDetail is HistoricDetailEventEntity)
                        {
                            ((HistoricDetailEventEntity)historicDetail).Delete();
                        }
                        else
                        {
                            throw new System.NotImplementedException("类型转换异常HistoricDetailEventEntity");
                        }
                    }
                }

                //throw new System.NotImplementedException("EF缓存列表");
                //TODO 不需要再次清理缓存?delete entries in Cache
                //IList<HistoricDetailEventEntity> cachedHistoricDetails = Get();// DbEntityManager.GetCachedEntitiesByType< HistoricDetailEventEntity>(typeof(HistoricDetailEventEntity));
                //foreach (HistoricDetailEventEntity historicDetail in cachedHistoricDetails)
                //{
                //    // make sure we only delete the right ones (as we cannot make a proper query in the cache)
                //    if ((historicProcessInstanceId != null && historicProcessInstanceId.Equals(historicDetail.ProcessInstanceId)) || (historicCaseInstanceId != null && historicCaseInstanceId.Equals(historicDetail.CaseInstanceId)))
                //    {
                //        historicDetail.Delete();
                //    }
                //}
            }
        }
コード例 #8
0
        public virtual IDmnDecisionResult Evaluate()
        {
            EnsureUtil.EnsureOnlyOneNotNull(typeof(NotValidException), "either decision definition id or key must be set",
                                            decisionDefinitionId, decisionDefinitionKey);

            if (IsTenantIdSet && !ReferenceEquals(DecisionDefinitionId, null))
            {
                throw Log.ExceptionEvaluateDecisionDefinitionByIdAndTenantId();
            }

            try
            {
                return(CommandExecutor.Execute(new EvaluateDecisionCmd(this)));
            }
            catch (NullValueException e)
            {
                throw new NotValidException(e.Message, e);
            }
            catch (DecisionDefinitionNotFoundException e)
            {
                throw new NotFoundException(e.Message, e);
            }
        }
コード例 #9
0
        protected internal virtual void DeleteHistoricVariableInstancesByProcessCaseInstanceId(string historicProcessInstanceId, string historicCaseInstanceId)
        {
            EnsureUtil.EnsureOnlyOneNotNull("Only the process instance or case instance id should be set", historicProcessInstanceId, historicCaseInstanceId);
            if (HistoryEnabled)
            {
                //throw new NotImplementedException();
                // delete entries in DB
                IList <IHistoricVariableInstance> historicVariableInstances;
                if (historicProcessInstanceId != null)
                {
                    historicVariableInstances = FindHistoricVariableInstancesByProcessInstanceId(historicProcessInstanceId);
                }
                else
                {
                    historicVariableInstances = FindHistoricVariableInstancesByCaseInstanceId(historicCaseInstanceId);
                }
                if (historicVariableInstances != null)
                {
                    foreach (IHistoricVariableInstance historicVariableInstance in historicVariableInstances)
                    {
                        ((HistoricVariableInstanceEntity)historicVariableInstance).Delete();
                    }
                }


                //// delete entries in Cache
                //IList<HistoricVariableInstanceEntity> cachedHistoricVariableInstances = DbEntityManager.GetCachedEntitiesByType(typeof(HistoricVariableInstanceEntity));
                //foreach (HistoricVariableInstanceEntity historicVariableInstance in cachedHistoricVariableInstances)
                //{
                //    // make sure we only delete the right ones (as we cannot make a proper query in the cache)
                //    if ((historicProcessInstanceId != null && historicProcessInstanceId.Equals(historicVariableInstance.ProcessInstanceId)) || (historicCaseInstanceId != null && historicCaseInstanceId.Equals(historicVariableInstance.CaseInstanceId)))
                //    {
                //        historicVariableInstance.Delete();
                //    }
                //}
            }
        }