Skip to content

Commit

Permalink
Oppdatert entity-klasse #deploy-test-dolly-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
krharum committed Dec 15, 2023
1 parent e4c2056 commit 284d74b
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 113 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ public class Bestilling implements Serializable {
private Boolean navSyntetiskIdent;

@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "bestilling_id")
@JoinColumn(name = "bestilling_id", updatable = false)
@Builder.Default
private List<BestillingProgress> progresser = new ArrayList<>();

@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "bestilling_id")
@JoinColumn(name = "bestilling_id", updatable = false)
@Builder.Default
private List<BestillingKontroll> kontroller = new ArrayList<>();

@OneToMany(fetch = FetchType.LAZY)
@JoinColumn(name = "bestilling_id")
@JoinColumn(name = "bestilling_id", updatable = false)
@Builder.Default
private List<TransaksjonMapping> transaksjonmapping = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,79 +172,86 @@ public void setDokarkivStatus(String dokarkivStatus) {
this.dokarkivStatus = StringUtils.left(dokarkivStatus, MAX_DOKARKIV_STATUS_LENGTH);
}

//Husk å regenerere disse når nye systemer legges til
@Override
public boolean equals(Object o) {
if (this == o) return true;

if (o == null || getClass() != o.getClass()) return false;

BestillingProgress that = (BestillingProgress) o;

return new EqualsBuilder().append(id, that.id)
.append(versjon, that.versjon)
.append(bestilling, that.bestilling)
.append(ident, that.ident)
.append(sigrunstubStatus, that.sigrunstubStatus)
.append(krrstubStatus, that.krrstubStatus)
.append(medlStatus, that.medlStatus)
.append(udistubStatus, that.udistubStatus)
.append(aaregStatus, that.aaregStatus)
.append(arenaforvalterStatus, that.arenaforvalterStatus)
.append(instdataStatus, that.instdataStatus)
.append(inntektstubStatus, that.inntektstubStatus)
.append(pensjonforvalterStatus, that.pensjonforvalterStatus)
.append(inntektsmeldingStatus, that.inntektsmeldingStatus)
.append(brregstubStatus, that.brregstubStatus)
.append(dokarkivStatus, that.dokarkivStatus)
.append(histarkStatus, that.histarkStatus)
.append(sykemeldingStatus, that.sykemeldingStatus)
.append(skjermingsregisterStatus, that.skjermingsregisterStatus)
.append(tpsMessagingStatus, that.tpsMessagingStatus)
.append(pdlImportStatus, that.pdlImportStatus)
.append(pdlForvalterStatus, that.pdlForvalterStatus)
.append(pdlOrdreStatus, that.pdlOrdreStatus)
.append(kontoregisterStatus, that.kontoregisterStatus)
.append(pdlPersonStatus, that.pdlPersonStatus)
.append(arbeidsplassenCVStatus, that.arbeidsplassenCVStatus)
.append(master, that.master)
.append(feil, that.feil)
if (!(o instanceof BestillingProgress that)) return false;

return new EqualsBuilder()
.append(getId(), that.getId())
.append(getVersjon(), that.getVersjon())
.append(getBestilling(), that.getBestilling())
.append(getIdent(), that.getIdent())
.append(getSigrunstubStatus(), that.getSigrunstubStatus())
.append(getKrrstubStatus(), that.getKrrstubStatus())
.append(getMedlStatus(), that.getMedlStatus())
.append(getUdistubStatus(), that.getUdistubStatus())
.append(getAaregStatus(), that.getAaregStatus())
.append(getArenaforvalterStatus(), that.getArenaforvalterStatus())
.append(getInstdataStatus(), that.getInstdataStatus())
.append(getInntektstubStatus(), that.getInntektstubStatus())
.append(getPensjonforvalterStatus(), that.getPensjonforvalterStatus())
.append(getInntektsmeldingStatus(), that.getInntektsmeldingStatus())
.append(getBrregstubStatus(), that.getBrregstubStatus())
.append(getDokarkivStatus(), that.getDokarkivStatus())
.append(getHistarkStatus(), that.getHistarkStatus())
.append(getSykemeldingStatus(), that.getSykemeldingStatus())
.append(getSkjermingsregisterStatus(), that.getSkjermingsregisterStatus())
.append(getTpsMessagingStatus(), that.getTpsMessagingStatus())
.append(getPdlImportStatus(), that.getPdlImportStatus())
.append(getPdlForvalterStatus(), that.getPdlForvalterStatus())
.append(getPdlOrdreStatus(), that.getPdlOrdreStatus())
.append(getKontoregisterStatus(), that.getKontoregisterStatus())
.append(getPdlPersonStatus(), that.getPdlPersonStatus())
.append(getTpsSyncStatus(), that.getTpsSyncStatus())
.append(getArbeidsplassenCVStatus(), that.getArbeidsplassenCVStatus())
.append(getMaster(), that.getMaster())
.append(getFeil(), that.getFeil())
.isEquals();
}

@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(id)
.append(versjon)
.append(bestilling)
.append(ident).append(sigrunstubStatus).append(krrstubStatus)
.append(medlStatus)
.append(udistubStatus).append(aaregStatus)
.append(arenaforvalterStatus).append(instdataStatus)
.append(inntektstubStatus)
.append(pensjonforvalterStatus)
.append(inntektsmeldingStatus).append(brregstubStatus)
.append(dokarkivStatus)
.append(histarkStatus)
.append(sykemeldingStatus)
.append(skjermingsregisterStatus)
.append(tpsMessagingStatus)
.append(pdlImportStatus)
.append(pdlForvalterStatus)
.append(pdlOrdreStatus)
.append(kontoregisterStatus)
.append(pdlPersonStatus).append(arbeidsplassenCVStatus)
.append(master).append(feil).toHashCode();
.append(getId())
.append(getVersjon())
.append(getBestilling())
.append(getIdent())
.append(getSigrunstubStatus())
.append(getKrrstubStatus())
.append(getMedlStatus())
.append(getUdistubStatus())
.append(getAaregStatus())
.append(getArenaforvalterStatus())
.append(getInstdataStatus())
.append(getInntektstubStatus())
.append(getPensjonforvalterStatus())
.append(getInntektsmeldingStatus())
.append(getBrregstubStatus())
.append(getDokarkivStatus())
.append(getHistarkStatus())
.append(getSykemeldingStatus())
.append(getSkjermingsregisterStatus())
.append(getTpsMessagingStatus())
.append(getPdlImportStatus())
.append(getPdlForvalterStatus())
.append(getPdlOrdreStatus())
.append(getKontoregisterStatus())
.append(getPdlPersonStatus())
.append(getTpsSyncStatus())
.append(getArbeidsplassenCVStatus())
.append(getMaster())
.append(getFeil())
.toHashCode();
}

@Override
public String toString() {
return "BestillingProgress{" +
"id=" + id +
", versjon=" + versjon +
", bestilling=" + bestilling.getId() +
", gruppe=" + bestilling.getGruppe().getId() +
", bestilling=" + bestilling +
", ident='" + ident + '\'' +
", sigrunstubStatus='" + sigrunstubStatus + '\'' +
", krrstubStatus='" + krrstubStatus + '\'' +
Expand All @@ -267,9 +274,11 @@ public String toString() {
", pdlOrdreStatus='" + pdlOrdreStatus + '\'' +
", kontoregisterStatus='" + kontoregisterStatus + '\'' +
", pdlPersonStatus='" + pdlPersonStatus + '\'' +
", tpsSyncStatus='" + tpsSyncStatus + '\'' +
", arbeidsplassenCVStatus='" + arbeidsplassenCVStatus + '\'' +
", master=" + master +
", isPdlSync=" + isPdlSync +
", isTpsSyncEnv=" + isTpsSyncEnv +
", feil='" + feil + '\'' +
'}';
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package no.nav.dolly.mapper.strategy;

import lombok.experimental.UtilityClass;
import no.nav.dolly.domain.jpa.Bestilling;

@UtilityClass
public class BestillingMapper {

public Bestilling shallowCopyBestilling(Bestilling bestilling) {

return Bestilling.builder()
.id(bestilling.getId())
.gruppe(bestilling.getGruppe())
.antallIdenter(bestilling.getAntallIdenter())
.bestKriterier(bestilling.getBestKriterier())
.beskrivelse(bestilling.getBeskrivelse())
.kildeMiljoe(bestilling.getKildeMiljoe())
.miljoer(bestilling.getMiljoer())
.navSyntetiskIdent(bestilling.getNavSyntetiskIdent())
.opprettFraIdenter(bestilling.getOpprettFraIdenter())
.pdlImport(bestilling.getPdlImport())
.sistOppdatert(bestilling.getSistOppdatert())
.gjenopprettetFraIdent(bestilling.getGjenopprettetFraIdent())
.opprettetFraGruppeId(bestilling.getOpprettetFraGruppeId())
.opprettetFraId(bestilling.getOpprettetFraId())
.feil(bestilling.getFeil())
.ferdig(true)
.stoppet(false)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import no.nav.dolly.domain.jpa.Testgruppe;
import no.nav.dolly.domain.jpa.Testident;
import no.nav.dolly.exceptions.NotFoundException;
import no.nav.dolly.mapper.strategy.BestillingMapper;
import no.nav.dolly.repository.BestillingKontrollRepository;
import no.nav.dolly.repository.BestillingProgressRepository;
import no.nav.dolly.repository.BestillingRepository;
Expand Down Expand Up @@ -64,46 +65,40 @@ private void moveIdenter(Set<String> identer, Testgruppe testgruppe) {

private Bestilling moveBestillinger(Bestilling bestilling, Set<String> identer, Testgruppe testgruppe) {

var nyeProgresser = bestilling.getProgresser().stream()
var progresser = bestilling.getProgresser().stream()
.filter(progress -> identer.contains(progress.getIdent()))
.map(SerializationUtils::clone)
.toList();
var nyeTransaksjonMappinger = bestilling.getTransaksjonmapping().stream()
var transaksjonMappinger = bestilling.getTransaksjonmapping().stream()
.filter(mapping -> identer.contains(mapping.getIdent()))
.map(SerializationUtils::clone)
.toList();

var nyBestilling = SerializationUtils.clone(bestilling);
var nyBestilling = BestillingMapper.shallowCopyBestilling(bestilling);
nyBestilling.setId(null);
nyBestilling.setGruppe(testgruppe);
nyBestilling.setProgresser(null);
nyBestilling.setTransaksjonmapping(null);
nyBestilling.setKontroller(null);
nyBestilling.setAntallIdenter(nyeProgresser.size());
nyBestilling.setFerdig(true);
nyBestilling.setStoppet(false);

var oppdatertBestilling = bestillingRepository.save(nyBestilling);

nyeProgresser
progresser
.forEach(progress -> {
bestillingProgressRepository.findById(progress.getId())
.ifPresent(bestillingProgressRepository::delete);
progress.setId(null);
progress.setBestilling(oppdatertBestilling);
bestillingProgressRepository.save(progress);
var nyProgress = SerializationUtils.clone(progress);
bestillingProgressRepository.deleteById(progress.getId());

nyProgress.setId(null);
nyProgress.setBestilling(oppdatertBestilling);
bestillingProgressRepository.save(nyProgress);
});

nyeTransaksjonMappinger
transaksjonMappinger
.forEach(transaksjonMapping -> {
transaksjonMappingRepository.findById(transaksjonMapping.getId())
.ifPresent(transaksjonMappingRepository::delete);
transaksjonMapping.setId(null);
transaksjonMapping.setBestillingId(oppdatertBestilling.getId());
transaksjonMappingRepository.save(transaksjonMapping);
var nyTransaksjonMapping = SerializationUtils.clone(transaksjonMapping);
transaksjonMappingRepository.deleteById(transaksjonMapping.getId());

nyTransaksjonMapping.setId(null);
nyTransaksjonMapping.setBestillingId(oppdatertBestilling.getId());
transaksjonMappingRepository.save(nyTransaksjonMapping);
});

deleteKildeBestilling(bestilling, nyeProgresser);
deleteKildeBestilling(bestilling, progresser);

return oppdatertBestilling;
}
Expand Down

0 comments on commit 284d74b

Please sign in to comment.