Skip to content

Commit

Permalink
Merge branch 'OK-415' into MERGE__OY-4799__OY-4780__OY-4797__OK-415
Browse files Browse the repository at this point in the history
  • Loading branch information
msiukola committed May 2, 2024
2 parents dc8b31c + 3f227c5 commit a4d405c
Show file tree
Hide file tree
Showing 29 changed files with 1,461 additions and 613 deletions.
66 changes: 37 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
<scalatra.version>2.6.3</scalatra.version>
<slick.version>3.3.0</slick.version>
<json4s.version>3.4.2</json4s.version>
<netty.version>4.1.35.Final</netty.version>
<netty.version>4.1.94.Final</netty.version>
<jetty.version>9.4.43.v20210629</jetty.version>
<dokumenttipalvelu.version>6.12-SNAPSHOT</dokumenttipalvelu.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -152,32 +153,7 @@
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<artifactId>netty-all</artifactId>
<version>${netty.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -216,10 +192,15 @@
<artifactId>HikariCP</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.asynchttpclient</groupId>
<artifactId>async-http-client</artifactId>
<version>2.8.1</version>
<version>2.12.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand All @@ -229,11 +210,38 @@
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fi.vm.sade.dokumenttipalvelu</groupId>
<artifactId>dokumenttipalvelu</artifactId>
<version>${dokumenttipalvelu.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>fi.vm.sade.dokumenttipalvelu</groupId>
<artifactId>dokumenttipalvelu</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>com.github.blemale</groupId>
<artifactId>scaffeine_2.12</artifactId>
Expand Down Expand Up @@ -686,7 +694,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
<version>4.5.13</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ suoritusrekisteri.koski.update.cronJob={{ suoritusrekisteri_koski_update_cronjob
suoritusrekisteri.koski.update.kkHaut={{ suoritusrekisteri_koski_update_kkHaut | default('false') }}
suoritusrekisteri.koski.update.toisenAsteenHaut={{ suoritusrekisteri_koski_update_toisenAsteenHaut | default('false') }}
suoritusrekisteri.koski.update.jatkuvatHaut={{ suoritusrekisteri_koski_update_jatkuvatHaut | default('false') }}
suoritusrekisteri.modifiedhakemukset.backtrack.days={{ suoritusrekisteri_modifiedhakemukset_backtrack_days | default('2')}}
suoritusrekisteri.oppijanumerorekisteri-service.max-connections={{ suoritusrekisteri_oppijanumerorekisteriservice_max_connections | default('50')}}
suoritusrekisteri.oppijanumerorekisteri-service.max-connection-queue-ms={{ suoritusrekisteri_oppijanumerorekisteriservice_max_connection_queue_ms | default('60000')}}
suoritusrekisteri.oppijanumerorekisteri-service.max.oppijat.batch.size={{ suoritusrekisteri_oppijanumerorekisteriservice_max_oppijat_batch_size | default('5000')}}
Expand All @@ -139,9 +140,12 @@ suoritusrekisteri.pistesyotto-service.max-connections={{ suoritusrekisteri_piste
suoritusrekisteri.pistesyotto-service.max-connection-queue-ms={{ suoritusrekisteri_pistesyottoservice_max_connection_queue_ms | default('44444') }}
suoritusrekisteri.hakemusservice.max.oids.chunk.size = {{ suoritusrekisteri_hakemusservice_max_oids_chunk_size | default('150')}}
suoritusrekisteri.async.pools.size = {{ suoritusrekisteri_async_pools_size | default('8') }}
suoritusrekisteri.ovara.s3.region = {{ aws_region }}
suoritusrekisteri.ovara.s3.bucket = {{ ovara_siirtotiedosto_s3_bucket }}
suoritusrekisteri.ovara.s3.target-role-arn = {{ ovara_siirtotiedosto_s3_target_role_arn }}
suoritusrekisteri.ovara.pagesize = {{ suoritusrekisteri_ovara_pagesize | default('10000')}}
user.home.conf=${user.home}/oph-configuration
web.url.cas=https\://${host.cas}/cas

# YTL HTTP API
ytl.baseUrl={{suoritusrekisteri_ytl_http_host}}
ytl.http.download.directory={{suoritusrekisteri_ytl_http_download_directory}}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/suoritusrekisteri-oph.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kouta-internal.koulutus=/kouta-internal/koulutus/$1
kouta-internal.haku=/kouta-internal/haku/$1
haku-app.listfull=/haku-app/applications/listfull
ataru.applications=/lomake-editori/api/external/suoritusrekisteri
ataru.applications.henkilotiedot=/lomake-editori/api/external/suoritusrekisteri/henkilot
ataru.applications.toinenaste=/lomake-editori/api/external/suoritusrekisteri/haku/$1/toinenaste
haku-app.hakemus=/haku-app/virkailija/hakemus/$1/
ataru.hakemus=/lomake-editori/applications/search?term=$1
Expand Down
15 changes: 14 additions & 1 deletion src/main/scala/ScalatraBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import akka.actor.ActorSystem
import akka.event.{Logging, LoggingAdapter}
import fi.vm.sade.hakurekisteri.integration.OphUrlProperties
import fi.vm.sade.hakurekisteri.integration.henkilo.PersonOidsWithAliases
import fi.vm.sade.hakurekisteri.ovara.{
OvaraDbRepositoryImpl,
OvaraResource,
OvaraService,
SiirtotiedostoClient
}
import fi.vm.sade.hakurekisteri.web.HakuJaValintarekisteriStack
import fi.vm.sade.hakurekisteri.web.arvosana.{ArvosanaResource, EmptyLisatiedotResource}
import fi.vm.sade.hakurekisteri.web.ensikertalainen.EnsikertalainenResource
Expand Down Expand Up @@ -150,6 +156,13 @@ class ScalatraBootstrap extends LifeCycle {
("/siirtotiedostojono", "siirtotiedostojono") -> new SiirtotiedostojonoResource(
koosteet.siirtotiedostojono
),
("/ovara", "ovara") -> new OvaraResource(
new OvaraService(
registers.ovaraDbRepository,
new SiirtotiedostoClient(config.siirtotiedostoClientConfig),
config.siirtotiedostoPageSize
)
),
("/rest/v1/hakijat", "rest/v1/hakijat") -> new HakijaResource(koosteet.hakijat),
("/rest/v2/hakijat", "rest/v2/hakijat") -> new HakijaResourceV2(koosteet.hakijat),
("/rest/v3/hakijat", "rest/v3/hakijat") -> new HakijaResourceV3(koosteet.hakijat),
Expand Down Expand Up @@ -224,7 +237,7 @@ class ScalatraBootstrap extends LifeCycle {
("/virta", "virta") -> new VirtaResource(
koosteet.virtaQueue
), // Continuous Virta queue processing
("/ytl", "ytl") -> new YtlResource(integrations.ytlIntegration),
("/ytl", "ytl") -> new YtlResource(integrations.ytlFetchActor),
("/vastaanottotiedot", "vastaanottotiedot") -> new VastaanottotiedotProxyServlet(
integrations.proxies.vastaanottotiedot,
system,
Expand Down
10 changes: 10 additions & 0 deletions src/main/scala/fi/vm/sade/hakurekisteri/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import akka.util.Timeout
import fi.vm.sade.hakurekisteri.integration.hakemus.HakemusConfig
import fi.vm.sade.hakurekisteri.integration.virta.VirtaConfig
import fi.vm.sade.hakurekisteri.integration.{OphUrlProperties, ServiceConfig}
import fi.vm.sade.hakurekisteri.ovara.SiirtotiedostoClientConfig
import fi.vm.sade.hakurekisteri.web.rest.support.Security
import org.slf4j.LoggerFactory
import support.{Integrations, SureDbLoggingConfig}
Expand Down Expand Up @@ -278,6 +279,15 @@ abstract class Config {
val integrations = new IntegrationConfig(hostQa, properties)
val email: EmailConfig = new EmailConfig(properties)

val siirtotiedostoClientConfig = SiirtotiedostoClientConfig(
properties.getOrElse("suoritusrekisteri.ovara.s3.region", "REGION MISSING"),
properties.getOrElse("suoritusrekisteri.ovara.s3.bucket", "BUCKET MISSING"),
properties.getOrElse("suoritusrekisteri.ovara.s3.target-role-arn", "TARGET ROLE MISSING")
)

val siirtotiedostoPageSize: Int =
properties.getOrElse("suoritusrekisteri.ovara.pagesize", "10000").toInt

OphUrlProperties.defaults.put("baseUrl", properties.getOrElse("host.ilb", "https://" + hostQa))

val tiedonsiirtoStorageDir = properties.getOrElse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SureStandaloneJetty(config: Config = Config.globalConfig) {

private val port: Int = OphUrlProperties.require("suoritusrekisteri.port").toInt

val threadPool: ThreadPool = new QueuedThreadPool(40, 10, 60000)
val threadPool: ThreadPool = new QueuedThreadPool(200, 10, 60000)
val server = new Server(threadPool)

server.setHandler(suoritusrekisteriApp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,14 @@ trait IHakemusService {
def addTrigger(trigger: Trigger): Unit
def reprocessHaunHakemukset(hakuOid: String): Unit
def hetuAndPersonOidForHaku(hakuOid: String): Future[Seq[HetuPersonOid]]
def hetuAndPersonOidForHakuLite(hakuOid: String): Future[Seq[HetuPersonOid]]
def hetuAndPersonOidForPersonOid(personOid: String): Future[Seq[HakemusHakuHetuPersonOid]]
}

case class AtaruHenkiloSearchParams(
hakukohdeOids: Option[List[String]],
hakuOid: Option[String]
)
case class AtaruSearchParams(
hakijaOids: Option[List[String]],
hakukohdeOids: Option[List[String]],
Expand Down Expand Up @@ -497,6 +502,43 @@ class HakemusService(
)
}

private def ataruhakemustenHenkilot(
params: AtaruHenkiloSearchParams
): Future[List[AtaruHakemuksenHenkilotiedot]] = {
val p = params.hakuOid.fold[Map[String, Any]](Map.empty)(oid => Map("hakuOid" -> oid)) ++
params.hakukohdeOids.fold[Map[String, Any]](Map.empty)(hakukohdeOids =>
Map("hakukohdeOids" -> hakukohdeOids)
)

def page(
offset: Option[String]
): Future[(List[AtaruHakemuksenHenkilotiedot], Option[String])] = {
logger.info(s"Haetaan sivu henkilöitä, $params, offset $offset")
ataruHakemusClient
.postObjectWithCodes[Map[String, Any], AtaruResponseHenkilot](
uriKey = "ataru.applications.henkilotiedot",
acceptedResponseCodes = List(200),
maxRetries = 2,
resource = offset.fold(p)(o => p + ("offset" -> o)),
basicAuth = false
)
.map(result => {
logger.info(s"Saatiin ${result.applications.size} henkilötietoa parametreilla $params")
(result.applications, result.offset)
})
}

def allPages(
offset: Option[String],
acc: Future[List[AtaruHakemuksenHenkilotiedot]]
): Future[List[AtaruHakemuksenHenkilotiedot]] = page(offset).flatMap {
case (applicationPersons, None) => acc.map(_ ++ applicationPersons)
case (applicationPersons, newOffset) => allPages(newOffset, acc.map(_ ++ applicationPersons))
}

allPages(None, Future.successful(List.empty))
}

private def ataruhakemukset(
params: AtaruSearchParams,
skipResolvingTarjoaja: Boolean = false
Expand Down Expand Up @@ -990,6 +1032,25 @@ class HakemusService(
} yield hakuappPersonOids ++ ataruHakemukset.flatMap(_.personOid)
}

def hetuAndPersonOidForHakuLite(hakuOid: String): Future[Seq[HetuPersonOid]] = {
ataruhakemustenHenkilot(
AtaruHenkiloSearchParams(
hakukohdeOids = None,
hakuOid = Some(hakuOid)
)
).map(result => {
logger.info(s"Saatiin atarusta henkilötiedot ${result.size} hakemukselta")
val hetuJaPersonOidTiedossa: Seq[HetuPersonOid] =
result.collect({ case AtaruHakemuksenHenkilotiedot(_, Some(personOid), Some(ssn)) =>
HetuPersonOid(ssn, personOid)
})
logger.info(
s"Hetu ja personOid tiedossa ${hetuJaPersonOidTiedossa.size} hakemukselle ${result.size} hakemuksesta"
)
hetuJaPersonOidTiedossa
})
}

def hetuAndPersonOidForHaku(hakuOid: String): Future[Seq[HetuPersonOid]] = {
for {
ataruHakemukset <- ataruhakemukset(
Expand Down Expand Up @@ -1187,10 +1248,14 @@ class HakemusServiceMock extends IHakemusService {

override def hetuAndPersonOidForHaku(hakuOid: String) = Future.successful(Seq[HetuPersonOid]())

override def hetuAndPersonOidForHakuLite(hakuOid: String): Future[Seq[HetuPersonOid]] =
Future.successful(Seq[HetuPersonOid]())

override def hetuAndPersonOidForPersonOid(
personOid: String
): Future[Seq[HakemusHakuHetuPersonOid]] = Future.successful(Seq[HakemusHakuHetuPersonOid]())

override def springPersonOidsForJatkuvaHaku(hakuOid: String): Future[Set[String]] =
Future.successful(Set.empty)

}
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,11 @@ case class FullHakemus(
answers.flatMap(_.lisatiedot).flatMap(_.get("lupaMarkkinointi")).getOrElse("false").toBoolean
}

case class AtaruResponseHenkilot(
applications: List[AtaruHakemuksenHenkilotiedot],
offset: Option[String]
)

case class AtaruResponse(applications: List[AtaruHakemusDto], offset: Option[String])
case class AtaruResponseToinenAste(
applications: List[AtaruHakemusToinenAsteDto],
Expand Down Expand Up @@ -1647,6 +1652,8 @@ case class AtaruHakemusToinenAsteDto(
urheilijanLisakysymyksetAmmatillinen: Option[UrheilijanLisakysymykset]
)

case class AtaruHakemuksenHenkilotiedot(oid: String, personOid: Option[String], ssn: Option[String])

@SerialVersionUID(1)
case class AtaruHakemus(
oid: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fi.vm.sade.hakurekisteri.integration.haku

import akka.actor.{Actor, ActorLogging, Cancellable}
import akka.actor.{Actor, ActorLogging, ActorRef, Cancellable}
import akka.pattern.pipe
import fi.vm.sade.hakurekisteri.Config
import fi.vm.sade.hakurekisteri.dates.InFuture
Expand All @@ -12,7 +12,7 @@ import fi.vm.sade.hakurekisteri.integration.parametrit.{
ParametritActorRef
}
import fi.vm.sade.hakurekisteri.integration.tarjonta.GetHautQueryFailedException
import fi.vm.sade.hakurekisteri.integration.ytl.YtlIntegration
import fi.vm.sade.hakurekisteri.integration.ytl.{ActiveKkHakuOids, YtlFetchActorRef}
import org.joda.time.ReadableInstant

import scala.concurrent.duration._
Expand All @@ -24,7 +24,7 @@ class HakuActor(
hakuAggregator: HakuAggregatorActorRef,
koskiService: IKoskiService,
parametrit: ParametritActorRef,
ytlIntegration: YtlIntegration,
ytlIntegrationActor: YtlFetchActorRef,
config: Config
) extends Actor
with ActorLogging {
Expand Down Expand Up @@ -90,7 +90,7 @@ class HakuActor(
.map(_.oid)
.toSet
log.info(s"Asetetaan aktiiviset YTL-haut: ${ytlHakuOidsWithNames.toString()} ")
ytlIntegration.setAktiivisetKKHaut(ytlHakuOids)
ytlIntegrationActor.actor ! ActiveKkHakuOids(ytlHakuOids)
koskiService.setAktiiviset2AsteYhteisHaut(active2AsteYhteisHakuOids)
koskiService.setAktiivisetKKYhteisHaut(activeKKYhteisHakuOids)
koskiService.setAktiivisetToisenAsteenJatkuvatHaut(activeToisenAsteenJatkuvaKoutaHakuOids)
Expand Down
Loading

0 comments on commit a4d405c

Please sign in to comment.