public static ExprDotDTMethodDesc ValidateMake( StreamTypeService streamTypeService, Deque<Chainable> chainSpecStack, DatetimeMethodDesc dtMethod, string dtMethodName, EPType inputType, IList<ExprNode> parameters, ExprDotNodeFilterAnalyzerInput inputDesc, TimeAbacus timeAbacus, TableCompileTimeResolver tableCompileTimeResolver, ImportServiceCompileTime importService, StatementRawInfo statementRawInfo) { // verify input var message = "Date-time enumeration method '" + dtMethodName + "' requires either a DateTimeEx, DateTimeOffset, DateTime, or long value as input or events of an event type that declares a timestamp property"; if (inputType is EventEPType eventEpType) { if (eventEpType.EventType.StartTimestampPropertyName == null) { throw new ExprValidationException(message); } } else { if (!(inputType is ClassEPType || inputType is NullEPType)) { throw new ExprValidationException( message + " but received " + inputType.ToTypeDescriptive()); } if (inputType is ClassEPType classEpType) { if (!TypeHelper.IsDateTime(classEpType.Clazz)) { throw new ExprValidationException( message + " but received " + classEpType.Clazz.CleanName()); } } } IList<CalendarForge> calendarForges = new List<CalendarForge>(); ReformatForge reformatForge = null; IntervalForge intervalForge = null; var currentMethod = dtMethod; var currentParameters = parameters; var currentMethodName = dtMethodName; // drain all calendar op FilterExprAnalyzerAffector filterAnalyzerDesc = null; while (true) { // handle the first one only if its a calendar op var forges = GetForges(currentParameters); var opFactory = currentMethod.ForgeFactory; // compile parameter abstract for validation against available footprints var footprintProvided = DotMethodUtil.GetProvidedFootprint(currentParameters); // validate parameters var footprintFound = DotMethodUtil.ValidateParametersDetermineFootprint( currentMethod.Footprints, DotMethodTypeEnum.DATETIME, currentMethodName, footprintProvided, DotMethodInputTypeMatcherImpl.DEFAULT_ALL); if (opFactory is CalendarForgeFactory calendarForgeFactory) { var calendarForge = calendarForgeFactory.GetOp( currentMethod, currentMethodName, currentParameters, forges); calendarForges.Add(calendarForge); } else if (opFactory is ReformatForgeFactory reformatForgeFactory) { reformatForge = reformatForgeFactory.GetForge( inputType, timeAbacus, currentMethod, currentMethodName, currentParameters); // compile filter analyzer information if there are no calendar op in the chain if (calendarForges.IsEmpty()) { filterAnalyzerDesc = reformatForge.GetFilterDesc( streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } else { filterAnalyzerDesc = null; } } else if (opFactory is IntervalForgeFactory intervalForgeFactory) { intervalForge = intervalForgeFactory.GetForge( streamTypeService, currentMethod, currentMethodName, currentParameters, timeAbacus, tableCompileTimeResolver); // compile filter analyzer information if there are no calendar op in the chain if (calendarForges.IsEmpty()) { filterAnalyzerDesc = intervalForge.GetFilterDesc( streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } } else if (opFactory is DTMPluginForgeFactory dtmPluginForgeFactory) { var usageDesc = new DateTimeMethodValidateContext( footprintFound, streamTypeService, currentMethod, currentParameters, statementRawInfo); var ops = dtmPluginForgeFactory.Validate(usageDesc); if (ops == null) { throw new ExprValidationException( "Plug-in datetime method provider " + dtmPluginForgeFactory.GetType() + " returned a null-value for the operations"); } var input = EPTypeHelper.GetClassSingleValued(inputType); if (ops is DateTimeMethodOpsModify dateTimeMethodOpsModify) { calendarForges.Add(new DTMPluginValueChangeForge(input, dateTimeMethodOpsModify, usageDesc.CurrentParameters)); } else if (ops is DateTimeMethodOpsReformat dateTimeMethodOpsReformat) { reformatForge = new DTMPluginReformatForge(input, dateTimeMethodOpsReformat, usageDesc.CurrentParameters); } else { throw new ExprValidationException("Plug-in datetime method ops " + ops.GetType() + " is not recognized"); } // no action } else { throw new IllegalStateException("Invalid op factory class " + opFactory); } // see if there is more if (chainSpecStack.IsEmpty() || !DatetimeMethodResolver.IsDateTimeMethod(chainSpecStack.First.GetRootNameOrEmptyString(), importService)) { break; } // pull next var next = chainSpecStack.RemoveFirst(); currentMethodName = next.GetRootNameOrEmptyString(); currentMethod = DatetimeMethodResolver.FromName(currentMethodName, importService); currentParameters = next.GetParametersOrEmpty(); if (reformatForge != null || intervalForge != null) { throw new ExprValidationException("Invalid input for date-time method '" + currentMethodName + "'"); } } var dotForge = new ExprDotDTForge( calendarForges, timeAbacus, reformatForge, intervalForge, inputType.GetClassSingleValued(), inputType.GetEventTypeSingleValued()); var returnType = dotForge.TypeInfo; return new ExprDotDTMethodDesc(dotForge, returnType, filterAnalyzerDesc); }
public static ExprDotDTMethodDesc ValidateMake( StreamTypeService streamTypeService, Deque<ExprChainedSpec> chainSpecStack, DateTimeMethodEnum dtMethod, string dtMethodName, EPType inputType, IList<ExprNode> parameters, ExprDotNodeFilterAnalyzerInput inputDesc, TimeAbacus timeAbacus, ExprEvaluatorContext exprEvaluatorContext, TableCompileTimeResolver tableCompileTimeResolver) { // verify input var message = "Date-time enumeration method '" + dtMethodName + "' requires either a DateTimeEx, DateTimeOffset, DateTime, or long value as input or events of an event type that declares a timestamp property"; if (inputType is EventEPType) { if (((EventEPType) inputType).EventType.StartTimestampPropertyName == null) { throw new ExprValidationException(message); } } else { if (!(inputType is ClassEPType || inputType is NullEPType)) { throw new ExprValidationException( message + " but received " + inputType.ToTypeDescriptive()); } if (inputType is ClassEPType) { var classEPType = (ClassEPType) inputType; if (!TypeHelper.IsDateTime(classEPType.Clazz)) { throw new ExprValidationException( message + " but received " + classEPType.Clazz.CleanName()); } } } IList<CalendarForge> calendarForges = new List<CalendarForge>(); ReformatForge reformatForge = null; IntervalForge intervalForge = null; var currentMethod = dtMethod; var currentParameters = parameters; var currentMethodName = dtMethodName; // drain all calendar op FilterExprAnalyzerAffector filterAnalyzerDesc = null; while (true) { // handle the first one only if its a calendar op var forges = GetForges(currentParameters); var opFactory = currentMethod.GetForgeFactory(); // compile parameter abstract for validation against available footprints DotMethodFPProvided footprintProvided = DotMethodUtil.GetProvidedFootprint(currentParameters); // validate parameters DotMethodUtil.ValidateParametersDetermineFootprint( currentMethod.GetFootprints(), DotMethodTypeEnum.DATETIME, currentMethodName, footprintProvided, DotMethodInputTypeMatcherImpl.DEFAULT_ALL); if (opFactory is CalendarForgeFactory) { var calendarForge = ((CalendarForgeFactory) currentMethod.GetForgeFactory()).GetOp( currentMethod, currentMethodName, currentParameters, forges); calendarForges.Add(calendarForge); } else if (opFactory is ReformatForgeFactory) { reformatForge = ((ReformatForgeFactory) opFactory).GetForge( inputType, timeAbacus, currentMethod, currentMethodName, currentParameters, exprEvaluatorContext); // compile filter analyzer information if there are no calendar op in the chain if (calendarForges.IsEmpty()) { filterAnalyzerDesc = reformatForge.GetFilterDesc( streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } else { filterAnalyzerDesc = null; } } else if (opFactory is IntervalForgeFactory) { intervalForge = ((IntervalForgeFactory) opFactory).GetForge( streamTypeService, currentMethod, currentMethodName, currentParameters, timeAbacus, tableCompileTimeResolver); // compile filter analyzer information if there are no calendar op in the chain if (calendarForges.IsEmpty()) { filterAnalyzerDesc = intervalForge.GetFilterDesc( streamTypeService.EventTypes, currentMethod, currentParameters, inputDesc); } else { filterAnalyzerDesc = null; } } else { throw new IllegalStateException("Invalid op factory class " + opFactory); } // see if there is more if (chainSpecStack.IsEmpty() || !DatetimeMethodEnumHelper.IsDateTimeMethod(chainSpecStack.First.Name)) { break; } // pull next var next = chainSpecStack.RemoveFirst(); currentMethod = DatetimeMethodEnumHelper.FromName(next.Name); currentParameters = next.Parameters; currentMethodName = next.Name; if (reformatForge != null || intervalForge != null) { throw new ExprValidationException("Invalid input for date-time method '" + next.Name + "'"); } } ExprDotForge dotForge; EPType returnType; dotForge = new ExprDotDTForge( calendarForges, timeAbacus, reformatForge, intervalForge, inputType.GetClassSingleValued(), inputType.GetEventTypeSingleValued()); returnType = dotForge.TypeInfo; return new ExprDotDTMethodDesc(dotForge, returnType, filterAnalyzerDesc); }