From 2b473ae0b5fa16d8fcf25aec9502569ad85001dc Mon Sep 17 00:00:00 2001 From: Eirik Vigeland Date: Thu, 12 Dec 2024 08:27:30 +0100 Subject: [PATCH] =?UTF-8?q?feat.=20trenger=20ikke=20lengre=20=C3=A5=20hopp?= =?UTF-8?q?e=20over=20dubletter=20av=20deltaker=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nå støtter arena-agreement-migration -tabellen å ha flere deltakere på ett tiltak. Derfor er det ikke noe behov for å ha egen logikk for å hoppe over disse - de kan bare ignoreres. --- .../migration/ArenaAgreementAggregate.java | 8 ++------ .../migration/ArenaMigrationAction.java | 14 ++----------- .../ArenaMigrationProcessResult.java | 1 - .../ArenaAgreementProcessingService.java | 20 ++----------------- 4 files changed, 6 insertions(+), 37 deletions(-) diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementAggregate.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementAggregate.java index 80bb3385c..377e4ad98 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementAggregate.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaAgreementAggregate.java @@ -73,12 +73,8 @@ public Optional findSluttdato() { .findFirst(); } - public boolean isTiltakDublett() { - return isDublett(eksternIdTiltak); - } - - public boolean isDeltakerDublett() { - return isDublett(eksternIdDeltaker); + public boolean isDublett() { + return isDublett(eksternIdTiltak) || isDublett(eksternIdDeltaker); } public Optional getEksternIdAsUuid() throws IllegalArgumentException { diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationAction.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationAction.java index e593152f6..62af289ea 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationAction.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationAction.java @@ -8,7 +8,6 @@ import java.time.LocalDate; public enum ArenaMigrationAction { - HOPP_OVER, GJENOPPRETT, OPPRETT, OPPDATER, @@ -21,14 +20,9 @@ public static ArenaMigrationAction map(ArenaAgreementAggregate agreementAggregat boolean isSluttdatoInTheFuture = agreementAggregate.findSluttdato() .map(sluttdato -> sluttdato.isAfter(LocalDate.now())).orElse(false); - if (agreementAggregate.isDeltakerDublett()) { - return HOPP_OVER; - } - - if (agreementAggregate.isTiltakDublett()) { + if (agreementAggregate.isDublett()) { return IGNORER; } - return switch (deltakerstatuskode) { case GJENN, TILBUD -> isSluttdatoInTheFuture ? OPPRETT : IGNORER; case null, default -> IGNORER; @@ -46,11 +40,7 @@ public static ArenaMigrationAction map( boolean isSluttdatoIFremtiden = agreementAggregate.findSluttdato() .map(sluttdato -> sluttdato.isAfter(LocalDate.now())).orElse(false); - if (agreementAggregate.isDeltakerDublett()) { - return HOPP_OVER; - } - - if (agreementAggregate.isTiltakDublett()) { + if (agreementAggregate.isDublett()) { return IGNORER; } diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationProcessResult.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationProcessResult.java index f462eec74..4f8f0b959 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationProcessResult.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/models/migration/ArenaMigrationProcessResult.java @@ -3,7 +3,6 @@ import no.nav.tag.tiltaksgjennomforing.avtale.Avtale; public sealed interface ArenaMigrationProcessResult { - record Skip(ArenaMigrationAction action) implements ArenaMigrationProcessResult {} record Ignored(ArenaMigrationAction action) implements ArenaMigrationProcessResult {} record Completed(ArenaMigrationAction action, Avtale avtale) implements ArenaMigrationProcessResult {} } diff --git a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java index 287fb24df..bfcaeff58 100644 --- a/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java +++ b/src/main/java/no/nav/tag/tiltaksgjennomforing/arena/service/ArenaAgreementProcessingService.java @@ -116,9 +116,6 @@ public void process(ArenaAgreementAggregate agreementAggregate) { eksternId, null ); - case ArenaMigrationProcessResult.Skip skip -> { - // Gjør ingenting - } } } catch(Exception e) { log.error("Feil ved prossesering av avtale fra Arena", e); @@ -158,12 +155,6 @@ private void saveMigrationStatus( private ArenaMigrationProcessResult updateAvtale(Avtale avtale, ArenaAgreementAggregate agreementAggregate) { ArenaMigrationAction action = ArenaMigrationAction.map(avtale, agreementAggregate); switch (action) { - case HOPP_OVER -> { - log.info( - "Avtale har deltaker som er duplett i Arena. Hopper over avtalen. Den vil sannsynligvis bli oppdatert senere." - ); - return new ArenaMigrationProcessResult.Skip(action); - } case IGNORER -> { log.info( "Avtale med id {} og status {} har tiltakstatus {}, deltakerstatus {} og tiltaket er {} i Arena. Ignorerer avtalen.", @@ -171,7 +162,7 @@ private ArenaMigrationProcessResult updateAvtale(Avtale avtale, ArenaAgreementAg avtale.getStatus(), agreementAggregate.getTiltakstatuskode(), agreementAggregate.getDeltakerstatuskode(), - agreementAggregate.isTiltakDublett() ? "dublett" : "ikke dublett" + agreementAggregate.isDublett() ? "dublett" : "ikke dublett" ); return new ArenaMigrationProcessResult.Ignored(action); } @@ -224,20 +215,13 @@ private ArenaMigrationProcessResult updateAvtale(Avtale avtale, ArenaAgreementAg private ArenaMigrationProcessResult createAvtale(ArenaAgreementAggregate agreementAggregate) { ArenaMigrationAction action = ArenaMigrationAction.map(agreementAggregate); - if (ArenaMigrationAction.HOPP_OVER == action) { - log.info( - "Avtale har deltaker som er duplett i Arena. Hopper over avtalen. Den vil sannsynligvis bli oppdatert senere." - ); - return new ArenaMigrationProcessResult.Skip(action); - } - if (ArenaMigrationAction.IGNORER == action) { log.info( "Avtale har tiltaksstatus {}, deltakerstatus {}, sluttdato {} og er {} i Arena. Ignorerer avtalen.", agreementAggregate.getTiltakstatuskode(), agreementAggregate.getDeltakerstatuskode(), agreementAggregate.findSluttdato().orElse(null), - agreementAggregate.isTiltakDublett() ? "dublett" : "ikke dublett" + agreementAggregate.isDublett() ? "dublett" : "ikke dublett" ); return new ArenaMigrationProcessResult.Ignored(action); }