Skip to content

Commit

Permalink
Erstattet dependency som ikke blir oppdatert med apache commons (#1735)
Browse files Browse the repository at this point in the history
  • Loading branch information
albrektsson authored Nov 2, 2023
1 parent 860941c commit f8b8681
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ val k9SakVersion = "4.1.2"
val k9KlageVersion = "0.4.0"
val fuelVersion = "2.3.1"
val jacksonVersion = "2.15.3"
val commonsTextVersion = "1.11.0"

val dusseldorfKtorVersion = "4.1.0"
val ktorVersion = "2.3.5"
Expand Down Expand Up @@ -74,13 +75,14 @@ dependencies {

// Div
implementation(enforcedPlatform( "com.fasterxml.jackson:jackson-bom:$jacksonVersion"))
implementation("info.debatty:java-string-similarity:2.0.0")
implementation("org.apache.commons:commons-text:$commonsTextVersion")
implementation("com.papertrailapp:logback-syslog4j:1.0.0")
implementation("com.github.kittinunf.fuel:fuel:$fuelVersion")
implementation("com.github.kittinunf.fuel:fuel-coroutines:$fuelVersion"){
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
}


// DI
implementation("io.insert-koin:koin-core:$koinVersion")
implementation("io.insert-koin:koin-ktor:$koinVersion")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.k9.los.tjenester.saksbehandler.oppgave

import info.debatty.java.stringsimilarity.Levenshtein
import kotlinx.coroutines.runBlocking
import no.nav.k9.kodeverk.behandling.aksjonspunkt.AksjonspunktDefinisjon
import no.nav.k9.los.Configuration
Expand All @@ -25,6 +24,7 @@ import no.nav.k9.los.tjenester.saksbehandler.merknad.Merknad
import no.nav.k9.los.tjenester.saksbehandler.nokkeltall.NyeOgFerdigstilteOppgaverDto
import no.nav.k9.los.utils.Cache
import no.nav.k9.los.utils.CacheObject
import org.apache.commons.text.similarity.LevenshteinDistance
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.time.LocalDateTime
Expand Down Expand Up @@ -961,7 +961,10 @@ class OppgaveTjeneste constructor(

suspend fun sokSaksbehandler(søkestreng: String): Saksbehandler {
val alleSaksbehandlere = saksbehandlerRepository.hentAlleSaksbehandlere()
val levenshtein = Levenshtein()

fun levenshtein(lhs: CharSequence, rhs: CharSequence): Double {
return LevenshteinDistance().apply(lhs, rhs).toDouble()
}

var d = Double.MAX_VALUE
var i = -1
Expand All @@ -976,23 +979,23 @@ class OppgaveTjeneste constructor(
break
}

var distance = levenshtein.distance(
var distance = levenshtein(
søkestreng.lowercase(Locale.getDefault()),
saksbehandler.brukerIdent!!.lowercase(Locale.getDefault())
)
if (distance < d) {
d = distance
i = index
}
distance = levenshtein.distance(
distance = levenshtein(
søkestreng.lowercase(Locale.getDefault()),
saksbehandler.navn?.lowercase(Locale.getDefault()) ?: ""
)
if (distance < d) {
d = distance
i = index
}
distance = levenshtein.distance(
distance = levenshtein(
søkestreng.lowercase(Locale.getDefault()),
saksbehandler.epost.lowercase(Locale.getDefault())
)
Expand Down

0 comments on commit f8b8681

Please sign in to comment.