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

232 missing filters #242

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import au.org.ala.names.ws.api.SearchStyle
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

Expand Down Expand Up @@ -135,6 +136,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
Expand All @@ -160,6 +169,9 @@ class SpeciesListController {
formParams.listWkt,
formParams.isBIE,
formParams.isSDS,
formParams.isAuthoritative,
formParams.isThreatened,
formParams.isInvasive,
formParams.isPrivate,
formParams.region,
formParams.authority,
Expand Down
11 changes: 6 additions & 5 deletions grails-app/services/au/org/ala/specieslist/HelperService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,9 @@ 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,
String generalisation, String sdsType, Boolean looseSearch, SearchStyle searchStyle, String [] header, Map vocabs) {
Boolean isBIE, Boolean isSDS, Boolean isAuthoritative, Boolean isThreatened, Boolean isInvasive,
Boolean isPrivate, String region, String authority, String category,
String generalisation, String sdsType, Boolean looseSearch, SearchStyle searchStyle, String[] header, Map vocabs) {
log.debug("Loading species list " + druid + " " + listname + " " + description + " " + listUrl + " " + header + " " + vocabs)
def kvpmap = [:]
addVocab(druid,vocabs,kvpmap)
Expand All @@ -433,10 +434,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
sl.looseSearch = looseSearch
sl.searchStyle = searchStyle
sl.lastUploaded = new Date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -482,7 +482,7 @@ class QueryService {
default: value; break;
}
}

/**
* Constructs a query based on the filters that have been applied in the KVPs etc.
* @param base
Expand Down
33 changes: 28 additions & 5 deletions grails-app/views/speciesList/upload.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,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();
Expand Down Expand Up @@ -390,13 +403,23 @@
<td><label for="isSDS"><g:message code= "speciesList.isSDS.label" default= "Part of the Sensitive Data Service"/></label> </td>
<td><g:checkBox name="isSDS" id="isSDS" checked="${list?.isSDS}"/></td>
</tr>
</g:if>
<tr class="SDSOnly">
<tr>
<td><label for="isAuthoritative"><g:message code= "speciesList.isAuthoritative.label" default= "Authoritative"/></label> </td>
<td><g:checkBox name="isAuthoritative" id="isAuthoritative" checked="${list?.isAuthoritative}"/></td>
</tr>
<tr>
<td><label for="isThreatened"><g:message code= "speciesList.isThreatened.label" default= "Threatened"/></label> </td>
<td><g:checkBox name="isThreatened" id="isThreatened" checked="${list?.isThreatened}"/></td>
</tr>
<tr>
<td><label for="isInvasive"><g:message code= "speciesList.isInvasive.label" default= "Invasive"/></label> </td>
<td><g:checkBox name="isInvasive" id="isInvasive" checked="${list?.isInvasive}"/></td>
</tr>
<td><label>${message(code:'speciesList.region.label', deafult:'Region')}</label></td>
<td>
<g:textField name="sdsRegion" style="width:99%" value="${list?.region}"/>
</td>
</tr>
</g:if>
<tr class="SDSOnly">
<td><label>${message(code:'speciesList.authority.label', deafult:'Authority')}</label></td>
<td>
Expand Down Expand Up @@ -482,4 +505,4 @@
</div> <!-- content div -->
<asset:javascript src="fileupload.js"/>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class HelperServiceSpec extends Specification implements ServiceUnitTest<HelperS

when:
def itemCounts = helperService.loadSpeciesListFromCSV(reader, "Dr1", "listname", null, "description",
"url", "listWkt", false, false, false, "region", "authority", "category", "generalistaion", "sdsType",
"url", "listWkt", false, false, false, false, false, false, "region", "authority", "category", "generalistaion", "sdsType",
false, SearchStyle.STRICT, (String[]) ["Header1", "Header2", "Header3"], [:])

then:
Expand Down Expand Up @@ -189,7 +189,7 @@ class HelperServiceSpec extends Specification implements ServiceUnitTest<HelperS

when:
def itemCounts = helperService.loadSpeciesListFromCSV(reader, "Dr1", "listname", null, "description",
"url", "listWkt", false, false, true, "region", "authority", "category", "generalistaion", "sdsType",
"url", "listWkt", false, false, false, false, false, true, "region", "authority", "category", "generalistaion", "sdsType",
false, SearchStyle.STRICT, (String[]) ["Header1", "scientificname", "Header3"], [:])

then:
Expand Down