/// <summary>Ctor. </summary> /// <param name="revisionSpec">specification</param> /// <param name="revisionEventTypeName">name of event type</param> /// <param name="eventAdapterService">for nested property handling</param> protected VAERevisionProcessorBase(RevisionSpec revisionSpec, String revisionEventTypeName, EventAdapterService eventAdapterService) { RevisionSpec = revisionSpec; RevisionEventTypeName = revisionEventTypeName; EventAdapterService = eventAdapterService; TypeDescriptors = new Dictionary <EventType, RevisionTypeDesc>(); }
/// <summary> /// Ctor. /// </summary> /// <param name="revisionEventTypeName">name</param> /// <param name="spec">specification</param> /// <param name="statementStopService">for stop handling</param> /// <param name="eventAdapterService">for nested property handling</param> /// <param name="eventTypeIdGenerator">The event type id generator.</param> public VAERevisionProcessorDeclared( string revisionEventTypeName, RevisionSpec spec, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) : base(spec, revisionEventTypeName, eventAdapterService) { // on statement stop, remove versions statementStopService.StatementStopped += () => _statePerKey.Clear(); _statePerKey = new Dictionary <object, RevisionStateDeclared>().WithNullSupport(); _baseEventType = spec.BaseEventType; _fullKeyGetters = PropertyUtility.GetGetters(_baseEventType, spec.KeyPropertyNames); // sort non-key properties, removing keys _groups = PropertyUtility.AnalyzeGroups(spec.ChangesetPropertyNames, spec.DeltaTypes, spec.DeltaNames); var propertyDesc = CreatePropertyDescriptors(spec, _groups); TypeDescriptors = PropertyUtility.GetPerType(_groups, spec.ChangesetPropertyNames, spec.KeyPropertyNames); var metadata = EventTypeMetadata.CreateValueAdd(revisionEventTypeName, TypeClass.REVISION); RevisionEventType = new RevisionEventType(metadata, eventTypeIdGenerator.GetTypeId(revisionEventTypeName), propertyDesc, eventAdapterService); }
public EventType GetValueAddUnderlyingType(String name) { RevisionSpec spec = SpecificationsByRevisionName.Get(name); if (spec == null) { return(null); } return(spec.BaseEventType); }
public EventType CreateRevisionType(String namedWindowName, String name, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) { RevisionSpec spec = SpecificationsByRevisionName.Get(name); ValueAddEventProcessor processor; if (spec.PropertyRevision == PropertyRevisionEnum.OVERLAY_DECLARED) { processor = new VAERevisionProcessorDeclared(name, spec, statementStopService, eventAdapterService, eventTypeIdGenerator); } else { processor = new VAERevisionProcessorMerge(name, spec, statementStopService, eventAdapterService, eventTypeIdGenerator); } ProcessorsByNamedWindow.Put(namedWindowName, processor); return(processor.ValueAddEventType); }
/// <summary>Ctor. </summary> /// <param name="spec">is the specification</param> protected UpdateStrategyBase(RevisionSpec spec) { this.spec = spec; }
/// <summary>Creates property descriptors for revision. </summary> /// <param name="spec">specifies revision</param> /// <param name="groups">the groups that group properties</param> /// <returns>map of property and descriptor</returns> public static IDictionary <String, RevisionPropertyTypeDesc> CreatePropertyDescriptors(RevisionSpec spec, PropertyGroupDesc[] groups) { IDictionary <String, int[]> propsPerGroup = PropertyUtility.GetGroupsPerProperty(groups); IDictionary <String, RevisionPropertyTypeDesc> propertyDesc = new Dictionary <String, RevisionPropertyTypeDesc>(); int count = 0; foreach (String property in spec.ChangesetPropertyNames) { var fullGetter = spec.BaseEventType.GetGetter(property); var propertyNumber = count; var propGroupsProperty = propsPerGroup.Get(property); var paramList = new RevisionGetterParameters(property, propertyNumber, fullGetter, propGroupsProperty); // if there are no groups (full event property only), then simply use the full event getter EventPropertyGetter revisionGetter = new ProxyEventPropertyGetter( eventBean => ((RevisionEventBeanDeclared)eventBean).GetVersionedValue(paramList), eventBean => null, eventBean => true); var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, paramList, type); propertyDesc.Put(property, propertyTypeDesc); count++; } foreach (String property in spec.BaseEventOnlyPropertyNames) { EventPropertyGetter fullGetter = spec.BaseEventType.GetGetter(property); // if there are no groups (full event property only), then simply use the full event getter EventPropertyGetter revisionGetter = new ProxyEventPropertyGetter( eventBean => { var riv = (RevisionEventBeanDeclared)eventBean; var bean = riv.LastBaseEvent; return(bean == null ? null : fullGetter.Get(bean)); }, eventBean => null, eventBean => true); var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } count = 0; foreach (String property in spec.KeyPropertyNames) { int keyPropertyNumber = count; EventPropertyGetter revisionGetter; if (spec.KeyPropertyNames.Length == 1) { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => ((RevisionEventBeanDeclared)eventBean).Key, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } else { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => { var riv = (RevisionEventBeanDeclared)eventBean; return(((MultiKeyUntyped)riv.Key).Keys[keyPropertyNumber]); }, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } return(propertyDesc); }
/// <summary>Ctor. </summary> /// <param name="spec">the specification</param> public UpdateStrategyExists(RevisionSpec spec) : base(spec) { }
/// <summary>Creates property descriptors for revision. </summary> /// <param name="spec">specifies revision</param> /// <param name="groups">the groups that group properties</param> /// <returns>map of property and descriptor</returns> public static IDictionary <string, RevisionPropertyTypeDesc> CreatePropertyDescriptors( RevisionSpec spec, PropertyGroupDesc[] groups) { var propsPerGroup = PropertyUtility.GetGroupsPerProperty(groups); IDictionary <string, RevisionPropertyTypeDesc> propertyDesc = new Dictionary <string, RevisionPropertyTypeDesc>(); var count = 0; foreach (var property in spec.ChangesetPropertyNames) { var fullGetter = spec.BaseEventType.GetGetter(property); var propertyNumber = count; var propGroupsProperty = propsPerGroup.Get(property); var paramList = new RevisionGetterParameters(property, propertyNumber, fullGetter, propGroupsProperty); // if there are no groups (full event property only), then simply use the full event getter var revisionGetter = new VAERevisionEventPropertyGetterDeclaredGetVersioned(paramList); var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, paramList, type); propertyDesc.Put(property, propertyTypeDesc); count++; } foreach (var property in spec.BaseEventOnlyPropertyNames) { var fullGetter = ((EventTypeSPI)spec.BaseEventType).GetGetterSPI(property); // if there are no groups (full event property only), then simply use the full event getter var revisionGetter = new VAERevisionEventPropertyGetterDeclaredLast(fullGetter); var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } count = 0; foreach (var property in spec.KeyPropertyNames) { var keyPropertyNumber = count; EventPropertyGetterSPI revisionGetter; if (spec.KeyPropertyNames.Length == 1) { revisionGetter = new VAERevisionEventPropertyGetterDeclaredOneKey(); } else { revisionGetter = new VAERevisionEventPropertyGetterDeclaredNKey(keyPropertyNumber); } var type = spec.BaseEventType.GetPropertyType(property); var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } return(propertyDesc); }
/// <summary> /// Ctor. /// </summary> /// <param name="revisioneventTypeName">name</param> /// <param name="spec">specification</param> /// <param name="statementStopService">for stop handling</param> /// <param name="eventAdapterService">for nested property handling</param> /// <param name="eventTypeIdGenerator">The event type id generator.</param> public VAERevisionProcessorMerge(String revisioneventTypeName, RevisionSpec spec, StatementStopService statementStopService, EventAdapterService eventAdapterService, EventTypeIdGenerator eventTypeIdGenerator) : base(spec, revisioneventTypeName, eventAdapterService) { // on statement stop, remove versions statementStopService.StatementStopped += () => _statePerKey.Clear(); _statePerKey = new Dictionary <Object, RevisionStateMerge>(); // For all changeset properties, add type descriptors (property number, getter etc) var propertyDesc = new Dictionary <String, RevisionPropertyTypeDesc>(); var count = 0; foreach (String property in spec.ChangesetPropertyNames) { var fullGetter = spec.BaseEventType.GetGetter(property); var propertyNumber = count; var paramList = new RevisionGetterParameters(property, propertyNumber, fullGetter, null); // if there are no groups (full event property only), then simply use the full event getter EventPropertyGetter revisionGetter = new ProxyEventPropertyGetter( eventBean => { var riv = (RevisionEventBeanMerge)eventBean; return(riv.GetVersionedValue(paramList)); }, eventBean => null, eventBean => true); var type = spec.BaseEventType.GetPropertyType(property); if (type == null) { foreach (EventType deltaType in spec.DeltaTypes) { var dtype = deltaType.GetPropertyType(property); if (dtype != null) { type = dtype; break; } } } var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, paramList, type); propertyDesc.Put(property, propertyTypeDesc); count++; } count = 0; foreach (String property in spec.KeyPropertyNames) { var keyPropertyNumber = count; EventPropertyGetter revisionGetter; if (spec.KeyPropertyNames.Length == 1) { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => ((RevisionEventBeanMerge)eventBean).Key, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } else { revisionGetter = new ProxyEventPropertyGetter { ProcGet = eventBean => { var riv = (RevisionEventBeanMerge)eventBean; return(((MultiKeyUntyped)riv.Key).Keys[keyPropertyNumber]); }, ProcIsExistsProperty = eventBean => true, ProcGetFragment = eventBean => null }; } var type = spec.BaseEventType.GetPropertyType(property); if (type == null) { foreach (EventType deltaType in spec.DeltaTypes) { var dtype = deltaType.GetPropertyType(property); if (dtype != null) { type = dtype; break; } } } var propertyTypeDesc = new RevisionPropertyTypeDesc(revisionGetter, null, type); propertyDesc.Put(property, propertyTypeDesc); count++; } // compile for each event type a list of getters and indexes within the overlay foreach (EventType deltaType in spec.DeltaTypes) { RevisionTypeDesc typeDesc = MakeTypeDesc(deltaType, spec.PropertyRevision); TypeDescriptors.Put(deltaType, typeDesc); } _infoFullType = MakeTypeDesc(spec.BaseEventType, spec.PropertyRevision); // how to handle updates to a full event if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_DECLARED) { _updateStrategy = new UpdateStrategyDeclared(spec); } else if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_NON_NULL) { _updateStrategy = new UpdateStrategyNonNull(spec); } else if (spec.PropertyRevision == PropertyRevisionEnum.MERGE_EXISTS) { _updateStrategy = new UpdateStrategyExists(spec); } else { throw new ArgumentException("Unknown revision type '" + spec.PropertyRevision + "'"); } EventTypeMetadata metadata = EventTypeMetadata.CreateValueAdd(revisioneventTypeName, TypeClass.REVISION); RevisionEventType = new RevisionEventType(metadata, eventTypeIdGenerator.GetTypeId(revisioneventTypeName), propertyDesc, eventAdapterService); }
/// <summary>Ctor. </summary> /// <param name="spec">the specification</param> public UpdateStrategyDeclared(RevisionSpec spec) : base(spec) { }
public void AddRevisionEventType(String revisioneventTypeName, ConfigurationRevisionEventType config, EventAdapterService eventAdapterService) { RevisionSpec specification = ValidateRevision(revisioneventTypeName, config, eventAdapterService); SpecificationsByRevisionName.Put(revisioneventTypeName, specification); }
/// <summary>Ctor. </summary> /// <param name="spec">the specification</param> public UpdateStrategyNonNull(RevisionSpec spec) : base(spec) { }