Skip to content

Commit

Permalink
Fixed rank issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed May 13, 2024
1 parent fab3c8e commit 8092a25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
5 changes: 4 additions & 1 deletion oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ object MutableConcept {
}
})

if (concept.rank.isEmpty && row.rank.isDefined) {
concept.rank = row.rank
}

val cn = CName(row.name, row.nameType)
concept.rank = row.rank
concept.names = concept.names :+ cn

}
Expand Down
28 changes: 21 additions & 7 deletions oni/src/test/scala/org/mbari/oni/jdbc/MutableConceptSuite.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/*
* Copyright (c) Monterey Bay Aquarium Research Institute 2024
*
* oni code is non-public software. Unauthorized copying of this file,
* via any medium is strictly prohibited. Proprietary and confidential.
*/

package org.mbari.oni.jdbc

import org.mbari.oni.domain.ConceptNameTypes
Expand All @@ -18,7 +25,7 @@ class MutableConceptSuite extends munit.FunSuite {
`- 7 - child7
*/
val rows = Seq(
ConceptRow(1, None, "root"),
ConceptRow(1, None, "root", rankLevel = Some("super"), rankName = Some("family")),
ConceptRow(1, None, "object", nameType = ConceptNameTypes.ALTERNATE.getType),
ConceptRow(2, Some(1), "child2"),
ConceptRow(3, Some(1), "child3"),
Expand All @@ -28,22 +35,29 @@ class MutableConceptSuite extends munit.FunSuite {
ConceptRow(7, Some(3), "child7"),
ConceptRow(8, Some(4), "child8"),
ConceptRow(9, Some(4), "child9"),
ConceptRow(10, Some(9), "child10")
ConceptRow(10, Some(9), "child10", nameType = ConceptNameTypes.PRIMARY.getType),
ConceptRow(10, Some(9), "child10a", nameType = ConceptNameTypes.ALTERNATE.getType),
ConceptRow(10, Some(9), "child10s", nameType = ConceptNameTypes.SYNONYM.getType, rankLevel = Some("sub"), rankName = Some("species")),
ConceptRow(10, Some(9), "child10c", nameType = ConceptNameTypes.COMMON.getType),
ConceptRow(10, Some(9), "child10f", nameType = ConceptNameTypes.FORMER.getType)
)

val (rootOpt, nodes) = MutableConcept.toTree(rows)



test("toTree") {
val (rootOpt, nodes) = MutableConcept.toTree(rows)
assert(rootOpt.isDefined)
val root = rootOpt.get
assertEquals(root.id.get, 1L)
assertEquals(root.children.size, 2)
assertEquals(nodes.size, 10)
assertEquals(root.primaryName, Some("root"))
assertEquals(root.names.map(_.name).sorted, Seq("object", "root"))
assertEquals(root.rank, Some("superfamily"))
}

test("root") {
val (rootOpt, nodes) = MutableConcept.toTree(rows)
val root = rootOpt.get
val child2 = root.children.head
val child4 = child2.children.head
Expand All @@ -61,7 +75,6 @@ class MutableConceptSuite extends munit.FunSuite {
}

test("copyUp") {
val (rootOpt, nodes) = MutableConcept.toTree(rows)
val child9 = nodes.find(_.id.get == 9).get
val child9Copy = child9.copyUp()
assertEquals(child9Copy.id, child9.id)
Expand All @@ -73,15 +86,16 @@ class MutableConceptSuite extends munit.FunSuite {
}

test("toImmutable") {
val (rootOpt, nodes) = MutableConcept.toTree(rows)
val root = rootOpt.get
val concept = root.toImmutable
assertEquals(concept.name, "root")
assertEquals(concept.rank, None)
assertEquals(concept.rank, Some("superfamily"))
assertEquals(concept.alternativeNames, Seq("object"))
assertEquals(concept.children.size, 2)
assertEquals(concept.children.head.name, "child2")
assertEquals(concept.children(1).name, "child3")
assertEquals(concept.descendants.size, 10)
assertEquals(concept.descendantNames.size, 15)
}

}
5 changes: 3 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Dependencies {
lazy val scilube = "org.mbari.scilube" %% "scilube" % "3.0.1"
lazy val slf4jSystem = "org.slf4j" % "slf4j-jdk-platform-logging" % "2.0.13"

private val tapirVersion = "1.10.6"
private val tapirVersion = "1.10.7"
lazy val tapirCirce = "com.softwaremill.sttp.tapir" %% "tapir-json-circe" % tapirVersion
lazy val tapirHelidon = "com.softwaremill.sttp.tapir" %% "tapir-nima-server" % tapirVersion
lazy val tapirPrometheus = "com.softwaremill.sttp.tapir" %% "tapir-prometheus-metrics" % tapirVersion
Expand All @@ -37,7 +37,8 @@ object Dependencies {
lazy val tapirVertex = "com.softwaremill.sttp.tapir" %% "tapir-vertx-server" % tapirVersion

lazy val tapirSttpCirce = "com.softwaremill.sttp.client3" %% "circe" % "3.9.6"
val testcontainersVersion = "1.19.7"

val testcontainersVersion = "1.19.8"
lazy val testcontainersCore = "org.testcontainers" % "testcontainers" % testcontainersVersion
lazy val testcontainersJdbc = "org.testcontainers" % "jdbc" % testcontainersVersion
lazy val testcontainersSqlserver = "org.testcontainers" % "mssqlserver" % testcontainersVersion
Expand Down

0 comments on commit 8092a25

Please sign in to comment.