From 0815e495ea7583e4f09eb4168135de1d670b0e7d Mon Sep 17 00:00:00 2001 From: Dragutin Vujovic Date: Thu, 27 Oct 2022 14:11:45 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Publish=20endring=20p=C3=A5=20m=C3=A5l=20ti?= =?UTF-8?q?l=20Aiven?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/no/nav/veilarboppfolging/config/KafkaConfig.java | 3 ++- .../no/nav/veilarboppfolging/config/KafkaProperties.java | 1 + .../nav/veilarboppfolging/service/KafkaProducerService.java | 5 +++-- .../java/no/nav/veilarboppfolging/service/MaalService.java | 6 ++++-- src/main/resources/application-local.properties | 1 + src/main/resources/application.properties | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/no/nav/veilarboppfolging/config/KafkaConfig.java b/src/main/java/no/nav/veilarboppfolging/config/KafkaConfig.java index 73a0b7bad..f8c35b068 100644 --- a/src/main/java/no/nav/veilarboppfolging/config/KafkaConfig.java +++ b/src/main/java/no/nav/veilarboppfolging/config/KafkaConfig.java @@ -145,7 +145,8 @@ public KafkaConfig( kafkaProperties.getVeilederTilordnetTopic(), kafkaProperties.getOppfolgingsperiodeTopic(), kafkaProperties.getEndringPaManuellStatusTopic(), - kafkaProperties.getEndringPaNyForVeilederTopic() + kafkaProperties.getEndringPaNyForVeilederTopic(), + kafkaProperties.getEndringPaMalAiven() ) ); } diff --git a/src/main/java/no/nav/veilarboppfolging/config/KafkaProperties.java b/src/main/java/no/nav/veilarboppfolging/config/KafkaProperties.java index 71869eb33..a231e4d90 100644 --- a/src/main/java/no/nav/veilarboppfolging/config/KafkaProperties.java +++ b/src/main/java/no/nav/veilarboppfolging/config/KafkaProperties.java @@ -22,4 +22,5 @@ public class KafkaProperties { String sisteOppfolgingsperiodeTopic; String oppfolgingsperiodeTopic; String sisteTilordnetVeilederTopic; + String endringPaMalAiven; } diff --git a/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java b/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java index 92f96498b..12d328d83 100644 --- a/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java +++ b/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java @@ -114,10 +114,10 @@ public void publiserKvpAvsluttet(AktorId aktorId, String avsluttetAv, String beg store(kafkaProperties.getKvpAvlsuttetTopic(), aktorId.get(), recordValue); } - public void publiserEndretMal(AktorId aktorId, String veilederIdent) { + public void publiserEndretMal(AktorId aktorId, String veilederIdent, ZonedDateTime endretDato) { EndringPaMalV1 recordValue = EndringPaMalV1.builder() .aktorId(aktorId.get()) - .endretTidspunk(ZonedDateTime.now()) + .endretTidspunk(endretDato) .veilederIdent(veilederIdent) .lagtInnAv( authContextHolder.erEksternBruker() @@ -127,6 +127,7 @@ public void publiserEndretMal(AktorId aktorId, String veilederIdent) { .build(); store(kafkaProperties.getEndringPaMalTopic(), aktorId.get(), recordValue); + store(kafkaProperties.getEndringPaMalAiven(), aktorId.get(), recordValue); } private void store(String topic, String key, Object value) { diff --git a/src/main/java/no/nav/veilarboppfolging/service/MaalService.java b/src/main/java/no/nav/veilarboppfolging/service/MaalService.java index 6b35e1afe..069631c95 100644 --- a/src/main/java/no/nav/veilarboppfolging/service/MaalService.java +++ b/src/main/java/no/nav/veilarboppfolging/service/MaalService.java @@ -105,15 +105,17 @@ public MaalEntity oppdaterMaal(String mal, Fnr fnr, String endretAvVeileder) { Optional maybeKvpPeriode = kvpRepository.hentKvpPeriode(kvpRepository.gjeldendeKvp(aktorId)); maybeKvpPeriode.ifPresent(this::sjekkKvpEnhetTilgang); + ZonedDateTime endretDato = ZonedDateTime.now(); + MaalEntity malData = new MaalEntity() .setAktorId(aktorId.get()) .setMal(mal) .setEndretAv(StringUtils.of(endretAvVeileder).orElse(aktorId.get())) - .setDato(ZonedDateTime.now()); + .setDato(endretDato); transactor.executeWithoutResult((ignored) -> { maalRepository.opprett(malData); - kafkaProducerService.publiserEndretMal(aktorId, endretAvVeileder); + kafkaProducerService.publiserEndretMal(aktorId, endretAvVeileder, endretDato); }); metricsService.oppdatertMittMal(malData, maalRepository.aktorMal(aktorId).size()); diff --git a/src/main/resources/application-local.properties b/src/main/resources/application-local.properties index 08f7b0358..f911d93b7 100644 --- a/src/main/resources/application-local.properties +++ b/src/main/resources/application-local.properties @@ -28,3 +28,4 @@ app.kafka.endringPaMalTopic=endringPaMal-topic app.kafka.sisteOppfolgingsperiodeTopic=sisteOppfolgingsperiode-topic app.kafka.oppfolgingsperiodeTopic=oppfolgingsperiode-topic app.kafka.sisteTilordnetVeilederTopic=sisteTilordnetVeileder-topic +app.kafka.endringPaMalAiven=endringPaaMaal-topic diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e06699125..6ec0b6278 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -65,6 +65,7 @@ app.kafka.sisteTilordnetVeilederTopic=pto.siste-tilordnet-veileder-v1 app.kafka.veilederTilordnetTopic=pto.veileder-tilordnet-v1 app.kafka.endringPaManuellStatusTopic=pto.endring-paa-manuell-status-v1 app.kafka.endringPaNyForVeilederTopic=pto.endring-paa-ny-for-veileder-v1 +app.kafka.endringPaMalAiven=pto.endring-paa-maal-v1 app.datasource.url=${JDBC_URL:null} app.datasource.username=${JDBC_USERNAME:null} From 9424ecbc445fbab3dd92c2d4a1b643e0c5a85f64 Mon Sep 17 00:00:00 2001 From: Dragutin Vujovic Date: Tue, 22 Nov 2022 13:31:41 +0100 Subject: [PATCH 2/2] Revert unnecessary changes --- .../service/KafkaProducerService.java | 10 +++++----- .../no/nav/veilarboppfolging/service/MaalService.java | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java b/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java index 12d328d83..efe32edb1 100644 --- a/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java +++ b/src/main/java/no/nav/veilarboppfolging/service/KafkaProducerService.java @@ -15,7 +15,7 @@ import java.time.ZonedDateTime; -import static no.nav.common.kafka.producer.util.ProducerUtils.*; +import static no.nav.common.kafka.producer.util.ProducerUtils.serializeJsonRecord; import static no.nav.pto_schema.kafka.json.JsonSchemaLocator.getKafkaSchema; @Service @@ -114,15 +114,15 @@ public void publiserKvpAvsluttet(AktorId aktorId, String avsluttetAv, String beg store(kafkaProperties.getKvpAvlsuttetTopic(), aktorId.get(), recordValue); } - public void publiserEndretMal(AktorId aktorId, String veilederIdent, ZonedDateTime endretDato) { + public void publiserEndretMal(AktorId aktorId, String veilederIdent) { EndringPaMalV1 recordValue = EndringPaMalV1.builder() .aktorId(aktorId.get()) - .endretTidspunk(endretDato) + .endretTidspunk(ZonedDateTime.now()) .veilederIdent(veilederIdent) .lagtInnAv( authContextHolder.erEksternBruker() - ? EndringPaMalV1.InnsenderData.BRUKER - : EndringPaMalV1.InnsenderData.NAV + ? EndringPaMalV1.InnsenderData.BRUKER + : EndringPaMalV1.InnsenderData.NAV ) .build(); diff --git a/src/main/java/no/nav/veilarboppfolging/service/MaalService.java b/src/main/java/no/nav/veilarboppfolging/service/MaalService.java index 069631c95..6b35e1afe 100644 --- a/src/main/java/no/nav/veilarboppfolging/service/MaalService.java +++ b/src/main/java/no/nav/veilarboppfolging/service/MaalService.java @@ -105,17 +105,15 @@ public MaalEntity oppdaterMaal(String mal, Fnr fnr, String endretAvVeileder) { Optional maybeKvpPeriode = kvpRepository.hentKvpPeriode(kvpRepository.gjeldendeKvp(aktorId)); maybeKvpPeriode.ifPresent(this::sjekkKvpEnhetTilgang); - ZonedDateTime endretDato = ZonedDateTime.now(); - MaalEntity malData = new MaalEntity() .setAktorId(aktorId.get()) .setMal(mal) .setEndretAv(StringUtils.of(endretAvVeileder).orElse(aktorId.get())) - .setDato(endretDato); + .setDato(ZonedDateTime.now()); transactor.executeWithoutResult((ignored) -> { maalRepository.opprett(malData); - kafkaProducerService.publiserEndretMal(aktorId, endretAvVeileder, endretDato); + kafkaProducerService.publiserEndretMal(aktorId, endretAvVeileder); }); metricsService.oppdatertMittMal(malData, maalRepository.aktorMal(aktorId).size());