-
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 d513aa7
Showing
16 changed files
with
414 additions
and
5 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
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
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 dialogmote: MoteDTO, | ||
val status: DialogmoteStatus, | ||
val opprettetAv: String, | ||
) | ||
|
||
data class MoteDTO( | ||
val id: Int, | ||
val tid: LocalDateTime, | ||
val sted: String, | ||
val opprettetAv: 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
71 changes: 71 additions & 0 deletions
71
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,71 @@ | ||
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.database.domain.PMoteStatusEndret | ||
import no.nav.syfo.dialogmote.database.domain.toDialogmoteStatusEndret | ||
import no.nav.syfo.dialogmote.domain.DialogmoteStatus | ||
import no.nav.syfo.dialogmote.domain.DialogmoteStatusEndret | ||
import no.nav.syfo.domain.PersonIdent | ||
import java.sql.ResultSet | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
class MoteStatusEndretRepository(private val database: DatabaseInterface) { | ||
|
||
fun getMoteStatusEndringer(personident: PersonIdent): List<Triple<DialogmoteStatusEndret, String, Pair<LocalDateTime, String>>> = | ||
database.connection.use { connection -> | ||
connection.prepareStatement(GET_MOTE_STATUS_ENDRINGER).use { ps -> | ||
ps.setString(1, personident.value) | ||
ps.executeQuery() | ||
.toList { | ||
Triple( | ||
first = toPMoteStatusEndret(), | ||
second = getString("mote_opprettet_av"), | ||
third = Pair( | ||
getTimestamp("tid").toLocalDateTime(), | ||
getString("sted") | ||
) | ||
) | ||
} | ||
.map { | ||
Triple( | ||
first = it.first.toDialogmoteStatusEndret(), | ||
second = it.second, | ||
third = it.third, | ||
) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val GET_MOTE_STATUS_ENDRINGER = | ||
""" | ||
SELECT | ||
mse.*, | ||
m.opprettet_av as mote_opprettet_av, | ||
ts.tid, | ||
ts.sted | ||
FROM mote_status_endret mse | ||
INNER JOIN mote m on mse.mote_id = m.id | ||
INNER JOIN tid_sted ts on m.id = ts.mote_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.