Search in sources :

Example 46 with AktorId

use of no.nav.common.types.identer.AktorId in project veilarbportefolje by navikt.

the class OppfolgingService method hentUnderOppfolging.

@SneakyThrows
public boolean hentUnderOppfolging(AktorId aktorId) {
    Fnr fnr = aktorClient.hentFnr(aktorId);
    Request request = new Request.Builder().url(joinPaths(veilarboppfolgingUrl, "/api/v2/oppfolging?fnr=" + fnr)).header(HttpHeaders.AUTHORIZATION, "Bearer " + systemUserTokenProvider.getSystemUserToken()).build();
    try (Response response = client.newCall(request).execute()) {
        RestUtils.throwIfNotSuccessful(response);
        return RestUtils.getBodyStr(response).map((bodyStr) -> JsonUtils.fromJson(bodyStr, UnderOppfolgingV2Response.class)).map(r -> r.erUnderOppfolging).orElseThrow(() -> new IllegalStateException("Unable to parse json"));
    }
}
Also used : Response(okhttp3.Response) SystemUserTokenProvider(no.nav.common.sts.SystemUserTokenProvider) SneakyThrows(lombok.SneakyThrows) Veilarbportefoljeinfo(no.nav.pto.veilarbportefolje.oppfolging.response.Veilarbportefoljeinfo) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) UrlUtils.joinPaths(no.nav.common.utils.UrlUtils.joinPaths) RestUtils(no.nav.common.rest.client.RestUtils) AktorId(no.nav.common.types.identer.AktorId) Service(org.springframework.stereotype.Service) Response(okhttp3.Response) BrukerOppdatertInformasjon(no.nav.pto.veilarbportefolje.domene.BrukerOppdatertInformasjon) AktorClient(no.nav.pto.veilarbportefolje.domene.AktorClient) Request(okhttp3.Request) Fnr(no.nav.common.types.identer.Fnr) HttpHeaders(org.springframework.http.HttpHeaders) JsonUtils(no.nav.common.json.JsonUtils) Timestamp(java.sql.Timestamp) NavIdent(no.nav.common.types.identer.NavIdent) IOException(java.io.IOException) ZoneId(java.time.ZoneId) RestClient(no.nav.common.rest.client.RestClient) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) JobRunner(no.nav.common.job.JobRunner) OkHttpClient(okhttp3.OkHttpClient) Optional(java.util.Optional) UrlUtils(no.nav.common.utils.UrlUtils) VeilederId(no.nav.pto.veilarbportefolje.domene.value.VeilederId) Request(okhttp3.Request) Fnr(no.nav.common.types.identer.Fnr) SneakyThrows(lombok.SneakyThrows)

Example 47 with AktorId

use of no.nav.common.types.identer.AktorId in project veilarbportefolje by navikt.

the class AktivitetService method upsertOgIndekserUtdanningsAktivitet.

public void upsertOgIndekserUtdanningsAktivitet(KafkaAktivitetMelding melding) {
    AktorId aktorId = AktorId.of(melding.getAktorId());
    // ORACLE
    aktivitetDAO.upsertAktivitet(melding);
    utledAktivitetstatuserForAktoerid(aktorId);
    // POSTGRES
    aktiviteterRepositoryV2.upsertAktivitet(melding);
    // OPENSEARCH
    opensearchIndexer.indekser(aktorId);
}
Also used : AktorId(no.nav.common.types.identer.AktorId)

Example 48 with AktorId

use of no.nav.common.types.identer.AktorId in project veilarbportefolje by navikt.

the class AktivitetService method behandleKafkaMeldingLogikk.

public void behandleKafkaMeldingLogikk(KafkaAktivitetMelding aktivitetData) {
    sisteEndringService.behandleAktivitet(aktivitetData);
    // ORACLE
    AktorId aktorId = AktorId.of(aktivitetData.getAktorId());
    boolean bleProsessert = aktivitetDAO.tryLagreAktivitetData(aktivitetData);
    if (bleProsessert && aktivitetData.isAvtalt()) {
        // TODO: ved fjerning av oracle lagring. Dra ut oppdatering av mapping aktorId -> PersonId
        utledAktivitetstatuserForAktoerid(aktorId);
    }
    // POSTGRES
    aktiviteterRepositoryV2.tryLagreAktivitetData(aktivitetData);
    // OPENSEARCH
    if (bleProsessert) {
        opensearchIndexer.indekser(aktorId);
    }
}
Also used : AktorId(no.nav.common.types.identer.AktorId)

Example 49 with AktorId

use of no.nav.common.types.identer.AktorId in project veilarbportefolje by navikt.

the class AdminController method testHentIndeksertPostgresOgOracleBruker.

@PutMapping("/test/hentFraOracleOgPostgres")
public String testHentIndeksertPostgresOgOracleBruker(@RequestBody String aktoerIdString) {
    authorizeAdmin();
    AktorId aktoerId = AktorId.of(aktoerIdString);
    OppfolgingsBruker fraOracle = brukerRepository.hentBrukerFraView(aktoerId).get();
    OppfolgingsBruker fraPostgres = brukerRepository.hentBrukerFraView(aktoerId).get();
    postgresOpensearchMapper.flettInnPostgresData(List.of(fraPostgres), true);
    PostgresAktorIdEntity aktorIdData = aktoerDataOpensearchMapper.hentAktoerData(List.of(aktoerId)).get(aktoerId);
    return "{ \"oracle\":" + JsonUtils.toJson(fraOracle) + ", \"postgres\":" + JsonUtils.toJson(aktorIdData) + " }";
}
Also used : PostgresAktorIdEntity(no.nav.pto.veilarbportefolje.postgres.opensearch.PostgresAktorIdEntity) AktorId(no.nav.common.types.identer.AktorId) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 50 with AktorId

use of no.nav.common.types.identer.AktorId in project veilarbportefolje by navikt.

the class OpensearchIndexer method indexerInParallel.

@SneakyThrows
public boolean indexerInParallel(List<AktorId> alleBrukere) {
    List<List<AktorId>> brukerePartition = Lists.partition(alleBrukere, (alleBrukere.size() / getNumberOfThreads()) + 1);
    ExecutorService executor = Executors.newFixedThreadPool(getNumberOfThreads());
    executor.execute(() -> brukerePartition.parallelStream().forEach(bolk -> partition(bolk, BATCH_SIZE).forEach(this::indekserBolk)));
    executor.shutdown();
    return executor.awaitTermination(7, TimeUnit.HOURS);
}
Also used : RequestOptions(org.opensearch.client.RequestOptions) SneakyThrows(lombok.SneakyThrows) CollectionUtils.partition(no.nav.common.utils.CollectionUtils.partition) RequiredArgsConstructor(lombok.RequiredArgsConstructor) BulkRequest(org.opensearch.action.bulk.BulkRequest) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) JsonUtils.toJson(no.nav.common.json.JsonUtils.toJson) SisteEndringRepository(no.nav.pto.veilarbportefolje.sisteendring.SisteEndringRepository) AktorId(no.nav.common.types.identer.AktorId) PostgresOpensearchMapper(no.nav.pto.veilarbportefolje.postgres.opensearch.PostgresOpensearchMapper) EnvironmentUtils.isDevelopment(no.nav.common.utils.EnvironmentUtils.isDevelopment) Lists(com.google.common.collect.Lists) BrukertiltakV2(no.nav.pto.veilarbportefolje.arenapakafka.arenaDTO.BrukertiltakV2) Service(org.springframework.stereotype.Service) Map(java.util.Map) ActionListener(org.opensearch.action.ActionListener) UnderOppfolgingRegler.erUnderOppfolging(no.nav.pto.veilarbportefolje.util.UnderOppfolgingRegler.erUnderOppfolging) PersonId(no.nav.pto.veilarbportefolje.domene.value.PersonId) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) ExecutorService(java.util.concurrent.ExecutorService) Collectors.toSet(java.util.stream.Collectors.toSet) IndekseringUtils.finnBruker(no.nav.pto.veilarbportefolje.opensearch.IndekseringUtils.finnBruker) AktivitetDAO(no.nav.pto.veilarbportefolje.aktiviteter.AktivitetDAO) TiltakRepositoryV1(no.nav.pto.veilarbportefolje.arenapakafka.aktiviteter.TiltakRepositoryV1) Set(java.util.Set) Executors(java.util.concurrent.Executors) String.format(java.lang.String.format) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) BulkResponse(org.opensearch.action.bulk.BulkResponse) XContentType(org.opensearch.common.xcontent.XContentType) AktivitetStatus(no.nav.pto.veilarbportefolje.aktiviteter.AktivitetStatus) IndexRequest(org.opensearch.action.index.IndexRequest) BrukerRepository(no.nav.pto.veilarbportefolje.database.BrukerRepository) Collections(java.util.Collections) ExecutorService(java.util.concurrent.ExecutorService) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SneakyThrows(lombok.SneakyThrows)

Aggregations

AktorId (no.nav.common.types.identer.AktorId)85 Test (org.junit.jupiter.api.Test)31 TestDataUtils.randomAktorId (no.nav.pto.veilarbportefolje.util.TestDataUtils.randomAktorId)24 EndToEndTest (no.nav.pto.veilarbportefolje.util.EndToEndTest)21 ZonedDateTime (java.time.ZonedDateTime)15 PersonId (no.nav.pto.veilarbportefolje.domene.value.PersonId)13 List (java.util.List)12 Slf4j (lombok.extern.slf4j.Slf4j)12 ApplicationConfigTest (no.nav.pto.veilarbportefolje.config.ApplicationConfigTest)12 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)12 Fnr (no.nav.common.types.identer.Fnr)11 VeilederId (no.nav.pto.veilarbportefolje.domene.value.VeilederId)11 Test (org.junit.Test)11 Timestamp (java.sql.Timestamp)10 Optional (java.util.Optional)10 AktorClient (no.nav.pto.veilarbportefolje.domene.AktorClient)10 BrukerOppdatertInformasjon (no.nav.pto.veilarbportefolje.domene.BrukerOppdatertInformasjon)10 GetResponse (org.opensearch.action.get.GetResponse)10 Collectors (java.util.stream.Collectors)8 Service (org.springframework.stereotype.Service)8