コード例 #1
0
 private static void UpdateNameByLanguage(StreetNameSyndicationItem streetNameSyndicationItem, List <StreetNameName> streetNameNames)
 {
     foreach (var streetNameName in streetNameNames)
     {
         UpdateNameByLanguage(streetNameSyndicationItem, streetNameName.Name, streetNameName.Language);
     }
 }
コード例 #2
0
 public static void ApplyProvenance(
     this StreetNameSyndicationItem item,
     ProvenanceData provenance)
 {
     item.Application  = provenance.Application;
     item.Modification = provenance.Modification;
     item.Operator     = provenance.Operator;
     item.Organisation = provenance.Organisation;
     item.Reason       = provenance.Reason;
 }
コード例 #3
0
        private static void UpdateHomonymAdditionByLanguage(StreetNameSyndicationItem streetNameSyndicationItem, string homonymAddition, Language?language)
        {
            switch (language)
            {
            case Language.Dutch:
                streetNameSyndicationItem.HomonymAdditionDutch = homonymAddition;
                break;

            case Language.French:
                streetNameSyndicationItem.HomonymAdditionFrench = homonymAddition;
                break;

            case Language.German:
                streetNameSyndicationItem.HomonymAdditionGerman = homonymAddition;
                break;

            case Language.English:
                streetNameSyndicationItem.HomonymAdditionEnglish = homonymAddition;
                break;
            }
        }
コード例 #4
0
        private static void UpdateNameByLanguage(StreetNameSyndicationItem streetNameSyndicationItem, string name, Language?language)
        {
            switch (language)
            {
            case Language.Dutch:
                streetNameSyndicationItem.NameDutch = name;
                break;

            case Language.French:
                streetNameSyndicationItem.NameFrench = name;
                break;

            case Language.German:
                streetNameSyndicationItem.NameGerman = name;
                break;

            case Language.English:
                streetNameSyndicationItem.NameEnglish = name;
                break;
            }
        }
コード例 #5
0
        public StreetNameSyndicationProjections()
        {
            #region Legacy Events

            When <Envelope <StreetNameWasRegistered> >(async(context, message, ct) =>
            {
                var streetNameSyndicationItem = new StreetNameSyndicationItem
                {
                    Position                 = message.Position,
                    StreetNameId             = message.Message.StreetNameId,
                    NisCode                  = message.Message.NisCode,
                    RecordCreatedAt          = message.Message.Provenance.Timestamp,
                    LastChangedOn            = message.Message.Provenance.Timestamp,
                    ChangeType               = message.EventName,
                    SyndicationItemCreatedAt = DateTimeOffset.UtcNow
                };

                streetNameSyndicationItem.ApplyProvenance(message.Message.Provenance);
                streetNameSyndicationItem.SetEventData(message.Message, message.EventName);

                await context
                .StreetNameSyndication
                .AddAsync(streetNameSyndicationItem, ct);
            });

            When <Envelope <StreetNamePersistentLocalIdWasAssigned> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.PersistentLocalId = message.Message.PersistentLocalId,
                    ct);
            });

            When <Envelope <StreetNameWasNamed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, message.Message.Name, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCorrected> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, message.Message.Name, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCorrectedToCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasDefined> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, message.Message.HomonymAddition, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCorrected> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, message.Message.HomonymAddition, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCorrectedToCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameBecameCurrent> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Current,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToCurrent> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Current,
                    ct);
            });

            When <Envelope <StreetNameWasProposed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Proposed,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToProposed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Proposed,
                    ct);
            });

            When <Envelope <StreetNameWasRetired> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Retired,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToRetired> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Retired,
                    ct);
            });

            When <Envelope <StreetNameStatusWasRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = null,
                    ct);
            });

            When <Envelope <StreetNameStatusWasCorrectedToRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = null,
                    ct);
            });

            When <Envelope <StreetNameBecameComplete> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.IsComplete = true,
                    ct);
            });

            When <Envelope <StreetNameBecameIncomplete> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.IsComplete = false,
                    ct);
            });

            When <Envelope <StreetNameWasRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => { },
                    ct);
            });

            When <Envelope <StreetNamePrimaryLanguageWasCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasCorrected> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasCorrectedToCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasDefined> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCorrected> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCorrectedToCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasDefined> >(async(context, message, ct) => DoNothing());

            When <Envelope <StreetNameWasImportedFromCrab> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameStatusWasImportedFromCrab> >(async(context, message, ct) => DoNothing());

            #endregion

            When <Envelope <StreetNameWasProposedV2> >(async(context, message, ct) =>
            {
                var streetNameSyndicationItem = new StreetNameSyndicationItem
                {
                    Position                 = message.Position,
                    PersistentLocalId        = message.Message.PersistentLocalId,
                    MunicipalityId           = message.Message.MunicipalityId,
                    NisCode                  = message.Message.NisCode,
                    RecordCreatedAt          = message.Message.Provenance.Timestamp,
                    LastChangedOn            = message.Message.Provenance.Timestamp,
                    ChangeType               = message.EventName,
                    SyndicationItemCreatedAt = DateTimeOffset.UtcNow
                };
                UpdateNameByLanguage(streetNameSyndicationItem, message.Message.StreetNameNames);
                streetNameSyndicationItem.ApplyProvenance(message.Message.Provenance);
                streetNameSyndicationItem.SetEventData(message.Message, message.EventName);

                await context
                .StreetNameSyndication
                .AddAsync(streetNameSyndicationItem, ct);
            });

            When <Envelope <MunicipalityNisCodeWasChanged> >(async(context, message, ct) =>
            {
                var streetNames = context
                                  .StreetNameSyndication
                                  .Local
                                  .Where(s => s.MunicipalityId == message.Message.MunicipalityId)
                                  .Union(context.StreetNameSyndication.Where(s => s.MunicipalityId == message.Message.MunicipalityId));

                foreach (var streetNameSyndicationItem in streetNames)
                {
                    streetNameSyndicationItem.NisCode = message.Message.NisCode;
                    streetNameSyndicationItem.ApplyProvenance(message.Message.Provenance);
                    streetNameSyndicationItem.SetEventData(message.Message, message.EventName);
                }
            });
        }
コード例 #6
0
 public static void SetEventData <T>(this StreetNameSyndicationItem syndicationItem, T message, string eventName)
 => syndicationItem.EventDataAsXml = message.ToXml(eventName).ToString(SaveOptions.DisableFormatting);
コード例 #7
0
        public StreetNameSyndicationProjections()
        {
            When <Envelope <StreetNameWasRegistered> >(async(context, message, ct) =>
            {
                var streetNameSyndicationItem = new StreetNameSyndicationItem
                {
                    Position        = message.Position,
                    StreetNameId    = message.Message.StreetNameId,
                    NisCode         = message.Message.NisCode,
                    RecordCreatedAt = message.Message.Provenance.Timestamp,
                    LastChangedOn   = message.Message.Provenance.Timestamp,
                    ChangeType      = message.EventName
                };

                streetNameSyndicationItem.ApplyProvenance(message.Message.Provenance);
                streetNameSyndicationItem.SetEventData(message.Message, message.EventName);

                await context
                .StreetNameSyndication
                .AddAsync(streetNameSyndicationItem, ct);
            });

            When <Envelope <StreetNamePersistentLocalIdWasAssigned> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.PersistentLocalId = message.Message.PersistentLocalId,
                    ct);
            });

            When <Envelope <StreetNameWasNamed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, message.Message.Name, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCorrected> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, message.Message.Name, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameNameWasCorrectedToCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateNameByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasDefined> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, message.Message.HomonymAddition, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCorrected> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, message.Message.HomonymAddition, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameHomonymAdditionWasCorrectedToCleared> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => UpdateHomonymAdditionByLanguage(x, null, message.Message.Language),
                    ct);
            });

            When <Envelope <StreetNameBecameCurrent> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Current,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToCurrent> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Current,
                    ct);
            });

            When <Envelope <StreetNameWasProposed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Proposed,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToProposed> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Proposed,
                    ct);
            });

            When <Envelope <StreetNameWasRetired> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Retired,
                    ct);
            });

            When <Envelope <StreetNameWasCorrectedToRetired> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = StreetNameStatus.Retired,
                    ct);
            });

            When <Envelope <StreetNameStatusWasRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = null,
                    ct);
            });

            When <Envelope <StreetNameStatusWasCorrectedToRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.Status = null,
                    ct);
            });

            When <Envelope <StreetNameBecameComplete> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.IsComplete = true,
                    ct);
            });

            When <Envelope <StreetNameBecameIncomplete> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => x.IsComplete = false,
                    ct);
            });

            When <Envelope <StreetNameWasRemoved> >(async(context, message, ct) =>
            {
                await context.CreateNewStreetNameSyndicationItem(
                    message.Message.StreetNameId,
                    message,
                    x => { },
                    ct);
            });

            When <Envelope <StreetNamePrimaryLanguageWasCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasCorrected> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasCorrectedToCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNamePrimaryLanguageWasDefined> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCorrected> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasCorrectedToCleared> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameSecondaryLanguageWasDefined> >(async(context, message, ct) => DoNothing());

            When <Envelope <StreetNameWasImportedFromCrab> >(async(context, message, ct) => DoNothing());
            When <Envelope <StreetNameStatusWasImportedFromCrab> >(async(context, message, ct) => DoNothing());
        }