Search in sources :

Example 1 with Bruker

use of no.nav.pto.veilarbportefolje.domene.Bruker in project veilarbportefolje by navikt.

the class OpensearchService method hentBrukereMedArbeidsliste.

public List<Bruker> hentBrukereMedArbeidsliste(String veilederId, String enhetId) {
    SearchSourceBuilder request = byggArbeidslisteQuery(enhetId, veilederId);
    OpensearchResponse response = search(request, indexName.getValue(), OpensearchResponse.class);
    return response.hits().getHits().stream().map(hit -> Bruker.of(hit.get_source(), erVedtakstottePilotPa(EnhetId.of(enhetId)))).collect(toList());
}
Also used : OpensearchQueryBuilder.byggArbeidslisteQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggArbeidslisteQuery) RequestOptions(org.opensearch.client.RequestOptions) QueryBuilders.boolQuery(org.opensearch.index.query.QueryBuilders.boolQuery) SneakyThrows(lombok.SneakyThrows) OpensearchQueryBuilder.byggPortefoljestorrelserQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggPortefoljestorrelserQuery) RequiredArgsConstructor(lombok.RequiredArgsConstructor) OpensearchQueryBuilder.sorterQueryParametere(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.sorterQueryParametere) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) FacetResults(no.nav.pto.veilarbportefolje.domene.FacetResults) VeilarbVeilederClient(no.nav.pto.veilarbportefolje.client.VeilarbVeilederClient) StringUtils(org.apache.commons.lang3.StringUtils) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) Bruker(no.nav.pto.veilarbportefolje.domene.Bruker) OpensearchQueryBuilder.sorterPaaNyForEnhet(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.sorterPaaNyForEnhet) StatustallResponse(no.nav.pto.veilarbportefolje.opensearch.domene.StatustallResponse) SortOrder(org.opensearch.search.sort.SortOrder) OpensearchQueryBuilder.byggStatusTallForVeilederQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForVeilederQuery) Service(org.springframework.stereotype.Service) Hit(no.nav.pto.veilarbportefolje.opensearch.domene.Hit) PortefoljestorrelserResponse(no.nav.pto.veilarbportefolje.opensearch.domene.PortefoljestorrelserResponse) SearchRequest(org.opensearch.action.search.SearchRequest) OpensearchResponse(no.nav.pto.veilarbportefolje.opensearch.domene.OpensearchResponse) VedtakstottePilotRequest(no.nav.pto.veilarbportefolje.util.VedtakstottePilotRequest) SearchResponse(org.opensearch.action.search.SearchResponse) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) QueryBuilders.termQuery(org.opensearch.index.query.QueryBuilders.termQuery) OpensearchQueryBuilder.byggStatusTallForEnhetQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForEnhetQuery) Bucket(no.nav.pto.veilarbportefolje.opensearch.domene.Bucket) StatusTall(no.nav.pto.veilarbportefolje.domene.StatusTall) OpensearchQueryBuilder.leggTilManuelleFilter(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilManuelleFilter) Collections.emptyList(java.util.Collections.emptyList) JsonUtils(no.nav.common.json.JsonUtils) EnhetId(no.nav.common.types.identer.EnhetId) UnleashService(no.nav.pto.veilarbportefolje.service.UnleashService) StatustallBuckets(no.nav.pto.veilarbportefolje.opensearch.domene.StatustallResponse.StatustallAggregation.StatustallFilter.StatustallBuckets) QueryBuilders.matchQuery(org.opensearch.index.query.QueryBuilders.matchQuery) OpensearchQueryBuilder.leggTilFerdigFilter(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilFerdigFilter) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) Optional(java.util.Optional) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) OpensearchResponse(no.nav.pto.veilarbportefolje.opensearch.domene.OpensearchResponse) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder)

Example 2 with Bruker

use of no.nav.pto.veilarbportefolje.domene.Bruker in project veilarbportefolje by navikt.

the class OpensearchService method hentBrukere.

public BrukereMedAntall hentBrukere(String enhetId, Optional<String> veilederIdent, String sortOrder, String sortField, Filtervalg filtervalg, Integer fra, Integer antall) {
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
    int from = Optional.ofNullable(fra).orElse(0);
    int size = Optional.ofNullable(antall).orElse(5000);
    searchSourceBuilder.from(from);
    searchSourceBuilder.size(size);
    BoolQueryBuilder boolQuery = boolQuery();
    boolQuery.must(matchQuery("enhet_id", enhetId));
    boolQuery.must(matchQuery("oppfolging", true));
    boolean kallesFraMinOversikt = veilederIdent.isPresent() && StringUtils.isNotBlank(veilederIdent.get());
    if (kallesFraMinOversikt) {
        boolQuery.filter(termQuery("veileder_id", veilederIdent.get()));
    }
    List<String> veiledereMedTilgangTilEnhet = veilarbVeilederClient.hentVeilederePaaEnhet(EnhetId.of(enhetId));
    if (filtervalg.harAktiveFilter()) {
        boolean erVedtakstottePilotPa = erVedtakstottePilotPa(EnhetId.of(enhetId));
        filtervalg.ferdigfilterListe.forEach(filter -> boolQuery.filter(leggTilFerdigFilter(filter, veiledereMedTilgangTilEnhet, erVedtakstottePilotPa)));
        leggTilManuelleFilter(boolQuery, filtervalg, unleashService);
    }
    searchSourceBuilder.query(boolQuery);
    if (kallesFraMinOversikt) {
        searchSourceBuilder.sort("ny_for_veileder", SortOrder.DESC);
    } else {
        sorterPaaNyForEnhet(searchSourceBuilder, veiledereMedTilgangTilEnhet);
    }
    sorterQueryParametere(sortOrder, sortField, searchSourceBuilder, filtervalg);
    OpensearchResponse response = search(searchSourceBuilder, indexName.getValue(), OpensearchResponse.class);
    int totalHits = response.hits().getTotal().getValue();
    List<Bruker> brukere = response.hits().getHits().stream().map(Hit::get_source).map(oppfolgingsBruker -> setNyForEnhet(oppfolgingsBruker, veiledereMedTilgangTilEnhet)).map(oppfolgingsBruker -> mapOppfolgingsBrukerTilBruker(oppfolgingsBruker, filtervalg, enhetId)).collect(toList());
    return new BrukereMedAntall(totalHits, brukere);
}
Also used : OpensearchQueryBuilder.byggArbeidslisteQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggArbeidslisteQuery) RequestOptions(org.opensearch.client.RequestOptions) QueryBuilders.boolQuery(org.opensearch.index.query.QueryBuilders.boolQuery) SneakyThrows(lombok.SneakyThrows) OpensearchQueryBuilder.byggPortefoljestorrelserQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggPortefoljestorrelserQuery) RequiredArgsConstructor(lombok.RequiredArgsConstructor) OpensearchQueryBuilder.sorterQueryParametere(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.sorterQueryParametere) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) FacetResults(no.nav.pto.veilarbportefolje.domene.FacetResults) VeilarbVeilederClient(no.nav.pto.veilarbportefolje.client.VeilarbVeilederClient) StringUtils(org.apache.commons.lang3.StringUtils) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) Bruker(no.nav.pto.veilarbportefolje.domene.Bruker) OpensearchQueryBuilder.sorterPaaNyForEnhet(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.sorterPaaNyForEnhet) StatustallResponse(no.nav.pto.veilarbportefolje.opensearch.domene.StatustallResponse) SortOrder(org.opensearch.search.sort.SortOrder) OpensearchQueryBuilder.byggStatusTallForVeilederQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForVeilederQuery) Service(org.springframework.stereotype.Service) Hit(no.nav.pto.veilarbportefolje.opensearch.domene.Hit) PortefoljestorrelserResponse(no.nav.pto.veilarbportefolje.opensearch.domene.PortefoljestorrelserResponse) SearchRequest(org.opensearch.action.search.SearchRequest) OpensearchResponse(no.nav.pto.veilarbportefolje.opensearch.domene.OpensearchResponse) VedtakstottePilotRequest(no.nav.pto.veilarbportefolje.util.VedtakstottePilotRequest) SearchResponse(org.opensearch.action.search.SearchResponse) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) QueryBuilders.termQuery(org.opensearch.index.query.QueryBuilders.termQuery) OpensearchQueryBuilder.byggStatusTallForEnhetQuery(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForEnhetQuery) Bucket(no.nav.pto.veilarbportefolje.opensearch.domene.Bucket) StatusTall(no.nav.pto.veilarbportefolje.domene.StatusTall) OpensearchQueryBuilder.leggTilManuelleFilter(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilManuelleFilter) Collections.emptyList(java.util.Collections.emptyList) JsonUtils(no.nav.common.json.JsonUtils) EnhetId(no.nav.common.types.identer.EnhetId) UnleashService(no.nav.pto.veilarbportefolje.service.UnleashService) StatustallBuckets(no.nav.pto.veilarbportefolje.opensearch.domene.StatustallResponse.StatustallAggregation.StatustallFilter.StatustallBuckets) QueryBuilders.matchQuery(org.opensearch.index.query.QueryBuilders.matchQuery) OpensearchQueryBuilder.leggTilFerdigFilter(no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilFerdigFilter) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) Filtervalg(no.nav.pto.veilarbportefolje.domene.Filtervalg) Optional(java.util.Optional) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) OpensearchResponse(no.nav.pto.veilarbportefolje.opensearch.domene.OpensearchResponse) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) Bruker(no.nav.pto.veilarbportefolje.domene.Bruker) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder)

Example 3 with Bruker

use of no.nav.pto.veilarbportefolje.domene.Bruker in project veilarbportefolje by navikt.

the class VeilederController method hentPortefoljeForVeileder.

@PostMapping("/{veilederident}/portefolje")
public Portefolje hentPortefoljeForVeileder(@PathVariable("veilederident") String veilederIdent, @RequestParam("enhet") String enhet, @RequestParam(value = "fra", required = false) Integer fra, @RequestParam(value = "antall", required = false) Integer antall, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortField") String sortField, @RequestBody Filtervalg filtervalg) {
    ValideringsRegler.sjekkVeilederIdent(veilederIdent, false);
    ValideringsRegler.sjekkEnhet(enhet);
    ValideringsRegler.sjekkSortering(sortDirection, sortField);
    ValideringsRegler.sjekkFiltervalg(filtervalg);
    authService.tilgangTilOppfolging();
    authService.tilgangTilEnhet(enhet);
    String ident = AuthUtils.getInnloggetVeilederIdent().toString();
    String identHash = DigestUtils.md5Hex(ident).toUpperCase();
    BrukereMedAntall brukereMedAntall = opensearchService.hentBrukere(enhet, Optional.of(veilederIdent), sortDirection, sortField, filtervalg, fra, antall);
    List<Bruker> sensurerteBrukereSublist = authService.sensurerBrukere(brukereMedAntall.getBrukere());
    Portefolje portefolje = PortefoljeUtils.buildPortefolje(brukereMedAntall.getAntall(), sensurerteBrukereSublist, enhet, Optional.ofNullable(fra).orElse(0));
    Event event = new Event("minoversiktportefolje.lastet");
    event.addFieldToReport("identhash", identHash);
    metricsClient.report(event);
    return portefolje;
}
Also used : BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) Portefolje(no.nav.pto.veilarbportefolje.domene.Portefolje) Event(no.nav.common.metrics.Event) Bruker(no.nav.pto.veilarbportefolje.domene.Bruker) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with Bruker

use of no.nav.pto.veilarbportefolje.domene.Bruker in project veilarbportefolje by navikt.

the class EnhetController method hentPortefoljeForEnhet.

@PostMapping("/{enhet}/portefolje")
public Portefolje hentPortefoljeForEnhet(@PathVariable("enhet") String enhet, @RequestParam(value = "fra", required = false) Integer fra, @RequestParam(value = "antall", required = false) Integer antall, @RequestParam("sortDirection") String sortDirection, @RequestParam("sortField") String sortField, @RequestBody Filtervalg filtervalg) {
    ValideringsRegler.sjekkEnhet(enhet);
    ValideringsRegler.sjekkSortering(sortDirection, sortField);
    ValideringsRegler.sjekkFiltervalg(filtervalg);
    authService.tilgangTilOppfolging();
    authService.tilgangTilEnhet(enhet);
    String ident = AuthUtils.getInnloggetVeilederIdent().toString();
    String identHash = DigestUtils.md5Hex(ident).toUpperCase();
    BrukereMedAntall brukereMedAntall = opensearchService.hentBrukere(enhet, Optional.empty(), sortDirection, sortField, filtervalg, fra, antall);
    List<Bruker> sensurerteBrukereSublist = authService.sensurerBrukere(brukereMedAntall.getBrukere());
    Portefolje portefolje = PortefoljeUtils.buildPortefolje(brukereMedAntall.getAntall(), sensurerteBrukereSublist, enhet, Optional.ofNullable(fra).orElse(0));
    Event event = new Event("enhetsportefolje.lastet");
    event.addFieldToReport("identhash", identHash);
    metricsClient.report(event);
    return portefolje;
}
Also used : BrukereMedAntall(no.nav.pto.veilarbportefolje.domene.BrukereMedAntall) Portefolje(no.nav.pto.veilarbportefolje.domene.Portefolje) Event(no.nav.common.metrics.Event) Bruker(no.nav.pto.veilarbportefolje.domene.Bruker) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Bruker (no.nav.pto.veilarbportefolje.domene.Bruker)4 BrukereMedAntall (no.nav.pto.veilarbportefolje.domene.BrukereMedAntall)4 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors.toList (java.util.stream.Collectors.toList)2 RequiredArgsConstructor (lombok.RequiredArgsConstructor)2 SneakyThrows (lombok.SneakyThrows)2 JsonUtils (no.nav.common.json.JsonUtils)2 EnhetId (no.nav.common.types.identer.EnhetId)2 VeilarbVeilederClient (no.nav.pto.veilarbportefolje.client.VeilarbVeilederClient)2 FacetResults (no.nav.pto.veilarbportefolje.domene.FacetResults)2 Filtervalg (no.nav.pto.veilarbportefolje.domene.Filtervalg)2 StatusTall (no.nav.pto.veilarbportefolje.domene.StatusTall)2 OpensearchQueryBuilder.byggArbeidslisteQuery (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggArbeidslisteQuery)2 OpensearchQueryBuilder.byggPortefoljestorrelserQuery (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggPortefoljestorrelserQuery)2 OpensearchQueryBuilder.byggStatusTallForEnhetQuery (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForEnhetQuery)2 OpensearchQueryBuilder.byggStatusTallForVeilederQuery (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.byggStatusTallForVeilederQuery)2 OpensearchQueryBuilder.leggTilFerdigFilter (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilFerdigFilter)2 OpensearchQueryBuilder.leggTilManuelleFilter (no.nav.pto.veilarbportefolje.opensearch.OpensearchQueryBuilder.leggTilManuelleFilter)2