From 3f30deb0c22582da05023d002413d04572795c89 Mon Sep 17 00:00:00 2001 From: Adam Collins Date: Thu, 9 Feb 2023 13:31:44 +1000 Subject: [PATCH 1/2] #231 fix list reupload --- .../specieslist/SpeciesListController.groovy | 12 +++++++ .../org/ala/specieslist/HelperService.groovy | 9 ++--- grails-app/views/speciesList/upload.gsp | 33 ++++++++++++++++--- .../service/HelperServiceSpec.groovy | 4 +-- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/grails-app/controllers/au/org/ala/specieslist/SpeciesListController.groovy b/grails-app/controllers/au/org/ala/specieslist/SpeciesListController.groovy index 947735166..8c35652cd 100644 --- a/grails-app/controllers/au/org/ala/specieslist/SpeciesListController.groovy +++ b/grails-app/controllers/au/org/ala/specieslist/SpeciesListController.groovy @@ -18,6 +18,7 @@ import au.org.ala.web.AuthService import com.opencsv.CSVReader import grails.converters.JSON import grails.gorm.transactions.Transactional +import org.apache.commons.io.filefilter.FalseFileFilter import org.grails.web.json.JSONObject import org.springframework.web.multipart.MultipartHttpServletRequest @@ -133,6 +134,14 @@ class SpeciesListController { formParams.speciesListName ) + // default all lists to isAuthoritative = false: it is an admin task to determine whether a list is authoritative or not + if (!request.isUserInRole("ROLE_ADMIN")) { + def list = SpeciesList.findByDataResourceUid(params.id) + formParams.isAuthoritative = list?.isAuthoritative || Boolean.FALSE + formParams.isThreatened = list?.isAuthoritative || Boolean.FALSE + formParams.isInvasive = list?.isAuthoritative || Boolean.FALSE + } + if(druid) { log.debug("Loading species list " + formParams.speciesListName) def vocabs = formParams.findAll { it.key.startsWith("vocab") && it.value } //map of vocabs @@ -158,6 +167,9 @@ class SpeciesListController { formParams.listWkt, formParams.isBIE, formParams.isSDS, + formParams.isAuthoritative, + formParams.isThreatened, + formParams.isInvasive, formParams.isPrivate, formParams.region, formParams.authority, diff --git a/grails-app/services/au/org/ala/specieslist/HelperService.groovy b/grails-app/services/au/org/ala/specieslist/HelperService.groovy index b8d42e976..34df54936 100644 --- a/grails-app/services/au/org/ala/specieslist/HelperService.groovy +++ b/grails-app/services/au/org/ala/specieslist/HelperService.groovy @@ -523,7 +523,8 @@ class HelperService { } def loadSpeciesListFromCSV(CSVReader reader, druid, listname, ListType listType, description, listUrl, listWkt, - Boolean isBIE, Boolean isSDS, Boolean isPrivate, String region, String authority, String category, + Boolean isBIE, Boolean isSDS, Boolean isAuthoritative, Boolean isThreatened, Boolean isInvasive, + Boolean isPrivate, String region, String authority, String category, String generalisation, String sdsType, String[] header, Map vocabs) { log.debug("Loading species list " + druid + " " + listname + " " + description + " " + listUrl + " " + header + " " + vocabs) def kvpmap = [:] @@ -550,10 +551,10 @@ class HelperService { sl.sdsType = sdsType sl.isBIE = isBIE sl.isSDS = isSDS + sl.isAuthoritative = isAuthoritative + sl.isThreatened = isThreatened + sl.isInvasive = isInvasive sl.isPrivate = isPrivate - sl.isAuthoritative = false // default all new lists to isAuthoritative = false: it is an admin task to determine whether a list is authoritative or not - sl.isInvasive = false - sl.isThreatened = false String [] nextLine boolean checkedHeader = false Map termIdx = getTermAndIndex(header) diff --git a/grails-app/views/speciesList/upload.gsp b/grails-app/views/speciesList/upload.gsp index d7f97b5c1..1e380c822 100644 --- a/grails-app/views/speciesList/upload.gsp +++ b/grails-app/views/speciesList/upload.gsp @@ -168,13 +168,26 @@ if($('#isBIE').length>0){ map['isBIE']=$('#isBIE').is(':checked'); } + //admin values + if ($('#isAuthoritative').length>0) { + map['isAuthoritative']=$('#isAuthoritative').is(':checked'); + } + if ($('#isThreatened').length>0) { + map['isThreatened']=$('#isThreatened').is(':checked'); + } + if ($('#isInvasive').length>0) { + map['isInvasive']=$('#isInvasive').is(':checked'); + } + if ($('#sdsRegion').length>0) { + map['region'] = $('#sdsRegion').val(); + } //if the isSDS checkbox exists add the value if($('#isSDS').length>0){ map['isSDS']=$('#isSDS').is(':checked'); var ischecked=$('#isSDS').is(':checked'); if(ischecked){ //add the SDS only properties - map['region'] = $('#sdsRegion').val(); + //SDS region is also part of admin values map['authority'] = $('#authority').val(); map['category'] = $('#category').val(); map['generalisation'] = $('#generalisation').val(); @@ -387,13 +400,23 @@ - - + + + + + + + + + + + + - + @@ -468,4 +491,4 @@ - \ No newline at end of file + diff --git a/src/test/groovy/au/org/ala/specieslist/service/HelperServiceSpec.groovy b/src/test/groovy/au/org/ala/specieslist/service/HelperServiceSpec.groovy index c91742ad5..de8e16e5c 100644 --- a/src/test/groovy/au/org/ala/specieslist/service/HelperServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/specieslist/service/HelperServiceSpec.groovy @@ -119,7 +119,7 @@ class HelperServiceSpec extends Specification implements ServiceUnitTest Date: Thu, 9 Feb 2023 13:44:02 +1000 Subject: [PATCH 2/2] #231 fix missing filters --- .../services/au/org/ala/specieslist/QueryService.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grails-app/services/au/org/ala/specieslist/QueryService.groovy b/grails-app/services/au/org/ala/specieslist/QueryService.groovy index afcd73b1a..e260f63be 100644 --- a/grails-app/services/au/org/ala/specieslist/QueryService.groovy +++ b/grails-app/services/au/org/ala/specieslist/QueryService.groovy @@ -243,7 +243,7 @@ class QueryService { } def getTagFacetCounts(params, List itemIds){ - getTypeFacetCounts(params, false, itemIds) + getTagFacetCounts(params, false, itemIds) } def getTypeFacetCounts(params, boolean hidePrivateLists, List itemIds) { @@ -476,7 +476,7 @@ class QueryService { default: value; break; } } - + /** * Constructs a query based on the filters that have been applied in the KVPs etc. * @param base