Exemple #1
0
 protected DTLocalForgeCalopReformatBase(
     IList<CalendarForge> calendarForges,
     ReformatForge reformatForge)
 {
     this.calendarForges = calendarForges;
     this.reformatForge = reformatForge;
 }
Exemple #2
0
        public ExprDotDTForge(
            IList<CalendarForge> calendarForges,
            TimeAbacus timeAbacus,
            ReformatForge reformatForge,
            IntervalForge intervalForge,
            Type inputType,
            EventType inputEventType)
        {
            if (intervalForge != null) {
                TypeInfo = EPTypeHelper.SingleValue(typeof(bool?));
            }
            else if (reformatForge != null) {
                TypeInfo = EPTypeHelper.SingleValue(reformatForge.ReturnType);
            }
            else { // only calendar op
                if (inputEventType != null) {
                    TypeInfo = EPTypeHelper.SingleValue(
                        inputEventType.GetPropertyType(inputEventType.StartTimestampPropertyName));
                }
                else {
                    TypeInfo = EPTypeHelper.SingleValue(inputType);
                }
            }

            forge = GetForge(calendarForges, timeAbacus, inputType, inputEventType, reformatForge, intervalForge);
        }
 public DTLocalDtoOpsReformatForge(
     IList<CalendarForge> calendarForges,
     ReformatForge reformatForge)
     :
     base(calendarForges, reformatForge)
 {
 }
 public DTLocalLongOpsReformatForge(
     IList<CalendarForge> calendarForges,
     ReformatForge reformatForge,
     TimeAbacus timeAbacus)
     : base(calendarForges, reformatForge)
 {
     this.timeAbacus = timeAbacus;
 }
Exemple #5
0
        public DTLocalForge GetForge(
            IList<CalendarForge> calendarForges,
            TimeAbacus timeAbacus,
            Type inputType,
            EventType inputEventType,
            ReformatForge reformatForge,
            IntervalForge intervalForge)
        {
            if (inputEventType == null) {
                var inputTypeBoxed = inputType.GetBoxedType();
                if (reformatForge != null) {
                    if (TypeHelper.IsSubclassOrImplementsInterface(inputType, typeof(DateTimeEx))) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDtxReformatForge(reformatForge);
                        }

                        return new DTLocalDtxOpsReformatForge(calendarForges, reformatForge);
                    }

                    if (inputTypeBoxed == typeof(long?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalLongReformatForge(reformatForge);
                        }

                        return new DTLocalLongOpsReformatForge(calendarForges, reformatForge, timeAbacus);
                    }

                    if (inputTypeBoxed == typeof(DateTimeOffset?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDtoReformatForge(reformatForge);
                        }

                        return new DTLocalDtoOpsReformatForge(calendarForges, reformatForge);
                    }

                    if (inputTypeBoxed == typeof(DateTime?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDateTimeReformatForge(reformatForge);
                        }

                        return new DTLocalDateTimeOpsReformatForge(calendarForges, reformatForge);
                    }
                }
                else if (intervalForge != null) {
                    if (TypeHelper.IsSubclassOrImplementsInterface(inputType, typeof(DateTimeEx))) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDtxIntervalForge(intervalForge);
                        }

                        return new DTLocalDtxOpsIntervalForge(calendarForges, intervalForge);
                    }

                    if (inputTypeBoxed == typeof(long?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalLongIntervalForge(intervalForge);
                        }

                        return new DTLocalLongOpsIntervalForge(calendarForges, intervalForge, timeAbacus);
                    }

                    if (inputTypeBoxed == typeof(DateTimeOffset?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDtoIntervalForge(intervalForge);
                        }

                        return new DTLocalDtoOpsIntervalForge(calendarForges, intervalForge);
                    }

                    if (inputTypeBoxed == typeof(DateTime?)) {
                        if (calendarForges.IsEmpty()) {
                            return new DTLocalDateTimeIntervalForge(intervalForge);
                        }

                        return new DTLocalDateTimeOpsIntervalForge(calendarForges, intervalForge);
                    }
                }
                else { // only calendar op, nothing else
                    if (TypeHelper.IsSubclassOrImplementsInterface(inputType, typeof(DateTimeEx))) {
                        return new DTLocalDtxOpsDtxForge(calendarForges);
                    }

                    if (inputTypeBoxed == typeof(long?)) {
                        return new DTLocalDtxOpsLongForge(calendarForges, timeAbacus);
                    }

                    if (inputTypeBoxed == typeof(DateTimeOffset?)) {
                        return new DTLocalDtxOpsDtoForge(calendarForges);
                    }

                    if (inputTypeBoxed == typeof(DateTime?)) {
                        return new DTLocalDtxOpsDtzForge(calendarForges);
                    }
                }

                throw new ArgumentException("Invalid input type '" + inputTypeBoxed + "'");
            }

            var getter = ((EventTypeSPI) inputEventType).GetGetterSPI(inputEventType.StartTimestampPropertyName);
            var getterResultType = inputEventType.GetPropertyType(inputEventType.StartTimestampPropertyName);

            if (reformatForge != null) {
                var inner = GetForge(calendarForges, timeAbacus, getterResultType, null, reformatForge, null);
                return new DTLocalBeanReformatForge(getter, getterResultType, inner, reformatForge.ReturnType);
            }

            if (intervalForge == null) { // only calendar op
                var inner = GetForge(calendarForges, timeAbacus, getterResultType, null, null, null);
                return new DTLocalBeanCalOpsForge(
                    getter,
                    getterResultType,
                    inner,
                    EPTypeHelper.GetNormalizedClass(TypeInfo));
            }

            // have interval op but no end timestamp
            if (inputEventType.EndTimestampPropertyName == null) {
                var inner = GetForge(calendarForges, timeAbacus, getterResultType, null, null, intervalForge);
                return new DTLocalBeanIntervalNoEndTSForge(
                    getter,
                    getterResultType,
                    inner,
                    EPTypeHelper.GetNormalizedClass(TypeInfo));
            }

            // interval op and have end timestamp
            var getterEndTimestamp =
                ((EventTypeSPI) inputEventType).GetGetterSPI(inputEventType.EndTimestampPropertyName);
            var getterEndType = inputEventType.GetPropertyType(inputEventType.EndTimestampPropertyName);
            var innerX = (DTLocalForgeIntervalComp) GetForge(
                calendarForges,
                timeAbacus,
                getterResultType,
                null,
                null,
                intervalForge);
            return new DTLocalBeanIntervalWithEndForge(
                getter,
                getterResultType,
                getterEndTimestamp,
                getterEndType,
                innerX);
        }
 public DTLocalDtoReformatForge(ReformatForge reformatForge)
     : base(reformatForge)
 {
 }
Exemple #7
0
        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 DTLocalLongReformatForge(ReformatForge reformatForge)
     : base(reformatForge)
 {
 }
 protected DTLocalReformatForgeBase(ReformatForge reformatForge)
 {
     this.reformatForge = reformatForge;
 }
 public DTLocalDateTimeReformatForge(ReformatForge reformatForge)
     : base(reformatForge)
 {
 }
Exemple #11
0
        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);
        }