public ContextControllerConditionPattern(EPServicesContext servicesContext, AgentInstanceContext agentInstanceContext, ContextDetailConditionPattern endpointPatternSpec, ContextControllerConditionCallback callback, ContextInternalFilterAddendum filterAddendum, bool startEndpoint, ContextStatePathKey contextStatePathKey) { _servicesContext = servicesContext; _agentInstanceContext = agentInstanceContext; _endpointPatternSpec = endpointPatternSpec; _callback = callback; _filterAddendum = filterAddendum; _isStartEndpoint = startEndpoint; _contextStatePathKey = contextStatePathKey; }
private Pair <MatchEventSpec, ISet <string> > ValidatePatternContextConditionPattern( StatementContext statementContext, ContextDetailConditionPattern pattern, ISet <string> eventTypesReferenced, MatchEventSpec priorMatches, ISet <string> priorAllTags) { var raw = new PatternStreamSpecRaw(pattern.PatternRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions(), false, false); var compiled = raw.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), priorMatches, priorAllTags, false, true, false); pattern.PatternCompiled = compiled; return(new Pair <MatchEventSpec, ISet <string> >(new MatchEventSpec(compiled.TaggedEventTypes, compiled.ArrayEventTypes), compiled.AllTags)); }
private ContextDetailMatchPair ValidateRewriteContextCondition( EPServicesContext servicesContext, StatementContext statementContext, ContextDetailCondition endpoint, ISet <string> eventTypesReferenced, MatchEventSpec priorMatches, ISet <string> priorAllTags) { if (endpoint is ContextDetailConditionCrontab) { var crontab = (ContextDetailConditionCrontab)endpoint; var schedule = ExprNodeUtility.ToCrontabSchedule(ExprNodeOrigin.CONTEXTCONDITION, crontab.Crontab, statementContext, false); crontab.Schedule = schedule; return(new ContextDetailMatchPair(crontab, new MatchEventSpec(), new LinkedHashSet <string>())); } if (endpoint is ContextDetailConditionTimePeriod) { var timePeriod = (ContextDetailConditionTimePeriod)endpoint; var validationContext = new ExprValidationContext( new StreamTypeServiceImpl(servicesContext.EngineURI, false), statementContext.EngineImportService, statementContext.StatementExtensionServicesContext, null, statementContext.SchedulingService, statementContext.VariableService, statementContext.TableService, GetDefaultAgentInstanceContext(statementContext), statementContext.EventAdapterService, statementContext.StatementName, statementContext.StatementId, statementContext.Annotations, statementContext.ContextDescriptor, statementContext.ScriptingService, false, false, false, false, null, false); ExprNodeUtility.GetValidatedSubtree(ExprNodeOrigin.CONTEXTCONDITION, timePeriod.TimePeriod, validationContext); if (timePeriod.TimePeriod.IsConstantResult) { if (timePeriod.TimePeriod.EvaluateAsSeconds(null, true, null) < 0) { throw new ExprValidationException("Invalid negative time period expression '" + ExprNodeUtility.ToExpressionStringMinPrecedenceSafe(timePeriod.TimePeriod) + "'"); } } return(new ContextDetailMatchPair(timePeriod, new MatchEventSpec(), new LinkedHashSet <string>())); } if (endpoint is ContextDetailConditionPattern) { var pattern = (ContextDetailConditionPattern)endpoint; var matches = ValidatePatternContextConditionPattern(statementContext, pattern, eventTypesReferenced, priorMatches, priorAllTags); return(new ContextDetailMatchPair(pattern, matches.First, matches.Second)); } if (endpoint is ContextDetailConditionFilter) { var filter = (ContextDetailConditionFilter)endpoint; ValidateNotTable(servicesContext, filter.FilterSpecRaw.EventTypeName); // compile as filter if there are no prior match to consider if (priorMatches == null || (priorMatches.ArrayEventTypes.IsEmpty() && priorMatches.TaggedEventTypes.IsEmpty())) { var rawExpr = new FilterStreamSpecRaw(filter.FilterSpecRaw, ViewSpec.EMPTY_VIEWSPEC_ARRAY, null, new StreamSpecOptions()); var compiled = (FilterStreamSpecCompiled)rawExpr.Compile(statementContext, eventTypesReferenced, false, Collections.GetEmptyList <int>(), false, true, false, filter.OptionalFilterAsName); filter.FilterSpecCompiled = compiled.FilterSpec; var matchEventSpec = new MatchEventSpec(); var filterForType = compiled.FilterSpec.FilterForEventType; var allTags = new LinkedHashSet <string>(); if (filter.OptionalFilterAsName != null) { matchEventSpec.TaggedEventTypes.Put(filter.OptionalFilterAsName, new Pair <EventType, string>(filterForType, rawExpr.RawFilterSpec.EventTypeName)); allTags.Add(filter.OptionalFilterAsName); } return(new ContextDetailMatchPair(filter, matchEventSpec, allTags)); } // compile as pattern if there are prior matches to consider, since this is a type of followed-by relationship var factoryNode = servicesContext.PatternNodeFactory.MakeFilterNode(filter.FilterSpecRaw, filter.OptionalFilterAsName, 0); var pattern = new ContextDetailConditionPattern(factoryNode, true, false); var matches = ValidatePatternContextConditionPattern(statementContext, pattern, eventTypesReferenced, priorMatches, priorAllTags); return(new ContextDetailMatchPair(pattern, matches.First, matches.Second)); } else if (endpoint is ContextDetailConditionImmediate) { return(new ContextDetailMatchPair(endpoint, new MatchEventSpec(), new LinkedHashSet <string>())); } else { throw new IllegalStateException("Unrecognized endpoint type " + endpoint); } }