Skip to content

Commit

Permalink
Add action (copy of syncReport) and placeholder view
Browse files Browse the repository at this point in the history
  • Loading branch information
matsbov committed Mar 19, 2024
1 parent 4c8e038 commit 67fbc1a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions grails-app/controllers/au/org/ala/collectory/IptController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,58 @@ class IptController {
csvWriter.flush()
}
}

def syncView() {
def provider = providerGroupService._get(params.uid)
if (provider.websiteUrl) {
def newMap = [:]
DataResource.findAll().each { dr ->
def idx = dr.name.toLowerCase().indexOf("- version")
if (idx > 0) {
def searchedWith = dr.name.substring(0, idx).trim()
newMap.put(searchedWith, dr.uid)
} else {
newMap.put(dr.name.toLowerCase(), dr.uid)
}
}

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())
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)
}
count += 1
}
[result: result]
}
}
}
1 change: 1 addition & 0 deletions grails-app/views/ipt/syncView.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${result}

0 comments on commit 67fbc1a

Please sign in to comment.