Skip to content

Commit

Permalink
Refactor services to use 'Foedselsdato' and 'Foedested' #deploy-test-…
Browse files Browse the repository at this point in the history
…pdl-forvalter

Replace usage of 'FoedselService' with 'FoedselsdatoService' and 'FoedestedService' in 'ValidateArtifactsService', 'CreatePersonService' and 'PersonArtifactService'. Also, enhance filter conditions in 'FoedselsdatoUtility'. This update refactors services to handle birthdate and birthplace as separate aspects, improving code clarity and flexibility.
  • Loading branch information
krharum committed Jun 19, 2024
1 parent ee30084 commit 1a52375
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public class CreatePersonService {
private final MergeService mergeService;
private final PersonRepository personRepository;
private final KjoennService kjoennService;
private final FoedselService foedselService;
private final FoedselsdatoService foedselsdatoService;
private final FoedestedService foedestedService;
private final StatsborgerskapService statsborgerskapService;
private final BostedAdresseService bostedAdresseService;
private final NavnService navnService;
Expand Down Expand Up @@ -103,9 +104,10 @@ public PersonDTO execute(PersonRequestDTO request) {
.getIdent());

Stream.of(
Flux.just(foedselService.convert(mergedPerson)),
Flux.just(foedselsdatoService.convert(mergedPerson)),
Flux.just(navnService.convert(mergedPerson)),
Flux.just(bostedAdresseService.convert(mergedPerson, null)),
Flux.just(foedestedService.convert(mergedPerson)),
Flux.just(kjoennService.convert(mergedPerson)),
Flux.just(statsborgerskapService.convert(mergedPerson)),
Flux.just(adressebeskyttelseService.convert(mergedPerson)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public class PersonArtifactService {
public PersonDTO buildPerson(PersonDTO person, Boolean relaxed) {

// Orders below matters to some degree, don´t rearrange without checking consequences
person.setFoedsel(foedselService.convert(person));
person.setFoedselsdato(foedselsdatoService.convert(person));
person.setKjoenn(kjoennService.convert(person));
person.setBostedsadresse(bostedAdresseService.convert(person, relaxed));
person.setInnflytting(innflyttingService.convert(person));
person.setFoedested(foedestedService.convert(person));
person.setFoedsel(foedselService.convert(person));
person.setFoedselsdato(foedselsdatoService.convert(person));
person.setStatsborgerskap(statsborgerskapService.convert(person));
person.setNavn(navnService.convert(person));
person.setOppholdsadresse(oppholdsadresseService.convert(person));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public class ValidateArtifactsService {
private final DoedfoedtBarnService doedfoedtBarnService;
private final DoedsfallService doedsfallService;
private final FalskIdentitetService falskIdentitetService;
private final FoedselService foedselService;
private final FoedselsdatoService foedselsdatoService;
private final FoedestedService foedestedService;
private final FolkeregisterPersonstatusService folkeregisterPersonstatusService;
private final ForelderBarnRelasjonService forelderBarnRelasjonService;
private final ForeldreansvarService foreldreansvarService;
Expand Down Expand Up @@ -48,7 +49,8 @@ public void validate(PersonDTO person) {
validate(kjoennService, person.getKjoenn(), person),
validate(innflyttingService, person.getInnflytting()),
validate(bostedAdresseService, person.getBostedsadresse(), person),
validate(foedselService, person.getFoedsel(), person),
validate(foedselsdatoService, person.getFoedselsdato(), person),
validate(foedestedService, person.getFoedested(), person),
validate(statsborgerskapService, person.getStatsborgerskap()),
validate(navnService, person.getNavn(), person),
validate(oppholdsadresseService, person.getOppholdsadresse(), person),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class FoedselsdatoUtility {
public LocalDateTime getFoedselsdato(PersonDTO person) {

return person.getFoedselsdato().stream()
.filter(foedsel -> nonNull(foedsel.getFoedselsdato()) || nonNull(foedsel.getFoedselsaar()))
.map(foedsel-> getFoedselsdato(foedsel, person.getIdent()))
.findFirst()
.orElse(person.getFoedsel().stream()
.filter(foedsel -> nonNull(foedsel.getFoedselsdato()) || nonNull(foedsel.getFoedselsaar()))
.map(foedsel-> getFoedselsdato(foedsel, person.getIdent()))
.findFirst()
.orElse(DatoFraIdentUtility.getDato(person.getIdent()).atStartOfDay()));
Expand Down

0 comments on commit 1a52375

Please sign in to comment.