Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLEASE Don't MERGE #1672

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ dependencies {
implementation "io.jsonwebtoken:jjwt-api:0.11.5"
if (!Boolean.valueOf(inplace)) {
implementation "org.grails.plugins:ala-map-plugin:3.0.1"
implementation "org.grails.plugins:ecodata-client-plugin:7.2-SNAPSHOT"
implementation "org.grails.plugins:ecodata-client-plugin:7.3-SNAPSHOT"
}

testCompileOnly "org.grails:grails-test-mixins:3.3.0"
Expand Down
51 changes: 41 additions & 10 deletions grails-app/assets/javascripts/speciesFieldsSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,43 @@ var SpeciesConstraintViewModel = function (o, fieldName) {
self.transients.fieldName = ko.observable(fieldName);
self.transients.bioSearch = ko.observable(fcConfig.speciesSearchUrl);
self.transients.allowedListTypes = [
{id: 'SPECIES_CHARACTERS', name: 'SPECIES_CHARACTERS'},
{id: 'CONSERVATION_LIST', name: 'CONSERVATION_LIST'},
{id: 'SENSITIVE_LIST', name: 'SENSITIVE_LIST'},
{id: 'LOCAL_LIST', name: 'LOCAL_LIST'},
{id: 'COMMON_TRAIT', name: 'COMMON_TRAIT'},
{id: 'COMMON_HABITAT', name: 'COMMON_HABITAT'},
{id: 'TEST', name: 'TEST'},
{id: 'OTHER', name: 'OTHER'}];
{id: 'SPECIES_CHARACTERS', name: 'Species characters'},
{id: 'CONSERVATION_LIST', name: 'Conservation species list'},
{id: 'SENSITIVE_LIST', name: 'Sensitive list'},
{id: 'LOCAL_LIST', name: 'Local checklist'},
{id: 'COMMON_TRAIT', name: 'Traits'},
{id: 'TEST', name: 'Testing List'}
];
self.transients.allowedLicences = [
{
"value": "CC0",
"label": "Creative Commons Zero"
},
{
"value": "CC-BY",
"label": "Creative Commons By Attribution"
},
{
"value": "CC-BY-NC",
"label": "Creative Commons By Attribution-Noncommercial"
},
{
"value": "CC-BY-NC-ND",
"label": "Creative Commons By Attribution-Noncommercial-Noderivatives"
},
{
"value": "CC-BY-NC-SA",
"label": "Creative Commons By Attribution-Noncommercial-Sharealike"
},
{
"value": "CC-BY-ND",
"label": "Creative Commons By Attribution-Noderivatives"
},
{
"value": "CC-BY-SA",
"label": "Creative Commons By Attribution-Sharealike"
}
]

self.transients.showAddSpeciesLists = ko.observable(false);
self.transients.showExistingSpeciesLists = ko.observable(false);
Expand Down Expand Up @@ -206,6 +235,7 @@ var SpeciesConstraintViewModel = function (o, fieldName) {
var jsData = {};
jsData.listName = self.newSpeciesLists.listName();
jsData.listType = self.newSpeciesLists.listType();
jsData.licence = self.newSpeciesLists.licence();
jsData.description = self.newSpeciesLists.description();
jsData.listItems = "";

Expand Down Expand Up @@ -283,6 +313,7 @@ var NewSpeciesListViewModel = function (o) {
self.dataResourceUid = ko.observable(o.dataResourceUid);
self.description = ko.observable(o.description);
self.listType = ko.observable(o.listType);
self.licence = ko.observable(o.licence);
self.allSpecies = ko.observableArray();

self.inputSpeciesViewModel = new SpeciesViewModel({}, fcConfig);
Expand All @@ -309,7 +340,7 @@ var NewSpeciesListViewModel = function (o) {
};

self.transients = {};
self.transients.url = ko.observable(fcConfig.speciesListsServerUrl + "/speciesListItem/list/" + o.dataResourceUid);
self.transients.url = ko.observable(fcConfig.speciesListsServerUrl + "/" + o.dataResourceUid);

};

Expand Down Expand Up @@ -542,7 +573,7 @@ var SpeciesList = function (o) {


self.transients = {};
self.transients.url = ko.observable(fcConfig.speciesListsServerUrl + "/speciesListItem/list/" + o.dataResourceUid);
self.transients.url = ko.observable(fcConfig.speciesListsServerUrl + "/" + o.dataResourceUid);
self.transients.check = ko.observable(false);
self.transients.truncatedListName = ko.computed(function () {
return truncate(self.listName(), 45);
Expand Down
7 changes: 7 additions & 0 deletions grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,15 @@ images:

lists:
baseURL: "https://lists.ala.org.au" # "https://lists-test.ala.org.au/public/speciesLists"
uiBaseURL: "https://lists.ala.org.au"
commonFields: ['rawScientificName', 'matchedName', 'commonName']
facetsToRemoveFromProjectFinderPage: ['projLifecycleStatus']
apiVersion: "v1"

listsFieldMappingV2:
matchedName: "classification.scientificName"
commonName: "classification.vernacularName"
rawScientificName: "scientificName"

merit:
baseURL: "https://fieldcapture-test.ala.org.au"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import org.grails.web.json.JSONObject
import org.springframework.context.MessageSource
import org.springframework.web.multipart.MultipartFile

import static org.apache.http.HttpStatus.SC_BAD_REQUEST
import static org.apache.http.HttpStatus.SC_OK
import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR
import static org.apache.http.HttpStatus.*

@SecurityScheme(name = "auth",
type = SecuritySchemeType.HTTP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ class ProjectActivityController {
}
}
log.debug "values: " + (values as JSON).toString()
def response = speciesService.addSpeciesList(postBody);
def result
if (response?.resp?.druid) {
result = [status: "ok", id: response.resp.druid]
Map response = speciesService.addSpeciesList(postBody);
Map result
if (response) {
result = [status: "ok", id: response.druid]
} else {
result = [status: 'error', error: "Error creating new species lists, please try again later."]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.ala.biocollect.merit

import au.org.ala.biocollect.ProjectActivityService
import au.org.ala.biocollect.merit.SpeciesService
import grails.converters.JSON
import org.apache.http.HttpStatus
import org.apache.poi.ss.usermodel.Workbook
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package au.org.ala.biocollect.merit

import au.org.ala.ecodata.forms.SpeciesListService
import grails.converters.JSON
import org.apache.commons.io.FilenameUtils
import au.org.ala.web.SSO

class ProxyController {

static responseFormats = ['json']
def webService, commonService, projectService
SpeciesService speciesService

Expand All @@ -18,16 +19,20 @@ class ProxyController {
}

def speciesLists() {
def paramString = commonService.buildUrlParamsFromMap(params)
render webService.get("${grailsApplication.config.lists.baseURL}/ws/speciesList${paramString}", false)
respond speciesListService.searchSpeciesList(params.sort, params.max, params.offset, params.guid, params.order, params.searchTerm)
}

def speciesList() {
render webService.get("${grailsApplication.config.lists.baseURL}/ws/speciesList?druid=${params.druid}", false)
SpeciesListService.SpeciesList speciesList = speciesListService.getSpeciesListMetadata(params.druid)
// it is possible for old species list to return list of species list when druid is not found
if (!speciesList.isValid())
speciesList = null

respond speciesList
}

def speciesItemsForList() {
render webService.get("${grailsApplication.config.lists.baseURL}/ws/speciesListItems/${params.druid}?includeKVP=true", false)
respond speciesListService.allSpeciesListItems(params.druid)
}

def intersect(){
Expand All @@ -43,17 +48,16 @@ class ProxyController {
}

def speciesProfile(String id) {
Map result = speciesService.getSpeciesDetailsForTaxonId(id);
Map result = speciesService.getSpeciesDetailsForTaxonId(id)
render result
}

@SSO
def speciesListPost() {
def postBody = request.JSON
def druidParam = (postBody.druid) ? "/${postBody.druid}" : "" // URL part
def postResponse = webService.doPost("${grailsApplication.config.lists.baseURL}/ws/speciesListPost${druidParam}", postBody)
if (postResponse.resp && postResponse.resp.druid) {
def druid = postResponse.resp?.druid?:druid
def postResponse = speciesService.addSpeciesList(postBody)
String druid = postResponse?.druid
if (druid) {
postBody.druid = druid
def result = projectService.update(postBody.projectId, [listId: druid, listReason: postBody.reason])

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package au.org.ala.biocollect.merit

import au.org.ala.ecodata.forms.SpeciesListService
import grails.converters.JSON
import org.apache.commons.lang.StringUtils
import org.springframework.http.HttpStatus

class SearchController {
static responseFormats = ['json']
def searchService, webService, speciesService, commonService, projectActivityService
SpeciesListService speciesListService
grails.core.GrailsApplication grailsApplication

/**
Expand All @@ -24,11 +28,11 @@ class SearchController {
* @return
*/
def species(String q, Integer limit) {
render speciesService.searchForSpecies(q, limit, params.listId) as JSON
respond speciesService.searchForSpecies(q, limit, params.listId)
}

def searchSpeciesList(String sort, Integer max, Integer offset, String guid, String order, String searchTerm){
render speciesService.searchSpeciesList(sort, max, offset, guid, order, searchTerm) as JSON
respond speciesListService.searchSpeciesList(sort, max, offset, guid, order, searchTerm)
}

/**
Expand All @@ -54,25 +58,11 @@ class SearchController {
}

def getCommonKeys(){
try {
if(params.druid){
def resp = webService.getJson("${grailsApplication.config.lists.baseURL}/ws/listCommonKeys?druid=${params.druid}")?:[]
if(resp instanceof List){
if(grailsApplication.config.lists.commonFields){
resp?.addAll(grailsApplication.config.lists.commonFields)
}

resp.sort()
render text: resp as JSON, contentType: 'application/json'
} else {
render text: resp.error, status: resp.statusCode?:HttpStatus.INTERNAL_SERVER_ERROR
}
} else {
render status: HttpStatus.BAD_REQUEST, text: 'Parameter druid is required.'
}
} catch (Exception ex){
log.error (ex.message, ex)
render status: HttpStatus.INTERNAL_SERVER_ERROR, text: "An error occurred - ${ex.message}"
if (params.druid) {
List commonFields = speciesListService.getCommonKeys(params.druid)
respond commonFields
} else {
render status: HttpStatus.BAD_REQUEST, text: 'Parameter druid is required.'
}
}

Expand All @@ -89,15 +79,14 @@ class SearchController {
* Example: /search/getSpeciesTranslation?id=urn:lsid:biodiversity.org.au:afd.taxon:4136b6d0-b5be-45d4-8323-e96e03d94218&listId=dr8016
* */
def getSpeciesTranslation(String id, String listId) {
def items = webService.getJson("${grailsApplication.config.lists.baseURL}/ws/speciesListItems/${listId}?includeKVP=true")?:[]
def kvp = [:]
if(items instanceof List){
items.each {
if("${it.lsid}" == "${id}") {
kvp = it.kvpValues
}
SpeciesListService.SpeciesListItem items = speciesListService.allSpeciesListItems(listId) ?: []
List kvp = []
items.each {
if (it.lsid == id) {
kvp = it.kvpValues
}
}
render kvp as JSON

respond kvp
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package au.org.ala.biocollect.merit

import au.org.ala.biocollect.merit.SpeciesService
import grails.converters.JSON
import org.apache.http.HttpStatus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package au.org.ala.biocollect.merit
import au.org.ala.biocollect.DateUtils
import au.org.ala.biocollect.ProjectActivityService
import au.org.ala.biocollect.UtilService
import au.org.ala.biocollect.merit.SpeciesService
import grails.core.GrailsApplication
import org.joda.time.DateTime
import org.joda.time.Period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package au.org.ala.biocollect.merit
import au.org.ala.biocollect.EmailService
import au.org.ala.biocollect.OrganisationService
import au.org.ala.biocollect.merit.hub.HubSettings
import au.org.ala.biocollect.merit.SpeciesService
import grails.converters.JSON
import org.springframework.context.MessageSource
import au.org.ala.web.UserDetails
Expand Down
Loading
Loading