From aefa972bacd77cd7732ad4b7affbed5e3f44b2a8 Mon Sep 17 00:00:00 2001 From: Patricia Koh Date: Thu, 2 Mar 2017 14:54:59 +1100 Subject: [PATCH] https://github.com/AtlasOfLivingAustralia/images-client-plugin/issues/12 - Fix species list getPreferredSpeciesList 500 error. Only get the list where imageId is set. Also remove the functionality to update Bie from species list --- .../au/org/ala/specieslist/EditorController.groovy | 5 +++-- .../org/ala/specieslist/WebServiceController.groovy | 11 +++++++++-- .../au/org/ala/specieslist/HelperService.groovy | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/grails-app/controllers/au/org/ala/specieslist/EditorController.groovy b/grails-app/controllers/au/org/ala/specieslist/EditorController.groovy index dc982f0ae..7f12baf71 100644 --- a/grails-app/controllers/au/org/ala/specieslist/EditorController.groovy +++ b/grails-app/controllers/au/org/ala/specieslist/EditorController.groovy @@ -246,10 +246,11 @@ class EditorController { // find common name and save it helperService.matchCommonNamesForSpeciesListItems([sli]) - def preferredSpeciesImageListName = grailsApplication.config.ala.preferred.species.name + // Commented out as we would like to keep species list generic + /* def preferredSpeciesImageListName = grailsApplication.config.ala.preferred.species.name if (sl.listName == preferredSpeciesImageListName) { helperService.syncBieImage (sli, params.imageId) - } + }*/ render(text: "Record successfully created", status: 200) } else { diff --git a/grails-app/controllers/au/org/ala/specieslist/WebServiceController.groovy b/grails-app/controllers/au/org/ala/specieslist/WebServiceController.groovy index 34b621791..7dc8bb90a 100644 --- a/grails-app/controllers/au/org/ala/specieslist/WebServiceController.groovy +++ b/grails-app/controllers/au/org/ala/specieslist/WebServiceController.groovy @@ -250,8 +250,15 @@ class WebServiceController { if (preferredSpeciesListDruid) { def speciesList = SpeciesListItem.findAllByDataResourceUid(preferredSpeciesListDruid) if (speciesList.size() > 0) { - newList = speciesList.collect({ - [name: it.rawScientificName, imageId: it.kvpValues.first().grep { it.value }.value.get(0)] + speciesList.each({ + def scientificName = it.rawScientificName + if (it.kvpValues) { + it.kvpValues.each { + if (it.key == 'imageId' && it.value != "") { + newList.push(name: scientificName, imageId: it.getValue()) + } + } + } }) } } diff --git a/grails-app/services/au/org/ala/specieslist/HelperService.groovy b/grails-app/services/au/org/ala/specieslist/HelperService.groovy index c48d8883d..ccab3fb8e 100644 --- a/grails-app/services/au/org/ala/specieslist/HelperService.groovy +++ b/grails-app/services/au/org/ala/specieslist/HelperService.groovy @@ -678,6 +678,7 @@ class HelperService { } } +/* Commented out to keep species list from updating Bie def syncBieImage (sli, imageId) { boolean updateBieImage = false int imageIdPos = sli.getImageUrl()? sli.getImageUrl().toLowerCase().indexOf("?imageid=") : 0 @@ -703,6 +704,7 @@ class HelperService { } } } +*/ /**