Skip to content

Commit

Permalink
Oppdatert personstatus, rettet feil
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Oct 7, 2024
1 parent c6fe59d commit c9f9e36
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions apps/pdl-forvalter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ properties {

dependencies {
implementation "no.nav.testnav.libs:database"
implementation "no.nav.testnav.libs:vault"
implementation "no.nav.testnav.libs:data-transfer-objects"
implementation "no.nav.testnav.libs:data-transfer-search-objects"
implementation "no.nav.testnav.libs:servlet-core"
Expand Down
1 change: 1 addition & 0 deletions apps/pdl-forvalter/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ includeBuild "../../plugins/java"
includeBuild '../../libs/data-transfer-objects'
includeBuild '../../libs/data-transfer-search-objects'
includeBuild '../../libs/database'
includeBuild '../../libs/vault'
includeBuild '../../libs/reactive-core'
includeBuild '../../libs/security-core'
includeBuild '../../libs/servlet-core'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package no.nav.pdl.forvalter.config;

import no.nav.testnav.libs.database.config.FlywayConfiguration;
import no.nav.testnav.libs.database.config.VaultHikariConfiguration;
import no.nav.testnav.libs.vault.AbstractLocalVaultConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("local")
@Import({
FlywayConfiguration.class,
VaultHikariConfiguration.class
})
public class LocalVaultConfig extends AbstractLocalVaultConfiguration {
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ public void deleteFolkeregisterPersonstatus(String ident, Integer id) {
dbPerson.getPerson().setFolkeregisterPersonstatus(dbPerson.getPerson().getFolkeregisterPersonstatus().stream()
.filter(type -> !id.equals(type.getId()))
.toList());

FolkeregisterPersonstatusService.setGyldigTilOgMed(dbPerson.getPerson().getFolkeregisterPersonstatus());
}

public void deleteSikkerhetstiltak(String ident, Integer id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ public List<FolkeregisterPersonstatusDTO> convert(PersonDTO person) {

public List<FolkeregisterPersonstatusDTO> update(PersonDTO person) {

person.getFolkeregisterPersonstatus().clear();
person.getFolkeregisterPersonstatus()
.add(FolkeregisterPersonstatusDTO.builder()
.id(person.getFolkeregisterPersonstatus().size() + 1)
.isNew(true)
.build());

person.setIsChanged(true);
return convert(person);
}

Expand Down Expand Up @@ -195,13 +189,15 @@ private static LocalDateTime getBoadresseGyldigFraDato(PersonDTO person) {
.orElse(FoedselsdatoUtility.getFoedselsdato(person));
}

private static void setGyldigTilOgMed(List<FolkeregisterPersonstatusDTO> folkeregisterPersonstatus) {
protected static void setGyldigTilOgMed(List<FolkeregisterPersonstatusDTO> folkeregisterPersonstatus) {

for (var i = 0; i < folkeregisterPersonstatus.size(); i++) {
if (i + 1 < folkeregisterPersonstatus.size() && nonNull(folkeregisterPersonstatus.get(i).getGyldigFraOgMed())) {
folkeregisterPersonstatus.get(i + 1)
.setGyldigTilOgMed(folkeregisterPersonstatus.get(i).getGyldigFraOgMed().minusDays(1));
}
}

folkeregisterPersonstatus.getFirst().setGyldigTilOgMed(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static no.nav.testnav.libs.data.pdlforvalter.v1.Identtype.DNR;
import static no.nav.testnav.libs.data.pdlforvalter.v1.Identtype.FNR;
import static no.nav.testnav.libs.data.pdlforvalter.v1.Identtype.NPID;
import static org.apache.commons.lang3.BooleanUtils.isNotTrue;
import static org.apache.commons.lang3.BooleanUtils.isTrue;

@Data
Expand All @@ -33,6 +34,9 @@ public class PersonDTO implements Serializable {
private Identtype identtype;
private Boolean standalone;

@JsonIgnore
private Boolean isChanged;

private List<AdressebeskyttelseDTO> adressebeskyttelse;
private List<BostedadresseDTO> bostedsadresse;
private List<DeltBostedDTO> deltBosted;
Expand Down Expand Up @@ -304,7 +308,7 @@ public boolean isStandalone() {
@JsonIgnore
public boolean isNotChanged() {

return Arrays.stream(this.getClass().getMethods())
return isNotTrue(isChanged) && Arrays.stream(this.getClass().getMethods())
.filter(method -> method.getName().startsWith("get"))
.filter(method -> method.getReturnType().equals(List.class))
.map(method -> {
Expand Down

0 comments on commit c9f9e36

Please sign in to comment.