Skip to content

Commit

Permalink
Fikset problem med bestilling av barn som hovedperson #deploy-test-pd…
Browse files Browse the repository at this point in the history
…l-forvalter #deploy-pdl-forvalter (#3286)
  • Loading branch information
krharum authored Sep 22, 2023
1 parent ddb7439 commit ca76dbf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@

import lombok.extern.slf4j.Slf4j;
import no.nav.pdl.forvalter.config.credentials.IdentPoolProperties;
import no.nav.pdl.forvalter.consumer.command.IdentpoolGetCommand;
import no.nav.pdl.forvalter.consumer.command.IdentpoolGetLedigCommand;
import no.nav.pdl.forvalter.consumer.command.IdentpoolPostCommand;
import no.nav.pdl.forvalter.consumer.command.IdentpoolPostVoidCommand;
import no.nav.pdl.forvalter.dto.AllokerIdentRequest;
import no.nav.pdl.forvalter.dto.HentIdenterRequest;
import no.nav.pdl.forvalter.dto.IdentDTO;
import no.nav.pdl.forvalter.dto.IdentpoolLedigDTO;
import no.nav.pdl.forvalter.dto.IdentpoolStatusDTO;
import no.nav.testnav.libs.securitycore.domain.ServerProperties;
import no.nav.testnav.libs.servletsecurity.exchange.TokenExchange;
import org.springframework.stereotype.Service;

import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Slf4j
@Service
Expand Down Expand Up @@ -61,15 +57,6 @@ public Flux<List<IdentDTO>> releaseIdents(Set<String> identer, Bruker bruker) {
token.getTokenValue()).call()));
}

public Flux<IdentpoolStatusDTO> getIdents(Set<String> identer) {

return tokenExchange.exchange(properties)
.flatMapMany(token -> Flux.concat(identer.stream()
.map(ident ->
new IdentpoolGetCommand(webClient, ACQUIRE_IDENTS_URL, ident, token.getTokenValue()).call())
.collect(Collectors.toList())));
}

public Flux<IdentpoolLedigDTO> getErLedig(Set<String> identer) {

return tokenExchange.exchange(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import no.nav.pdl.forvalter.database.repository.AliasRepository;
import no.nav.pdl.forvalter.database.repository.PersonRepository;
import no.nav.pdl.forvalter.dto.HentIdenterRequest;
import no.nav.pdl.forvalter.dto.IdentDTO;
import no.nav.pdl.forvalter.dto.Paginering;
import no.nav.pdl.forvalter.exception.InvalidRequestException;
import no.nav.pdl.forvalter.exception.NotFoundException;
Expand Down Expand Up @@ -205,7 +206,9 @@ public String createPerson(BestillingRequestDTO request) {
if (isBlank(request.getOpprettFraIdent())) {
request.getPerson().setIdent(identPoolConsumer.acquireIdents(
mapperFacade.map(request, HentIdenterRequest.class))
.blockFirst().stream().findFirst().get().getIdent());
.flatMap(Flux::fromIterable)
.map(IdentDTO::getIdent)
.blockFirst());
} else {
if (personRepository.existsByIdent(request.getOpprettFraIdent())) {
throw new InvalidRequestException(format(IDENT_ALREADY_EXISTS, request.getOpprettFraIdent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ private static void fixFoedsel(BestillingRequestDTO request) {
request.setFoedtFoer(LocalDateTime.of(foedsel.getFoedselsaar() + 1, 1, 1, 0, 0));
}
});

if (request.hasAlder() && nonNull(request.getAlder())) {
request.setFoedtEtter(LocalDateTime.now().minusYears(request.getAlder()).minusMonths(6));
request.setFoedtFoer(LocalDateTime.now().minusYears(request.getAlder()));
request.setAlder(null);
}
}

private Integer getAlderForelder(ForelderBarnRelasjonDTO relasjon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public Identtype getIdenttype() {
}
}


@JsonIgnore
public boolean isStrengtFortrolig() {

return getAdressebeskyttelse().stream().anyMatch(AdressebeskyttelseDTO::isStrengtFortrolig);
Expand Down

0 comments on commit ca76dbf

Please sign in to comment.