Skip to content

Commit

Permalink
add integrationdb registration to api
Browse files Browse the repository at this point in the history
  • Loading branch information
pgallik authored and emalfroy committed Dec 15, 2023
1 parent b4f8e84 commit e0a9608
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public Importer(IntegrationContext integrationContext)

public async Task ExecuteAsync()
{
var k = _integrationContext.SuspiciousCaseListItems.Take(5).ToList();

using var httpClient = new HttpClient();

foreach (var nisCode in _integrationContext.Municipalities.Select(x => x.NisCode))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Configure(EntityTypeBuilder<SuspiciousCaseListItem> builder)
""NisCode""
,""Count""
,""Type""
FROM {ViewName};");
FROM {ViewName}");
}

public const string ViewName = @$"""{IntegrationContext.Schema}"".""VIEW_{nameof(SuspiciousCaseListItemConfiguration)}""";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,42 @@ public enum Category
/// <summary>
/// Adres.
/// </summary>
[DataMember(Name = "adres")]
[EnumMember]
Address = 1,

/// <summary>
/// Perceel.
/// </summary>
[DataMember(Name = "perceel")]
[EnumMember]
Parcel = 2,

/// <summary>
/// Wegverbinding.
/// </summary>
[DataMember(Name = "wegsegment")]
[EnumMember]
RoadSegment = 3,

/// <summary>
/// Gebouw.
/// </summary>
[DataMember(Name = "gebouw")]
[EnumMember]
Building = 4,

/// <summary>
/// Gebouweenheid.
/// </summary>
[DataMember(Name = "gebouweenheid")]
[EnumMember]
Buildingunit = 5,

/// <summary>
/// Straatnaam.
/// </summary>
[DataMember(Name = "straatnaam")]
[EnumMember]
StreetName = 6
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ namespace Basisregisters.IntegrationDb.SuspiciousCases.Api.Infrastructure
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.OpenApi.Models;
using Modules;
using Schema;

/// <summary>Represents the startup process for the application.</summary>
public class Startup
Expand Down Expand Up @@ -105,10 +108,27 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
Authorization = options => { options.AddAcmIdmAuthorization(); }
}
}
.EnableJsonErrorActionFilterOption())

.EnableJsonErrorActionFilterOption())
.Configure<ResponseOptions>(_configuration.GetSection("ResponseOptions"))
.AddSingleton<IActionContextAccessor, ActionContextAccessor>(); // Used to retrieve the authenticated user claims.

var connectionString = _configuration.GetConnectionString("IntegrationDb")
?? throw new InvalidOperationException(
$"Could not find a connection string with name 'IntegrationDb'");

services
.AddDbContext<IntegrationContext>((_, options) =>
{
options.UseLoggerFactory(new NullLoggerFactory());
options.UseNpgsql(connectionString, sqlServerOptions =>
{
sqlServerOptions.EnableRetryOnFailure();
sqlServerOptions.MigrationsHistoryTable(IntegrationContext.MigrationsTableName, IntegrationContext.Schema);
sqlServerOptions.UseNetTopologySuite();
});
});

var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterModule(new ApiModule(_configuration, services, _loggerFactory));
_applicationContainer = containerBuilder.Build();
Expand Down Expand Up @@ -185,7 +205,7 @@ public void Configure(
// _configuration.GetConnectionString("SuspiciousCasesAdmin"),
// serviceProvider.GetService<ILoggerFactory>());

StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag, loggerFactory).GetAwaiter().GetResult();
//StartupHelpers.CheckDatabases(healthCheckService, DatabaseTag, loggerFactory).GetAwaiter().GetResult();
}

private static string GetApiLeadingText(ApiVersionDescription description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed class SuspiciousCasesListResponse
/// <summary>
/// Collectie van verdachte gevallen.
/// </summary>
[DataMember(Name = "Gebouwen", Order = 1)]
[DataMember(Name = "resultaat", Order = 1)]
[JsonProperty(Required = Required.DisallowNull)]
public List<SuspiciousCasesListResponseItem> VerdachteGevallen { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed class SuspiciousCasesListResponseItem
/// <summary>
/// Naam van het verdacht geval. Dit is uitbreidbaar in de toekomst met nieuwe verdachte gevallen.
/// </summary>
[DataMember(Name = "Naam", Order = 4)]
[DataMember(Name = "Aantal", Order = 4)]
[JsonProperty(Required = Required.DisallowNull)]
public int Count { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ public enum Severity
/// <summary>
/// Foutief.
/// </summary>
[DataMember(Name = "foutief")]
[EnumMember]
Incorrect = 1,

/// <summary>
/// Verdacht.
/// </summary>
[DataMember(Name = "verdacht")]
[EnumMember]
Suspicious = 2,

/// <summary>
/// Verbeterbaar.
/// </summary>
[DataMember(Name = "verbeterbaar")]
[EnumMember]
Improveable = 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,63 @@ public class SuspiciousCase
{
{
SuspiciousCasesType.CurrentAddressWithoutLinkedParcelsOrBuildingUnits,
new SuspiciousCase(Category.Address, "Adressen \"in gebruik\" zonder koppeling aan perceel of gebouweenheid", Severity.Incorrect)
new SuspiciousCase(Category.Address, "Adressen 'in gebruik' zonder koppeling aan perceel of gebouweenheid", Severity.Incorrect)
},
{
SuspiciousCasesType.ProposedAddressWithoutLinkedParcelsOrBuildingUnits,
new SuspiciousCase(Category.Address, "Adressen \"voorgesteld\" zonder koppeling aan perceel of gebouweenheid", Severity.Suspicious)
new SuspiciousCase(Category.Address, "Adressen 'voorgesteld' zonder koppeling aan perceel of gebouweenheid", Severity.Suspicious)
},
{
SuspiciousCasesType.AddressesOutsideOfMunicipalityBoundaries,
new SuspiciousCase(Category.Address, "Adressen die buiten de grenzen van de gemeente vallen", Severity.Incorrect)
},
{
SuspiciousCasesType.CurrentStreetNamesWithoutRoadSegment,
new SuspiciousCase(Category.StreetName, "Straatnamen \"in gebruik\" zonder koppeling met wegverbinding", Severity.Incorrect)
new SuspiciousCase(Category.StreetName, "Straatnamen 'in gebruik' zonder koppeling met wegverbinding", Severity.Incorrect)
},
{
SuspiciousCasesType.StreetNamesLongerThanTwoYearsProposed,
new SuspiciousCase(Category.StreetName, "Straatnamen langer dan 2 jaar \"voorgesteld\"", Severity.Improveable)
new SuspiciousCase(Category.StreetName, "Straatnamen langer dan 2 jaar 'voorgesteld'", Severity.Improveable)
},
{
SuspiciousCasesType.AddressesLongerThanTwoYearsProposed,
new SuspiciousCase(Category.Address, "Adressen bestaat langer dan 2 jaar en heeft nog de status \"voorgesteld\"", Severity.Improveable)
new SuspiciousCase(Category.Address, "Adressen bestaat langer dan 2 jaar en heeft nog de status 'voorgesteld'", Severity.Improveable)
},
{
SuspiciousCasesType.RoadSegmentsLongerThanTwoYearsProposed,
new SuspiciousCase(Category.RoadSegment, "Wegverbindingen bestaat langer dan 2 jaar en heeft nog de status \"voorgesteld\"", Severity.Improveable)
new SuspiciousCase(Category.RoadSegment, "Wegverbindingen bestaat langer dan 2 jaar en heeft nog de status 'voorgesteld'", Severity.Improveable)
},
{
SuspiciousCasesType.BuildingLongerThanTwoYearsPlanned,
new SuspiciousCase(Category.Building, "Gebouw bestaat langer dan 2 jaar en heeft nog steeds de status \"gepland\"", Severity.Improveable)
new SuspiciousCase(Category.Building, "Gebouw bestaat langer dan 2 jaar en heeft nog steeds de status 'gepland'", Severity.Improveable)
},
{
SuspiciousCasesType.BuildingUnitLongerThanTwoYearsPlanned,
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden bestaat langer dan 2 jaar en heeft nog de status \"gepland\"", Severity.Improveable)
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden bestaat langer dan 2 jaar en heeft nog de status 'gepland'", Severity.Improveable)
},
{
SuspiciousCasesType.StreetNameWithOnlyOneRoadSegmentToOnlyOneSide,
new SuspiciousCase(Category.RoadSegment, "Straatnaam waarbij enkel een wegverbindingen gekoppeld aan slechts 1 kant", Severity.Improveable)
},
{
SuspiciousCasesType.AddressesAppointedByAdministratorOutsideLinkedBuilding,
new SuspiciousCase(Category.Address, "Adressen met herkomst \"AangeduidDoorBeheerder\" buiten het gekoppelde gebouw", Severity.Improveable)
new SuspiciousCase(Category.Address, "Adressen met herkomst 'AangeduidDoorBeheerder' buiten het gekoppelde gebouw", Severity.Improveable)
},
{
SuspiciousCasesType.AddressesWithBuildingUnitSpecificationOutsideLinkedActiveBuildingUnit,
new SuspiciousCase(Category.Address, "Adressen met specificatie \"gebouweenheid \" en status \"inGebruik\" zonder koppeling met gebouweenheid", Severity.Improveable)
new SuspiciousCase(Category.Address, "Adressen met specificatie 'gebouweenheid ' en status 'inGebruik' zonder koppeling met gebouweenheid", Severity.Improveable)
},
{
SuspiciousCasesType.BuildingUnitsWithoutAddress,
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden met status \"gepland\" of \"gerealiseerd\" die niet gekoppeld zijn aan een adres", Severity.Improveable)
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden met status 'gepland' of 'gerealiseerd' die niet gekoppeld zijn aan een adres", Severity.Improveable)
},
{
SuspiciousCasesType.BuildingUnitsLinkedToMultipleAddresses,
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden met status \"gepland\" of \"gerealiseerd\" die gekoppeld zijn aan meerdere adressen", Severity.Improveable)
new SuspiciousCase(Category.Buildingunit, "Gebouweenheden met status 'gepland' of 'gerealiseerd' die gekoppeld zijn aan meerdere adressen", Severity.Improveable)
},
{
SuspiciousCasesType.AddressesLinkedToMultipleBuildingUnits,
new SuspiciousCase(Category.Address, "Adressen met status \"voorgesteld\" of \"inGebruik\" die gekoppeld zijn aan meerdere gebouweenheden", Severity.Improveable)
new SuspiciousCase(Category.Address, "Adressen met status 'voorgesteld' of 'inGebruik' die gekoppeld zijn aan meerdere gebouweenheden", Severity.Improveable)
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task<IActionResult> List(CancellationToken cancellationToken)
filtering.Filter.NisCode = nisCode;
}

if (string.IsNullOrWhiteSpace(filtering.Filter.NisCode))
if (string.IsNullOrWhiteSpace(filtering.Filter?.NisCode))
{
throw new ValidationException(new[]
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"ConnectionStrings": {
"SuspiciousCases": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.BuildingRegistry;Trusted_Connection=True;TrustServerCertificate=True;",
"SuspiciousCasesAdmin": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.BuildingRegistry;Trusted_Connection=True;TrustServerCertificate=True;"
"IntegrationDb": "Server=(localdb)\\mssqllocaldb;Database=EFProviders.InMemory.BuildingRegistry;Trusted_Connection=True;TrustServerCertificate=True;"
},
"OAuth2IntrospectionOptions": {
"ClientId": "clientid",
"ClientSecret": "clientsecret",
"Authority": "https://authenticatie-ti.vlaanderen.be/op/v1/auth",
"IntrospectionEndpoint": "https://authenticatie-ti.vlaanderen.be/op/v1/introspect"
},
"ClientId": "",
"ClientSecret": "",

"BaseUrl": "https://api.staging-basisregisters.vlaanderen/",
"DataDog": {
"Enabled": true,
Expand Down

0 comments on commit e0a9608

Please sign in to comment.