Skip to content

Commit b86a340

Browse files
committed
AtlasOfLivingAustralia/bicollect#1898
- added matchedName field to the species list item response
1 parent faa2f1a commit b86a340

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

grails-app/services/au/org/ala/ecodata/forms/SpeciesListService.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class SpeciesListService {
3939
String dataResourceUid
4040
String rawScientificName
4141
String scientificName
42+
// for backward compatibility in BioCollect
43+
String matchedName
4244
String commonName
4345
List kvpValues
4446
String lsid
@@ -550,11 +552,12 @@ class SpeciesListService {
550552
static SpeciesListItem mapV2API(Map speciesListItem) {
551553
String scientificName = speciesListItem.scientificName
552554
String commonName = speciesListItem.vernacularName
555+
String matchedName = null
553556
String lsid = null
554557

555558
// If the item successfully matched, use the matched classification
556559
if (speciesListItem.classification?.success) {
557-
scientificName = speciesListItem.classification.scientificName
560+
matchedName = scientificName = speciesListItem.classification.scientificName
558561
commonName = speciesListItem.classification.vernacularName
559562
lsid = speciesListItem.classification.taxonConceptID
560563
}
@@ -566,6 +569,7 @@ class SpeciesListService {
566569
name:scientificName,
567570
rawScientificName: speciesListItem.scientificName,
568571
scientificName:scientificName,
572+
matchedName:matchedName,
569573
commonName:commonName,
570574
kvpValues: speciesListItem.properties,
571575
)
@@ -577,7 +581,8 @@ class SpeciesListService {
577581
dataResourceUid: speciesListItem.dataResourceUid,
578582
name: speciesListItem.name,
579583
rawScientificName: speciesListItem.rawScientificName ?: speciesListItem.name,
580-
scientificName: speciesListItem.scientificName,
584+
scientificName: speciesListItem.scientificName ?: speciesListItem.matchedName,
585+
matchedName: speciesListItem.matchedName ?: speciesListItem.scientificName,
581586
commonName: speciesListItem.commonName,
582587
kvpValues: speciesListItem.kvpValues,
583588
lsid: speciesListItem.lsid

src/test/groovy/au/org/ala/ecodata/forms/SpeciesListServiceSpec.groovy

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
3737
result.size() == 1
3838
result[0].name == "Testus species"
3939
result[0].scientificName == "Testus species"
40+
result[0].matchedName == "Testus species"
4041
result[0].rawScientificName == "Testus species"
4142
result[0].commonName == "Test Species"
4243
result[0].lsid == "testLsid"
@@ -83,6 +84,7 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
8384
result.size() == 1
8485
result[0].name == "Testus species"
8586
result[0].scientificName == "Testus species"
87+
result[0].matchedName == "Testus species"
8688
result[0].rawScientificName == "Testus species"
8789
result[0].commonName == "Test Species"
8890
result[0].lsid == "testLsid"
@@ -483,14 +485,14 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
483485
resp: [
484486
[
485487
id: 123,
486-
scientificName: "Eucalyptus globulus",
488+
matchedName: "Eucalyptus globulus",
487489
rawScientificName: "Eucalyptus globulus",
488490
commonName: "Tasmanian Blue Gum",
489491
kvpValues: [[kingdom: "Plantae"]]
490492
],
491493
[
492494
id: 124,
493-
scientificName: "Eucalyptus camaldulensis",
495+
matchedName: "Eucalyptus camaldulensis",
494496
rawScientificName: "Eucalyptus camaldulensis",
495497
commonName: "River Red Gum",
496498
kvpValues: [[kingdom: "Plantae"]]
@@ -506,8 +508,9 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
506508
then:
507509
result.size() == 2
508510
result[0].scientificName == "Eucalyptus globulus"
511+
result[0].matchedName == "Eucalyptus globulus"
509512
result[0].rawScientificName == "Eucalyptus globulus"
510-
result[1].scientificName == "Eucalyptus camaldulensis"
513+
result[1].matchedName == "Eucalyptus camaldulensis"
511514
result[1].rawScientificName == "Eucalyptus camaldulensis"
512515
}
513516

@@ -600,12 +603,14 @@ class SpeciesListServiceSpec extends Specification implements ServiceUnitTest<Sp
600603
then:
601604
result.size() == 2
602605
result[0].scientificName == "Eucalyptus globulus"
606+
result[0].matchedName == "Eucalyptus globulus"
603607
result[0].rawScientificName == "Eucalyptus globilus"
604608
result[0].commonName == "Tasmanian Blue Gum"
605609
result[0].lsid == "testLsid1"
606610
result[0].kvpValues == [[kingdom: "Plantae"]]
607611
result[1].rawScientificName == "Eucalyptus cameldulensis"
608612
result[1].scientificName == "Eucalyptus camaldulensis"
613+
result[1].matchedName == "Eucalyptus camaldulensis"
609614
result[1].commonName == "River Red Gum"
610615
result[1].kvpValues == [[kingdom: "Plantae"]]
611616
result[1].lsid == "testLsid2"

0 commit comments

Comments
 (0)