Skip to content

Commit

Permalink
Merge pull request #360 from AtlasOfLivingAustralia/develop
Browse files Browse the repository at this point in the history
Merging develop to master for 1.8.2 release
  • Loading branch information
sughics authored Nov 2, 2022
2 parents 3d0d155 + c9e2df6 commit ec539bb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}
}

version "1.8.1"
version "1.9-SNAPSHOT"
group "au.org.ala"

apply plugin:"eclipse"
Expand Down
2 changes: 1 addition & 1 deletion grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ knowledgeBase:
articleCssSelector: .article-title a.c-link
lists:
service: https://lists.ala.org.au/ws
items: /speciesListItems/{0}?includeKVP=true
items: /speciesListItems/{0}?includeKVP=true&max={1}&offset={2}
# If attribution entry is null, the default is used
naming:
service: https://namematching-ws.ala.org.au
Expand Down
25 changes: 20 additions & 5 deletions grails-app/services/au/org/ala/bie/ListService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,26 @@ class ListService {
* @param fields Additional fields to get from the list
*/
def get(uid, List fields = []) {
def url = Encoder.buildServiceUrl(grailsApplication.config.lists.service, grailsApplication.config.lists.items, uid)
def slurper = new JsonSlurper()
def json = slurper.parseText(url.getText('UTF-8'))
return json.collect { item ->
def result = [lsid: item.lsid, name: item.name ]
boolean hasAnotherPage = true
int max = 400
int offset = 0

def items = []

while (hasAnotherPage) {
def url = Encoder.buildServiceUrl(grailsApplication.config.lists.service, grailsApplication.config.lists.items, uid, max, offset)

def slurper = new JsonSlurper()
def json = slurper.parseText(url.getText('UTF-8'))
items.addAll(json)

hasAnotherPage = json.size() == max
offset += max

}

return items.collect { item ->
def result = [lsid: item.lsid, name: item.name]
fields.each { field ->
def value = field ? item.kvpValues.find { it.key == field }?.get("value") : null
if (value)
Expand Down

0 comments on commit ec539bb

Please sign in to comment.