-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Oppdater dependabot.yml * Logo!! * Enabler køer * Enabler køer * Rydder i yml filer
- Loading branch information
Showing
16 changed files
with
415 additions
and
34 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
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
66 changes: 66 additions & 0 deletions
66
src/main/kotlin/no/nav/k9/aksjonspunktbehandling/AksjonspunktPunsjStream.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,66 @@ | ||
package no.nav.k9.aksjonspunktbehandling | ||
|
||
import io.ktor.util.* | ||
import no.nav.helse.kafka.ManagedKafkaStreams | ||
import no.nav.helse.kafka.ManagedStreamHealthy | ||
import no.nav.helse.kafka.ManagedStreamReady | ||
import no.nav.k9.Configuration | ||
import no.nav.k9.integrasjon.kafka.KafkaConfig | ||
import org.apache.kafka.streams.StreamsBuilder | ||
import org.apache.kafka.streams.Topology | ||
import org.apache.kafka.streams.kstream.Consumed | ||
import org.slf4j.LoggerFactory | ||
|
||
internal class AksjonspunktPunsjStream @KtorExperimentalAPI constructor( | ||
kafkaConfig: KafkaConfig, | ||
configuration: Configuration, | ||
K9punsjEventHandler: K9punsjEventHandler | ||
) { | ||
|
||
@KtorExperimentalAPI | ||
private val stream = ManagedKafkaStreams( | ||
name = NAME, | ||
properties = kafkaConfig.stream(NAME), | ||
topology = topology( | ||
configuration = configuration, | ||
K9punsjEventHandler = K9punsjEventHandler | ||
), | ||
unreadyAfterStreamStoppedIn = kafkaConfig.unreadyAfterStreamStoppedIn | ||
) | ||
|
||
@KtorExperimentalAPI | ||
internal val ready = ManagedStreamReady(stream) | ||
@KtorExperimentalAPI | ||
internal val healthy = ManagedStreamHealthy(stream) | ||
|
||
private companion object { | ||
private const val NAME = "AksjonspunktLagetPunsjV1" | ||
private val log = LoggerFactory.getLogger("no.nav.$NAME.topology") | ||
|
||
@KtorExperimentalAPI | ||
private fun topology( | ||
configuration: Configuration, | ||
K9punsjEventHandler: K9punsjEventHandler | ||
): Topology { | ||
val builder = StreamsBuilder() | ||
val fromTopic = Topic( | ||
name = configuration.getAksjonspunkthendelsePunsjTopic(), | ||
serDes = AksjonspunktPunsjLaget() | ||
) | ||
builder | ||
.stream( | ||
fromTopic.name, | ||
Consumed.with(fromTopic.keySerde, fromTopic.valueSerde) | ||
) | ||
.foreach { _, entry -> | ||
if (entry != null) { | ||
K9punsjEventHandler.prosesser(entry) | ||
} | ||
} | ||
return builder.build() | ||
} | ||
} | ||
|
||
@KtorExperimentalAPI | ||
internal fun stop() = stream.stop(becauseOfError = false) | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/no/nav/k9/aksjonspunktbehandling/K9punsjEventHandler.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,34 @@ | ||
package no.nav.k9.aksjonspunktbehandling | ||
|
||
import io.ktor.util.* | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlinx.coroutines.channels.sendBlocking | ||
import no.nav.k9.Configuration | ||
import no.nav.k9.domene.lager.oppgave.Oppgave | ||
import no.nav.k9.domene.repository.* | ||
import no.nav.k9.integrasjon.datavarehus.StatistikkProducer | ||
import no.nav.k9.integrasjon.kafka.dto.PunsjEventDto | ||
import no.nav.k9.integrasjon.sakogbehandling.SakOgBehandlingProducer | ||
import org.slf4j.LoggerFactory | ||
|
||
|
||
class K9punsjEventHandler @KtorExperimentalAPI constructor( | ||
val oppgaveRepository: OppgaveRepository, | ||
val punsjEventK9Repository: PunsjEventK9Repository, | ||
val oppgaverSomSkalInnPåKøer: Channel<Oppgave>, | ||
val statistikkRepository: StatistikkRepository, | ||
val saksbehhandlerRepository: SaksbehandlerRepository | ||
) { | ||
private val log = LoggerFactory.getLogger(K9punsjEventHandler::class.java) | ||
|
||
@KtorExperimentalAPI | ||
fun prosesser( | ||
event: PunsjEventDto | ||
) { | ||
val modell = punsjEventK9Repository.lagre(event = event) | ||
val oppgave = modell.oppgave() | ||
oppgaveRepository.lagre(oppgave.eksternId){oppgave} | ||
oppgaverSomSkalInnPåKøer.sendBlocking(oppgave) | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package no.nav.k9.domene.modell | ||
|
||
import no.nav.k9.domene.lager.oppgave.Oppgave | ||
import no.nav.k9.domene.repository.ReservasjonRepository | ||
import no.nav.k9.domene.repository.SaksbehandlerRepository | ||
import no.nav.k9.integrasjon.kafka.dto.PunsjEventDto | ||
import no.nav.k9.statistikk.kontrakter.Behandling | ||
import no.nav.k9.statistikk.kontrakter.Sak | ||
|
||
class K9punsjModell( | ||
val eventer: List<PunsjEventDto> | ||
) : IModell { | ||
|
||
override fun starterSak(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun erTom(): Boolean { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dvhSak(): Sak { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun dvhBehandling( | ||
saksbehandlerRepository: SaksbehandlerRepository, | ||
reservasjonRepository: ReservasjonRepository | ||
): Behandling { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun sisteSaksNummer(): String { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
fun oppgave(): Oppgave { | ||
|
||
val sisteEvent = eventer.last() | ||
val førsteEvent = eventer.first() | ||
return Oppgave( | ||
behandlingId = null, | ||
fagsakSaksnummer = "", | ||
aktorId = "", | ||
behandlendeEnhet = "", | ||
behandlingsfrist =førsteEvent.eventTid.toLocalDate().plusDays(21).atStartOfDay(), | ||
behandlingOpprettet =førsteEvent.eventTid, | ||
forsteStonadsdag =førsteEvent.eventTid.toLocalDate(), | ||
behandlingStatus =BehandlingStatus.OPPRETTET, | ||
behandlingType =BehandlingType.PUNSJ, | ||
fagsakYtelseType =FagsakYtelseType.PPN, | ||
eventTid =sisteEvent.eventTid, | ||
aktiv = false, | ||
system = FagsakYtelseType.PUNSJ.kode, | ||
oppgaveAvsluttet = null, | ||
utfortFraAdmin = false, | ||
eksternId =sisteEvent.eksternId, | ||
oppgaveEgenskap = listOf(), | ||
aksjonspunkter = Aksjonspunkter(liste = mapOf()), | ||
tilBeslutter = false, | ||
utbetalingTilBruker = false, | ||
selvstendigFrilans = false, | ||
kombinert = false, | ||
søktGradering = false, | ||
registrerPapir = false, | ||
årskvantum = false, | ||
avklarMedlemskap = false, | ||
kode6 = false, | ||
skjermet = false, | ||
utenlands = false, | ||
vurderopptjeningsvilkåret = false, | ||
ansvarligSaksbehandlerForTotrinn = null, | ||
ansvarligSaksbehandlerIdent = null | ||
) | ||
} | ||
} |
Oops, something went wrong.