Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class SpeciesListService {
String dataResourceUid
String rawScientificName
String scientificName
// for backward compatibility in BioCollect
String matchedName
String commonName
List kvpValues
String lsid
Expand Down Expand Up @@ -550,11 +552,12 @@ class SpeciesListService {
static SpeciesListItem mapV2API(Map speciesListItem) {
String scientificName = speciesListItem.scientificName
String commonName = speciesListItem.vernacularName
String matchedName = null
String lsid = null

// If the item successfully matched, use the matched classification
if (speciesListItem.classification?.success) {
scientificName = speciesListItem.classification.scientificName
matchedName = scientificName = speciesListItem.classification.scientificName
commonName = speciesListItem.classification.vernacularName
lsid = speciesListItem.classification.taxonConceptID
}
Expand All @@ -566,6 +569,7 @@ class SpeciesListService {
name:scientificName,
rawScientificName: speciesListItem.scientificName,
scientificName:scientificName,
matchedName:matchedName,
commonName:commonName,
kvpValues: speciesListItem.properties,
)
Expand All @@ -577,7 +581,8 @@ class SpeciesListService {
dataResourceUid: speciesListItem.dataResourceUid,
name: speciesListItem.name,
rawScientificName: speciesListItem.rawScientificName ?: speciesListItem.name,
scientificName: speciesListItem.scientificName,
scientificName: speciesListItem.scientificName ?: speciesListItem.matchedName,
matchedName: speciesListItem.matchedName ?: speciesListItem.scientificName,
commonName: speciesListItem.commonName,
kvpValues: speciesListItem.kvpValues,
lsid: speciesListItem.lsid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
result.size() == 1
result[0].name == "Testus species"
result[0].scientificName == "Testus species"
result[0].matchedName == "Testus species"
result[0].rawScientificName == "Testus species"
result[0].commonName == "Test Species"
result[0].lsid == "testLsid"
Expand Down Expand Up @@ -83,6 +84,7 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
result.size() == 1
result[0].name == "Testus species"
result[0].scientificName == "Testus species"
result[0].matchedName == "Testus species"
result[0].rawScientificName == "Testus species"
result[0].commonName == "Test Species"
result[0].lsid == "testLsid"
Expand Down Expand Up @@ -483,14 +485,14 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
resp: [
[
id: 123,
scientificName: "Eucalyptus globulus",
matchedName: "Eucalyptus globulus",
rawScientificName: "Eucalyptus globulus",
commonName: "Tasmanian Blue Gum",
kvpValues: [[kingdom: "Plantae"]]
],
[
id: 124,
scientificName: "Eucalyptus camaldulensis",
matchedName: "Eucalyptus camaldulensis",
rawScientificName: "Eucalyptus camaldulensis",
commonName: "River Red Gum",
kvpValues: [[kingdom: "Plantae"]]
Expand All @@ -506,8 +508,9 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
then:
result.size() == 2
result[0].scientificName == "Eucalyptus globulus"
result[0].matchedName == "Eucalyptus globulus"
result[0].rawScientificName == "Eucalyptus globulus"
result[1].scientificName == "Eucalyptus camaldulensis"
result[1].matchedName == "Eucalyptus camaldulensis"
result[1].rawScientificName == "Eucalyptus camaldulensis"
}

Expand Down Expand Up @@ -600,12 +603,14 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
then:
result.size() == 2
result[0].scientificName == "Eucalyptus globulus"
result[0].matchedName == "Eucalyptus globulus"
result[0].rawScientificName == "Eucalyptus globilus"
result[0].commonName == "Tasmanian Blue Gum"
result[0].lsid == "testLsid1"
result[0].kvpValues == [[kingdom: "Plantae"]]
result[1].rawScientificName == "Eucalyptus cameldulensis"
result[1].scientificName == "Eucalyptus camaldulensis"
result[1].matchedName == "Eucalyptus camaldulensis"
result[1].commonName == "River Red Gum"
result[1].kvpValues == [[kingdom: "Plantae"]]
result[1].lsid == "testLsid2"
Expand Down
Loading