Ejemplo n.º 1
0
        public void TestCopyView()
        {
            AddPropertyValueOptionalView copied = (AddPropertyValueOptionalView)_myView.CloneView();

            Assert.AreEqual(_myView.PropertyNames, copied.PropertyNames);
            Assert.AreEqual(_myView.PropertyValues, copied.PropertyValues);
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            var schema = new Dictionary <String, Object>();

            schema["STDDEV"] = typeof(double?);
            _parentEventType = SupportEventTypeFactory.CreateMapType(schema);

            var addProps = new Dictionary <String, Object>();

            addProps["Symbol"] = typeof(string);

            var mergeEventType = SupportEventAdapterService.Service.CreateAnonymousWrapperType(
                "test", _parentEventType, addProps);

            // Set up length window view and a test child view
            _myView = new AddPropertyValueOptionalView(
                SupportStatementContextFactory.MakeAgentInstanceViewFactoryContext(),
                new String[] { "Symbol" }, "IBM", mergeEventType);

            _parentView = new SupportMapView(schema);
            _parentView.AddView(_myView);

            _childView = new SupportSchemaNeutralView();
            _myView.AddView(_childView);
        }
Ejemplo n.º 3
0
        private static void CopySubViews(
            ExprNode[] criteriaExpressions,
            String[] propertyNames,
            Object groupByValues,
            View originalView,
            View copyView,
            AgentInstanceViewFactoryChainContext agentInstanceContext)
        {
            foreach (var subView in originalView.Views)
            {
                // Determine if view is our merge view
                if (subView is MergeViewMarker)
                {
                    var mergeView = (MergeViewMarker)subView;
                    if (ExprNodeUtility.DeepEquals(mergeView.GroupFieldNames, criteriaExpressions))
                    {
                        if (mergeView.EventType != copyView.EventType)
                        {
                            // We found our merge view - install a new data merge view on top of it
                            var addPropertyView = new AddPropertyValueOptionalView(agentInstanceContext, propertyNames, groupByValues, mergeView.EventType);

                            // Add to the copied parent subview the view merge data view
                            copyView.AddView(addPropertyView);

                            // Add to the new merge data view the actual single merge view instance that clients may attached to
                            addPropertyView.AddView(mergeView);

                            // Add a parent view to the single merge view instance
                            mergeView.AddParentView(addPropertyView);
                        }
                        else
                        {
                            // Add to the copied parent subview the view merge data view
                            copyView.AddView(mergeView);

                            // Add a parent view to the single merge view instance
                            mergeView.AddParentView(copyView);
                        }

                        continue;
                    }
                }

                if (!(subView is CloneableView))
                {
                    throw new EPException("Unexpected error copying subview");
                }
                var cloneableView = (CloneableView)subView;
                var copiedChild   = cloneableView.CloneView();
                copyView.AddView(copiedChild);

                // Make the sub views for child
                CopySubViews(criteriaExpressions, propertyNames, groupByValues, subView, copiedChild, agentInstanceContext);
            }
        }
Ejemplo n.º 4
0
        public void TestAddProperty()
        {
            IDictionary <String, Object> eventData = new Dictionary <String, Object>();

            eventData["STDDEV"] = 100;
            EventBean eventBean = SupportEventBeanFactory.CreateMapFromValues(eventData, _parentEventType);

            IDictionary <String, Object> addProps = new Dictionary <String, Object>();

            addProps["test"] = typeof(int);
            EventType newEventType = SupportEventAdapterService.Service.CreateAnonymousWrapperType("test", _parentEventType, addProps);
            EventBean newBean      = AddPropertyValueOptionalView.AddProperty(
                eventBean,
                new String[] { "test" },
                new MultiKeyUntyped(new Object[] { 2 }),
                newEventType,
                SupportEventAdapterService.Service);

            Assert.AreEqual(2, newBean.Get("test"));
            Assert.AreEqual(100, newBean.Get("STDDEV"));
        }