Skip to content

Commit

Permalink
Refactor and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matsbov committed Mar 19, 2024
1 parent 67fbc1a commit 92db48c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
37 changes: 11 additions & 26 deletions grails-app/controllers/au/org/ala/collectory/IptController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -242,40 +242,25 @@ class IptController {
}

def iptInventory = new JsonSlurper().parse(new URL(provider.websiteUrl + "/inventory/dataset"))
def count = 0
def iptMap = [:]
def result = []

String[] header = [
"EML URL",
"GUID",
"Title",
"Number of records in IPT",
"Number of records in Atlas",
"Atlas ID"
]
result.add(header)

iptInventory.registeredResources.each { item ->
iptMap.put(item.title, item.records)
//retrieve UID, and do a count from the services
def uid = newMap.get(item.title.toLowerCase())
def row= [
title: item.title,
eml: item.eml,
gbifKey: item.gbifKey,
uid: "Not registered",
gbifCount: item.records,
atlasCount: 0
]
if (uid) {
def jsonCount = new JsonSlurper().parse(new URL(grailsApplication.config.biocacheServicesUrl + "/occurrences/search?pageSize=0&fq=data_resource_uid:" + uid))
String[] row = [
item.eml,
item.gbifKey,
item.title,
item.records,
jsonCount.totalRecords,
uid
]
result.add(row)
} else {
String[] row = [item.eml, item.gbifKey, item.title, item.records, "0", "Not registered"]
result.add(row)
row.uid = uid
row.atlasCount = jsonCount.totalRecords
}
count += 1
result.add(row)
}
[result: result]
}
Expand Down
6 changes: 5 additions & 1 deletion grails-app/views/ipt/syncView.gsp
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
${result}
<pre>
<g:each in="${result}" var="item">
${item}
</g:each>
</pre>

0 comments on commit 92db48c

Please sign in to comment.