コード例 #1
0
ファイル: ViewServiceHelper.cs プロジェクト: ecakirman/nesper
        /// <summary>
        /// Given a list of view specifications obtained from by parsing this method instantiates a list of view
        /// factories. The view factories are not yet aware of each other after leaving this method (so not yet
        /// chained logically). They are simply instantiated and assigned view parameters.
        /// </summary>
        /// <param name="streamNum">is the stream number</param>
        /// <param name="viewSpecList">is the view definition</param>
        /// <param name="statementContext">is statement service context and statement info</param>
        /// <returns>list of view factories</returns>
        /// <throws>ViewProcessingException if the factory cannot be creates such as for invalid view spec</throws>
        public static IList <ViewFactory> InstantiateFactories(int streamNum, IList <ViewSpec> viewSpecList, StatementContext statementContext)
        {
            IList <ViewFactory> factoryChain = new List <ViewFactory>();

            int viewNum = 0;

            foreach (ViewSpec spec in viewSpecList)
            {
                // Create the new view factory
                var viewFactory = statementContext.ViewResolutionService.Create(spec.ObjectNamespace, spec.ObjectName);

                var audit = AuditEnum.VIEW.GetAudit(statementContext.Annotations);
                if (audit != null)
                {
                    viewFactory = (ViewFactory)ViewFactoryProxy.NewInstance(statementContext.EngineURI, statementContext.StatementName, viewFactory, spec.ObjectName);
                }
                factoryChain.Add(viewFactory);

                // Set view factory parameters
                try
                {
                    ViewFactoryContext context = new ViewFactoryContext(statementContext, streamNum, viewNum, spec.ObjectNamespace, spec.ObjectName);
                    viewFactory.SetViewParameters(context, spec.ObjectParameters);
                }
                catch (ViewParameterException e)
                {
                    throw new ViewProcessingException(string.Format("Error in view '{0}{1}{2}', {3}", spec.ObjectNamespace, ':', spec.ObjectName, e.Message), e);
                }
                viewNum++;
            }

            return(factoryChain);
        }
コード例 #2
0
        /// <summary>
        /// Given a list of view specifications obtained from by parsing this method instantiates a list of view factories.
        /// The view factories are not yet aware of each other after leaving this method (so not yet chained logically).
        /// They are simply instantiated and assigned view parameters.
        /// </summary>
        /// <param name="streamNum">is the stream number</param>
        /// <param name="viewSpecList">is the view definition</param>
        /// <param name="statementContext">is statement service context and statement INFO</param>
        /// <param name="isSubquery">subquery indicator</param>
        /// <param name="subqueryNumber">for subqueries</param>
        /// <exception cref="ViewProcessingException">if the factory cannot be creates such as for invalid view spec</exception>
        /// <returns>list of view factories</returns>
        public static IList <ViewFactory> InstantiateFactories(
            int streamNum,
            IList <ViewSpec> viewSpecList,
            StatementContext statementContext,
            bool isSubquery,
            int subqueryNumber)
        {
            var factoryChain = new List <ViewFactory>();

            var grouped = false;

            foreach (var spec in viewSpecList)
            {
                // Create the new view factory
                var viewFactory = statementContext.ViewResolutionService.Create(
                    statementContext.Container, spec.ObjectNamespace, spec.ObjectName);

                var audit = AuditEnum.VIEW.GetAudit(statementContext.Annotations);
                if (audit != null)
                {
                    viewFactory = ViewFactoryProxy.NewInstance(
                        statementContext.EngineURI, statementContext.StatementName, viewFactory, spec.ObjectName);
                }
                factoryChain.Add(viewFactory);

                // Set view factory parameters
                try
                {
                    var context = new ViewFactoryContext(
                        statementContext, streamNum, spec.ObjectNamespace, spec.ObjectName, isSubquery, subqueryNumber,
                        grouped);
                    viewFactory.SetViewParameters(context, spec.ObjectParameters);
                }
                catch (ViewParameterException e)
                {
                    throw new ViewProcessingException(
                              "Error in view '" + spec.ObjectName +
                              "', " + e.Message, e);
                }

                if (viewFactory is GroupByViewFactoryMarker)
                {
                    grouped = true;
                }
                if (viewFactory is MergeViewFactoryMarker)
                {
                    grouped = false;
                }
            }

            return(factoryChain);
        }