예제 #1
0
        public void SetUp()
        {
            _eventService = SupportEventAdapterService.Service;
            EventType underlyingEventTypeSimple   = _eventService.AddBeanType("UnderlyingSimpleBean", typeof(SupportBeanSimple), true, true, true);
            EventType underlyingEventTypeCombined = _eventService.AddBeanType("UnderlyingCombinedBean", typeof(SupportBeanCombinedProps), true, true, true);

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

            typeMap["string"] = typeof(string);
            typeMap["int"]    = typeof(int);

            EventTypeMetadata meta = EventTypeMetadata.CreateWrapper("test", true, false, false);

            _eventTypeSimple      = new WrapperEventType(meta, "mytype", 1, underlyingEventTypeSimple, typeMap, _eventService);
            _eventTypeCombined    = new WrapperEventType(meta, "mytype", 1, underlyingEventTypeCombined, typeMap, _eventService);
            _properties           = new Dictionary <String, Object>();
            _properties["string"] = "xx";
            _properties["int"]    = 11;

            EventBean wrappedSimple = _eventService.AdapterForObject(new SupportBeanSimple("EventString", 0));

            _eventBeanSimple = _eventService.AdapterForTypedWrapper(wrappedSimple, _properties, _eventTypeSimple);

            EventBean wrappedCombined = _eventService.AdapterForObject(SupportBeanCombinedProps.MakeDefaultBean());

            _eventBeanCombined = _eventService.AdapterForTypedWrapper(wrappedCombined, _properties, _eventTypeCombined);
        }
예제 #2
0
        public static EventBean[] TypeCast(IList <EventBean> events, EventType targetType, EventAdapterService eventAdapterService)
        {
            var convertedArray = new EventBean[events.Count];
            var count          = 0;

            foreach (EventBean theEvent in events)
            {
                EventBean converted;
                if (theEvent is DecoratingEventBean)
                {
                    var wrapper = (DecoratingEventBean)theEvent;
                    if (targetType is MapEventType)
                    {
                        IDictionary <String, Object> props = new Dictionary <String, Object>();
                        props.PutAll(wrapper.DecoratingProperties);
                        foreach (EventPropertyDescriptor propDesc in wrapper.UnderlyingEvent.EventType.PropertyDescriptors)
                        {
                            props.Put(propDesc.PropertyName, wrapper.UnderlyingEvent.Get(propDesc.PropertyName));
                        }
                        converted = eventAdapterService.AdapterForTypedMap(props, targetType);
                    }
                    else
                    {
                        converted = eventAdapterService.AdapterForTypedWrapper(wrapper.UnderlyingEvent, wrapper.DecoratingProperties, targetType);
                    }
                }
                else if ((theEvent.EventType is MapEventType) && (targetType is MapEventType))
                {
                    var mapEvent = (MappedEventBean)theEvent;
                    converted = eventAdapterService.AdapterForTypedMap(mapEvent.Properties, targetType);
                }
                else if ((theEvent.EventType is MapEventType) && (targetType is WrapperEventType))
                {
                    converted = eventAdapterService.AdapterForTypedWrapper(theEvent, Collections.EmptyDataMap, targetType);
                }
                else if ((theEvent.EventType is BeanEventType) && (targetType is BeanEventType))
                {
                    converted = eventAdapterService.AdapterForTypedObject(theEvent.Underlying, targetType);
                }
                else if (theEvent.EventType is ObjectArrayEventType && targetType is ObjectArrayEventType)
                {
                    Object[] convertedObjectArray = ObjectArrayEventType.ConvertEvent(theEvent, (ObjectArrayEventType)targetType);
                    converted = eventAdapterService.AdapterForTypedObjectArray(convertedObjectArray, targetType);
                }
                else
                {
                    throw new EPException("Unknown event type " + theEvent.EventType);
                }
                convertedArray[count] = converted;
                count++;
            }
            return(convertedArray);
        }
예제 #3
0
        /// <summary>
        /// Add a property to the event passed in.
        /// </summary>
        /// <param name="originalEvent">event to add property to</param>
        /// <param name="propertyNames">names of properties to add</param>
        /// <param name="propertyValues">value of properties to add</param>
        /// <param name="targetEventType">new event type</param>
        /// <param name="eventAdapterService">service for generating events and handling event types</param>
        /// <returns>event with added property</returns>
        internal static EventBean AddProperty(
            EventBean originalEvent,
            string[] propertyNames,
            object propertyValues,
            EventType targetEventType,
            EventAdapterService eventAdapterService)
        {
            IDictionary <string, object> values = new Dictionary <string, object>();

            if (propertyValues is MultiKeyUntyped)
            {
                var props             = (MultiKeyUntyped)propertyValues;
                var propertyValuesArr = props.Keys;

                for (int i = 0; i < propertyNames.Length; i++)
                {
                    values.Put(propertyNames[i], propertyValuesArr[i]);
                }
            }
            else
            {
                values.Put(propertyNames[0], propertyValues);
            }

            return(eventAdapterService.AdapterForTypedWrapper(originalEvent, values, targetEventType));
        }
        public override EventBean ProcessFirstCol(Object result)
        {
            EventBean wrappedEvent = EventAdapterService.AdapterForObject(result);

            return(_vaeProcessor.GetValueAddEventBean(
                       EventAdapterService.AdapterForTypedWrapper(wrappedEvent, new Dictionary <string, object>(), _vaeInnerEventType)));
        }
        public override EventBean ProcessFirstCol(Object result)
        {
            EventBean wrappedEvent = EventAdapterService.AdapterForObject(result);
            EventBean variant      = _vaeProcessor.GetValueAddEventBean(wrappedEvent);

            return(EventAdapterService.AdapterForTypedWrapper(variant, Collections.EmptyDataMap, ResultEventType));
        }
예제 #6
0
        public override EventBean ProcessSpecific(IDictionary <String, Object> props,
                                                  EventBean[] eventsPerStream,
                                                  bool isNewData,
                                                  bool isSynthesize,
                                                  ExprEvaluatorContext exprEvaluatorContext)
        {
            // In case of a wildcard and single stream that is itself a
            // wrapper bean, we also need to add the map properties
            var wrapper = (DecoratingEventBean)eventsPerStream[0];

            if (wrapper != null)
            {
                IDictionary <String, Object> map = wrapper.DecoratingProperties;
                if ((ExprNodes.Length == 0) && (map.IsNotEmpty()))
                {
                    props = new Dictionary <String, Object>(map);
                }
                else
                {
                    props.PutAll(map);
                }
            }

            EventBean theEvent = eventsPerStream[0];

            // Using a wrapper bean since we cannot use the same event type else same-type filters match.
            // Wrapping it even when not adding properties is very inexpensive.
            return(EventAdapterService.AdapterForTypedWrapper(theEvent, props, ResultEventType));
        }
        public EventBean Copy(EventBean theEvent)
        {
            DecoratingEventBean          decorated           = (DecoratingEventBean)theEvent;
            EventBean                    decoratedUnderlying = decorated.UnderlyingEvent;
            IDictionary <String, Object> copiedMap           = new Dictionary <String, Object>(decorated.DecoratingProperties);

            return(_eventAdapterService.AdapterForTypedWrapper(decoratedUnderlying, copiedMap, _wrapperEventType));
        }
예제 #8
0
        public EventBean Process(EventBean[] eventsPerStream,
                                 bool isNewData,
                                 bool isSynthesize,
                                 ExprEvaluatorContext exprEvaluatorContext)
        {
            EventBean theEvent = eventsPerStream[_streamNumber];
            EventBean recast   = _eventAdapterService.AdapterForTypedObject(theEvent.Underlying,
                                                                            _eventType.UnderlyingEventType);

            return(_eventAdapterService.AdapterForTypedWrapper(recast, new Dictionary <string, object>(), _eventType));
        }
        public EventBean Copy(EventBean theEvent)
        {
            DecoratingEventBean decorated           = (DecoratingEventBean)theEvent;
            EventBean           decoratedUnderlying = decorated.UnderlyingEvent;
            EventBean           copiedUnderlying    = _underlyingCopyMethod.Copy(decoratedUnderlying);

            if (copiedUnderlying == null)
            {
                return(null);
            }
            return(_eventAdapterService.AdapterForTypedWrapper(copiedUnderlying, decorated.DecoratingProperties, _wrapperEventType));
        }
예제 #10
0
        public override EventBean ProcessSpecific(IDictionary <String, Object> props,
                                                  EventBean[] eventsPerStream,
                                                  bool isNewData,
                                                  bool isSynthesize,
                                                  ExprEvaluatorContext exprEvaluatorContext)
        {
            EventBean theEvent = _joinWildcardProcessor.Process(eventsPerStream, isNewData, isSynthesize,
                                                                exprEvaluatorContext);

            // Using a wrapper bean since we cannot use the same event type else same-type filters match.
            // Wrapping it even when not adding properties is very inexpensive.
            return(EventAdapterService.AdapterForTypedWrapper(theEvent, props, ResultEventType));
        }
예제 #11
0
        public EventBean Wrap(Object underlying)
        {
            EventBean bean = _eventAdapterService.AdapterForTypedObject(underlying, _beanEventType);

            return(_eventAdapterService.AdapterForTypedWrapper(bean, new EmptyDictionary <string, object>(), _wrapperEventType));
        }