Search in sources :

Example 11 with Fnr

use of no.nav.common.types.identer.Fnr 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 12 with Fnr

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

the class ArbeidsListeController method deleteArbeidslisteListe.

@PostMapping("/delete")
public RestResponse<String> deleteArbeidslisteListe(@RequestBody java.util.List<ArbeidslisteRequest> arbeidslisteData) {
    authService.tilgangTilOppfolging();
    java.util.List<String> feiledeFnrs = new ArrayList<>();
    java.util.List<String> okFnrs = new ArrayList<>();
    java.util.List<Fnr> fnrs = arbeidslisteData.stream().map(data -> Fnr.ofValidFnr(data.getFnr())).collect(Collectors.toList());
    Validation<List<Fnr>, List<Fnr>> validerFnrs = ValideringsRegler.validerFnrs(fnrs);
    Validation<String, List<Fnr>> veilederForBrukere = arbeidslisteService.erVeilederForBrukere(fnrs);
    if (validerFnrs.isInvalid() || veilederForBrukere.isInvalid()) {
        throw new IllegalStateException(format("%s inneholder ett eller flere ugyldige fødselsnummer", validerFnrs.getError()));
    }
    validerFnrs.get().forEach(fnr -> {
        final int antallRaderSlettet = arbeidslisteService.slettArbeidsliste(fnr);
        final AktorId aktoerId = brukerService.hentAktorId(fnr).orElse(new AktorId("uten aktør-ID"));
        if (antallRaderSlettet != 1) {
            feiledeFnrs.add(fnr.get());
            log.warn("Kunne ikke slette arbeidsliste for bruker {} ", aktoerId.get());
        } else {
            okFnrs.add(fnr.get());
            log.info("Arbeidsliste for aktoerid {} slettet", aktoerId.get());
        }
    });
    if (feiledeFnrs.size() == fnrs.size()) {
        throw new IllegalStateException();
    }
    return RestResponse.of(okFnrs, feiledeFnrs);
}
Also used : BrukerService(no.nav.pto.veilarbportefolje.service.BrukerService) ValideringsRegler.validerArbeidsliste(no.nav.pto.veilarbportefolje.util.ValideringsRegler.validerArbeidsliste) PathVariable(org.springframework.web.bind.annotation.PathVariable) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) RestResponse(no.nav.pto.veilarbportefolje.domene.RestResponse) Function(java.util.function.Function) ArrayList(java.util.ArrayList) RequestBody(org.springframework.web.bind.annotation.RequestBody) AktorId(no.nav.common.types.identer.AktorId) PutMapping(org.springframework.web.bind.annotation.PutMapping) GetMapping(org.springframework.web.bind.annotation.GetMapping) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) AktorClient(no.nav.pto.veilarbportefolje.domene.AktorClient) PostMapping(org.springframework.web.bind.annotation.PostMapping) ValideringsRegler(no.nav.pto.veilarbportefolje.util.ValideringsRegler) ResponseStatusException(org.springframework.web.server.ResponseStatusException) Fnr(no.nav.common.types.identer.Fnr) Timestamp(java.sql.Timestamp) Instant(java.time.Instant) RestController(org.springframework.web.bind.annotation.RestController) Collectors(java.util.stream.Collectors) AuthService(no.nav.pto.veilarbportefolje.auth.AuthService) String.format(java.lang.String.format) HttpStatus(org.springframework.http.HttpStatus) StringUtils.nullOrEmpty(no.nav.common.utils.StringUtils.nullOrEmpty) Try(io.vavr.control.Try) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ResponseEntity(org.springframework.http.ResponseEntity) VeilederId(no.nav.pto.veilarbportefolje.domene.value.VeilederId) AuthUtils(no.nav.pto.veilarbportefolje.auth.AuthUtils) Validation(io.vavr.control.Validation) ArrayList(java.util.ArrayList) AktorId(no.nav.common.types.identer.AktorId) Fnr(no.nav.common.types.identer.Fnr) ArrayList(java.util.ArrayList) List(java.util.List) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 13 with Fnr

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

the class BrukerRepositoryTest method skal_hente_bruker_fra_view.

@Test
public void skal_hente_bruker_fra_view() {
    final Fnr fnr = randomFnr();
    final AktorId aktorId = randomAktorId();
    final PersonId personId = randomPersonId();
    SqlUtils.insert(jdbcTemplate, Table.OPPFOLGINGSBRUKER.TABLE_NAME).value(Table.OPPFOLGINGSBRUKER.FODSELSNR, fnr.toString()).value(Table.OPPFOLGINGSBRUKER.PERSON_ID, personId.toString()).execute();
    SqlUtils.insert(jdbcTemplate, Table.AKTOERID_TO_PERSONID.TABLE_NAME).value(Table.AKTOERID_TO_PERSONID.AKTOERID, aktorId.toString()).value(Table.AKTOERID_TO_PERSONID.PERSONID, personId.toString()).value(Table.AKTOERID_TO_PERSONID.GJELDENE, 1).execute();
    final Optional<OppfolgingsBruker> bruker = brukerRepository.hentBrukerFraView(brukerRepository.hentAktorIdFraView(fnr).get());
    assertThat(bruker).isPresent();
}
Also used : PersonId(no.nav.pto.veilarbportefolje.domene.value.PersonId) TestDataUtils.randomPersonId(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomPersonId) AktorId(no.nav.common.types.identer.AktorId) TestDataUtils.randomAktorId(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomAktorId) Fnr(no.nav.common.types.identer.Fnr) TestDataUtils.randomFnr(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomFnr) OppfolgingsBruker(no.nav.pto.veilarbportefolje.opensearch.domene.OppfolgingsBruker) Test(org.junit.Test)

Example 14 with Fnr

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

the class BrukerRepositoryTest method skalIkkeFeileOmIngenPersonIdFinnes.

@Test
public void skalIkkeFeileOmIngenPersonIdFinnes() {
    Fnr fnr = Fnr.ofValidFnr("99999999999");
    Optional<PersonId> result = brukerRepository.retrievePersonidFromFnr(fnr);
    assertTrue(result.isEmpty());
}
Also used : PersonId(no.nav.pto.veilarbportefolje.domene.value.PersonId) TestDataUtils.randomPersonId(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomPersonId) Fnr(no.nav.common.types.identer.Fnr) TestDataUtils.randomFnr(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomFnr) Test(org.junit.Test)

Example 15 with Fnr

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

the class BrukerRepositoryTest method skalHentePersonIdFraDatabase.

@Test
public void skalHentePersonIdFraDatabase() {
    Fnr fnr = Fnr.ofValidFnr("12345678900");
    PersonId expectedPersonId = PersonId.of("123456");
    insertOppfolgingsbrukerForPersonIdToFnrMapping(fnr, expectedPersonId);
    Optional<PersonId> result = brukerRepository.retrievePersonidFromFnr(fnr);
    assertTrue(result.isPresent());
    assertEquals(expectedPersonId, result.get());
}
Also used : PersonId(no.nav.pto.veilarbportefolje.domene.value.PersonId) TestDataUtils.randomPersonId(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomPersonId) Fnr(no.nav.common.types.identer.Fnr) TestDataUtils.randomFnr(no.nav.pto.veilarbportefolje.util.TestDataUtils.randomFnr) Test(org.junit.Test)

Aggregations

Fnr (no.nav.common.types.identer.Fnr)22 AktorId (no.nav.common.types.identer.AktorId)10 PersonId (no.nav.pto.veilarbportefolje.domene.value.PersonId)8 TestDataUtils.randomFnr (no.nav.pto.veilarbportefolje.util.TestDataUtils.randomFnr)7 Test (org.junit.Test)7 AktorClient (no.nav.pto.veilarbportefolje.domene.AktorClient)6 TestDataUtils.randomPersonId (no.nav.pto.veilarbportefolje.util.TestDataUtils.randomPersonId)6 List (java.util.List)5 Slf4j (lombok.extern.slf4j.Slf4j)5 VeilederId (no.nav.pto.veilarbportefolje.domene.value.VeilederId)5 Try (io.vavr.control.Try)4 Validation (io.vavr.control.Validation)4 String.format (java.lang.String.format)4 Timestamp (java.sql.Timestamp)4 ArrayList (java.util.ArrayList)4 AuthUtils (no.nav.pto.veilarbportefolje.auth.AuthUtils)4 BrukerService (no.nav.pto.veilarbportefolje.service.BrukerService)4 ValideringsRegler (no.nav.pto.veilarbportefolje.util.ValideringsRegler)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 Instant (java.time.Instant)3