Skip to content

Commit

Permalink
feat. trenger ikke lengre å hoppe over dubletter av deltaker id
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eirikv committed Dec 12, 2024
1 parent 753fc3c commit 2b473ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,8 @@ public Optional<LocalDate> findSluttdato() {
.findFirst();
}

public boolean isTiltakDublett() {
return isDublett(eksternIdTiltak);
}

public boolean isDeltakerDublett() {
return isDublett(eksternIdDeltaker);
public boolean isDublett() {
return isDublett(eksternIdTiltak) || isDublett(eksternIdDeltaker);
}

public Optional<UUID> getEksternIdAsUuid() throws IllegalArgumentException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.time.LocalDate;

public enum ArenaMigrationAction {
HOPP_OVER,
GJENOPPRETT,
OPPRETT,
OPPDATER,
Expand All @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -158,20 +155,14 @@ 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.",
avtale.getId(),
avtale.getStatus(),
agreementAggregate.getTiltakstatuskode(),
agreementAggregate.getDeltakerstatuskode(),
agreementAggregate.isTiltakDublett() ? "dublett" : "ikke dublett"
agreementAggregate.isDublett() ? "dublett" : "ikke dublett"
);
return new ArenaMigrationProcessResult.Ignored(action);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 2b473ae

Please sign in to comment.