-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add suspicious case CurrentAddressLinkedToProposedStreetName
- Loading branch information
1 parent
676c37f
commit e97fe85
Showing
8 changed files
with
625 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
500 changes: 500 additions & 0 deletions
500
...ses/Migrations/20241210123817_AddViewCurrentAddressLinkedToProposedStreetName.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...piciousCases/Migrations/20241210123817_AddViewCurrentAddressLinkedToProposedStreetName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Basisregisters.IntegrationDb.SuspiciousCases.Migrations | ||
{ | ||
using System; | ||
using Infrastructure; | ||
using Views; | ||
|
||
/// <inheritdoc /> | ||
public partial class AddViewCurrentAddressLinkedToProposedStreetName : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.Sql($"DROP VIEW IF EXISTS {Schema.SuspiciousCases}.{CurrentAddressLinkedToProposedStreetNameConfiguration.ViewName};"); | ||
|
||
migrationBuilder.Sql(CurrentAddressLinkedToProposedStreetNameConfiguration.Create); | ||
|
||
migrationBuilder.Sql(SuspiciousCaseCountConfiguration.Create); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...registers.IntegrationDb.SuspiciousCases/Views/CurrentAddressLinkedToProposedStreetName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace Basisregisters.IntegrationDb.SuspiciousCases.Views | ||
{ | ||
using Infrastructure; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||
|
||
public sealed class CurrentAddressLinkedToProposedStreetName : SuspiciousCase | ||
{ | ||
public int AddressPersistentLocalId { get; set; } | ||
|
||
public override Category Category => Category.Address; | ||
} | ||
|
||
public sealed class CurrentAddressLinkedToProposedStreetNameConfiguration : IEntityTypeConfiguration<CurrentAddressLinkedToProposedStreetName> | ||
{ | ||
public void Configure(EntityTypeBuilder<CurrentAddressLinkedToProposedStreetName> builder) | ||
{ | ||
builder | ||
.ToView(ViewName, Schema.SuspiciousCases) | ||
.HasNoKey() | ||
.ToSqlQuery(@$" | ||
SELECT | ||
persistent_local_id, | ||
address_persistent_local_id, | ||
nis_code, | ||
description | ||
FROM {Schema.SuspiciousCases}.{ViewName}"); | ||
|
||
builder.Property(x => x.PersistentLocalId).HasColumnName("persistent_local_id"); | ||
builder.Property(x => x.AddressPersistentLocalId).HasColumnName("address_persistent_local_id"); | ||
builder.Property(x => x.NisCode).HasColumnName("nis_code"); | ||
builder.Property(x => x.Description).HasColumnName("description"); | ||
} | ||
|
||
public const string ViewName = "view_current_address_linked_to_proposed_streetname"; | ||
|
||
public const string Create = $@" | ||
CREATE OR REPLACE VIEW {Schema.SuspiciousCases}.{ViewName} AS | ||
SELECT | ||
CAST(a.persistent_local_id as varchar) AS persistent_local_id, | ||
a.persistent_local_id AS address_persistent_local_id, | ||
s.nis_code AS nis_code, | ||
{Schema.FullAddress}(s.name_dutch, a.house_number, a.box_number, a.postal_code, m.name_dutch) as description | ||
FROM {SchemaLatestItems.Address} AS a | ||
JOIN {SchemaLatestItems.StreetName} s ON s.persistent_local_id = a.street_name_persistent_local_id AND s.status = 0 | ||
JOIN {SchemaLatestItems.Municipality} m ON s.municipality_id = m.municipality_id | ||
WHERE | ||
a.status = 2 | ||
AND a.removed = false | ||
;"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters