Example #1
0
 public ExprValidationContext(StreamTypeServiceImpl types, ExprValidationContext ctx)
     : this(
         types,
         ctx.EngineImportService,
         ctx.StatementExtensionSvcContext,
         ctx.ViewResourceDelegate,
         ctx.TimeProvider,
         ctx.VariableService,
         ctx.TableService,
         ctx.ExprEvaluatorContext,
         ctx.EventAdapterService,
         ctx.StatementName,
         ctx.StatementId,
         ctx.Annotations,
         ctx.ContextDescriptor,
         ctx.ScriptingService,
         ctx.IsDisablePropertyExpressionEventCollCache, false,
         ctx.IsAllowBindingConsumption,
         ctx.IsResettingAggregations,
         ctx.IntoTableName,
         false)
 {
 }
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            if (StreamName == null && _isWildcard)
            {
                if (validationContext.StreamTypeService.StreamNames.Length > 1)
                {
                    throw new ExprValidationException("Wildcard must be stream wildcard if specifying multiple streams, use the 'streamname.*' syntax instead");
                }
                _streamNum = 0;
            }
            else
            {
                _streamNum = validationContext.StreamTypeService.GetStreamNumForStreamName(StreamName);
            }

            if (_streamNum == -1)
            {
                throw new ExprValidationException("Stream by name '" + StreamName + "' could not be found among all streams");
            }

            _eventType = validationContext.StreamTypeService.EventTypes[_streamNum];
            _type      = _eventType.UnderlyingType;
            return(null);
        }
Example #3
0
 public override ExprNode Validate(ExprValidationContext validationContext)
 {
     return(null);
 }
Example #4
0
 public override ExprNode Validate(ExprValidationContext validationContext)
 {
     throw new ExprValidationException(ERROR_MSG);
 }
Example #5
0
 public abstract ExprNode Validate(ExprValidationContext validationContext);
Example #6
0
 public override ExprNode Validate(ExprValidationContext validationContext)
 {
     _evaluator = ChildNodes[0].ExprEvaluator; // always valid
     return(null);
 }
Example #7
0
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            // determine if any types are property agnostic; If yes, resolve to variable
            var hasPropertyAgnosticType = false;
            var types = validationContext.StreamTypeService.EventTypes;

            for (var i = 0; i < validationContext.StreamTypeService.EventTypes.Length; i++)
            {
                if (types[i] is EventTypeSPI)
                {
                    hasPropertyAgnosticType |= ((EventTypeSPI)types[i]).Metadata.IsPropertyAgnostic;
                }
            }

            if (!hasPropertyAgnosticType)
            {
                // the variable name should not overlap with a property name
                try
                {
                    validationContext.StreamTypeService.ResolveByPropertyName(_variableName, false);
                    throw new ExprValidationException("The variable by name '" + _variableName + "' is ambigous to a property of the same name");
                }
                catch (DuplicatePropertyException e)
                {
                    throw new ExprValidationException("The variable by name '" + _variableName + "' is ambigous to a property of the same name");
                }
                catch (PropertyNotFoundException e)
                {
                    // expected
                }
            }

            VariableMetaData variableMetadata = validationContext.VariableService.GetVariableMetaData(_variableName);

            if (variableMetadata == null)
            {
                throw new ExprValidationException("Failed to find variable by name '" + _variableName + "'");
            }
            _isPrimitive  = variableMetadata.EventType == null;
            _variableType = variableMetadata.VariableType;

            if (_optSubPropName != null)
            {
                if (variableMetadata.EventType == null)
                {
                    throw new ExprValidationException("Property '" + _optSubPropName + "' is not valid for variable '" + _variableName + "'");
                }
                _eventTypeGetter = variableMetadata.EventType.GetGetter(_optSubPropName);
                if (_eventTypeGetter == null)
                {
                    throw new ExprValidationException("Property '" + _optSubPropName + "' is not valid for variable '" + _variableName + "'");
                }
                _variableType = variableMetadata.EventType.GetPropertyType(_optSubPropName);
            }

            _readersPerCp = validationContext.VariableService.GetReadersPerCP(_variableName);
            if (variableMetadata.ContextPartitionName == null)
            {
                _readerNonCP = _readersPerCp.Get(EPStatementStartMethodConst.DEFAULT_AGENT_INSTANCE_ID);
            }

            return(null);
        }