Skip to content

Commit

Permalink
Flytt MeldekortGrunnlagDTO til libs
Browse files Browse the repository at this point in the history
  • Loading branch information
hestad committed Aug 15, 2024
1 parent 6dec13d commit d74435b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jobber/main/no/nav/tiltakspenger/libs/jobber/StoppableJob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun startStoppableJob(
sikkerLogg: KLogger,
mdcCallIdKey: String,
runJobCheck: List<RunJobCheck>,
enableDebuggingLogging: Boolean = true,
job: (CorrelationId) -> Unit,
): StoppableJob {
logger.info { "Starter skeduleringsjobb '$jobName'. Intervall: hvert ${intervall.toMinutes()}. minutt. Initial delay: ${initialDelay.toMinutes()} minutt(er)" }
Expand All @@ -44,7 +45,9 @@ fun startStoppableJob(
sikkerLogg = sikkerLogg,
mdcCallIdKey = mdcCallIdKey,
runJobCheck = runJobCheck,
enableDebuggingLogging = enableDebuggingLogging,
job = job,

) {
fixedRateTimer(
name = jobName,
Expand All @@ -71,6 +74,7 @@ fun startStoppableJob(
sikkerLogg: KLogger,
mdcCallIdKey: String,
runJobCheck: List<RunJobCheck>,
enableDebuggingLogging: Boolean = true,
job: (CorrelationId) -> Unit,
): StoppableJob {
logger.info { "Starter skeduleringsjobb '$jobName'. Intervall: hvert ${intervall.toMinutes()}. minutt. Starter kl. $startAt." }
Expand All @@ -81,6 +85,7 @@ fun startStoppableJob(
mdcCallIdKey = mdcCallIdKey,
runJobCheck = runJobCheck,
job = job,
enableDebuggingLogging = enableDebuggingLogging,
) {
fixedRateTimer(
name = jobName,
Expand All @@ -99,16 +104,17 @@ private fun startStoppableJob(
mdcCallIdKey: String,
runJobCheck: List<RunJobCheck>,
job: (CorrelationId) -> Unit,
enableDebuggingLogging: Boolean,
scheduleJob: (TimerTask.() -> Unit) -> Timer,
): StoppableJob {
return scheduleJob {
Either.catch {
if (runJobCheck.shouldRun()) {
log.debug("Kjører skeduleringsjobb '$jobName'.")
if (enableDebuggingLogging) { log.debug("Kjører skeduleringsjobb '$jobName'.") }
withCorrelationId(log, mdcCallIdKey) { job(it) }
log.debug("Fullførte skeduleringsjobb '$jobName'.")
if (enableDebuggingLogging) { log.debug("Fullførte skeduleringsjobb '$jobName'.") }
} else {
log.debug("Skeduleringsjobb '$jobName' kjører ikke pga. startKriterier i runJobCheck. Eksempelvis er vi ikke leader pod.")
if (enableDebuggingLogging) { log.debug("Skeduleringsjobb '$jobName' kjører ikke pga. startKriterier i runJobCheck. Eksempelvis er vi ikke leader pod.") }
}
}.onLeft {
log.error(
Expand Down
9 changes: 9 additions & 0 deletions meldekort/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies {
implementation(project(":common"))

}

configurations.all {
// exclude JUnit 4
exclude(group = "junit", module = "junit")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package no.nav.tiltakspenger.libs.meldekort

import java.time.LocalDate

/**
* Kontrakt mellom tiltakspenger-vedtak og tiltakspenger-meldekort-api
*/
data class MeldekortGrunnlagDTO(
val vedtakId: String,
val sakId: String,
val behandlingId: String,
val status: StatusDTO,
val vurderingsperiode: PeriodeDTO,
val tiltak: List<TiltakDTO>,
val personopplysninger: PersonopplysningerDTO,
val utfallsperioder: List<UtfallsperiodeDTO>,
)

data class UtfallsperiodeDTO(
val fom: String,
val tom: String,
val utfall: UtfallForPeriodeDTO,
)

enum class UtfallForPeriodeDTO {
GIR_RETT_TILTAKSPENGER,
GIR_IKKE_RETT_TILTAKSPENGER,
}

data class PersonopplysningerDTO(
val fornavn: String,
val etternavn: String,
val ident: String,
)

enum class StatusDTO {
AKTIV,
IKKE_AKTIV,
}

data class TiltakDTO(
val periodeDTO: PeriodeDTO,
val typeKode: String,
val antDagerIUken: Int,
)

data class PeriodeDTO(
val fra: LocalDate,
val til: LocalDate,
)
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ include(
"test-common",
"persistering:persistering-infrastruktur",
"persistering:persistering-domene",
"meldekort",
)

0 comments on commit d74435b

Please sign in to comment.