Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/OY-4836' into MERGE__OY-415__OY-…
Browse files Browse the repository at this point in the history
…4836__OY-4825
  • Loading branch information
marjakari committed May 15, 2024
2 parents 0b5b2b7 + d435503 commit 0e99b2d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +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.modifiedhakemukset.backtrack.hours={{ suoritusrekisteri_modifiedhakemukset_backtrack_hours | 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ import fi.vm.sade.hakurekisteri.integration.kouta.{
KoutaInternalHakukohde
}
import fi.vm.sade.hakurekisteri.integration.organisaatio.{Organisaatio, OrganisaatioActorRef}
import fi.vm.sade.hakurekisteri.integration.{OphUrlProperties, ServiceConfig, VirkailijaRestClient}
import fi.vm.sade.hakurekisteri.integration.{
ExecutorUtil,
OphUrlProperties,
ServiceConfig,
VirkailijaRestClient
}
import fi.vm.sade.hakurekisteri.rest.support.{HakurekisteriJsonSupport, Query}
import fi.vm.sade.properties.OphProperties
import org.joda.time.{DateTimeZone, LocalDate}
Expand All @@ -42,8 +47,7 @@ import java.text.SimpleDateFormat
import java.util.Date
import java.util.concurrent.TimeUnit
import scala.compat.Platform
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}

Expand Down Expand Up @@ -192,6 +196,11 @@ class HakemusService(
)(implicit val system: ActorSystem)
extends IHakemusService {

implicit val ec: ExecutionContext = ExecutorUtil.createExecutor(
config.integrations.asyncOperationThreadPoolSize,
getClass.getSimpleName
)

case class SearchParams(
aoOids: Seq[String] = null,
asId: String = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package fi.vm.sade.hakurekisteri.integration.henkilo
import akka.actor.ActorSystem
import akka.event.Logging
import fi.vm.sade.hakurekisteri.Config
import fi.vm.sade.hakurekisteri.integration.VirkailijaRestClient
import fi.vm.sade.hakurekisteri.integration.{ExecutorUtil, VirkailijaRestClient}
import fi.vm.sade.hakurekisteri.integration.hakemus.HakemusHenkilotiedot
import fi.vm.sade.hakurekisteri.integration.mocks.HenkiloMock
import org.apache.commons.httpclient.HttpStatus
Expand All @@ -12,8 +12,7 @@ import org.json4s.{DefaultFormats, _}
import support.PersonAliasesProvider

import scala.collection.Iterator
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success}

/**
Expand All @@ -35,12 +34,7 @@ case class LinkedHenkiloOids(

trait IOppijaNumeroRekisteri {
def fetchLinkedHenkiloOidsMap(henkiloOids: Set[String]): Future[LinkedHenkiloOids]

def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases] = {
fetchLinkedHenkiloOidsMap(henkiloOids)
.map(_.oidToLinkedOids)
.map(PersonOidsWithAliases(henkiloOids, _))
}
def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases]

def getByHetu(hetu: String): Future[Henkilo]
def fetchHenkilotInBatches(henkiloOids: Set[String]): Future[Map[String, Henkilo]]
Expand All @@ -64,6 +58,11 @@ class OppijaNumeroRekisteri(client: VirkailijaRestClient, val system: ActorSyste
extends IOppijaNumeroRekisteri {
private val logger = Logging.getLogger(system, this)

implicit val ec: ExecutionContext = ExecutorUtil.createExecutor(
config.integrations.asyncOperationThreadPoolSize,
getClass.getSimpleName
)

def fetchInBatches(henkiloOids: Set[String], batchSize: Int) = {
val started = System.currentTimeMillis()
val batches = henkiloOids.grouped(batchSize).zipWithIndex.toList
Expand All @@ -86,6 +85,12 @@ class OppijaNumeroRekisteri(client: VirkailijaRestClient, val system: ActorSyste
}
}

override def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases] = {
fetchLinkedHenkiloOidsMap(henkiloOids)
.map(_.oidToLinkedOids)
.map(PersonOidsWithAliases(henkiloOids, _))
}

override def fetchLinkedHenkiloOidsMap(henkiloOids: Set[String]): Future[LinkedHenkiloOids] = {

if (henkiloOids.isEmpty) {
Expand Down Expand Up @@ -183,6 +188,17 @@ object MockOppijaNumeroRekisteri extends IOppijaNumeroRekisteri {
val henkiloOid = "1.2.246.562.24.58099330694"
val linkedTestPersonOids = Seq(henkiloOid, masterOid)

implicit val ec: ExecutionContext = ExecutorUtil.createExecutor(
1,
getClass.getSimpleName
)

override def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases] = {
fetchLinkedHenkiloOidsMap(henkiloOids)
.map(_.oidToLinkedOids)
.map(PersonOidsWithAliases(henkiloOids, _))
}

def fetchLinkedHenkiloOidsMap(henkiloOids: Set[String]): Future[LinkedHenkiloOids] = {
Future.successful({
val oidToLinkedOids = henkiloOids.map { queriedOid =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fi.vm.sade.hakurekisteri.integration.ytl

import akka.actor.{Actor, ActorLogging, ActorRef}
import akka.actor.{Actor, ActorLogging, ActorRef, ActorSystem}
import akka.pattern.pipe
import fi.vm.sade.hakurekisteri.Config
import fi.vm.sade.hakurekisteri.integration.ExecutorUtil
Expand Down Expand Up @@ -52,7 +52,7 @@ class YtlFetchActor(
val minIntervalBetween = 1000 * 60 * 60 * 22 //At least 22 hours between nightly syncs

implicit val ec: ExecutionContext = ExecutorUtil.createExecutor(
config.integrations.asyncOperationThreadPoolSize,
20,
getClass.getSimpleName
)

Expand Down Expand Up @@ -99,7 +99,7 @@ class YtlFetchActor(
log.error(t, s"($tunniste) Manual sync for haku ${s.hakuOid} failed...")
}
log.info(s"Ytl-sync käynnistetty haulle ${s.hakuOid} tunnisteella $tunniste")
resultF pipeTo sender
sender ! tunniste
case s: YtlSyncSingle =>
if (s.needsToBeActiveKkHakuOid.forall(oid => activeKKHakuOids.get().contains(oid))) {
val tunniste = s.tunniste
Expand All @@ -110,7 +110,7 @@ class YtlFetchActor(
case Failure(t) =>
log.error(t, s"($tunniste) Manual sync for person ${s.personOid} failed...")
}
log.info(s"Ytl-sync käynnistetty haulle ${s.personOid} tunnisteella $tunniste")
log.info(s"Ytl-sync käynnistetty oidille ${s.personOid} tunnisteella $tunniste")
resultF pipeTo sender
} else {
val infoStr = s"Not ytl-syncing $s because the haku is not an active kk-haku"
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/support/Integrations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@ class BaseIntegrations(rekisterit: Registers, system: ActorSystem, config: Confi
hakemusService.addTrigger(arvosanaTrigger)
hakemusService.addTrigger(ytlTrigger)

val daysToBacktrack: Int =
OphUrlProperties.getProperty("suoritusrekisteri.modifiedhakemukset.backtrack.days").toInt
val hoursToBacktrack: Int =
OphUrlProperties.getProperty("suoritusrekisteri.modifiedhakemukset.backtrack.hours").toInt
implicit val scheduler = system.scheduler
hakemusService.processModifiedHakemukset(modifiedAfter =
new Date(Platform.currentTime - TimeUnit.DAYS.toMillis(daysToBacktrack))
new Date(Platform.currentTime - TimeUnit.HOURS.toMillis(hoursToBacktrack))
)

val quartzScheduler = StdSchedulerFactory.getDefaultScheduler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import fi.vm.sade.hakurekisteri.integration.henkilo.{
Henkilo,
IOppijaNumeroRekisteri,
LinkedHenkiloOids,
MockPersonAliasesProvider
MockPersonAliasesProvider,
PersonOidsWithAliases
}
import fi.vm.sade.hakurekisteri.integration.tarjonta._
import fi.vm.sade.hakurekisteri.integration.valintarekisteri.{
Expand Down Expand Up @@ -91,6 +92,13 @@ class OppijaResourceSpec
)
)
}

override def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases] = {
fetchLinkedHenkiloOidsMap(henkiloOids)
.map(_.oidToLinkedOids)
.map(PersonOidsWithAliases(henkiloOids, _))
}

override def getByHetu(hetu: String): Future[Henkilo] = {
throw new UnsupportedOperationException("Not implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import fi.vm.sade.hakurekisteri.integration.hakemus.{
import fi.vm.sade.hakurekisteri.integration.henkilo.{
Henkilo,
IOppijaNumeroRekisteri,
LinkedHenkiloOids
LinkedHenkiloOids,
PersonOidsWithAliases
}
import fi.vm.sade.hakurekisteri.integration.virta.{
VirtaClient,
Expand Down Expand Up @@ -143,6 +144,12 @@ class VirtaSuoritusResourceSpec extends ScalatraFunSuite with DispatchSupport wi
}
}

override def enrichWithAliases(henkiloOids: Set[String]): Future[PersonOidsWithAliases] = {
fetchLinkedHenkiloOidsMap(henkiloOids)
.map(_.oidToLinkedOids)
.map(PersonOidsWithAliases(henkiloOids, _))
}

override def getByOids(oids: Set[String]): Future[Map[String, Henkilo]] = Future.successful(
Map(
(
Expand Down

0 comments on commit 0e99b2d

Please sign in to comment.