Beispiel #1
0
        public EvalFilterNode(
            PatternAgentInstanceContext context,
            EvalFilterFactoryNode factoryNode)
            : base(context)
        {
            this.factoryNode = factoryNode;

            FilterValueSetParam[][] addendum = null;
            if (context.AgentInstanceContext.AgentInstanceFilterProxy != null) {
                addendum = context.AgentInstanceContext.AgentInstanceFilterProxy.GetAddendumFilters(
                    factoryNode.FilterSpec,
                    context.AgentInstanceContext);
            }

            var contextPathAddendum = context.GetFilterAddendumForContextPath(factoryNode.FilterSpec);
            if (contextPathAddendum != null) {
                if (addendum == null) {
                    addendum = contextPathAddendum;
                }
                else {
                    addendum = FilterAddendumUtil.MultiplyAddendum(addendum, contextPathAddendum);
                }
            }

            AddendumFilters = addendum;
        }
Beispiel #2
0
        private static FilterValueSetParam[][] ComputeAddendum(
            object[] parentPartitionKeys,
            FilterSpecActivatable filterCallback,
            bool forStatement,
            ContextControllerStatementDesc optionalStatementDesc,
            ContextControllerFactory[] controllerFactories,
            IDictionary<int, ContextControllerStatementDesc> statements,
            AgentInstanceContext agentInstanceContextCreate)
        {
            var result = new FilterValueSetParam[0][];
            for (var i = 0; i < parentPartitionKeys.Length; i++) {
                var addendumForController = controllerFactories[i]
                    .PopulateFilterAddendum(
                        filterCallback,
                        forStatement,
                        i + 1,
                        parentPartitionKeys[i],
                        optionalStatementDesc,
                        statements,
                        agentInstanceContextCreate);
                result = FilterAddendumUtil.MultiplyAddendum(result, addendumForController);
            }

            return result;
        }
Beispiel #3
0
        public static FilterValueSetParam[][] GetAddendumFilters(
            object getterKey,
            FilterSpecActivatable filtersSpec,
            ContextControllerDetailKeyed keyedSpec,
            bool includePartition,
            ContextControllerStatementDesc optionalStatementDesc,
            AgentInstanceContext agentInstanceContext)
        {
            // determine whether create-named-window
            var isCreateWindow = optionalStatementDesc != null &&
                                 optionalStatementDesc.Lightweight.StatementContext.StatementInformationals
                                     .StatementType ==
                                 StatementType.CREATE_WINDOW;
            ContextControllerDetailKeyedItem foundPartition = null;

            if (!isCreateWindow) {
                foreach (var partitionItem in keyedSpec.Items) {
                    var typeOrSubtype = EventTypeUtility.IsTypeOrSubTypeOf(
                        filtersSpec.FilterForEventType,
                        partitionItem.FilterSpecActivatable.FilterForEventType);
                    if (typeOrSubtype) {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }
            else {
                var factory = (StatementAgentInstanceFactoryCreateNW) optionalStatementDesc.Lightweight.StatementContext
                    .StatementAIFactoryProvider
                    .Factory;
                var declaredAsName = factory.AsEventTypeName;
                foreach (var partitionItem in keyedSpec.Items) {
                    if (partitionItem.FilterSpecActivatable.FilterForEventType.Name.Equals(declaredAsName)) {
                        foundPartition = partitionItem;
                        break;
                    }
                }
            }

            if (foundPartition == null) {
                return null;
            }

            var lookupables = foundPartition.Lookupables;
            var addendumFilters = new FilterValueSetParam[lookupables.Length];
            if (lookupables.Length == 1) {
                addendumFilters[0] = GetFilterMayEqualOrNull(lookupables[0], getterKey);
            }
            else {
                var keys = getterKey is HashableMultiKey ? ((HashableMultiKey) getterKey).Keys : (object[]) getterKey;
                for (var i = 0; i < lookupables.Length; i++) {
                    addendumFilters[i] = GetFilterMayEqualOrNull(lookupables[i], keys[i]);
                }
            }

            var addendum = new FilterValueSetParam[1][];
            addendum[0] = addendumFilters;

            var partitionFilters = foundPartition.FilterSpecActivatable.GetValueSet(
                null,
                null,
                agentInstanceContext,
                agentInstanceContext.StatementContextFilterEvalEnv);
            if (partitionFilters != null && includePartition) {
                addendum = FilterAddendumUtil.AddAddendum(partitionFilters, addendum[0]);
            }

            return addendum;
        }