Skip to content

Commit

Permalink
empty values are returned as null
Browse files Browse the repository at this point in the history
  • Loading branch information
hohonuuli committed Oct 21, 2024
1 parent b173055 commit 1b14464
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.10.3
2 changes: 2 additions & 0 deletions src/main/scala/org/fathomnet/worms/Data.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,5 @@ final case class Data(rootNode: WormsNode, wormsConcepts: Seq[WormsConcept]):
case (parent, Some(child)) =>
val newParent = parent.copy(children = Seq(child))
Some(newParent)


Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object MutableWormsNodeBuilder:
rows.filter(wc =>
val lr = wc.rank.toLowerCase
// (!lr.contains("species") && !lr.contains("variety")) || (!wc.isExtinct && wc.isMarine)
(!lr.contains("species") && !lr.contains("variety")) || (!wc.isExtinct)
(!lr.contains("species") && !lr.contains("variety")) || (!wc.isExtinct.getOrElse(false))
)

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/org/fathomnet/worms/io/WormsConcept.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ final case class WormsConcept(
parentId: Option[Long],
names: Seq[WormsConceptName],
rank: String,
isMarine: Boolean = false,
isFreshwater: Boolean = false,
isTerrestrial: Boolean = false,
isExtinct: Boolean = false,
isBrackish: Boolean = false
isMarine: Option[Boolean] = None,
isFreshwater: Option[Boolean] = None,
isTerrestrial: Option[Boolean] = None,
isExtinct: Option[Boolean] = None,
isBrackish: Option[Boolean] = None
)

object WormsConcept:
Expand Down
16 changes: 9 additions & 7 deletions src/main/scala/org/fathomnet/worms/io/model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,19 @@ object VernacularName:
def read(file: String): List[VernacularName] = readFile(file, VernacularName.from)

final case class SpeciesProfile(taxonID: String,
isMarine: Boolean,
isFreshwater: Boolean,
isTerrestrial: Boolean,
isExtinct: Boolean,
isBrackish: Boolean):
isMarine: Option[Boolean],
isFreshwater: Option[Boolean],
isTerrestrial: Option[Boolean],
isExtinct: Option[Boolean],
isBrackish: Option[Boolean]):
val id = taxonIDToKey(taxonID)

object SpeciesProfile:

private def toBool(value: String): Boolean =
value == "1"
private def toBool(value: String): Option[Boolean] =
if value.isBlank then None
else Some(value == "1")


def from(row: String): Option[SpeciesProfile] =
Try {
Expand Down

0 comments on commit 1b14464

Please sign in to comment.