Skip to content

Commit d07607f

Browse files
author
Adam Collins
committed
#468 partial species-list support
1 parent d04ee7a commit d07607f

File tree

8 files changed

+74
-42
lines changed

8 files changed

+74
-42
lines changed

grails-app/assets/javascripts/spApp/directive/listsList.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@
2727
if (data.length) {
2828
for (var i = 0; i < data.length; i++) {
2929
scope.items.push({
30-
dataResourceUid: data[i].dataResourceUid,
31-
listName: data[i].listName,
30+
dataResourceUid: data[i].id || data[i].dataResourceUid,
31+
listName: data[i].listName || data[i].title,
3232
lastUpdated: data[i].lastUpdated,
33-
itemCount: data[i].itemCount,
34-
fullName: data[i].fullName,
33+
itemCount: data[i].itemCount || data[i].rowCount,
34+
fullName: data[i].fullName || data[i].owner || data[i].authority,
3535
isAuthoritative:data[i].isAuthoritative,
3636
selected: false
3737
})
3838
}
39-
} else if (data.dataResourceUid) {
39+
} else if (data.dataResourceUid || data.id) {
4040
scope.items.push({
41-
dataResourceUid: data.dataResourceUid,
42-
listName: data.listName,
41+
dataResourceUid: data.id || data.dataResourceUid,
42+
listName: data.listName || data.title,
4343
lastUpdated: data.lastUpdated,
44-
itemCount: data.itemCount,
45-
fullName: data.fullName,
44+
itemCount: data.itemCount || data.rowCount,
45+
fullName: data.fullName || dats.owner || data[i].authority,
4646
selected: false
4747
});
4848
}
@@ -70,7 +70,12 @@
7070
};
7171

7272
scope.itemUrl = function (item) {
73-
return ListsService.url() + '/speciesListItem/list/' + item.dataResourceUid
73+
if (ListsService.urlUi()) {
74+
// new species-lists as urlUi defined
75+
return ListsService.urlUi() + '/#/list/' + item.dataResourceUid
76+
} else {
77+
return ListsService.url() + '/speciesListItem/list/' + item.dataResourceUid
78+
}
7479
};
7580

7681
scope.add = function (item) {

grails-app/assets/javascripts/spApp/service/facetAutoCompleteService.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@
170170
var data = ListsService.getItemsQCached(species_list);
171171
if (data === undefined) {
172172
return ListsService.getItemsQ(species_list).then(function () {
173-
// species list info is now cached
174-
return scope.getFacets(dynamic, groups, species_list)
173+
// species list info is now cached so repeat the parent function
174+
return scope.getGroupedFacets(dynamic, groups, species_list)
175175
})
176176
} else {
177177
if (data.length > 0 && data[0].kvpValues && data[0].kvpValues.length > 0) {
@@ -256,8 +256,8 @@
256256
var data = ListsService.getItemsQCached(species_list);
257257
if (data === undefined) {
258258
return ListsService.getItemsQ(species_list).then(function () {
259-
// species list info is now cached
260-
return scope.getFacets(dynamic, groups, species_list)
259+
// species list info is now cached, so repeat the parent function
260+
return scope.getAllFacets(dynamic, list, species_list)
261261
})
262262
} else {
263263
if (data.length > 0 && data[0].kvpValues && data[0].kvpValues.length > 0) {
@@ -347,4 +347,4 @@
347347

348348
return scope;
349349
}])
350-
}(angular));
350+
}(angular));

grails-app/assets/javascripts/spApp/service/listsService.js

+8-20
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,11 @@
2727
list: function (q, max, offset, sort, order, user) {
2828
var params = '';
2929
if (q) params += "/" + encodeURIComponent(q);
30-
//TODO: investigate paging
31-
// if(q) params += '&q=' + encodeURIComponent(q);
32-
// if(max) params += '&max=' + max;
33-
// if(offset) params += '&offset=' + offset;
34-
// if(sort) params += '&sort=' + sort;
35-
// if(order) params += '&order=' + order;
36-
// if(user) params += '&user=' + user;
37-
params += "?" + "&max=2000";
30+
// The new species-lists has separate graphql query that is more UI friendly. In the meantime,
31+
// get everything, or an approximation of everything.
32+
params += "?max=20000";
3833
if ($SH.userId) {
34+
// This is not used in the new species-lists. The purpose was to put lists by the current user at the top of the list.
3935
params += "&user=" + $SH.userId
4036
}
4137
return $http.get($SH.baseUrl + "/portal/speciesList" + params, _httpDescription('list')).then(function (response) {
@@ -74,22 +70,14 @@
7470
return cache.get(listId);
7571
},
7672
getItemsQ: function (listId) {
77-
// TODO: use 'species_list:' after biocache-service is redeployed
78-
//return $q.when('species_list:' + listId);
79-
80-
if (scope.getItemsQCached(listId)) {
81-
return $q.when(scope.listToFq(scope.getItemsQCached(listId)))
82-
} else {
83-
return scope.items(listId, {includeKVP: true}).then(function (data) {
84-
cache.put(listId, data);
85-
86-
return $q.when(scope.listToFq(data));
87-
});
88-
}
73+
return $q.when('species_list:' + listId);
8974
},
9075
url: function () {
9176
return $SH.listsUrl
9277
},
78+
urlUi: function () {
79+
return $SH.listsUrlUi
80+
},
9381
listToFq: function (data) {
9482
var terms = [];
9583
for (var i in data) {

grails-app/conf/application.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ i18n:
2828
layersService:
2929
url: 'https://spatial.ala.org.au/ws'
3030
geoserver:
31-
url: 'https://spatial.ala.org.au/geoserver/web/'
31+
url: 'https://spatial.ala.org.au/geoserver'
3232

3333
info:
3434
app:
@@ -205,12 +205,22 @@ skin:
205205

206206

207207
lists:
208+
useListWs: false
208209
url: 'https://lists.ala.org.au'
209210
threatenedSpeciesUrl: '/ws/speciesList/?isThreatened=eq:true&isAuthoritative=eq:true'
210211
invasiveSpeciesUrl: '/ws/speciesList/?isInvasive=eq:true&isAuthoritative=eq:true'
211212
facets: true
212213
migratoryDR: 'dr1005'
213214
iconicSpeciesDR: 'dr781'
215+
#lists:
216+
# useListWs: true
217+
# url: 'http://localhost:8080'
218+
# urlUi: 'http://localhost:5173'
219+
# threatenedSpeciesUrl: '/speciesList/?isThreatened=true&isAuthoritative=true&pageSize=1000'
220+
# invasiveSpeciesUrl: '/speciesList/?isInvasive=true&isAuthoritative=true&pageSize=1000'
221+
# facets: true
222+
# migratoryDR: 'dr1005'
223+
# iconicSpeciesDR: 'dr781'
214224

215225
journalmap:
216226
url: 'https://www.journalmap.org'

grails-app/controllers/au/org/ala/spatial/portal/PortalController.groovy

+30-3
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,24 @@ class PortalController {
376376

377377
def url = grailsApplication.config.lists.url
378378

379-
def r = webService.post("${url}/ws/speciesList/", json)
379+
def r
380+
if (grailsApplication.config.lists.useListWs) {
381+
// format input
382+
/*
383+
{
384+
"listName": name,
385+
"listItems": items,
386+
"description": description,
387+
"isPrivate": makePrivate,
388+
"listType": listType
389+
}
390+
*/
391+
r = webService.post("${url}/upload", json, null, ContentType.APPLICATION_JSON, false, true)
392+
393+
r = webService.post("${url}/ingest/${speciesListID}", json, null, ContentType.APPLICATION_JSON, false, true)
394+
} else {
395+
r = webService.post("${url}/ws/speciesList/", json)
396+
}
380397

381398
if (r == null) {
382399
def status = response.setStatus(HttpURLConnection.HTTP_INTERNAL_ERROR)
@@ -400,7 +417,12 @@ class PortalController {
400417
} else {
401418
def url = grailsApplication.config.lists.url
402419

403-
def r = webService.get("${url}/ws/speciesListItems/" + params.id, [:], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
420+
def r
421+
if (grailsApplication.config.lists.useListWs) {
422+
r = webService.get("${url}/speciesListItems/" + params.id, [:], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
423+
} else {
424+
r = webService.get("${url}/ws/speciesListItems/" + params.id, [:], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
425+
}
404426

405427
if (r == null) {
406428
def status = response.setStatus(HttpURLConnection.HTTP_INTERNAL_ERROR)
@@ -424,7 +446,12 @@ class PortalController {
424446
} else {
425447
def url = grailsApplication.config.lists.url
426448

427-
def r = webService.get("${url}/ws/speciesList", [user: params.user ? userId : null, max: params.max], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
449+
def r
450+
if (grailsApplication.config.lists.useListWs) {
451+
r = webService.get("${url}/speciesList/", [pageSize: params.max, page: params.page ?: 1], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
452+
} else {
453+
r = webService.get("${url}/ws/speciesList", [user: params.user ? userId : null, max: params.max], org.apache.http.entity.ContentType.APPLICATION_JSON, false, true, [:])
454+
}
428455

429456
if (r == null) {
430457
def status = response.setStatus(HttpURLConnection.HTTP_INTERNAL_ERROR)

grails-app/services/au/org/ala/spatial/portal/PortalService.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ class PortalService {
6060
def threatenedUrl =
6161
"${grailsApplication.config.lists.url}${grailsApplication.config.lists.threatenedSpeciesUrl}"
6262
def threatened = JSON.parse(hubWebService.getUrl(threatenedUrl, null, false)) as Map
63-
def threatenedJoined = threatened.lists*.dataResourceUid.join(joinStr)
63+
def threatenedJoined = threatened.lists.collect { it.id ?: it.dataResourceUid }.join(joinStr)
6464
def threatenedQ = "species_list_uid:(${threatenedJoined})"
6565
if (threatenedJoined) {
6666
grailsApplication.config.threatenedQ = threatenedQ
6767
}
6868

6969
def invasiveUrl = "${grailsApplication.config.lists.url}${grailsApplication.config.lists.invasiveSpeciesUrl}"
7070
def invasive = JSON.parse(hubWebService.getUrl(invasiveUrl, null, false)) as Map
71-
def invasiveJoined = invasive.lists*.dataResourceUid.join(joinStr)
71+
def invasiveJoined = invasive.lists.collect { it.id ?: it.dataResourceUid }.join(joinStr)
7272
def invasiveQ = "species_list_uid:(${invasiveJoined})"
7373
if (invasiveJoined) {
7474
grailsApplication.config.invasiveQ = invasiveQ

grails-app/views/portal/embedExample.gsp

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
layersServiceUrl: '${config.layersService.url}',
3030
samplingUrl: '${config.sampling.url}',
3131
listsUrl: '${config.lists.url}',
32+
listsUrlUi: '${config.lists.urlUi}',
3233
sandboxUrl: '${config.sandbox.url}',
3334
sandboxServiceUrl: '${config.sandboxService.url}',
3435
sandboxUiUrl: '${config.sandbox.uiUrl}',
@@ -88,4 +89,4 @@
8889
<sp-app></sp-app>
8990

9091
</body>
91-
</html>
92+
</html>

grails-app/views/portal/index.gsp

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
layersServiceUrl: '${config.layersService.url}',
4141
samplingUrl: '${config.sampling.url}',
4242
listsUrl: '${config.lists.url}',
43+
listsUrlUi: '${config.lists.urlUi}',
4344
listsFacets: ${config.lists.facets},
4445
sandboxUrl: '${config.sandbox.url}',
4546
sandboxServiceUrl: '${config.sandboxService.url}',

0 commit comments

Comments
 (0)