-
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.
Merge pull request #9 from Opetushallitus/OK-754-koulutustoimija-oppi…
…laitos-toimipiste Ok 754 koulutustoimija oppilaitos toimipiste
- Loading branch information
Showing
40 changed files
with
4,884 additions
and
383 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
13 changes: 0 additions & 13 deletions
13
.../src/main/scala/fi/oph/ovara/backend/domain/KoulutuksetToteutuksetHakukohteetResult.scala
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...-backend/src/main/scala/fi/oph/ovara/backend/domain/KoulutusToteutusHakukohdeResult.scala
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,30 @@ | ||
package fi.oph.ovara.backend.domain | ||
|
||
sealed trait KoulutusToteutusHakukohde { | ||
val hakukohdeNimi: Kielistetty | ||
val hakukohdeOid: String | ||
val koulutuksenTila: Option[String] | ||
val toteutuksenTila: Option[String] | ||
val hakukohteenTila: Option[String] | ||
val aloituspaikat: Option[Int] | ||
val onValintakoe: Option[Boolean] | ||
val voiSuorittaaKaksoistutkinnon: Option[Boolean] | ||
val jarjestaaUrheilijanAmmKoulutusta: Option[Boolean] | ||
} | ||
|
||
case class KoulutusToteutusHakukohdeResult( | ||
hakukohdeNimi: Kielistetty, | ||
hakukohdeOid: String, | ||
koulutuksenTila: Option[String] = None, | ||
toteutuksenTila: Option[String] = None, | ||
hakukohteenTila: Option[String] = None, | ||
aloituspaikat: Option[Int] = None, | ||
onValintakoe: Option[Boolean] = None, | ||
voiSuorittaaKaksoistutkinnon: Option[Boolean] = None, | ||
jarjestaaUrheilijanAmmKoulutusta: Option[Boolean] = None | ||
) extends KoulutusToteutusHakukohde | ||
|
||
case class OrganisaationKoulutusToteutusHakukohde( | ||
organisaatio_oid: Option[String], | ||
koulutusToteutusHakukohde: KoulutusToteutusHakukohdeResult | ||
) |
26 changes: 26 additions & 0 deletions
26
ovara-backend/src/main/scala/fi/oph/ovara/backend/domain/Organisaatio.scala
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,26 @@ | ||
package fi.oph.ovara.backend.domain | ||
|
||
case class Organisaatio(organisaatio_oid: String, organisaatio_nimi: Kielistetty, organisaatiotyypit: List[String]) | ||
|
||
case class OrganisaatioParentChild(parent_oid: String, child_oid: String, organisaatio: Organisaatio) | ||
|
||
case class OrganisaatioHierarkia( | ||
organisaatio_oid: String, | ||
organisaatio_nimi: Kielistetty, | ||
organisaatiotyypit: List[String], | ||
oppilaitostyyppi: Option[String] = None, | ||
tila: String, | ||
parent_oids: List[String], | ||
koulutustoimijaParent: Option[Organisaatio] = None, | ||
children: List[OrganisaatioHierarkia] | ||
) | ||
|
||
case class OrganisaatioHierarkiaWithHakukohteet( | ||
organisaatio_oid: String, | ||
organisaatio_nimi: Kielistetty, | ||
organisaatiotyypit: List[String], | ||
parent_oids: List[String], | ||
koulutustoimijaParent: Option[Organisaatio] = None, | ||
children: List[OrganisaatioHierarkiaWithHakukohteet] = List(), | ||
hakukohteet: List[OrganisaationKoulutusToteutusHakukohde] | ||
) |
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
103 changes: 95 additions & 8 deletions
103
ovara-backend/src/main/scala/fi/oph/ovara/backend/repository/CommonRepository.scala
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 |
---|---|---|
@@ -1,23 +1,110 @@ | ||
package fi.oph.ovara.backend.repository | ||
|
||
import fi.oph.ovara.backend.domain.{Haku, Kieli, Kielistetty, ammatillisetHakukohdekoodit} | ||
import fi.oph.ovara.backend.domain.* | ||
import org.springframework.stereotype.Component | ||
import slick.jdbc.PostgresProfile.api.* | ||
import slick.sql.SqlStreamingAction | ||
|
||
@Component | ||
class CommonRepository extends Extractors { | ||
def selectDistinctAlkamisvuodet(): SqlStreamingAction[Vector[String], String, Effect] = { | ||
sql"""select distinct koulutuksen_alkamisvuosi | ||
from pub.pub_dim_toteutus pdt | ||
where koulutuksen_alkamisvuosi is not null""".as[String] | ||
sql"""SELECT DISTINCT koulutuksen_alkamisvuosi | ||
FROM pub.pub_dim_toteutus pdt | ||
WHERE koulutuksen_alkamisvuosi IS NOT NULL""".as[String] | ||
} | ||
|
||
def selectDistinctExistingHaut(): SqlStreamingAction[Vector[Haku], Haku, Effect] = { | ||
val hakukohdekooditStr = ammatillisetHakukohdekoodit.map(s => s"'$s'").mkString(",") | ||
sql"""select distinct haku_oid, haku_nimi | ||
from pub.pub_dim_haku h | ||
where kohdejoukko_koodi in (#$hakukohdekooditStr) | ||
and h.tila != 'poistettu'""".as[Haku] | ||
sql"""SELECT DISTINCT haku_oid, haku_nimi | ||
FROM pub.pub_dim_haku h | ||
WHERE kohdejoukko_koodi IN (#$hakukohdekooditStr) | ||
AND h.tila != 'poistettu'""".as[Haku] | ||
} | ||
|
||
def selectDistinctOrganisaatiot( | ||
organisaatiot: List[String] | ||
): SqlStreamingAction[Vector[Organisaatio], Organisaatio, Effect] = { | ||
val organisaatiotStr = organisaatiot.map(s => s"'$s'").mkString(",") | ||
val optionalOrganisaatiotClause = | ||
if (organisaatiotStr.isEmpty) "" else s"where org.organisaatio_oid in ($organisaatiotStr)" | ||
sql"""SELECT DISTINCT * | ||
FROM (SELECT organisaatio_oid, organisaatio_nimi, organisaatiotyypit | ||
FROM pub.pub_dim_organisaatio o) AS org | ||
#$optionalOrganisaatiotClause""".as[Organisaatio] | ||
} | ||
|
||
def selectDistinctKoulutustoimijat( | ||
organisaatiot: List[String] | ||
): SqlStreamingAction[Vector[Organisaatio], Organisaatio, Effect] = { | ||
val organisaatiotStr = organisaatiot.map(s => s"'$s'").mkString(",") | ||
val optionalOrganisaatiotClause = | ||
if (organisaatiotStr.isEmpty) "" else s"where org.organisaatio_oid in ($organisaatiotStr)" | ||
sql"""SELECT DISTINCT * | ||
FROM (SELECT organisaatio_oid, organisaatio_nimi, organisaatiotyypit | ||
FROM pub.pub_dim_organisaatio o | ||
WHERE organisaatiotyypit ?? '01') AS org | ||
#$optionalOrganisaatiotClause""".as[Organisaatio] | ||
} | ||
|
||
def selectChildOrganisaatiot( | ||
organisaatiot: List[String] | ||
): SqlStreamingAction[Vector[OrganisaatioParentChild], OrganisaatioParentChild, Effect] = { | ||
val organisaatiotStr = organisaatiot.map(s => s"'$s'").mkString(",") | ||
|
||
sql"""WITH RECURSIVE x AS ( | ||
SELECT parent_oid, child_oid | ||
FROM pub.pub_dim_organisaatio_rakenne or1 | ||
WHERE parent_oid in (#$organisaatiotStr) | ||
UNION | ||
SELECT or2.parent_oid, or2.child_oid | ||
FROM pub.pub_dim_organisaatio_rakenne or2 | ||
INNER JOIN x x1 | ||
ON or2.parent_oid = x1.child_oid | ||
) SELECT parent_oid, child_oid, organisaatio_nimi, organisaatiotyypit | ||
FROM x | ||
inner join pub.pub_dim_organisaatio org | ||
on org.organisaatio_oid = x.child_oid""".as[OrganisaatioParentChild] | ||
} | ||
|
||
val selectOrganisaatioHierarkiaSql = | ||
"""SELECT organisaatio_oid, | ||
organisaatio_nimi, | ||
organisaatiotyypit, | ||
oppilaitostyyppi, | ||
tila, | ||
parent_oids, | ||
children""" | ||
|
||
def selectKoulutustoimijaDescendants( | ||
koulutustoimijaOids: List[String] | ||
): SqlStreamingAction[Vector[OrganisaatioHierarkia], OrganisaatioHierarkia, Effect] = { | ||
val organisaatiotStr = koulutustoimijaOids.map(s => s"'$s'").mkString(",") | ||
sql"""#$selectOrganisaatioHierarkiaSql | ||
FROM pub.pub_dim_koulutustoimija_ja_toimipisteet, | ||
LATERAL jsonb_array_elements_text(parent_oids) AS parent_oid | ||
WHERE parent_oid IN (#$organisaatiotStr) | ||
""".as[OrganisaatioHierarkia] | ||
} | ||
|
||
def selectOppilaitosDescendants( | ||
oids: List[String] | ||
): SqlStreamingAction[Vector[OrganisaatioHierarkia], OrganisaatioHierarkia, Effect] = { | ||
val organisaatiotStr = oids.map(s => s"'$s'").mkString(",") | ||
sql"""#$selectOrganisaatioHierarkiaSql | ||
FROM pub.pub_dim_oppilaitos_ja_toimipisteet, | ||
LATERAL jsonb_array_elements_text(parent_oids) AS parent_oid | ||
WHERE parent_oid IN (#$organisaatiotStr) | ||
""".as[OrganisaatioHierarkia] | ||
} | ||
|
||
def selectToimipisteDescendants( | ||
oids: List[String] | ||
): SqlStreamingAction[Vector[OrganisaatioHierarkia], OrganisaatioHierarkia, Effect] = { | ||
val organisaatiotStr = oids.map(s => s"'$s'").mkString(",") | ||
sql"""#$selectOrganisaatioHierarkiaSql | ||
FROM pub.pub_dim_toimipiste_ja_toimipisteet, | ||
LATERAL jsonb_array_elements_text(parent_oids) AS parent_oid | ||
WHERE parent_oid IN (#$organisaatiotStr) | ||
""".as[OrganisaatioHierarkia] | ||
} | ||
} |
Oops, something went wrong.