public async Task <IActionResult> Get(
     [FromServices] LegacyContext legacyContext,
     [FromServices] SyndicationContext syndicationContext,
     [FromServices] IOptions <ResponseOptions> responseOptions,
     [FromRoute] int persistentLocalId,
     CancellationToken cancellationToken = default)
 => Ok(await new StreetNameDetailQuery(legacyContext, syndicationContext, responseOptions).FilterAsync(persistentLocalId, cancellationToken));
        public async Task <IActionResult> List(
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] LegacyContext legacyContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            Taal?taal,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <StreetNameFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = Request.ExtractPaginationRequest();

            var pagedStreetNames = new StreetNameListQuery(legacyContext, syndicationContext)
                                   .Fetch(filtering, sorting, pagination);

            Response.AddPagedQueryResultHeaders(pagedStreetNames);

            return(Ok(
                       new StreetNameListResponse
            {
                Straatnamen = await pagedStreetNames
                              .Items
                              .Select(m => new StreetNameListItemResponse(
                                          m.PersistentLocalId,
                                          responseOptions.Value.Naamruimte,
                                          responseOptions.Value.DetailUrl,
                                          GetGeografischeNaamByTaal(m, m.PrimaryLanguage),
                                          GetHomoniemToevoegingByTaal(m, m.PrimaryLanguage),
                                          m.Status.ConvertFromStreetNameStatus(),
                                          m.VersionTimestamp.ToBelgianDateTimeOffset()))
                              .ToListAsync(cancellationToken),
                Volgende = BuildNextUri(pagedStreetNames.PaginationInfo, responseOptions.Value.VolgendeUrl)
            }));
        }
예제 #3
0
        public async Task <IActionResult> Count(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <StreetNameFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = new NoPaginationRequest();

            if (_useProjectionsV2Toggle.FeatureEnabled)
            {
                return(Ok(
                           new TotaalAantalResponse
                {
                    Aantal = await new StreetNameListOsloQuery <StreetNameListItemV2>(context, syndicationContext)
                             .Fetch <StreetNameListItemV2, StreetNameListItemV2>(filtering, sorting, pagination)
                             .Items
                             .CountAsync(cancellationToken)
                }));
            }

            return(Ok(
                       new TotaalAantalResponse
            {
                Aantal = filtering.ShouldFilter
                        ? await new StreetNameListOsloQuery <StreetNameListItem>(context, syndicationContext)
                         .Fetch <StreetNameListItem, StreetNameListItem>(filtering, sorting, pagination)
                         .Items
                         .CountAsync(cancellationToken)
                        : Convert.ToInt32((await context
                                           .StreetNameListViewCount
                                           .FirstAsync(cancellationToken: cancellationToken))
                                          .Count)
            }));
        }
        public async Task <IActionResult> Post(
            [FromServices] LegacyContext legacyContext,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            [FromBody] BosaStreetNameRequest request,
            CancellationToken cancellationToken = default)
        {
            if (Request.ContentLength.HasValue && Request.ContentLength > 0 && request == null)
            {
                return(Ok(new StreetNameBosaResponse()));
            }

            var filter = new StreetNameNameFilter(request);

            if (_useProjectionsV2Toggle.FeatureEnabled)
            {
                var streetNameBosaResponseV2 = await
                                               new StreetNameBosaQueryV2(
                    legacyContext,
                    syndicationContext,
                    responseOptions)
                                               .FilterAsync(filter, cancellationToken);

                return(Ok(streetNameBosaResponseV2));
            }

            var streetNameBosaResponse = await
                                         new StreetNameBosaQuery(
                legacyContext,
                syndicationContext,
                responseOptions)
                                         .FilterAsync(filter, cancellationToken);

            return(Ok(streetNameBosaResponse));
        }
 public StreetNameBosaQuery(
     LegacyContext legacyContext,
     SyndicationContext syndicationContext,
     IOptions <ResponseOptions> responseOptionsProvider)
 {
     _legacyContext           = legacyContext;
     _syndicationContext      = syndicationContext;
     _responseOptionsProvider = responseOptionsProvider;
 }
예제 #6
0
 public IActionResult Get(
     [FromServices] ExtractContext context,
     [FromServices] SyndicationContext syndicationContext,
     CancellationToken cancellationToken = default) =>
 new ExtractArchive($"{ZipName}-{DateTime.Now:yyyy-MM-dd}")
 {
     StreetNameRegistryExtractBuilder.CreateStreetNameFile(context, syndicationContext)
 }
 .CreateFileCallbackResult(cancellationToken);
 public StreetNameDetailQuery(
     LegacyContext legacyContext,
     SyndicationContext syndicationContext,
     IOptions <ResponseOptions> responseOptionsProvider)
 {
     _legacyContext      = legacyContext;
     _syndicationContext = syndicationContext;
     _responseOptions    = responseOptionsProvider.Value;
 }
        public static ExtractFile CreateStreetNameFile(ExtractContext context, SyndicationContext syndicationContext)
        {
            var extractItems = context
                               .StreetNameExtract
                               .AsNoTracking()
                               .Where(x => x.Complete)
                               .OrderBy(x => x.StreetNamePersistentLocalId);

            var cachedMunicipalities = syndicationContext.MunicipalityLatestItems.AsNoTracking().ToList();

            byte[] TransformRecord(StreetNameExtractItem r)
            {
                var item = new StreetNameDbaseRecord();

                item.FromBytes(r.DbaseRecord, DbfFileWriter <StreetNameDbaseRecord> .Encoding);

                var municipality = cachedMunicipalities.First(x => x.NisCode == item.gemeenteid.Value);

                switch (municipality.PrimaryLanguage)
                {
                case null:
                default:
                    item.straatnm.Value   = r.NameUnknown;
                    item.homoniemtv.Value = r.HomonymUnknown ?? string.Empty;
                    break;

                case Taal.NL:
                    item.straatnm.Value   = r.NameDutch;
                    item.homoniemtv.Value = r.HomonymDutch ?? string.Empty;
                    break;

                case Taal.FR:
                    item.straatnm.Value   = r.NameFrench;
                    item.homoniemtv.Value = r.HomonymFrench ?? string.Empty;
                    break;

                case Taal.DE:
                    item.straatnm.Value   = r.NameGerman;
                    item.homoniemtv.Value = r.HomonymGerman ?? string.Empty;
                    break;

                case Taal.EN:
                    item.straatnm.Value   = r.NameEnglish;
                    item.homoniemtv.Value = r.HomonymEnglish ?? string.Empty;
                    break;
                }

                return(item.ToBytes(DbfFileWriter <StreetNameDbaseRecord> .Encoding));
            }

            return(ExtractBuilder.CreateDbfFile <StreetNameExtractItem, StreetNameDbaseRecord>(
                       ExtractController.ZipName,
                       new StreetNameDbaseSchema(),
                       extractItems,
                       extractItems.Count,
                       TransformRecord));
        }
예제 #9
0
 public IActionResult Get(
     [FromServices] ExtractContext context,
     [FromServices] SyndicationContext syndicationContext,
     CancellationToken cancellationToken = default) =>
 new ExtractArchive(ExtractFileNames.GetAddressZip())
 {
     AddressRegistryExtractBuilder.CreateAddressFiles(context, syndicationContext),
     AddressCrabHouseNumberIdExtractBuilder.CreateAddressCrabHouseNumberIdFile(context),
     AddressCrabSubaddressIdExtractBuilder.CreateAddressSubaddressIdFile(context)
 }
 .CreateFileCallbackResult(cancellationToken);
예제 #10
0
        public async Task <IActionResult> PostBosaAddressRepresentations(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            [FromBody] BosaAddressRepresentationRequest request,
            CancellationToken cancellationToken = default)
        {
            if (Request.ContentLength.HasValue && Request.ContentLength > 0 && request == null)
            {
                return(Ok(new AddressRepresentationBosaResponse()));
            }

            if (string.IsNullOrEmpty(request?.AdresCode?.ObjectId) || !int.TryParse(request.AdresCode.ObjectId, out var addressId))
            {
                return(BadRequest("Valid objectId is required"));
            }

            var address = await context.AddressDetail.FirstOrDefaultAsync(x => x.PersistentLocalId == addressId, cancellationToken);

            if (address == null)
            {
                return(NotFound());
            }

            var streetName = await syndicationContext
                             .StreetNameBosaItems
                             .FirstOrDefaultAsync(x => x.StreetNameId == address.StreetNameId, cancellationToken);

            var municipality = await syndicationContext
                               .MunicipalityBosaItems
                               .FirstOrDefaultAsync(x => x.NisCode == streetName.NisCode, cancellationToken);

            var response = new AddressRepresentationBosaResponse
            {
                Identificator = new AdresIdentificator(responseOptions.Value.Naamruimte, address.PersistentLocalId.ToString(), address.VersionTimestamp.ToBelgianDateTimeOffset())
            };

            if (!request.Taal.HasValue || request.Taal.Value == municipality.PrimaryLanguage)
            {
                response.AdresVoorstellingen = new List <BosaAddressRepresentation>
                {
                    new BosaAddressRepresentation(
                        municipality.PrimaryLanguage.Value,
                        address.HouseNumber,
                        address.BoxNumber,
                        AddressMapper.GetVolledigAdres(address.HouseNumber, address.BoxNumber, address.PostalCode, streetName, municipality).GeografischeNaam.Spelling,
                        AddressMapper.GetDefaultMunicipalityName(municipality).Value,
                        AddressMapper.GetDefaultStreetNameName(streetName, municipality.PrimaryLanguage).Value,
                        address.PostalCode)
                };
            }

            return(Ok(response));
        }
예제 #11
0
        public IActionResult GetAddressLinks(
            [FromServices] SyndicationContext syndicationContext,
            CancellationToken cancellationToken = default)
        {
            var extractBuilder = new LinkedAddressExtractBuilder(syndicationContext);

            return(new ExtractArchive(ExtractFileNames.GetAddressLinksZip())
            {
                extractBuilder.CreateLinkedBuildingUnitAddressFiles(),
                extractBuilder.CreateLinkedParcelAddressFiles()
            }
                   .CreateFileCallbackResult(cancellationToken));
        }
예제 #12
0
        public async Task <IActionResult> GetAddressLinks(
            [FromServices] IConfiguration configuration,
            [FromServices] SyndicationContext syndicationContext,
            CancellationToken cancellationToken = default)
        {
            var extractBuilder = new LinkedAddressExtractBuilder(syndicationContext, configuration.GetConnectionString("SyndicationProjections"));

            return(new ExtractArchive(ExtractFileNames.GetAddressLinksZip())
            {
                extractBuilder.CreateLinkedBuildingUnitAddressFiles(),
                await extractBuilder.CreateLinkedParcelAddressFiles(cancellationToken)
            }
                   .CreateFileCallbackResult(cancellationToken));
        }
        public async Task <IActionResult> Get(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            [FromRoute] string caPaKey,
            CancellationToken cancellationToken = default)
        {
            var parcel =
                await context
                .ParcelDetail
                .Include(x => x.Addresses)
                .AsNoTracking()
                .SingleOrDefaultAsync(item => item.PersistentLocalId == caPaKey, cancellationToken);

            if (parcel != null && parcel.Removed)
            {
                throw new ApiException("Perceel werd verwijderd.", StatusCodes.Status410Gone);
            }

            if (parcel == null)
            {
                throw new ApiException("Onbestaand perceel.", StatusCodes.Status404NotFound);
            }

            var addressIds = parcel.Addresses.Select(x => x.AddressId);

            var addressPersistentLocalIds = await syndicationContext
                                            .AddressPersistentLocalIds
                                            .AsNoTracking()
                                            .Where(x => addressIds.Contains(x.AddressId) && x.IsComplete && !x.IsRemoved)
                                            .Select(x => x.PersistentLocalId)
                                            .OrderBy(x => x) //sorts on string! other order as a number!
                                            .ToListAsync(cancellationToken);

            return(Ok(
                       new ParcelOsloResponse(
                           responseOptions.Value.Naamruimte,
                           responseOptions.Value.ContextUrlDetail,
                           parcel.Status.MapToPerceelStatus(),
                           parcel.PersistentLocalId,
                           parcel.VersionTimestamp.ToBelgianDateTimeOffset(),
                           addressPersistentLocalIds.ToList(),
                           responseOptions.Value.AdresDetailUrl)));
        }
        public async Task <IActionResult> Propose(
            [FromServices] IOptions <ResponseOptions> options,
            [FromServices] IdempotencyContext idempotencyContext,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IPersistentLocalIdGenerator persistentLocalIdGenerator,
            [FromBody] StreetNameProposeRequest streetNameProposeRequest,
            CancellationToken cancellationToken = default)
        {
            try
            {
                //TODO REMOVE WHEN IMPLEMENTED
                return(new CreatedWithETagResult(new Uri(string.Format(options.Value.DetailUrl, "1")), "1"));

                //TODO real data please
                var fakeProvenanceData = new Provenance(
                    DateTime.UtcNow.ToInstant(),
                    Application.StreetNameRegistry,
                    new Reason(""),
                    new Operator(""),
                    Modification.Insert,
                    Organisation.DigitaalVlaanderen
                    );

                var identifier = streetNameProposeRequest.GemeenteId
                                 .AsIdentifier()
                                 .Map(IdentifierMappings.MunicipalityNisCode);

                var municipality = await syndicationContext.MunicipalityLatestItems
                                   .AsNoTracking()
                                   .SingleOrDefaultAsync(i =>
                                                         i.NisCode == identifier.Value, cancellationToken);

                var persistentLocalId = persistentLocalIdGenerator.GenerateNextPersistentLocalId();
                var cmd      = streetNameProposeRequest.ToCommand(new MunicipalityId(municipality.MunicipalityId), fakeProvenanceData, persistentLocalId);
                var position = await IdempotentCommandHandlerDispatch(idempotencyContext, cmd.CreateCommandId(), cmd, cancellationToken);

                return(new CreatedWithLastObservedPositionAsETagResult(new Uri(string.Format(options.Value.DetailUrl, persistentLocalId)), position.ToString(), Application.StreetNameRegistry.ToString()));
            }
            catch (IdempotencyException)
            {
                return(Accepted());
            }
        }
 public IActionResult Get(
     [FromServices] ExtractContext context,
     [FromServices] UseExtractV2Toggle useExtractV2Toggle,
     [FromServices] SyndicationContext syndicationContext,
     CancellationToken cancellationToken = default)
 {
     if (useExtractV2Toggle.FeatureEnabled)
     {
         return(new IsolationExtractArchive($"{ZipName}-{DateTime.Now:yyyy-MM-dd}", context)
         {
             StreetNameRegistryExtractBuilder.CreateStreetNameFilesV2(context, syndicationContext)
         }
                .CreateFileCallbackResult(cancellationToken));
     }
     return(new IsolationExtractArchive($"{ZipName}-{DateTime.Now:yyyy-MM-dd}", context)
     {
         StreetNameRegistryExtractBuilder.CreateStreetNameFiles(context, syndicationContext)
     }
            .CreateFileCallbackResult(cancellationToken));
 }
예제 #16
0
        public async Task <IActionResult> Get(
            [FromServices] LegacyContext legacyContext,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            [FromRoute] int persistentLocalId,
            CancellationToken cancellationToken = default)
        {
            if (_useProjectionsV2Toggle.FeatureEnabled)
            {
                return(Ok(await new StreetNameDetailOsloQuery(legacyContext, syndicationContext, responseOptions)
                          .FilterAsync <StreetNameDetailV2>(
                              i => i.PersistentLocalId,
                              i => i.PersistentLocalId == persistentLocalId
                              , cancellationToken)));
            }

            return(Ok(await new StreetNameDetailOsloQuery(legacyContext, syndicationContext, responseOptions)
                      .FilterAsync <StreetNameDetail>(
                          i => i.PersistentLocalId,
                          i => i.PersistentLocalId == persistentLocalId
                          , cancellationToken)));
        }
        public async Task <IActionResult> Count(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <PostalInformationFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = new NoPaginationRequest();

            return(Ok(
                       new TotaalAantalResponse
            {
                Aantal = filtering.ShouldFilter
                        ? await new PostalInformationListOsloQuery(context, syndicationContext)
                         .Fetch(filtering, sorting, pagination)
                         .Items
                         .CountAsync(cancellationToken)
                        : await context
                         .PostalInformation
                         .CountAsync(cancellationToken)
            }));
        }
        public async Task <IActionResult> List(
            [FromServices] LegacyContext legacyContext,
            [FromServices] SyndicationContext syndicationContext,
            [FromServices] IOptions <ResponseOptions> responseOptions,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <PostalInformationFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = Request.ExtractPaginationRequest();

            var pagedPostalInformationSet =
                new PostalInformationListOsloQuery(legacyContext, syndicationContext)
                .Fetch(filtering, sorting, pagination);

            Response.AddPagedQueryResultHeaders(pagedPostalInformationSet);

            var postalInformationSet = await pagedPostalInformationSet.Items
                                       .Include(x => x.PostalNames)
                                       .ToListAsync(cancellationToken);

            var items = postalInformationSet
                        .Select(p => new PostalInformationListItemOsloResponse(
                                    p.PostalCode,
                                    responseOptions.Value.Naamruimte,
                                    responseOptions.Value.DetailUrl,
                                    p.IsRetired ? PostInfoStatus.Gehistoreerd : PostInfoStatus.Gerealiseerd,
                                    p.VersionTimestamp.ToBelgianDateTimeOffset())
            {
                Postnamen = p.PostalNames.Select(x => x.ConvertFromPostalName()).ToList()
            }).ToList();

            return(Ok(new PostalInformationListOsloResponse
            {
                PostInfoObjecten = items,
                Volgende = BuildNextUri(pagedPostalInformationSet.PaginationInfo, responseOptions.Value.VolgendeUrl),
                Context = responseOptions.Value.ContextUrlList
            }));
        }
        public async Task <IActionResult> Count(
            [FromServices] LegacyContext context,
            [FromServices] SyndicationContext syndicationContext,
            CancellationToken cancellationToken = default)
        {
            var filtering  = Request.ExtractFilteringRequest <StreetNameFilter>();
            var sorting    = Request.ExtractSortingRequest();
            var pagination = new NoPaginationRequest();

            return(Ok(
                       new TotaalAantalResponse
            {
                Aantal = filtering.ShouldFilter
                        ? await new StreetNameListQuery(context, syndicationContext)
                         .Fetch(filtering, sorting, pagination)
                         .Items
                         .CountAsync(cancellationToken)
                        : Convert.ToInt32(context
                                          .StreetNameListViewCount
                                          .First()
                                          .Count)
            }));
        }
        private static async Task AddSyndicationItemEntry(AtomEntry <SyndicationItem <PostalInfo> > entry, SyndicationContext context, CancellationToken ct)
        {
            var latestItem = await context
                             .PostalInfoLatestItems
                             .FindAsync(entry.Content.Object.PostalCode);

            if (latestItem == null)
            {
                latestItem = new PostalInfoLatestItem
                {
                    PostalCode = entry.Content.Object.PostalCode,
                    Version    = entry.Content.Object.Identificator?.Versie,
                    Position   = long.Parse(entry.FeedEntry.Id),
                    NisCode    = entry.Content.Object.MunicipalityNisCode,
                };

                UpdateNames(latestItem, entry.Content.Object.PostalNames);

                await context
                .PostalInfoLatestItems
                .AddAsync(latestItem, ct);
            }
            else
            {
                await context.Entry(latestItem).Collection(x => x.PostalNames).LoadAsync(ct);

                latestItem.Version  = entry.Content.Object.Identificator?.Versie;
                latestItem.Position = long.Parse(entry.FeedEntry.Id);
                latestItem.NisCode  = entry.Content.Object.MunicipalityNisCode;

                UpdateNames(latestItem, entry.Content.Object.PostalNames);
            }
        }
 private static Task DoNothing(AtomEntry <SyndicationItem <Municipality> > entry, SyndicationContext context, CancellationToken ct) => Task.CompletedTask;
        private static async Task AddSyndicationItemEntry(AtomEntry <SyndicationItem <Municipality> > entry, SyndicationContext context, CancellationToken ct)
        {
            var municipalitySyndicationItem = new MunicipalitySyndicationItem
            {
                MunicipalityId    = entry.Content.Object.Id,
                NisCode           = entry.Content.Object.Identificator?.ObjectId,
                Version           = entry.Content.Object.Identificator?.Versie,
                Position          = long.Parse(entry.FeedEntry.Id),
                OfficialLanguages = entry.Content.Object.OfficialLanguages,
            };

            UpdateNamesByGemeentenamen(municipalitySyndicationItem, entry.Content.Object.MunicipalityNames);

            await context
            .MunicipalitySyndicationItems
            .AddAsync(municipalitySyndicationItem, ct);
        }
        private async Task <AddressBuildingUnitLinkExtractItem> CreateAddressBuildingUnitLinkExtractItem(AtomEntry <SyndicationItem <Building> > entry, Guid addressId, BuildingUnitSyndicationContent buildingUnit, SyndicationContext context)
        {
            var address = await context.AddressLinkAddresses.FindAsync(addressId);

            var dbaseRecord = CreateDbaseRecord(buildingUnit, address, context);

            return(new AddressBuildingUnitLinkExtractItem
            {
                AddressId = addressId,
                BuildingId = entry.Content.Object.Id,
                BuildingUnitPersistentLocalId = buildingUnit.Identificator.ObjectId,
                BuildingUnitId = buildingUnit.BuildingUnitId,
                DbaseRecord = dbaseRecord, //Add address info
                AddressComplete = address?.IsComplete ?? false,
                AddressPersistentLocalId = address?.PersistentLocalId,
            });
        }
        private async Task AddSyndicationItemEntry(AtomEntry <SyndicationItem <Building> > entry, SyndicationContext context, CancellationToken ct)
        {
            var addressBuildingUnitLinkExtractItems =
                context
                .AddressBuildingUnitLinkExtract
                .Where(x => x.BuildingId == entry.Content.Object.Id)
                .AsEnumerable()
                .Concat(context.AddressBuildingUnitLinkExtract.Local.Where(x => x.BuildingId == entry.Content.Object.Id))
                .Distinct()
                .ToList();

            var itemsToRemove = new List <AddressBuildingUnitLinkExtractItem>();

            foreach (var buildingUnitAddressMatchLatestItem in addressBuildingUnitLinkExtractItems)
            {
                if (!entry.Content.Object.BuildingUnits.Select(x => x.BuildingUnitId).Contains(buildingUnitAddressMatchLatestItem.BuildingUnitId))
                {
                    itemsToRemove.Add(buildingUnitAddressMatchLatestItem);
                }
            }

            context.AddressBuildingUnitLinkExtract.RemoveRange(itemsToRemove);

            foreach (var buildingUnit in entry.Content.Object.BuildingUnits)
            {
                var unitItems            = addressBuildingUnitLinkExtractItems.Where(x => x.BuildingUnitId == buildingUnit.BuildingUnitId).ToList();
                var addressItemsToRemove = unitItems.Where(x => !buildingUnit.Addresses.Contains(x.AddressId));
                foreach (var addressId in buildingUnit.Addresses)
                {
                    var addressItem = unitItems.FirstOrDefault(x => x.AddressId == addressId);
                    if (addressItem == null)
                    {
                        await context.AddressBuildingUnitLinkExtract.AddAsync(await
                                                                              CreateAddressBuildingUnitLinkExtractItem(entry, addressId, buildingUnit, context), ct);
                    }
                    else
                    {
                        addressItem.BuildingUnitPersistentLocalId = buildingUnit.Identificator.ObjectId;
                        UpdateDbaseRecordField(addressItem, record => record.adresobjid.Value = buildingUnit.Identificator.ObjectId);
                    }
                }

                context.AddressBuildingUnitLinkExtract.RemoveRange(addressItemsToRemove);
            }
        }
        private static async Task RemoveBuildingUnit(AtomEntry <SyndicationItem <Building> > entry, SyndicationContext context, CancellationToken ct)
        {
            var addressBuildingUnitLinkExtractItems =
                context
                .AddressBuildingUnitLinkExtract
                .Where(x => x.BuildingId == entry.Content.Object.Id)
                .AsEnumerable()
                .Concat(context.AddressBuildingUnitLinkExtract.Local.Where(x => x.BuildingId == entry.Content.Object.Id))
                .ToList();

            context.AddressBuildingUnitLinkExtract.RemoveRange(addressBuildingUnitLinkExtractItems);
        }
        internal static string CreateCompleteAddress(AddressLinkSyndicationItem address, SyndicationContext context)
        {
            // update streetname, municipality
            var streetName   = context.StreetNameLatestItems.AsNoTracking().First(x => x.StreetNameId == address.StreetNameId);
            var municipality = context.MunicipalityLatestItems.AsNoTracking().First(x => x.NisCode == streetName.NisCode);

            var municipalityName = string.Empty;
            var streetNameName   = string.Empty;

            switch (municipality.PrimaryLanguage)
            {
            case null:
            case Taal.NL:
            default:
                municipalityName = municipality.NameDutch;
                streetNameName   = streetName.NameDutch;
                break;

            case Taal.FR:
                municipalityName = municipality.NameFrench;
                streetNameName   = streetName.NameFrench;
                break;

            case Taal.DE:
                municipalityName = municipality.NameGerman;
                streetNameName   = streetName.NameGerman;
                break;

            case Taal.EN:
                municipalityName = municipality.NameEnglish;
                streetNameName   = streetName.NameEnglish;
                break;
            }

            return
                (new VolledigAdres(
                     streetNameName,
                     address.HouseNumber,
                     address.BoxNumber,
                     address.PostalCode,
                     municipalityName,
                     Taal.NL)
                 .GeografischeNaam
                 .Spelling);
        }
        private byte[] CreateDbaseRecord(BuildingUnitSyndicationContent buildingUnit, AddressLinkSyndicationItem address, SyndicationContext context)
        {
            var record = new AddressLinkDbaseRecord
            {
                objecttype = { Value = "Gebouweenheid" },
                adresobjid = { Value = string.IsNullOrEmpty(buildingUnit.Identificator.ObjectId) ? "" : buildingUnit.Identificator.ObjectId },
            };

            if (address != null)
            {
                if (!string.IsNullOrEmpty(address.PersistentLocalId))
                {
                    record.adresid.Value = Convert.ToInt32(address.PersistentLocalId);
                }

                record.voladres.Value = CreateCompleteAddress(address, context);
            }

            return(record.ToBytes(_encoding));
        }
 private static Task DoNothing(AtomEntry <SyndicationContent <Address> > entry, SyndicationContext context, CancellationToken ct) => Task.CompletedTask;
        private static async Task AddSyndicationItemEntry(AtomEntry <SyndicationContent <Gemeente> > entry, SyndicationContext context, CancellationToken ct)
        {
            var municipalityLatestItem = await context
                                         .MunicipalityLatestItems
                                         .FindAsync(entry.Content.Object.Id);

            if (municipalityLatestItem == null)
            {
                municipalityLatestItem = new MunicipalityLatestItem
                {
                    MunicipalityId  = entry.Content.Object.Id,
                    NisCode         = entry.Content.Object.Identificator?.ObjectId,
                    Version         = entry.Content.Object.Identificator?.Versie,
                    Position        = long.Parse(entry.FeedEntry.Id),
                    PrimaryLanguage = entry.Content.Object.OfficialLanguages.FirstOrDefault()
                };

                UpdateNamesByGemeentenamen(municipalityLatestItem, entry.Content.Object.Gemeentenamen);

                await context
                .MunicipalityLatestItems
                .AddAsync(municipalityLatestItem, ct);
            }
            else
            {
                municipalityLatestItem.NisCode         = entry.Content.Object.Identificator?.ObjectId;
                municipalityLatestItem.Version         = entry.Content.Object.Identificator?.Versie;
                municipalityLatestItem.Position        = long.Parse(entry.FeedEntry.Id);
                municipalityLatestItem.PrimaryLanguage = entry.Content.Object.OfficialLanguages.FirstOrDefault();

                UpdateNamesByGemeentenamen(municipalityLatestItem, entry.Content.Object.Gemeentenamen);
            }
        }
예제 #30
0
        internal static string CreateCompleteAddress(AddressLinkSyndicationItem address, SyndicationContext context)
        {
            // update streetname, municipality
            var streetName   = context.StreetNameLatestItems.AsNoTracking().First(x => x.StreetNameId == address.StreetNameId);
            var municipality = context.MunicipalityLatestItems.AsNoTracking().First(x => x.NisCode == streetName.NisCode);

            var municipalityName = string.Empty;
            var streetNameName   = string.Empty;

            switch (municipality.PrimaryLanguage)
            {
            case null:
            case Taal.NL:
            default:
                municipalityName = municipality.NameDutch;
                streetNameName   = streetName.NameDutch;
                break;

            case Taal.FR:
                municipalityName = municipality.NameFrench;
                streetNameName   = streetName.NameFrench;
                break;

            case Taal.DE:
                municipalityName = municipality.NameGerman;
                streetNameName   = streetName.NameGerman;
                break;

            case Taal.EN:
                municipalityName = municipality.NameEnglish;
                streetNameName   = streetName.NameEnglish;
                break;
            }

            return(string.IsNullOrEmpty(address.BoxNumber)
                ? $"{streetNameName} {address.HouseNumber}, {address.PostalCode}, {municipalityName}"
                : $"{streetNameName} {address.HouseNumber} bus {address.BoxNumber}, {address.PostalCode}, {municipalityName}");
        }