Skip to content

Commit

Permalink
Refactor handling of environments and document storage
Browse files Browse the repository at this point in the history
Add environment data directly during template creation in `MalBestillingService`. Ensure physical document contents are cleared after reference creation in `MigrateDokumentService`. Fix typos in API documentation for `DokumentController`.
  • Loading branch information
krharum committed Jan 9, 2025
1 parent eb28d5d commit 72562f0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public List<Dokument> getDokumenterRelatertTilBestilling(@Parameter(description
return dokumentService.getDokumenterByBestilling(bestilllingId);
}

@Operation(description = "Henter dokumenter basert på malId")
@Operation(description = "Henter dokumenter basert på mal-Id")
@GetMapping("/mal/{malId}")
public List<Dokument> getDokumenterRelatertTilMal(@Parameter(description = "malId fra mal")
public List<Dokument> getDokumenterRelatertTilMal(@Parameter(description = "mal-Id fra mal")
@PathVariable("malId") Long malId) {

return dokumentService.getDokumenterByMal(malId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,15 @@ public RsMalBestilling createFromIdent(String ident, String name) {
akkumulertMal = bestillingMalRepository.save(BestillingMal.builder()
.bruker(bruker)
.malNavn(name)
.miljoer(String.join(",", aggregertRequest.getEnvironments()))
.bestKriterier(toJson(aggregertRequest))
.build());
} else {

akkumulertMal = maler.getFirst();
akkumulertMal.setMiljoer(String.join(",", aggregertRequest.getEnvironments()));
akkumulertMal.setBestKriterier(toJson(aggregertRequest));
}
akkumulertMal.setMiljoer(String.join(",", aggregertRequest.getEnvironments()));
akkumulertMal.setBestKriterier(toJson(aggregertRequest));

return mapperFacade.map(akkumulertMal, RsMalBestilling.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ private void migrateBestillinger(Iterable<Bestilling> query, TriConsumer<RsDolly
private TriConsumer<RsDollyUtvidetBestilling, Long, DokumentType> lagreDokarkiv() {

return (utvidetBestilling, bestillingId, dokumentType) ->
utvidetBestilling.getDokarkiv().getDokumenter().forEach(dokument ->
dokument.getDokumentvarianter().forEach(dokumentVariant -> {
if (nonNull(dokumentVariant.getFysiskDokument())) {
dokumentVariant.setDokumentReferanse(
lagreDokument(dokumentVariant.getFysiskDokument(), bestillingId, dokumentType));
// dokumentVariant.setFysiskDokument(null);
}
}));
utvidetBestilling.getDokarkiv().getDokumenter().forEach(dokument ->
dokument.getDokumentvarianter().forEach(dokumentVariant -> {
if (nonNull(dokumentVariant.getFysiskDokument())) {
dokumentVariant.setDokumentReferanse(
lagreDokument(dokumentVariant.getFysiskDokument(), bestillingId, dokumentType));
dokumentVariant.setFysiskDokument(null);
}
}));
}

private TriConsumer<RsDollyUtvidetBestilling, Long, DokumentType> lagreHistark() {
Expand All @@ -97,17 +97,17 @@ private TriConsumer<RsDollyUtvidetBestilling, Long, DokumentType> lagreHistark()
if (nonNull(dokument.getFysiskDokument())) {
dokument.setDokumentReferanse(
lagreDokument(dokument.getFysiskDokument(), bestillingId, dokumentType));
// dokument.setFysiskDokument(null);
dokument.setFysiskDokument(null);
}
});
}

private Long lagreDokument(String fysiskDokument, Long bestillingId, DokumentType dokumentType) {

return dokumentRepository.save(Dokument.builder()
.contents(fysiskDokument)
.dokumentType(dokumentType)
.bestillingId(bestillingId)
.contents(fysiskDokument)
.dokumentType(dokumentType)
.bestillingId(bestillingId)
.build()).getId();
}
}

0 comments on commit 72562f0

Please sign in to comment.