Search in sources :

Example 1 with UnleashService

use of no.nav.pto.veilarbportefolje.service.UnleashService 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 2 with UnleashService

use of no.nav.pto.veilarbportefolje.service.UnleashService in project veilarbportefolje by navikt.

the class ApplicationConfigTest method unleashService.

@Bean
public UnleashService unleashService() {
    final UnleashService mock = mock(UnleashService.class);
    when(mock.isEnabled(anyString())).thenReturn(true);
    return mock;
}
Also used : UnleashService(no.nav.pto.veilarbportefolje.service.UnleashService) Bean(org.springframework.context.annotation.Bean)

Aggregations

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