From 8092a251ef6fcf4ae139e927d03e90983bdaac30 Mon Sep 17 00:00:00 2001 From: Brian Schlining Date: Mon, 13 May 2024 10:26:43 -0700 Subject: [PATCH] Fixed rank issue --- .../org/mbari/oni/jdbc/MutableConcept.scala | 5 +++- .../mbari/oni/jdbc/MutableConceptSuite.scala | 28 ++++++++++++++----- project/Dependencies.scala | 5 ++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala b/oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala index d48b412..1433ef4 100644 --- a/oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala +++ b/oni/src/main/scala/org/mbari/oni/jdbc/MutableConcept.scala @@ -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 } diff --git a/oni/src/test/scala/org/mbari/oni/jdbc/MutableConceptSuite.scala b/oni/src/test/scala/org/mbari/oni/jdbc/MutableConceptSuite.scala index 9658b25..e7a85cb 100644 --- a/oni/src/test/scala/org/mbari/oni/jdbc/MutableConceptSuite.scala +++ b/oni/src/test/scala/org/mbari/oni/jdbc/MutableConceptSuite.scala @@ -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 @@ -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"), @@ -28,11 +35,18 @@ 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) @@ -40,10 +54,10 @@ class MutableConceptSuite extends munit.FunSuite { 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 @@ -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) @@ -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) } } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index fa6d06b..f95b562 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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 @@ -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