Skip to content

Commit

Permalink
Oppdatert til bruk av inntektsmeldingRequest fra bibliotek
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Feb 7, 2024
1 parent 01cd626 commit 4be7d06
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ma.glasnost.orika.MapperFacade;
import no.nav.dolly.bestilling.ClientFuture;
import no.nav.dolly.bestilling.ClientRegister;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest;
import no.nav.dolly.bestilling.inntektsmelding.domain.TransaksjonMappingDTO;
import no.nav.dolly.domain.jpa.BestillingProgress;
import no.nav.dolly.domain.jpa.TransaksjonMapping;
Expand All @@ -17,6 +16,7 @@
import no.nav.dolly.mapper.MappingContextUtils;
import no.nav.dolly.service.TransaksjonMappingService;
import no.nav.dolly.util.TransactionHelperService;
import no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests.InntektsmeldingRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
Expand Down Expand Up @@ -53,12 +53,10 @@ public Flux<ClientFuture> gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly
var context = MappingContextUtils.getMappingContext();
context.setProperty("ident", dollyPerson.getIdent());

var inntektsmeldingRequest = mapperFacade.map(bestilling.getInntektsmelding(), InntektsmeldingRequest.class, context);

return Flux.from(
Flux.fromIterable(bestilling.getEnvironments())
.flatMap(environment -> {
var request = mapperFacade.map(inntektsmeldingRequest, InntektsmeldingRequest.class);
var request = mapperFacade.map(bestilling.getInntektsmelding(), InntektsmeldingRequest.class, context);
request.setMiljoe(environment);
return postInntektsmelding(isOpprettEndre ||
!transaksjonMappingService.existAlready(INNTKMELD, dollyPerson.getIdent(), environment, bestilling.getId()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import lombok.extern.slf4j.Slf4j;
import no.nav.dolly.bestilling.ConsumerStatus;
import no.nav.dolly.bestilling.inntektsmelding.command.OpprettInntektsmeldingCommand;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingResponse;
import no.nav.dolly.config.Consumers;
import no.nav.dolly.metrics.Timed;
import no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests.InntektsmeldingRequest;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.standalone.servletsecurity.exchange.TokenExchange;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package no.nav.dolly.bestilling.inntektsmelding.command;

import lombok.RequiredArgsConstructor;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingResponse;
import no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests.InntektsmeldingRequest;
import no.nav.testnav.libs.reactivecore.utils.WebClientFilter;
import no.nav.testnav.libs.securitycore.config.UserConstant;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests.InntektsmeldingRequest;

@Data
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
import ma.glasnost.orika.CustomMapper;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.MappingContext;
import no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest;
import no.nav.dolly.domain.resultset.inntektsmeldingstub.AarsakTilInnsendingType;
import no.nav.dolly.domain.resultset.inntektsmeldingstub.RsInntektsmelding;
import no.nav.dolly.mapper.MappingStrategy;
import no.nav.testnav.libs.dto.dokarkiv.v1.RsJoarkMetadata;
import no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.RsInntektsmeldingRequest;
import no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.enums.AarsakInnsendingKodeListe;
import no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.rs.RsAvsendersystem;
import no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.rs.RsKontaktinformasjon;
import no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests.InntektsmeldingRequest;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest.Avsendersystem;
import static no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest.Avsendertype;
import static no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest.Inntektsmelding;
import static no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest.JoarkMetadata;
import static no.nav.dolly.bestilling.inntektsmelding.domain.InntektsmeldingRequest.Kontaktinformasjon;
import static no.nav.dolly.util.NullcheckUtil.nullcheckSetDefaultValue;

@Component
public class InntektsmeldingMappingStrategy implements MappingStrategy {

private static Kontaktinformasjon getFiktivKontaktinformasjon() {
private static RsKontaktinformasjon getFiktivKontaktinformasjon() {

return Kontaktinformasjon.builder()
return RsKontaktinformasjon.builder()
.kontaktinformasjonNavn("Dolly Dollesen")
.telefonnummer("99999999")
.build();
Expand All @@ -41,27 +41,27 @@ public void mapAtoB(RsInntektsmelding rsInntektsmelding,
InntektsmeldingRequest inntektsmelding, MappingContext context) {

if (isNull(rsInntektsmelding.getJoarkMetadata())) {
inntektsmelding.setJoarkMetadata(new JoarkMetadata());
inntektsmelding.setJoarkMetadata(new RsJoarkMetadata());
}
inntektsmelding.getJoarkMetadata().setAvsenderMottakerIdType(
!inntektsmelding.getInntekter().isEmpty() &&
nonNull(inntektsmelding.getInntekter().get(0).getArbeidsgiver()) ?
Avsendertype.ORGNR : Avsendertype.FNR
(!inntektsmelding.getInntekter().isEmpty() &&
nonNull(inntektsmelding.getInntekter().getFirst().getArbeidsgiver()) ?
Avsendertype.ORGNR : Avsendertype.FNR).name()
);
inntektsmelding.setArbeidstakerFnr((String) context.getProperty("ident"));
}
})
.byDefault()
.register();

factory.classMap(RsInntektsmelding.Inntektsmelding.class, Inntektsmelding.class)
factory.classMap(RsInntektsmelding.Inntektsmelding.class, RsInntektsmeldingRequest.class)
.customize(new CustomMapper<>() {
@Override
public void mapAtoB(RsInntektsmelding.Inntektsmelding rsInntektsmelding,
Inntektsmelding inntektsmelding, MappingContext context) {
RsInntektsmeldingRequest inntektsmelding, MappingContext context) {

inntektsmelding.setAarsakTilInnsending(
nullcheckSetDefaultValue(rsInntektsmelding.getAarsakTilInnsending(), AarsakTilInnsendingType.NY));
nullcheckSetDefaultValue(inntektsmelding.getAarsakTilInnsending(), AarsakInnsendingKodeListe.NY));

if (nonNull(inntektsmelding.getArbeidsgiver()) &&
isNull(inntektsmelding.getArbeidsgiver().getKontaktinformasjon())) {
Expand All @@ -74,7 +74,7 @@ public void mapAtoB(RsInntektsmelding.Inntektsmelding rsInntektsmelding,
getFiktivKontaktinformasjon());
}
if (isNull(inntektsmelding.getAvsendersystem())) {
inntektsmelding.setAvsendersystem(Avsendersystem.builder()
inntektsmelding.setAvsendersystem(RsAvsendersystem.builder()
.innsendingstidspunkt(LocalDateTime.now())
.build());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package no.nav.testnav.libs.dto.dokarkiv.v1;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.Data;
import lombok.NoArgsConstructor;

@Builder
@Getter
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RsJoarkMetadata {

private String journalpostType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.rs;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Objects;

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

private static final String DEFAULT_SYSTEMNAVN = "ORKESTRATOREN";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.rs;

import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
package no.nav.testnav.libs.dto.inntektsmeldingservice.v1.requests;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import no.nav.testnav.libs.dto.dokarkiv.v1.RsJoarkMetadata;
import no.nav.testnav.libs.dto.inntektsmeldinggeneratorservice.v1.RsInntektsmeldingRequest;

import java.util.ArrayList;
import java.util.List;

import static java.util.Objects.isNull;

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

private String miljoe;
private String arbeidstakerFnr; // TODO: ident! (i v2)
private RsJoarkMetadata joarkMetadata;
private List<RsInntektsmeldingRequest> inntekter;

public List<RsInntektsmeldingRequest> getInntekter() {

if (isNull(inntekter)) {
inntekter = new ArrayList<>();
}
return inntekter;
}
}

0 comments on commit 4be7d06

Please sign in to comment.