Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MalBestilling functionality #3463

Merged
merged 21 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
816b123
Add MalBestilling functionality
krharum Apr 9, 2024
a3dc729
Updated MalBestillingService and added RsBestillingMal entity
krharum Apr 9, 2024
ee36b19
Remove name existence check in MalBestillingService
krharum Apr 9, 2024
a413823
Refactor BestillingMalService and update related classes
krharum Apr 9, 2024
e39cae3
Refactor service class name to MalBestillingService
krharum Apr 9, 2024
fb37d7f
Refactor handling of Bestilling structure and mappings
krharum Apr 10, 2024
2dd3ea0
Refactor Bestilling data structure and improve mapping
krharum Apr 11, 2024
ae5c475
Deploy #deploy-test-dolly-backend
krharum Apr 11, 2024
db1460c
Renamed 'bestKriterier' to 'bestilling' in multiple files #deploy-tes…
krharum Apr 11, 2024
0f43598
Refactor code and add new feature to create template from person
krharum Apr 11, 2024
a4335be
Lagt paa malbestilling for personer
betsytraran Apr 11, 2024
6140b23
Update exception handling in BestillingStatusMappingStrategy
krharum Apr 12, 2024
ebbe94c
Remove JsonInclude annotation in RsBestillingStatus
krharum Apr 12, 2024
cc483ad
Add getter methods and move BestillingMapper class
krharum Apr 12, 2024
139f7c4
Update Bestilling type and mapping strategy
krharum Apr 12, 2024
ba8aec7
Refactor MalBestillingService and mapping strategies
krharum Apr 12, 2024
415c039
Merge branch 'master' into feature/opprett-mal-fra-person
krharum Apr 12, 2024
e2281a6
deploy
krharum Apr 12, 2024
a6819d3
Update "create template" modal with topic context
krharum Apr 15, 2024
117f7b7
Oppdatert cypress-test
krharum Apr 15, 2024
c6425d2
Oppdatert etter Sonar-feedback
krharum Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
public class CachingConfig {

public static final String CACHE_BESTILLING = "bestilling";
public static final String CACHE_BESTILLING_MAL = "bestilling-mal";
public static final String CACHE_BRUKER = "bruker";
public static final String CACHE_GRUPPE = "gruppe";
public static final String CACHE_HELSEPERSONELL = "helsepersonell";
Expand All @@ -25,6 +26,7 @@ public class CachingConfig {
@Profile({ "dev", "prod" })
public CacheManager cacheManager(Caffeine caffeine) {
var caffeineCacheManager = new CaffeineCacheManager(CACHE_BESTILLING,
CACHE_BESTILLING_MAL,
CACHE_BRUKER,
CACHE_GRUPPE,
CACHE_HELSEPERSONELL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.dolly.domain.jpa;

import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
Expand Down Expand Up @@ -36,6 +37,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "BRUKER")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Bruker implements Serializable {

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
package no.nav.dolly.domain.resultset.entity.bestilling;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.nav.dolly.domain.resultset.RsStatusRapport;
import no.nav.dolly.domain.resultset.aareg.RsAareg;
import no.nav.dolly.domain.resultset.arenaforvalter.Arenadata;
import no.nav.dolly.domain.resultset.breg.RsBregdata;
import no.nav.dolly.domain.resultset.dokarkiv.RsDokarkiv;
import no.nav.dolly.domain.resultset.entity.bruker.RsBrukerUtenFavoritter;
import no.nav.dolly.domain.resultset.histark.RsHistark;
import no.nav.dolly.domain.resultset.inntektsmeldingstub.RsInntektsmelding;
import no.nav.dolly.domain.resultset.inntektstub.InntektMultiplierWrapper;
import no.nav.dolly.domain.resultset.inst.RsInstdata;
import no.nav.dolly.domain.resultset.kontoregister.BankkontoData;
import no.nav.dolly.domain.resultset.krrstub.RsDigitalKontaktdata;
import no.nav.dolly.domain.resultset.medl.RsMedl;
import no.nav.dolly.domain.resultset.pdldata.PdlPersondata;
import no.nav.dolly.domain.resultset.pensjon.PensjonData;
import no.nav.dolly.domain.resultset.sigrunstub.RsLignetInntekt;
import no.nav.dolly.domain.resultset.sigrunstub.RsPensjonsgivendeForFolketrygden;
import no.nav.dolly.domain.resultset.skjerming.RsSkjerming;
import no.nav.dolly.domain.resultset.sykemelding.RsSykemelding;
import no.nav.dolly.domain.resultset.tpsmessagingservice.RsTpsMessaging;
import no.nav.dolly.domain.resultset.udistub.model.RsUdiPerson;
import no.nav.testnav.libs.data.arbeidsplassencv.v1.ArbeidsplassenCVDTO;

import java.time.LocalDateTime;
import java.util.ArrayList;
Expand All @@ -39,7 +19,6 @@
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@Builder
public class RsBestillingStatus {

Expand All @@ -58,7 +37,7 @@ public class RsBestillingStatus {
private Long opprettetFraId;
private Long opprettetFraGruppeId;
private Long gjenopprettetFraIdent;
private RsBestilling bestilling;
private JsonNode bestilling;
private String opprettFraIdenter;

public Set<String> getEnvironments() {
Expand All @@ -74,36 +53,4 @@ public List<RsStatusRapport> getStatus() {
}
return status;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class RsBestilling {

private Boolean navSyntetiskIdent;
private List<String> importFraPdl;
private String kildeMiljoe;
private RsDigitalKontaktdata krrstub;
private List<RsInstdata> instdata;
private List<RsAareg> aareg;
private List<RsLignetInntekt> sigrunstub;
private List<RsPensjonsgivendeForFolketrygden> sigrunstubPensjonsgivende;
private InntektMultiplierWrapper inntektstub;
private Arenadata arenaforvalter;
private RsUdiPerson udistub;
private PensjonData pensjonforvalter;
private RsInntektsmelding inntektsmelding;
private RsBregdata brregstub;
private RsDokarkiv dokarkiv;
private RsMedl medl;
private RsHistark histark;
private RsSykemelding sykemelding;
private PdlPersondata pdldata;
private RsTpsMessaging tpsMessaging;
private BankkontoData bankkonto;
private RsSkjerming skjerming;
private ArbeidsplassenCVDTO arbeidsplassenCV;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package no.nav.dolly.domain.resultset.entity.bestilling;

import com.fasterxml.jackson.databind.JsonNode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.nav.dolly.domain.resultset.entity.bruker.RsBrukerUtenFavoritter;

import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RsMalBestilling {

private Long id;
private JsonNode bestilling;
private String miljoer;
private String malNavn;
private RsBrukerUtenFavoritter bruker;
private LocalDateTime sistOppdatert;
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
package no.nav.dolly.domain.resultset.entity.bestilling;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import no.nav.dolly.domain.resultset.aareg.RsAareg;
import no.nav.dolly.domain.resultset.arenaforvalter.Arenadata;
import no.nav.dolly.domain.resultset.breg.RsBregdata;
import no.nav.dolly.domain.resultset.dokarkiv.RsDokarkiv;
import no.nav.dolly.domain.resultset.entity.bruker.RsBrukerUtenFavoritter;
import no.nav.dolly.domain.resultset.histark.RsHistark;
import no.nav.dolly.domain.resultset.inntektsmeldingstub.RsInntektsmelding;
import no.nav.dolly.domain.resultset.inntektstub.InntektMultiplierWrapper;
import no.nav.dolly.domain.resultset.inst.RsInstdata;
import no.nav.dolly.domain.resultset.kontoregister.BankkontoData;
import no.nav.dolly.domain.resultset.krrstub.RsDigitalKontaktdata;
import no.nav.dolly.domain.resultset.medl.RsMedl;
import no.nav.dolly.domain.resultset.pdldata.PdlPersondata;
import no.nav.dolly.domain.resultset.pensjon.PensjonData;
import no.nav.dolly.domain.resultset.sigrunstub.RsLignetInntekt;
import no.nav.dolly.domain.resultset.sigrunstub.RsPensjonsgivendeForFolketrygden;
import no.nav.dolly.domain.resultset.skjerming.RsSkjerming;
import no.nav.dolly.domain.resultset.sykemelding.RsSykemelding;
import no.nav.dolly.domain.resultset.tpsmessagingservice.RsTpsMessaging;
import no.nav.dolly.domain.resultset.udistub.model.RsUdiPerson;
import no.nav.testnav.libs.data.arbeidsplassencv.v1.ArbeidsplassenCVDTO;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import static java.util.Objects.isNull;
Expand All @@ -51,52 +28,4 @@ public Map<String, List<RsMalBestilling>> getMalbestillinger() {
}
return malbestillinger;
}

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class RsMalBestilling {

private Long id;
private String malNavn;
private RsBestilling bestilling;
private RsBrukerUtenFavoritter bruker;
}

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class RsBestilling {

private Integer antallIdenter;
private Boolean navSyntetiskIdent;
private String opprettFraIdenter;
private Set<String> environments;
private PdlPersondata pdldata;
private RsDigitalKontaktdata krrstub;
private List<RsInstdata> instdata;
private List<RsAareg> aareg;
private List<RsLignetInntekt> sigrunstub;
private List<RsPensjonsgivendeForFolketrygden> sigrunstubPensjonsgivende;
private InntektMultiplierWrapper inntektstub;
private Arenadata arenaforvalter;
private RsUdiPerson udistub;
private RsInntektsmelding inntektsmelding;
private PensjonData pensjonforvalter;
private RsBregdata brregstub;
private RsDokarkiv dokarkiv;
private RsMedl medl;
private RsHistark histark;
private RsSykemelding sykemelding;
private RsTpsMessaging tpsMessaging;
private RsSkjerming skjerming;
private BankkontoData bankkonto;
private ArbeidsplassenCVDTO arbeidsplassenCV;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.dolly.mapper.strategy;
package no.nav.dolly.mapper;

import lombok.experimental.UtilityClass;
import no.nav.dolly.domain.jpa.Bestilling;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.dolly.mapper.strategy;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -9,16 +10,14 @@
import no.nav.dolly.domain.jpa.Bestilling;
import no.nav.dolly.domain.jpa.BestillingProgress;
import no.nav.dolly.domain.jpa.OrganisasjonBestilling;
import no.nav.dolly.domain.resultset.RsDollyBestillingRequest;
import no.nav.dolly.domain.resultset.entity.bestilling.RsBestillingStatus;
import no.nav.dolly.domain.resultset.entity.bruker.RsBrukerUtenFavoritter;
import no.nav.dolly.mapper.MappingStrategy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ResponseStatusException;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import static java.util.Objects.isNull;
import static no.nav.dolly.bestilling.service.DollyBestillingService.getEnvironments;
import static no.nav.dolly.mapper.AnnenFeilStatusMapper.buildAnnenFeilStatusMap;
import static no.nav.dolly.mapper.ArbeidsplassenCVStatusMapper.buildArbeidsplassenCVStatusMap;
Expand All @@ -44,14 +43,13 @@
import static no.nav.dolly.mapper.BestillingTpsMessagingStatusMapper.buildTpsMessagingStatusMap;
import static no.nav.dolly.mapper.BestillingUdiStubStatusMapper.buildUdiStubStatusMap;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;

@Slf4j
@Component
@RequiredArgsConstructor
public class BestillingStatusMappingStrategy implements MappingStrategy {

private final JsonBestillingMapper jsonBestillingMapper;
private static final String EMPTY_JSON = "{}";
private final ObjectMapper objectMapper;

@Override
Expand All @@ -62,12 +60,21 @@ public void register(MapperFactory factory) {
public void mapAtoB(Bestilling bestilling, RsBestillingStatus bestillingStatus, MappingContext context) {

var ident = (String) context.getProperty("ident");
try {
bestillingStatus.setBestilling(
objectMapper.readTree(isNull(bestilling.getBestKriterier()) ||
EMPTY_JSON.equals(bestilling.getBestKriterier()) ? EMPTY_JSON :
bestilling.getBestKriterier()));
} catch (JsonProcessingException e) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}

bestillingStatus.setBruker(mapperFacade.map(bestilling.getBruker(), RsBrukerUtenFavoritter.class));

var progresser = bestilling.getProgresser().stream()
.filter(progress -> isBlank(ident) || ident.equals(progress.getIdent()))
.toList();

RsDollyBestillingRequest bestillingRequest = jsonBestillingMapper
.mapBestillingRequest(bestilling.getId(), bestilling.getBestKriterier());
bestillingStatus.setAntallLevert((int) progresser.stream()
.filter(BestillingProgress::isIdentGyldig)
.count());
Expand Down Expand Up @@ -97,32 +104,6 @@ public void mapAtoB(Bestilling bestilling, RsBestillingStatus bestillingStatus,
bestillingStatus.getStatus().addAll(buildKontoregisterStatusMap(progresser));
bestillingStatus.getStatus().addAll(buildArbeidsplassenCVStatusMap(progresser));
bestillingStatus.getStatus().addAll(buildAnnenFeilStatusMap(progresser));
bestillingStatus.setBestilling(RsBestillingStatus.RsBestilling.builder()
.pdldata(bestillingRequest.getPdldata())
.aareg(bestillingRequest.getAareg())
.krrstub(bestillingRequest.getKrrstub())
.medl(bestillingRequest.getMedl())
.arenaforvalter(bestillingRequest.getArenaforvalter())
.instdata(bestillingRequest.getInstdata())
.inntektstub(bestillingRequest.getInntektstub())
.sigrunstub(bestillingRequest.getSigrunstub())
.sigrunstubPensjonsgivende(bestillingRequest.getSigrunstubPensjonsgivende())
.udistub(bestillingRequest.getUdistub())
.pensjonforvalter(bestillingRequest.getPensjonforvalter())
.inntektsmelding(bestillingRequest.getInntektsmelding())
.brregstub(bestillingRequest.getBrregstub())
.dokarkiv(bestillingRequest.getDokarkiv())
.histark(bestillingRequest.getHistark())
.sykemelding(bestillingRequest.getSykemelding())
.skjerming(bestillingRequest.getSkjerming())
.tpsMessaging(bestillingRequest.getTpsMessaging())
.bankkonto(bestillingRequest.getBankkonto())
.arbeidsplassenCV(bestillingRequest.getArbeidsplassenCV())
.importFraPdl(mapIdents(bestilling.getPdlImport()))
.kildeMiljoe(bestilling.getKildeMiljoe())
.navSyntetiskIdent(bestilling.getNavSyntetiskIdent())
.build());
bestillingStatus.setBruker(mapperFacade.map(bestilling.getBruker(), RsBrukerUtenFavoritter.class));
}
})
.exclude("bruker")
Expand All @@ -139,9 +120,6 @@ public void mapAtoB(OrganisasjonBestilling bestilling, RsBestillingStatus bestil
})
.byDefault()
.register();
}

private static List<String> mapIdents(String idents) {
return isNotBlank(idents) ? Arrays.asList(idents.split(",")) : Collections.emptyList();
}
}
Loading
Loading