-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-1879: Create repository for motestatusendringer and move repositor…
…ies to same folder
- Loading branch information
1 parent
9e1ba67
commit 12b0427
Showing
16 changed files
with
389 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/no/nav/syfo/dialogmote/api/domain/DialogmoteStatusEndringDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package no.nav.syfo.dialogmote.api.domain | ||
|
||
import no.nav.syfo.dialogmote.domain.DialogmoteStatus | ||
import java.time.LocalDateTime | ||
|
||
// TODO: Nå får man en liste med alle endringer på en person, som igjen er knyttet til et møte. | ||
// Burde det vært en liste med møter, og så alle endringer knyttet til det møtet? | ||
|
||
data class DialogmoteStatusEndringDTO( | ||
val uuid: String, | ||
val createdAt: LocalDateTime, | ||
val dialogmoteId: Int, | ||
val dialogmoteOpprettetAv: String, | ||
val status: DialogmoteStatus, | ||
val statusEndringOpprettetAv: String, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...yfo/dialogmote/database/MoteRepository.kt → ...ote/database/repository/MoteRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/kotlin/no/nav/syfo/dialogmote/database/repository/MoteStatusEndretRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package no.nav.syfo.dialogmote.database.repository | ||
|
||
import no.nav.syfo.application.database.DatabaseInterface | ||
import no.nav.syfo.application.database.toList | ||
import no.nav.syfo.dialogmote.api.domain.DialogmoteStatusEndringDTO | ||
import no.nav.syfo.dialogmote.database.domain.PMoteStatusEndret | ||
import no.nav.syfo.dialogmote.domain.DialogmoteStatus | ||
import no.nav.syfo.domain.PersonIdent | ||
import java.sql.ResultSet | ||
import java.util.* | ||
|
||
class MoteStatusEndretRepository(private val database: DatabaseInterface) { | ||
|
||
fun getMoteStatusEndringer(personident: PersonIdent): List<DialogmoteStatusEndringDTO> = | ||
database.connection.use { connection -> | ||
connection.prepareStatement(GET_MOTE_STATUS_ENDRINGER).use { ps -> | ||
ps.setString(1, personident.value) | ||
ps.executeQuery() | ||
.toList { | ||
Pair( | ||
first = toPMoteStatusEndret(), | ||
second = getString("mote_opprettet_av"), | ||
) | ||
} | ||
.map { | ||
DialogmoteStatusEndringDTO( | ||
uuid = it.first.uuid.toString(), | ||
createdAt = it.first.createdAt, | ||
dialogmoteId = it.first.moteId, | ||
dialogmoteOpprettetAv = it.second, | ||
status = it.first.status, | ||
statusEndringOpprettetAv = it.first.opprettetAv, | ||
) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val GET_MOTE_STATUS_ENDRINGER = | ||
""" | ||
SELECT | ||
mse.*, | ||
m.opprettet_av as mote_opprettet_av | ||
FROM mote_status_endret mse | ||
INNER JOIN mote m on mse.mote_id = m.id | ||
INNER JOIN motedeltaker_arbeidstaker mda on m.id = mda.mote_id | ||
WHERE mda.personident = ? | ||
ORDER BY mse.created_at DESC | ||
""" | ||
} | ||
} | ||
|
||
internal fun ResultSet.toPMoteStatusEndret(): PMoteStatusEndret = | ||
PMoteStatusEndret( | ||
id = getInt("id"), | ||
uuid = UUID.fromString(getString("uuid")), | ||
createdAt = getTimestamp("created_at").toLocalDateTime(), | ||
updatedAt = getTimestamp("updated_at").toLocalDateTime(), | ||
moteId = getInt("mote_id"), | ||
motedeltakerBehandler = getBoolean("motedeltaker_behandler"), | ||
status = DialogmoteStatus.valueOf(getString("status")), | ||
opprettetAv = getString("opprettet_av"), | ||
tilfelleStart = getTimestamp("tilfelle_start").toLocalDateTime().toLocalDate(), | ||
publishedAt = getTimestamp("published_at")?.toLocalDateTime(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.