Exemple #1
0
 public void OnUpdate(EventBean[] newData, EventBean[] oldData, NamedWindowRootViewInstance namedWindowRootView, EventTableIndexRepository indexRepository)
 {
     throw new UnsupportedOperationException();
 }
 public abstract InfraOnExprBaseViewResult MakeNamedWindow(
     SubordWMatchExprLookupStrategy lookupStrategy,
     NamedWindowRootViewInstance namedWindowRootViewInstance,
     AgentInstanceContext agentInstanceContext);
Exemple #3
0
        public override void OnUpdate(EventBean[] newData, EventBean[] oldData, NamedWindowRootViewInstance namedWindowRootView, EventTableIndexRepository indexRepository)
        {
            // If new data is filled, it is not a delete
            RevisionEventBeanMerge revisionEvent;
            Object key;

            if ((newData == null) || (newData.Length == 0))
            {
                // we are removing an event
                revisionEvent = (RevisionEventBeanMerge)oldData[0];
                key           = revisionEvent.Key;
                _statePerKey.Remove(key);

                // Insert into indexes for fast deletion, if there are any
                foreach (EventTable table in indexRepository.Tables)
                {
                    table.Remove(oldData);
                }

                // make as not the latest event since its due for removal
                revisionEvent.IsLatest = false;

                namedWindowRootView.UpdateChildren(null, oldData);
                return;
            }

            revisionEvent = (RevisionEventBeanMerge)newData[0];
            EventBean underlyingEvent    = revisionEvent.UnderlyingFullOrDelta;
            EventType underyingEventType = underlyingEvent.EventType;

            // obtain key values
            key = null;
            RevisionTypeDesc typesDesc;
            Boolean          isBaseEventType = false;

            if (underyingEventType == RevisionSpec.BaseEventType)
            {
                typesDesc       = _infoFullType;
                key             = PropertyUtility.GetKeys(underlyingEvent, _infoFullType.KeyPropertyGetters);
                isBaseEventType = true;
            }
            else
            {
                typesDesc = TypeDescriptors.Get(underyingEventType);

                // if this type cannot be found, check all supertypes, if any
                if (typesDesc == null)
                {
                    EventType[] superTypes = underyingEventType.DeepSuperTypes;
                    if (superTypes != null)
                    {
                        foreach (var superType in superTypes)
                        {
                            if (superType == RevisionSpec.BaseEventType)
                            {
                                typesDesc       = _infoFullType;
                                key             = PropertyUtility.GetKeys(underlyingEvent, _infoFullType.KeyPropertyGetters);
                                isBaseEventType = true;
                                break;
                            }
                            typesDesc = TypeDescriptors.Get(superType);
                            if (typesDesc != null)
                            {
                                TypeDescriptors.Put(underyingEventType, typesDesc);
                                key = PropertyUtility.GetKeys(underlyingEvent, typesDesc.KeyPropertyGetters);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    key = PropertyUtility.GetKeys(underlyingEvent, typesDesc.KeyPropertyGetters);
                }
            }

            // get the state for this key value
            RevisionStateMerge revisionState = _statePerKey.Get(key);

            // Delta event and no full
            if ((!isBaseEventType) && (revisionState == null))
            {
                return; // Ignore the event, its a delta and we don't currently have a full event for it
            }

            // New full event
            if (revisionState == null)
            {
                revisionState = new RevisionStateMerge(underlyingEvent, null, null);
                _statePerKey.Put(key, revisionState);

                // prepare revison event
                revisionEvent.LastBaseEvent = underlyingEvent;
                revisionEvent.Key           = key;
                revisionEvent.Overlay       = null;
                revisionEvent.IsLatest      = true;

                // Insert into indexes for fast deletion, if there are any
                foreach (EventTable table in indexRepository.Tables)
                {
                    table.Add(newData);
                }

                // post to data window
                revisionState.LastEvent = revisionEvent;
                namedWindowRootView.UpdateChildren(new EventBean[] { revisionEvent }, null);
                return;
            }

            // handle Update, changing revision state and event as required
            _updateStrategy.HandleUpdate(isBaseEventType, revisionState, revisionEvent, typesDesc);

            // prepare revision event
            revisionEvent.LastBaseEvent = revisionState.BaseEventUnderlying;
            revisionEvent.Overlay       = revisionState.Overlays;
            revisionEvent.Key           = key;
            revisionEvent.IsLatest      = true;

            // get prior event
            RevisionEventBeanMerge lastEvent = revisionState.LastEvent;

            lastEvent.IsLatest = false;

            // data to post
            var newDataPost = new EventBean[] { revisionEvent };
            var oldDataPost = new EventBean[] { lastEvent };

            // Update indexes
            foreach (EventTable table in indexRepository.Tables)
            {
                table.Remove(oldDataPost);
                table.Add(newDataPost);
            }

            // keep reference to last event
            revisionState.LastEvent = revisionEvent;

            namedWindowRootView.UpdateChildren(newDataPost, oldDataPost);
        }
 /// <summary>Upon new events arriving into a named window (new data), and upon events being deleted via on-delete (old data), Update child views of the root view and apply to index repository as required (fast deletion). </summary>
 /// <param name="newData">new events</param>
 /// <param name="oldData">remove stream</param>
 /// <param name="namedWindowRootView">the root view</param>
 /// <param name="indexRepository">delete and select indexes</param>
 public abstract void OnUpdate(
     EventBean[] newData,
     EventBean[] oldData,
     NamedWindowRootViewInstance namedWindowRootView,
     EventTableIndexRepository indexRepository);