Skip to content

Commit

Permalink
WIP: Divide DokumentUnderArbeid.
Browse files Browse the repository at this point in the history
Co-authored-by: Andreas Jonsson <[email protected]>
  • Loading branch information
oyvind-wedoe and flexable777 committed Sep 29, 2023
1 parent c4b6ea0 commit 20ab637
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
package no.nav.klage.dokument.domain.dokumenterunderarbeid

import jakarta.persistence.*
import no.nav.klage.kodeverk.DokumentType
import no.nav.klage.oppgave.domain.klage.BehandlingRole
import no.nav.klage.oppgave.domain.klage.DokumentTypeConverter
import org.hibernate.annotations.BatchSize
import org.hibernate.annotations.DynamicUpdate
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import java.time.LocalDateTime
import java.util.*

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@Table(name = "dokument_under_arbeid", schema = "klage")
@DynamicUpdate
@DiscriminatorColumn(name = "dokument_under_arbeid_type")
open class DokumentUnderArbeid(
@Id
val id: UUID = UUID.randomUUID(),
@Column(name = "mellomlager_id")
open var mellomlagerId: String?,
@Column(name = "opplastet")
open var opplastet: LocalDateTime?,
@Column(name = "size")
open var size: Long?,
@Column(name = "name")
open var name: String,
@Column(name = "smarteditor_id")
open var smartEditorId: UUID?,
@Column(name = "smarteditor_template_id")
open var smartEditorTemplateId: String?,
@Column(name = "behandling_id")
open var behandlingId: UUID,
@Column(name = "dokument_type_id")
@Convert(converter = DokumentTypeConverter::class)
open var dokumentType: DokumentType?,
@Column(name = "created")
open var created: LocalDateTime = LocalDateTime.now(),
@Column(name = "modified")
Expand All @@ -44,31 +30,8 @@ open class DokumentUnderArbeid(
open var markertFerdigBy: String? = null,
@Column(name = "ferdigstilt")
open var ferdigstilt: LocalDateTime? = null,
@Column(name = "dokument_enhet_id")
open var dokumentEnhetId: UUID? = null,
@ElementCollection
@CollectionTable(
schema = "klage",
name = "dokument_under_arbeid_brevmottaker_ident",
joinColumns = [JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)]
)
@Column(name="identifikator")
open var brevmottakerIdents: Set<String> = setOf(),
@Column(name = "parent_id")
open var parentId: UUID? = null,
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)
@Fetch(FetchMode.SELECT)
@BatchSize(size = 5)
open val journalposter: MutableSet<DokumentUnderArbeidJournalpostId> = mutableSetOf(),
@Embedded
@AttributeOverrides(
value = [
AttributeOverride(name = "journalpostId", column = Column(name = "journalfoert_dokument_journalpost_id")),
AttributeOverride(name = "dokumentInfoId", column = Column(name = "journalfoert_dokument_dokument_info_id")),
]
)
val journalfoertDokumentReference: JournalfoertDokumentReference?,
@Column(name = "creator_ident")
open var creatorIdent: String,
@Column(name = "creator_role")
Expand Down Expand Up @@ -126,13 +89,4 @@ open class DokumentUnderArbeid(
SMART,
JOURNALFOERT
}

fun getType(): DokumentUnderArbeidType {
return when {
smartEditorId != null -> DokumentUnderArbeidType.SMART
journalfoertDokumentReference != null -> DokumentUnderArbeidType.JOURNALFOERT
else -> DokumentUnderArbeidType.UPLOADED
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package no.nav.klage.dokument.domain.dokumenterunderarbeid

import jakarta.persistence.Column
import jakarta.persistence.DiscriminatorValue
import jakarta.persistence.Entity
import no.nav.klage.oppgave.domain.klage.BehandlingRole
import java.time.LocalDateTime
import java.util.*

@Entity
@DiscriminatorValue("journalfoertdokument")
class JournalfoertDokumentUnderArbeid (
@Column(name = "opprettet")
var opprettet: LocalDateTime,
@Column(name = "journalfoert_dokument_journalpost_id")
val journalpostId: String,
@Column(name = "journalfoert_dokument_dokument_info_id")
val dokumentInfoId: String,

//Common properties
id: UUID = UUID.randomUUID(),
mellomlagerId: String?,
name: String,
behandlingId: UUID,
created: LocalDateTime,
modified: LocalDateTime,
markertFerdig: LocalDateTime?,
markertFerdigBy: String?,
ferdigstilt: LocalDateTime?,
parentId: UUID?,
creatorIdent: String,
creatorRole: BehandlingRole,
) : DokumentUnderArbeid(
id = id,
mellomlagerId = mellomlagerId,
name = name,
behandlingId = behandlingId,
created = created,
modified = modified,
markertFerdig = markertFerdig,
markertFerdigBy = markertFerdigBy,
ferdigstilt = ferdigstilt,
parentId = parentId,
creatorIdent = creatorIdent,
creatorRole = creatorRole,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package no.nav.klage.dokument.domain.dokumenterunderarbeid

import jakarta.persistence.*
import no.nav.klage.kodeverk.DokumentType
import no.nav.klage.kodeverk.DokumentTypeConverter
import no.nav.klage.oppgave.domain.klage.BehandlingRole
import org.hibernate.annotations.BatchSize
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import java.time.LocalDateTime
import java.util.*


@Entity
@DiscriminatorValue("opplastetdokument")
class OpplastetDokumentUnderArbeid(
@Column(name = "size")
var size: Long?,
@Column(name = "dokument_type_id")
@Convert(converter = DokumentTypeConverter::class)
var dokumentType: DokumentType?,

@Column(name = "dokument_enhet_id")
var dokumentEnhetId: UUID? = null,
@ElementCollection
@CollectionTable(
schema = "klage",
name = "dokument_under_arbeid_brevmottaker_ident",
joinColumns = [JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)]
)
@Column(name="identifikator")
var brevmottakerIdents: Set<String> = setOf(),
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)
@Fetch(FetchMode.SELECT)
@BatchSize(size = 5)
val journalposter: MutableSet<DokumentUnderArbeidJournalpostId> = mutableSetOf(),

//Common properties
id: UUID = UUID.randomUUID(),
mellomlagerId: String?,
name: String,
behandlingId: UUID,
created: LocalDateTime,
modified: LocalDateTime,
markertFerdig: LocalDateTime?,
markertFerdigBy: String?,
ferdigstilt: LocalDateTime?,
parentId: UUID?,
creatorIdent: String,
creatorRole: BehandlingRole,
) : DokumentUnderArbeid(
id = id,
mellomlagerId = mellomlagerId,
name = name,
behandlingId = behandlingId,
created = created,
modified = modified,
markertFerdig = markertFerdig,
markertFerdigBy = markertFerdigBy,
ferdigstilt = ferdigstilt,
parentId = parentId,
creatorIdent = creatorIdent,
creatorRole = creatorRole,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package no.nav.klage.dokument.domain.dokumenterunderarbeid

import jakarta.persistence.*
import no.nav.klage.kodeverk.DokumentType
import no.nav.klage.kodeverk.DokumentTypeConverter
import no.nav.klage.oppgave.domain.klage.BehandlingRole
import org.hibernate.annotations.BatchSize
import org.hibernate.annotations.Fetch
import org.hibernate.annotations.FetchMode
import java.time.LocalDateTime
import java.util.*


@Entity
@DiscriminatorValue("smartdokument")
class SmartdokumentUnderArbeid(
@Column(name = "size")
var size: Long?,
@Column(name = "smarteditor_id")
var smartEditorId: UUID?,
@Column(name = "smarteditor_template_id")
var smartEditorTemplateId: String?,
@Column(name = "dokument_type_id")
@Convert(converter = DokumentTypeConverter::class)
var dokumentType: DokumentType?,
@Column(name = "dokument_enhet_id")
var dokumentEnhetId: UUID? = null,
@ElementCollection
@CollectionTable(
schema = "klage",
name = "dokument_under_arbeid_brevmottaker_ident",
joinColumns = [JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)]
)
@Column(name="identifikator")
var brevmottakerIdents: Set<String> = setOf(),
@OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, fetch = FetchType.EAGER)
@JoinColumn(name = "dokument_under_arbeid_id", referencedColumnName = "id", nullable = false)
@Fetch(FetchMode.SELECT)
@BatchSize(size = 5)
val journalposter: MutableSet<DokumentUnderArbeidJournalpostId> = mutableSetOf(),

//Common properties
id: UUID = UUID.randomUUID(),
mellomlagerId: String?,
name: String,
behandlingId: UUID,
created: LocalDateTime,
modified: LocalDateTime,
markertFerdig: LocalDateTime?,
markertFerdigBy: String?,
ferdigstilt: LocalDateTime?,
parentId: UUID?,
creatorIdent: String,
creatorRole: BehandlingRole,
) : DokumentUnderArbeid(
id = id,
mellomlagerId = mellomlagerId,
name = name,
behandlingId = behandlingId,
created = created,
modified = modified,
markertFerdig = markertFerdig,
markertFerdigBy = markertFerdigBy,
ferdigstilt = ferdigstilt,
parentId = parentId,
creatorIdent = creatorIdent,
creatorRole = creatorRole,
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ class KabalDocumentMapper(
val innholdsfortegnelseDocument = if (vedlegg.size > 1) {
DokumentEnhetWithDokumentreferanserInput.DokumentInput.Dokument(
mellomlagerId = innholdsfortegnelse?.mellomlagerId!!,
opplastet = innholdsfortegnelse.modified,
size = 0,
name = "Innholdsfortegnelse"
)
} else null
Expand Down Expand Up @@ -133,8 +131,6 @@ class KabalDocumentMapper(
private fun mapDokumentUnderArbeidToDokumentReferanse(dokument: DokumentUnderArbeid): DokumentEnhetWithDokumentreferanserInput.DokumentInput.Dokument {
return DokumentEnhetWithDokumentreferanserInput.DokumentInput.Dokument(
mellomlagerId = dokument.mellomlagerId!!,
opplastet = dokument.opplastet!!,
size = dokument.size!!,
name = dokument.name,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package no.nav.klage.oppgave.clients.kabaldocument.model.request

import java.time.LocalDateTime

data class DokumentEnhetWithDokumentreferanserInput(
val brevMottakere: List<BrevmottakerInput>,
val journalfoeringData: JournalfoeringDataInput,
Expand All @@ -16,8 +14,6 @@ data class DokumentEnhetWithDokumentreferanserInput(
) {
data class Dokument(
val mellomlagerId: String,
val opplastet: LocalDateTime,
val size: Long,
val name: String,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE klage.dokument_under_arbeid
ADD COLUMN dokument_under_arbeid_type TEXT,
ADD COLUMN opprettet TIMESTAMP;


0 comments on commit 20ab637

Please sign in to comment.