From eac553d519c14e64e51e35071c946d137bb580fd Mon Sep 17 00:00:00 2001 From: "Kristen.Herum" Date: Mon, 9 Dec 2024 16:12:31 +0100 Subject: [PATCH] Refactor DTO classes to use Lombok's @Data annotation #deploy-test-sykemelding-api Replaced @Value, @Getter, and @Setter with @Data for simplicity and consistency across all DTO classes. Removed the forced argument requirement from @NoArgsConstructor where it was previously applied. Additionally, adjusted null handling in the "Arbeidsgiver" domain class to manage DTO presence better. --- .../sykemelding/domain/Arbeidsgiver.java | 6 +++--- .../libs/dto/sykemelding/v1/AdresseDTO.java | 9 ++++----- .../libs/dto/sykemelding/v1/AktivitetDTO.java | 15 ++++++++------- .../libs/dto/sykemelding/v1/ArbeidsgiverDTO.java | 9 ++++----- .../libs/dto/sykemelding/v1/DetaljerDTO.java | 8 +++----- .../libs/dto/sykemelding/v1/DiagnoseDTO.java | 13 ++++--------- .../dto/sykemelding/v1/HelsepersonellDTO.java | 16 ++++------------ .../libs/dto/sykemelding/v1/OrganisasjonDTO.java | 15 +++++++-------- .../libs/dto/sykemelding/v1/PasientDTO.java | 9 ++++----- .../libs/dto/sykemelding/v1/PeriodeDTO.java | 9 ++++----- .../libs/dto/sykemelding/v1/SykemeldingDTO.java | 2 +- .../sykemelding/v1/UtdypendeOpplysningerDTO.java | 1 + 12 files changed, 47 insertions(+), 65 deletions(-) diff --git a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/domain/Arbeidsgiver.java b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/domain/Arbeidsgiver.java index 13210281a1a..9bc46c66130 100644 --- a/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/domain/Arbeidsgiver.java +++ b/apps/sykemelding-api/src/main/java/no/nav/registre/testnorge/sykemelding/domain/Arbeidsgiver.java @@ -7,13 +7,13 @@ import static java.util.Objects.nonNull; public class Arbeidsgiver { - private XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver xmlArbeidsgiver; + private final XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver xmlArbeidsgiver; Arbeidsgiver(ArbeidsgiverDTO dto) { xmlArbeidsgiver = new XMLHelseOpplysningerArbeidsuforhet.Arbeidsgiver() .withHarArbeidsgiver(new XMLCS() - .withDN("En arbeidsgiver") - .withV("1")) + .withDN(nonNull(dto) ? "En arbeidsgiver" : "Ingen arbeidsgiver") + .withV(nonNull(dto) ? "1" : "3")) .withNavnArbeidsgiver(nonNull(dto) ? dto.getNavn() : null) .withYrkesbetegnelse(nonNull(dto) ? dto.getYrkesbetegnelse() : null) .withStillingsprosent(nonNull(dto) ? getStillingsprosent(dto) : null); diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AdresseDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AdresseDTO.java index dc046646336..076118be865 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AdresseDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AdresseDTO.java @@ -2,16 +2,15 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class AdresseDTO { + private String gate; private String postnummer; private String by; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AktivitetDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AktivitetDTO.java index 59ea89c02ca..3f70e913664 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AktivitetDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/AktivitetDTO.java @@ -3,16 +3,17 @@ import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) +@NoArgsConstructor public class AktivitetDTO { - private final Integer grad; - private final Boolean reisetilskudd; - private final Integer behandlingsdager; - private final Aktivitet aktivitet; + + private Integer grad; + private Boolean reisetilskudd; + private Integer behandlingsdager; + private Aktivitet aktivitet; } diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/ArbeidsgiverDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/ArbeidsgiverDTO.java index 3b96842651c..2e6f6d56855 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/ArbeidsgiverDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/ArbeidsgiverDTO.java @@ -2,16 +2,15 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class ArbeidsgiverDTO { + private String navn; private String yrkesbetegnelse; private Float stillingsprosent; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DetaljerDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DetaljerDTO.java index b618ba279a4..3603fbca382 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DetaljerDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DetaljerDTO.java @@ -2,15 +2,13 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.Getter; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Setter; -@Getter -@Setter +@Data +@Builder @NoArgsConstructor @AllArgsConstructor -@Builder public class DetaljerDTO { private String tiltakArbeidsplass; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DiagnoseDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DiagnoseDTO.java index 18ebbed0794..293124b1def 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DiagnoseDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/DiagnoseDTO.java @@ -1,22 +1,17 @@ package no.nav.testnav.libs.dto.sykemelding.v1; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) +@NoArgsConstructor public class DiagnoseDTO { - @JsonProperty - private String diagnose; - @JsonProperty + private String diagnose; private String system; - - @JsonProperty private String diagnosekode; } diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/HelsepersonellDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/HelsepersonellDTO.java index d855e9b7b8e..3962f660f98 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/HelsepersonellDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/HelsepersonellDTO.java @@ -1,28 +1,20 @@ package no.nav.testnav.libs.dto.sykemelding.v1; -import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class HelsepersonellDTO { - @JsonProperty + private String ident; - @JsonProperty private String fornavn; - @JsonProperty private String mellomnavn; - @JsonProperty private String etternavn; - @JsonProperty private String hprId; - @JsonProperty private String samhandlerType; } diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/OrganisasjonDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/OrganisasjonDTO.java index 0e423729855..69d3013def3 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/OrganisasjonDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/OrganisasjonDTO.java @@ -2,17 +2,16 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class OrganisasjonDTO { - private final String navn; - private final String orgNr; - private final AdresseDTO adresse; + + private String navn; + private String orgNr; + private AdresseDTO adresse; } diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PasientDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PasientDTO.java index 5711f9066fd..ad060b2c579 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PasientDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PasientDTO.java @@ -2,18 +2,17 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; import java.time.LocalDate; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class PasientDTO { + private String ident; private String fornavn; private String mellomnavn; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PeriodeDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PeriodeDTO.java index 8d79436bb73..99485ed5fd5 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PeriodeDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/PeriodeDTO.java @@ -2,18 +2,17 @@ import lombok.AllArgsConstructor; import lombok.Builder; -import lombok.EqualsAndHashCode; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.Value; import java.time.LocalDate; -@Value +@Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) -@EqualsAndHashCode +@NoArgsConstructor public class PeriodeDTO { + private LocalDate fom; private LocalDate tom; private AktivitetDTO aktivitet; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingDTO.java index dc0e5e03a57..5b51f04b3cd 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/SykemeldingDTO.java @@ -14,7 +14,7 @@ @Data @Builder @AllArgsConstructor -@NoArgsConstructor(force = true) +@NoArgsConstructor public class SykemeldingDTO { private LocalDate startDato; diff --git a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/UtdypendeOpplysningerDTO.java b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/UtdypendeOpplysningerDTO.java index f9f66850c41..0131ae0d86e 100644 --- a/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/UtdypendeOpplysningerDTO.java +++ b/libs/data-transfer-objects/src/main/java/no/nav/testnav/libs/dto/sykemelding/v1/UtdypendeOpplysningerDTO.java @@ -12,6 +12,7 @@ @Data @Builder +@NoArgsConstructor @AllArgsConstructor public class UtdypendeOpplysningerDTO {