Skip to content

Commit

Permalink
Using findById when we need to check type.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Jan 2, 2024
1 parent fad5c0c commit 3406d80
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ class DokumentUnderArbeidService(
ident: String,
brevmottakerIdents: Set<String>?,
): DokumentUnderArbeid {
val hovedDokument = dokumentUnderArbeidRepository.getReferenceById(dokumentId)
val hovedDokument = dokumentUnderArbeidRepository.findById(dokumentId).get()
val processedBrevmottakerIdents = if (hovedDokument.dokumentType == DokumentType.KJENNELSE_FRA_TRYGDERETTEN) {
//Hardkoder Trygderetten
setOf("974761084")
Expand Down Expand Up @@ -856,7 +856,7 @@ class DokumentUnderArbeidService(
dokumentId: UUID,
innloggetIdent: String,
) {
val document = dokumentUnderArbeidRepository.getReferenceById(dokumentId)
val document = dokumentUnderArbeidRepository.findById(dokumentId).get()

//Sjekker tilgang på behandlingsnivå:
val behandling = behandlingService.getBehandlingAndCheckLeseTilgangForPerson(
Expand Down Expand Up @@ -945,7 +945,7 @@ class DokumentUnderArbeidService(
if (parentId == dokumentId) {
throw DokumentValidationException("Kan ikke gjøre et dokument til vedlegg for seg selv.")
}
val parentDocument = dokumentUnderArbeidRepository.getReferenceById(parentId)
val parentDocument = dokumentUnderArbeidRepository.findById(parentId).get()

behandlingService.getBehandlingAndCheckLeseTilgangForPerson(
behandlingId = parentDocument.behandlingId,
Expand All @@ -954,7 +954,7 @@ class DokumentUnderArbeidService(
if (parentDocument.erMarkertFerdig()) {
throw DokumentValidationException("Kan ikke koble til et dokument som er ferdigstilt")
}
val currentDocument = dokumentUnderArbeidRepository.getReferenceById(dokumentId)
val currentDocument = dokumentUnderArbeidRepository.findById(dokumentId).get()

if (currentDocument.dokumentType == DokumentType.KJENNELSE_FRA_TRYGDERETTEN) {
if (parentDocument !is OpplastetDokumentUnderArbeidAsHoveddokument) {
Expand Down Expand Up @@ -992,7 +992,7 @@ class DokumentUnderArbeidService(
parentId: UUID,
): Pair<DokumentUnderArbeid?, DokumentUnderArbeid?> {
var dokumentUnderArbeid: DokumentUnderArbeid =
dokumentUnderArbeidRepository.getReferenceById(currentDokumentId)
dokumentUnderArbeidRepository.findById(currentDokumentId).get()

if (dokumentUnderArbeid.erMarkertFerdig()) {
throw DokumentValidationException("Kan ikke koble et dokument som er ferdigstilt")
Expand Down Expand Up @@ -1041,7 +1041,7 @@ class DokumentUnderArbeidService(
dokumentId: UUID,
innloggetIdent: String
): DokumentUnderArbeid {
val dokument = dokumentUnderArbeidRepository.getReferenceById(dokumentId)
val dokument = dokumentUnderArbeidRepository.findById(dokumentId).get()

//Sjekker tilgang på behandlingsnivå:
behandlingService.getBehandlingAndCheckLeseTilgangForPerson(
Expand Down

0 comments on commit 3406d80

Please sign in to comment.