Exemplo n.º 1
0
        /// <summary>
        /// Create time dimension mapping with transcoding
        /// </summary>
        /// <param name="mapping">
        ///     The mapping entity<see cref="MappingEntity"/> of the Time Dimension component
        /// </param>
        /// <param name="databaseType">
        ///     The dissemination database vendor. Is needed to generate the correct SQL query where conditions
        /// </param>
        /// <param name="timeTranscoding">
        /// The Mapping Store <c>TIME_TRANSCODING</c> object
        /// </param>
        /// <exception cref="TranscodingException">
        /// Incomplete/Invalid mapping or expression
        /// </exception>
        /// <returns>
        /// An Time Dimension Transcoding object<see cref="ITimeDimension"/>
        /// </returns>
        private static ITimeDimensionMapping CreateTranscodedTimeDimensionMapping(MappingEntity mapping, string databaseType, TimeTranscodingEntity timeTranscoding)
        {
            ITimeDimensionMapping timeDimensionTranscoding;
            TimeExpressionEntity  expr = TimeExpressionEntity.CreateExpression(timeTranscoding);

            if (!expr.IsDateTime)
            {
                if (!expr.OneColumnMapping)
                {
                    timeDimensionTranscoding = new TimeDimension2Column(mapping, expr, databaseType);
                }
                else
                {
                    if (expr.YearLength != 4)
                    {
                        throw new TranscodingException(ErrorMessages.TimeDimensionYearNo4Digits);
                    }

                    if (expr.Freq != TimeFormatEnumType.Year)
                    {
                        if (expr.PeriodLength <= 0 && expr.YearStart > expr.PeriodStart)
                        {
                            throw new TranscodingException(ErrorMessages.TimeDimensionVariableLenPeriodNotFirst);
                        }

                        if (((expr.YearStart + expr.YearLength) > expr.PeriodStart && expr.YearStart < expr.PeriodStart)
                            ||
                            ((expr.PeriodStart + expr.PeriodLength) > expr.YearStart &&
                             expr.YearStart > expr.PeriodStart) || expr.PeriodStart == expr.YearStart)
                        {
                            throw new TranscodingException(ErrorMessages.TimeDimensionYearPeriodOverlap);
                        }
                    }

                    timeDimensionTranscoding = new TimeDimension1Column(mapping, expr, databaseType);
                }
            }
            else
            {
                timeDimensionTranscoding = new TimeDimensionDateType(mapping, expr, databaseType);
            }

            return(timeDimensionTranscoding);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create time dimension mapping with transcoding 
        /// </summary>
        /// <param name="mapping">
        ///     The mapping entity<see cref="MappingEntity"/> of the Time Dimension component
        /// </param>
        /// <param name="databaseType">
        ///     The dissemination database vendor. Is needed to generate the correct SQL query where conditions
        /// </param>
        /// <param name="timeTranscoding">
        /// The Mapping Store <c>TIME_TRANSCODING</c> object
        /// </param>
        /// <exception cref="TranscodingException">
        /// Incomplete/Invalid mapping or expression
        /// </exception>
        /// <returns>
        /// An Time Dimension Transcoding object<see cref="ITimeDimension"/>
        /// </returns>
        private static ITimeDimensionMapping CreateTranscodedTimeDimensionMapping(MappingEntity mapping, string databaseType, TimeTranscodingEntity timeTranscoding)
        {
            ITimeDimensionMapping timeDimensionTranscoding;
            TimeExpressionEntity expr = TimeExpressionEntity.CreateExpression(timeTranscoding);

            if (!expr.IsDateTime)
            {
                if (!expr.OneColumnMapping)
                {
                    timeDimensionTranscoding = new TimeDimension2Column(mapping, expr, databaseType);
                }
                else
                {
                    if (expr.YearLength != 4)
                    {
                        throw new TranscodingException(ErrorMessages.TimeDimensionYearNo4Digits);
                    }

                    if (expr.Freq != TimeFormatEnumType.Year)
                    {
                        if (expr.PeriodLength <= 0 && expr.YearStart > expr.PeriodStart)
                        {
                            throw new TranscodingException(ErrorMessages.TimeDimensionVariableLenPeriodNotFirst);
                        }

                        if (((expr.YearStart + expr.YearLength) > expr.PeriodStart && expr.YearStart < expr.PeriodStart)
                            ||
                            ((expr.PeriodStart + expr.PeriodLength) > expr.YearStart
                             && expr.YearStart > expr.PeriodStart) || expr.PeriodStart == expr.YearStart)
                        {
                            throw new TranscodingException(ErrorMessages.TimeDimensionYearPeriodOverlap);
                        }
                    }

                    timeDimensionTranscoding = new TimeDimension1Column(mapping, expr, databaseType);
                }
            }
            else
            {
                timeDimensionTranscoding = new TimeDimensionDateType(mapping, expr, databaseType);
            }

            return timeDimensionTranscoding;
        }