-
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.
Cast verdi til riktig db-datatype, og konverter param til riktig Kotl…
…in-klasse (#2733)
- Loading branch information
Showing
30 changed files
with
699 additions
and
306 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
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
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/no/nav/k9/los/nyoppgavestyring/query/mapping/OppgavefilterDatatypeMapper.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,42 @@ | ||
package no.nav.k9.los.nyoppgavestyring.query.mapping | ||
|
||
import no.nav.k9.los.nyoppgavestyring.mottak.feltdefinisjon.Datatype | ||
import no.nav.k9.los.nyoppgavestyring.query.db.OmrådeOgKode | ||
import no.nav.k9.los.nyoppgavestyring.query.db.OppgavefeltMedMer | ||
import no.nav.k9.los.nyoppgavestyring.query.dto.query.CombineOppgavefilter | ||
import no.nav.k9.los.nyoppgavestyring.query.dto.query.FeltverdiOppgavefilter | ||
import no.nav.k9.los.nyoppgavestyring.query.dto.query.Oppgavefilter | ||
import org.postgresql.util.PGInterval | ||
import java.math.BigInteger | ||
import java.time.LocalDateTime | ||
import kotlin.time.Duration | ||
|
||
object OppgavefilterDatatypeMapper { | ||
fun map(felter: Map<OmrådeOgKode, OppgavefeltMedMer>, oppgavefiltere: List<Oppgavefilter>): List<Oppgavefilter> { | ||
return oppgavefiltere.map { filter -> | ||
when (filter) { | ||
is FeltverdiOppgavefilter -> mapFeltverdiFilter(felter, filter) | ||
is CombineOppgavefilter -> CombineOppgavefilter( | ||
combineOperator = filter.combineOperator, map(felter, filter.filtere) | ||
) | ||
} | ||
} | ||
} | ||
|
||
private fun mapFeltverdiFilter( | ||
felter: Map<OmrådeOgKode, OppgavefeltMedMer>, | ||
filter: FeltverdiOppgavefilter | ||
): FeltverdiOppgavefilter { | ||
val datatype = felter[OmrådeOgKode(filter.område, filter.kode)]?.oppgavefelt?.tolkes_som | ||
?.let { Datatype.fraKode(it) } | ||
val verdi = filter.verdi[0] | ||
if (verdi == null || verdi !is String) return filter // er enten null eller har blitt konvertert tidligere | ||
return when (datatype) { | ||
Datatype.INTEGER -> filter.copy(verdi = listOf(verdi.toBigInteger())) | ||
Datatype.DURATION -> filter.copy(verdi = listOf(PGInterval(verdi))) | ||
Datatype.TIMESTAMP -> filter.copy(verdi = listOf(LocalDateTime.parse(verdi))) | ||
Datatype.BOOLEAN -> filter.copy(verdi = listOf(verdi.toBoolean())) | ||
else -> filter | ||
} | ||
} | ||
} |
96 changes: 0 additions & 96 deletions
96
src/main/kotlin/no/nav/k9/los/nyoppgavestyring/query/mapping/OppgavefilterDatoTypeUtvider.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.