예제 #1
0
        protected internal virtual IList <CorrelationHandlerResult> correlateStartMessageByEventSubscription(CommandContext commandContext, string messageName, CorrelationSet correlationSet)
        {
            IList <CorrelationHandlerResult> results = new List <CorrelationHandlerResult>();
            DeploymentCache deploymentCache          = commandContext.ProcessEngineConfiguration.DeploymentCache;

            IList <EventSubscriptionEntity> messageEventSubscriptions = findMessageStartEventSubscriptions(commandContext, messageName, correlationSet);

            foreach (EventSubscriptionEntity messageEventSubscription in messageEventSubscriptions)
            {
                if (!string.ReferenceEquals(messageEventSubscription.Configuration, null))
                {
                    string processDefinitionId = messageEventSubscription.Configuration;
                    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
                    // only an active process definition will be returned
                    if (processDefinition != null && !processDefinition.Suspended)
                    {
                        CorrelationHandlerResult result = CorrelationHandlerResult.matchedProcessDefinition(processDefinition, messageEventSubscription.ActivityId);
                        results.Add(result);
                    }
                    else
                    {
                        LOG.couldNotFindProcessDefinitionForEventSubscription(messageEventSubscription, processDefinitionId);
                    }
                }
            }
            return(results);
        }
예제 #2
0
        public virtual IList <CorrelationHandlerResult> correlateStartMessages(CommandContext commandContext, string messageName, CorrelationSet correlationSet)
        {
            if (string.ReferenceEquals(messageName, null))
            {
                // ignore empty message name
                return(Collections.emptyList());
            }

            if (string.ReferenceEquals(correlationSet.ProcessDefinitionId, null))
            {
                return(correlateStartMessageByEventSubscription(commandContext, messageName, correlationSet));
            }
            else
            {
                CorrelationHandlerResult correlationResult = correlateStartMessageByProcessDefinitionId(commandContext, messageName, correlationSet.ProcessDefinitionId);
                if (correlationResult != null)
                {
                    return(Collections.singletonList(correlationResult));
                }
                else
                {
                    return(Collections.emptyList());
                }
            }
        }
예제 #3
0
        public static CorrelationHandlerResult matchedExecution(ExecutionEntity executionEntity)
        {
            CorrelationHandlerResult messageCorrelationResult = new CorrelationHandlerResult();

            messageCorrelationResult.resultType      = MessageCorrelationResultType.Execution;
            messageCorrelationResult.executionEntity = executionEntity;
            return(messageCorrelationResult);
        }
예제 #4
0
        public static CorrelationHandlerResult matchedProcessDefinition(ProcessDefinitionEntity processDefinitionEntity, string startEventActivityId)
        {
            CorrelationHandlerResult messageCorrelationResult = new CorrelationHandlerResult();

            messageCorrelationResult.processDefinitionEntity = processDefinitionEntity;
            messageCorrelationResult.startEventActivityId    = startEventActivityId;
            messageCorrelationResult.resultType = MessageCorrelationResultType.ProcessDefinition;
            return(messageCorrelationResult);
        }
예제 #5
0
        protected internal virtual CorrelationHandlerResult correlateStartMessageByProcessDefinitionId(CommandContext commandContext, string messageName, string processDefinitionId)
        {
            DeploymentCache         deploymentCache   = commandContext.ProcessEngineConfiguration.DeploymentCache;
            ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

            // only an active process definition will be returned
            if (processDefinition != null && !processDefinition.Suspended)
            {
                string startActivityId = findStartActivityIdByMessage(processDefinition, messageName);
                if (!string.ReferenceEquals(startActivityId, null))
                {
                    return(CorrelationHandlerResult.matchedProcessDefinition(processDefinition, startActivityId));
                }
            }
            return(null);
        }
예제 #6
0
        protected internal virtual IList <CorrelationHandlerResult> correlateMessageToExecutions(CommandContext commandContext, string messageName, CorrelationSet correlationSet)
        {
            ExecutionQueryImpl query = new ExecutionQueryImpl();

            IDictionary <string, object> correlationKeys = correlationSet.CorrelationKeys;

            if (correlationKeys != null)
            {
                foreach (KeyValuePair <string, object> correlationKey in correlationKeys.SetOfKeyValuePairs())
                {
                    query.processVariableValueEquals(correlationKey.Key, correlationKey.Value);
                }
            }

            IDictionary <string, object> localCorrelationKeys = correlationSet.LocalCorrelationKeys;

            if (localCorrelationKeys != null)
            {
                foreach (KeyValuePair <string, object> correlationKey in localCorrelationKeys.SetOfKeyValuePairs())
                {
                    query.variableValueEquals(correlationKey.Key, correlationKey.Value);
                }
            }

            string businessKey = correlationSet.BusinessKey;

            if (!string.ReferenceEquals(businessKey, null))
            {
                query.processInstanceBusinessKey(businessKey);
            }

            string processInstanceId = correlationSet.ProcessInstanceId;

            if (!string.ReferenceEquals(processInstanceId, null))
            {
                query.processInstanceId(processInstanceId);
            }

            if (!string.ReferenceEquals(messageName, null))
            {
                query.messageEventSubscriptionName(messageName);
            }
            else
            {
                query.messageEventSubscription();
            }

            if (correlationSet.isTenantIdSet)
            {
                string tenantId = correlationSet.TenantId;
                if (!string.ReferenceEquals(tenantId, null))
                {
                    query.tenantIdIn(tenantId);
                }
                else
                {
                    query.withoutTenantId();
                }
            }

            // restrict to active executions
            query.active();

            IList <Execution> matchingExecutions = query.evaluateExpressionsAndExecuteList(commandContext, null);

            IList <CorrelationHandlerResult> result = new List <CorrelationHandlerResult>(matchingExecutions.Count);

            foreach (Execution matchingExecution in matchingExecutions)
            {
                CorrelationHandlerResult correlationResult = CorrelationHandlerResult.matchedExecution((ExecutionEntity)matchingExecution);
                if (!commandContext.DbEntityManager.isDeleted(correlationResult.ExecutionEntity))
                {
                    result.Add(correlationResult);
                }
            }

            return(result);
        }
예제 #7
0
 public MessageCorrelationResultImpl(CorrelationHandlerResult handlerResult)
 {
     this.execution  = handlerResult.Execution;
     this.resultType = handlerResult.ResultType;
 }