Skip to content

Commit

Permalink
#468 incremental species-list support
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Collins committed Mar 1, 2024
1 parent d07607f commit 701b459
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ webdriverBinariesVersion=2.6
#chromeDriverVersion=2.45.0
geckodriverVersion=0.24.0
seleniumSafariDriverVersion=3.14.0
alaSecurityLibsVersion=6.2.0
alaSecurityLibsVersion=6.3.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@
{
name: $i18n(372, "Migratory species - EPBC"),
query: {q: areaQ.q, bs: areaQ.bs, ws: areaQ.ws, wkt: areaQ.wkt, qid: areaQ.qid},
link: ListsService.url() + '/speciesListItem/list/' + $SH.migratoryDR,
link: ListsService.urlUi() + $SH.migratoryDR,
linkName: $i18n(373, "Full list"),
extraQ: ["species_list_uid:" + $SH.migratoryDR],
ignore: $SH.listsUrl === '' || $SH.migratoryDR === ''
},
{
name: $i18n(374, "Australian iconic species"),
query: {q: areaQ.q, bs: areaQ.bs, ws: areaQ.ws, wkt: areaQ.wkt, qid: areaQ.qid},
link: ListsService.url() + '/speciesListItem/list/' + $SH.iconicSpeciesDR,
link: ListsService.urlUi() + $SH.iconicSpeciesDR,
linkName: $i18n(373, "Full list"),
extraQ: ["species_list_uid:" + $SH.iconicSpeciesDR],
ignore: $SH.listsUrl === '' || $SH.iconicSpeciesDR === ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,7 @@

$scope.maxFileSize = $SH.maxUploadSize;

$scope.listTypes = [
{id: 'OTHER', label: "Other"},
{id: 'SPECIES_CHARACTERS', label: "Species characters list"},
{id: 'CONSERVATION_LIST', label: "Conservation list"},
{id: 'SENSITIVE_LIST', label: "Sensitive list of species"},
{id: 'LOCAL_LIST', label: "Local checklist"},
{id: 'COMMON_TRAIT', label: "Common trait of species"},
{id: 'COMMON_HABITAT', label: "Common habitat of species"},
{id: 'TEST', label: "Test list"}
]
$scope.listTypes = $SH.listTypes;

$scope.newListName = $i18n(375, "My species list");
$scope.newListDescription = '';
Expand Down
7 changes: 1 addition & 6 deletions grails-app/assets/javascripts/spApp/directive/listsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@
};

scope.itemUrl = function (item) {
if (ListsService.urlUi()) {
// new species-lists as urlUi defined
return ListsService.urlUi() + '/#/list/' + item.dataResourceUid
} else {
return ListsService.url() + '/speciesListItem/list/' + item.dataResourceUid
}
return ListsService.urlUi() + item.dataResourceUid
};

scope.add = function (item) {
Expand Down
30 changes: 30 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,23 @@ lists:
facets: true
migratoryDR: 'dr1005'
iconicSpeciesDR: 'dr781'
listTypes:
- id: 'OTHER'
label: "Other"
- id: 'SPECIES_CHARACTERS'
label: "Species characters list"
- id: 'CONSERVATION_LIST'
label: "Conservation list"
- id: 'SENSITIVE_LIST'
label: "Sensitive list of species"
- id: 'LOCAL_LIST'
label: "Local checklist"
- id: 'COMMON_TRAIT'
label: "Common trait of species"
- id: 'COMMON_HABITAT'
label: "Common habitat of species"
- id: 'TEST'
label: "Test list"
#lists:
# useListWs: true
# url: 'http://localhost:8080'
Expand All @@ -221,6 +238,19 @@ lists:
# facets: true
# migratoryDR: 'dr1005'
# iconicSpeciesDR: 'dr781'
# listTypes:
# - id: 'CONSERVATION_LIST'
# label: "Conservation species list"
# - id: 'SENSITIVE_LIST'
# label: "Sensitive list"
# - id: 'INVASIVE'
# label: "Invasive species list"
# - id: 'COMMON_TRAIT'
# label: "Traits"
# - id: 'LOCAL_LIST'
# label: "Local checklist"
# - id: 'SPECIES_CHARACTERS'
# label: "Species characters"

journalmap:
url: 'https://www.journalmap.org'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.apache.commons.lang.StringUtils
import org.apache.http.client.methods.HttpGet
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.ContentType
import org.jasig.cas.client.util.CommonUtils
import org.springframework.web.multipart.MultipartFile
import org.springframework.web.multipart.MultipartHttpServletRequest

Expand Down Expand Up @@ -378,19 +377,36 @@ class PortalController {

def r
if (grailsApplication.config.lists.useListWs) {
// format input
/*
{
"listName": name,
"listItems": items,
"description": description,
"isPrivate": makePrivate,
"listType": listType
}
*/
r = webService.post("${url}/upload", json, null, ContentType.APPLICATION_JSON, false, true)
// create tmp file
File tmpFile = File.createTempFile("spatial-species-list-",".csv")
BufferedWriter fw = new BufferedWriter(new FileWriter(tmpFile))
fw.writeLine("taxonID")
for (String item : json.listItems.split(",")) {
fw.writeLine(item)
}
fw.flush()
fw.close()

r = webService.postMultipart("${url}/upload", null, null, [file: tmpFile], ContentType.APPLICATION_JSON, false, true)

tmpFile.delete()

r = webService.post("${url}/ingest/${speciesListID}", json, null, ContentType.APPLICATION_JSON, false, true)
if (r.statusCode == 200) {
def metadata = [
file : r.resp.localFile,
title : json.listName,
description: json.description ?: json.listName,
listType : json.listType,
region : "AUS", // TODO: replicate species-lists behaviour, depends on species-lists issue #83
licence : "CC-BY", // TODO: replicate species-lists behaviour, depends on species-lists issue #83
isPrivate : json.isPrivate
]

r = webService.post("${url}/ingest", metadata, [file: r.resp.localFile], ContentType.APPLICATION_JSON, false, true)

// backward compatible id field
r.resp.druid = r.resp.id
}
} else {
r = webService.post("${url}/ws/speciesList/", json)
}
Expand Down
3 changes: 2 additions & 1 deletion grails-app/views/portal/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
layersServiceUrl: '${config.layersService.url}',
samplingUrl: '${config.sampling.url}',
listsUrl: '${config.lists.url}',
listsUrlUi: '${config.lists.urlUi}',
listsUrlUi: '${config.lists.urlUi + (config.lists.useListWs ? "/#/list/" : "/speciesListItem/list/")}',
listsFacets: ${config.lists.facets},
listTypes: ${(config.lists.listTypes as grails.converters.JSON).toString().encodeAsRaw()},
sandboxUrl: '${config.sandbox.url}',
sandboxServiceUrl: '${config.sandboxService.url}',
sandboxUiUrl: '${config.sandbox.uiUrl}',
Expand Down

0 comments on commit 701b459

Please sign in to comment.