Skip to content

Commit

Permalink
Refactor address expiry handling in MetadataTidspunkterService
Browse files Browse the repository at this point in the history
#deploy-test-pdl-forvalter

Replace fixOpphoert with fixAddrOpphoert to better describe the logic of setting address expiry dates. This change improves code clarity by using a more descriptive method name and ensures consistency in handling different address types.
  • Loading branch information
krharum committed Dec 10, 2024
1 parent dc688e5 commit f270bda
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ private void fixPerson(String ident) {
.forEach(MetadataTidspunkterService::fixVersioning);
person.getBostedsadresse()
.forEach(MetadataTidspunkterService::fixAdresser);
fixOpphoert(person.getBostedsadresse());
fixAddrOpphoert(person.getBostedsadresse());
person.getOppholdsadresse()
.forEach(MetadataTidspunkterService::fixAdresser);
fixOpphoert(person.getOppholdsadresse());
fixAddrOpphoert(person.getOppholdsadresse());
person.getKontaktadresse()
.forEach(MetadataTidspunkterService::fixAdresser);
fixOpphoert(person.getKontaktadresse());
fixAddrOpphoert(person.getKontaktadresse());
person.getDeltBosted()
.forEach(MetadataTidspunkterService::fixDeltBosted);
person.getDoedfoedtBarn()
Expand Down Expand Up @@ -120,6 +120,12 @@ private void fixPerson(String ident) {
});
}

private static void fixAddrOpphoert(List<? extends AdresseDTO> adresseopplysning) {

adresseopplysning.forEach(adresse ->
adresse.getFolkeregistermetadata().setOpphoerstidspunkt(adresse.getGyldigTilOgMed()));
}

private static void fixOpphoert(List<? extends DbVersjonDTO> opplysningstype) {

for (var i = opplysningstype.size() - 1; i > 0; i--) {
Expand Down Expand Up @@ -220,8 +226,8 @@ private static void fixSivilstand(PersonDTO person) {
person.getSivilstand().sort(Comparator.comparing(SivilstandDTO::getId).reversed());

var counter = new AtomicInteger(0);
person.getSivilstand().stream()
.forEachOrdered(sivilstand -> {
person.getSivilstand()
.forEach(sivilstand -> {
fixFolkeregisterMetadata(sivilstand);
if (isNull(sivilstand.getFolkeregistermetadata().getGyldighetstidspunkt())) {

Expand Down

0 comments on commit f270bda

Please sign in to comment.