Skip to content

Commit

Permalink
Merge branch 'AtlasOfLivingAustralia:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
matsbov authored Apr 3, 2024
2 parents 3332f54 + e952295 commit c7abb4f
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 62 deletions.
38 changes: 15 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
buildscript {
repositories {
mavenLocal()
maven { url "https://nexus.ala.org.au/content/groups/public/" }
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:$webdriverBinariesVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.4.6"
}
version "4.1.0"
group "au.org.ala"
}

plugins {
id "com.gorylenko.gradle-git-properties" version "2.4.1"
}

id "groovy"
id "org.grails.grails-gsp"
id "org.grails.grails-web"
id "com.github.erdi.webdriver-binaries" version "3.0"
id "war"
id "idea"
id "com.bertramlabs.asset-pipeline"
id "application"
id "eclipse"

version "4.0.0"
group "au.org.ala"
id "com.gorylenko.gradle-git-properties" version "2.4.1"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"com.bertramlabs.asset-pipeline"
apply plugin:"org.grails.grails-gsp"
apply plugin:"maven-publish"
id "maven-publish"
}

publishing {
repositories {
Expand Down Expand Up @@ -63,6 +54,7 @@ java {
repositories {
mavenLocal()
maven { url "https://nexus.ala.org.au/content/groups/public/" }
mavenCentral()
maven { url "https://repo.grails.org/grails/core" }
}

Expand Down
111 changes: 77 additions & 34 deletions grails-app/assets/javascripts/species.show.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* rights and limitations under the License.
*/

var IMAGE_FILTER = '&fq=spatiallyValid:true&fq=-user_assertions:50001&fq=-user_assertions:50005'

function showSpeciesPage(traitsTabSet) {
//console.log("Starting show species page");

Expand Down Expand Up @@ -268,7 +266,7 @@ function loadAusTraits() {

$.ajax({url: SHOW_CONF.ausTraitsCountUrl}).done(function (data) {
if (data[0] && data[0]["summary"] && data[0]["AusTraits"] && data[0]["taxon"]) {
let htmlContent = "<span> There are " + data[0]["summary"] + " available for <span class='scientific-name rank-" + SHOW_CONF.rankString + "'><span class='name'>" + data[0]["taxon"] + "</span></span> with data for " + data[0]["AusTraits"] +
let htmlContent = "<span> There are " + data[0]["summary"] + " traits available for <span class='scientific-name rank-" + SHOW_CONF.rankString + "'><span class='name'>" + data[0]["taxon"] + "</span></span> with data for " + data[0]["AusTraits"] +
" further traits in the <a target='_blank' href='" + SHOW_CONF.ausTraitsHomeUrl + "'>AusTraits</a> database. These are accessible via the download CSV button or alternatively the entire database can be accessed at <a target='_blank' href='" + SHOW_CONF.ausTraitsSourceUrl + "'>" + SHOW_CONF.ausTraitsSourceUrl + "</a>. </span>"
$('#traits-description').html(htmlContent);
}
Expand Down Expand Up @@ -327,34 +325,71 @@ function loadDataProviders() {
}

$('.datasetCount').html(datasetCount);

var uidList = []
var facetMap = {}
$.each(data.facetResults[0].fieldResult, function (idx, facetValue) {
if (facetValue.count > 0) {

var uid = facetValue.fq.replace(/data_resource_uid:/, '').replace(/[\\"]*/, '').replace(/[\\"]/, '');
var dataResourceUrl = SHOW_CONF.collectoryUrl + "/public/show/" + uid;
var tableRowPlaceholder = "<tr id='dataset_" + uid + "'></tr>"

$('#data-providers-list tbody').append(tableRowPlaceholder);

var tableRow = "<td><a href='" + dataResourceUrl + "'><span class='data-provider-name'>" + facetValue.label + "</span></a>";

$.ajax({
url: SHOW_CONF.collectoryServiceUrl + "/ws/dataResource/" + uid,
dataType: 'json',
success: function (collectoryData) {
if (collectoryData.provider) {
tableRow += "<br/><small><a href='" + SHOW_CONF.collectoryUrl + '/public/show/' + uid + "'>" + collectoryData.provider.name + "</a></small>";
}
tableRow += "</td>";
tableRow += "<td>" + collectoryData.licenseType + "</td>";
uidList.push(uid)
facetMap[uid] = facetValue
}
});

var queryUrl = uiUrl + "&fq=" + facetValue.fq;
tableRow += "</td><td><a href='" + queryUrl + "'><span class='record-count'>" + facetValue.count + "</span></a></td>"
$('#dataset_' + collectoryData.uid).html(tableRow);
$.post({
url: SHOW_CONF.collectoryServiceUrl + "/ws/find/dataResource",
data: JSON.stringify(uidList),
contentType : 'application/json',
dataType: 'json',
success: function (dataList) {
$.each(dataList, function(idx, d) {
var collectoryData = JSON.parse(d)
var dataResourceUrl = SHOW_CONF.collectoryUrl + "/public/show/" + collectoryData.uid;
var tableRow = "<td><a href='" + dataResourceUrl + "'><span class='data-provider-name'>" + facetMap[collectoryData.uid].label + "</span></a>";

if (collectoryData.provider) {
tableRow += "<br/><small><a href='" + SHOW_CONF.collectoryUrl + '/public/show/' + collectoryData.uid + "'>" + collectoryData.provider.name + "</a></small>";
}
});
tableRow += "</td>";
tableRow += "<td>" + collectoryData.licenseType + "</td>";

var queryUrl = uiUrl + "&fq=" + facetMap[collectoryData.uid].fq;
tableRow += "</td><td><a href='" + queryUrl + "'><span class='record-count'>" + facetMap[collectoryData.uid].count + "</span></a></td>"
$('#dataset_' + collectoryData.uid).html(tableRow);
})
}
});
}).fail(function () {
// fallback to the method used pre collectory 5.1.0
$.each(data.facetResults[0].fieldResult, function (idx, facetValue) {
if (facetValue.count > 0) {
var uid = facetValue.fq.replace(/data_resource_uid:/, '').replace(/[\\"]*/, '').replace(/[\\"]/, '');

var dataResourceUrl = SHOW_CONF.collectoryUrl + "/public/show/" + uid;
var tableRow = "<td><a href='" + dataResourceUrl + "'><span class='data-provider-name'>" + facetValue.label + "</span></a>";

$.ajax({
url: SHOW_CONF.collectoryServiceUrl + "/ws/dataResource/" + uid,
dataType: 'json',
success: function (collectoryData) {
if (collectoryData.provider) {
tableRow += "<br/><small><a href='" + SHOW_CONF.collectoryUrl + '/public/show/' + uid + "'>" + collectoryData.provider.name + "</a></small>";
}
tableRow += "</td>";
tableRow += "<td>" + collectoryData.licenseType + "</td>";

var queryUrl = uiUrl + "&fq=" + facetValue.fq;
tableRow += "</td><td><a href='" + queryUrl + "'><span class='record-count'>" + facetValue.count + "</span></a></td>"
$('#dataset_' + collectoryData.uid).html(tableRow);
}
});
}
})
})
}
});
}
Expand Down Expand Up @@ -427,7 +462,7 @@ function loadIndigenousData() {
});
}

function showWikipediaData(data, testPage) {
function showWikipediaData(data, testPage, targetName) {
var node = $(data)
node.find('[role="note"]').remove()

Expand All @@ -446,7 +481,7 @@ function showWikipediaData(data, testPage) {
var redirectItem = redirect[0].href.replace(/^.*\//, "")
var url = "/externalSite/wikipedia?name=" + encodeURI(redirectItem)
$.ajax({url: url}).done(function (data) {
showWikipediaData(data, testPage)
showWikipediaData(data, testPage, redirectItem)
});
return
}
Expand Down Expand Up @@ -508,7 +543,7 @@ function showWikipediaData(data, testPage) {
$description.css({'display': 'block'});

// set the source of this description
var sourceHtml = "<a href='https://wikipedia.org/wiki/" + encodeURI(SHOW_CONF.scientificName) + "' target='wikipedia'>Wikipedia</a>&nbsp;" + jQuery.i18n.prop("wikipedia.licence.comment")
var sourceHtml = "<a href='https://wikipedia.org/wiki/" + encodeURI(targetName) + "' target='wikipedia'>Wikipedia</a>&nbsp;" + jQuery.i18n.prop("wikipedia.licence.comment")
$description.find(".sourceText").html(sourceHtml);

// hide unused properties of this description
Expand All @@ -532,12 +567,12 @@ function loadExternalSources() {

var url = "/externalSite/wikipedia?name=" + encodeURI(name)
$.ajax({url: url}).done(function (data) {
showWikipediaData(data, false)
showWikipediaData(data, false, name)
});
} else {
var url = "/externalSite/wikipedia?name=" + encodeURI(name)
$.ajax({url: url}).done(function (data) {
showWikipediaData(data, true)
showWikipediaData(data, true, name)
});
}
}
Expand Down Expand Up @@ -643,7 +678,7 @@ function loadOverviewImages() {
var imageIds = SHOW_CONF.preferredImageId.split(',')
$.each(imageIds, function(idx, imageId) {
var prefUrl = SHOW_CONF.biocacheServiceUrl +
'/occurrences/search?q=images:' + imageId + IMAGE_FILTER +
'/occurrences/search?q=images:' + imageId + SHOW_CONF.imageFilter +
'&im=true&facet=off&pageSize=1&start=0';
$.ajax({
url: prefUrl,
Expand All @@ -658,6 +693,7 @@ function loadOverviewImages() {
}
if (data && data.totalRecords > 0) {
record.uuid = data.occurrences[0].uuid;
record.imageMetadata = data.occurrences[0].imageMetadata
}

if (countPreferredImages == 0) {
Expand All @@ -674,7 +710,7 @@ function loadOverviewImages() {
var url = SHOW_CONF.biocacheServiceUrl +
'/occurrences/search?q=lsid:' +
SHOW_CONF.guid +
'&fq=multimedia:"Image"&im=true&facet=off&pageSize=5&start=0' + IMAGE_FILTER;
'&fq=multimedia:"Image"&im=true&facet=off&pageSize=5&start=0' + SHOW_CONF.imageFilter;

$.getJSON(url, function (data) {
if (data && data.totalRecords > 0) {
Expand Down Expand Up @@ -889,7 +925,7 @@ function loadGalleryType(category, start) {
'/occurrences/search?q=lsid:' +
SHOW_CONF.guid +
'&fq=multimedia:"Image"&pageSize=' + pageSize +
'&facet=off&start=' + start + imageCategoryParams[category] + '&im=true' + IMAGE_FILTER;
'&facet=off&start=' + start + imageCategoryParams[category] + '&im=true' + SHOW_CONF.imageFilter;

$.getJSON(url, function (data) {

Expand Down Expand Up @@ -975,17 +1011,24 @@ function getImageTitleFromOccurrence(el) {
briefHtml += ((el.typeStatus) ? ' | ' : br) + el.institutionName;
}

if (el.imageMetadata && el.imageMetadata.length > 0 && el.imageMetadata[0].creator != null) {
if (briefHtml.length > 0) briefHtml += br;
briefHtml += "Photographer: " + el.imageMetadata[0].creator;
} else if (el.imageMetadata && el.imageMetadata.length > 0 && el.imageMetadata[0].rightsHolder != null) {
if (briefHtml.length > 0) briefHtml += br;
briefHtml += "Rights holder: " + el.imageMetadata[0].rightsHolder;
if (el.imageMetadata && el.imageMetadata.length > 0) {
$.each(el.imageMetadata, function (idx, im) {
if (im.imageId == el.image) {
if (im.creator != null) {
if (briefHtml.length > 0) briefHtml += br;
briefHtml += "Photographer: " + im.creator;
} else if (im.rightsHolder != null) {
if (briefHtml.length > 0) briefHtml += br;
briefHtml += "Rights holder: " + im.rightsHolder;
}
}
})
} else if (el.collector) {
if (briefHtml.length > 0) briefHtml += br;
briefHtml += "Supplied by: " + el.collector;
}


return briefHtml;
}

Expand Down
5 changes: 4 additions & 1 deletion grails-app/conf/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ausTraits:
baseURL: http://traitdata.austraits.cloud.edu.au
homeURL: https://austraits.org/
sourceURL: https://doi.org/10.5281/zenodo.3568417
definitionsURL: https://traitecoevo.github.io/austraits.build/articles/trait_definitions.html
definitionsURL: https://w3id.org/APD
alaCitingURL: https://support.ala.org.au/support/solutions/articles/6000261662-citing-the-ala#website
speciesList:
baseURL: https://lists.ala.org.au
Expand Down Expand Up @@ -285,3 +285,6 @@ springcache:
# sitemap proxied and edited from bie-index
sitemap:
enabled: true

# filter applied to occurrence search requests that fetch images for the gallery
imageFilter: '&fq=spatiallyValid:true&fq=-user_assertions:50001&fq=-user_assertions:50005&fq=-duplicate_status:ASSOCIATED&fq=-duplicateType:DIFFERENT_DATASET'
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ExternalSiteController {
*
*/
def proxyAutocomplete = {
URL url = ( "${grailsApplication.config.getProperty("bie.index.url")}/search/auto.json" + params.toQueryString() ).toURL()
URL url = ( "${grailsApplication.config.getProperty("bie.index.url")}/search/auto" + params.toQueryString() ).toURL()
StringBuilder content = new StringBuilder()
BufferedReader bufferedReader

Expand Down
2 changes: 2 additions & 0 deletions grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ idxtype.LAYER=Spatial layer
idxtype.COMMON=Common Name
idxtype.COMMON.formatted={0} Name
idxtype.IDENTIFIER=Species Identifier
idxtype.BIOCOLLECT=Biodiversity Science project
idxtype.SPECIESLIST=Species list

region.Australia=AU
region.Australian\ Government=AU
Expand Down
2 changes: 1 addition & 1 deletion grails-app/services/au/org/ala/bie/BieService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BieService {
if (!guid && guid != "undefined") {
return null
}
def json = webClientService.get(grailsApplication.config.bie.index.url + "/taxon/" + guid.replaceAll(/\s+/,'+'))
def json = webClientService.get(grailsApplication.config.bie.index.url + "/species/" + guid.replaceAll(/\s+/,'+'))
//log.debug "ETC json: " + json
try{
JSON.parse(json)
Expand Down
5 changes: 5 additions & 0 deletions grails-app/views/species/search.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@
<g:if test="${result.content}">
<p>${result.content.trimLength(500)}</p>
</g:if>
<g:if test="${result.image}">
<div class="result-thumbnail">
<img src="${result.image}" alt="">
</div>
</g:if>
</g:elseif>
<g:elseif test="${result.has("acronym") && result.get("acronym")}">
<h4><g:message code="idxtype.${result.idxtype}"/>:
Expand Down
5 changes: 3 additions & 2 deletions grails-app/views/species/show.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<g:else>
<g:set var="tabs" value="${grailsApplication.config.show.tabs.replace('ausTraits':'').split(',')}"/>
</g:else>
<g:set var="jsonLink" value="${grailsApplication.config.bie.index.url}/species/${tc?.taxonConcept?.guid}.json"/>
<g:set var="jsonLink" value="${grailsApplication.config.bie.index.url}/species/${tc?.taxonConcept?.guid}"/>
<g:set var="sciNameFormatted"><bie:formatSciName rankId="${tc?.taxonConcept?.rankID}"
nameFormatted="${tc?.taxonConcept?.nameFormatted}"
nameComplete="${tc?.taxonConcept?.nameComplete}"
Expand Down Expand Up @@ -464,7 +464,8 @@
ausTraitsCountUrl: "${raw(createLink(controller: 'externalSite', action: 'ausTraitsCount', params: [s: tc?.taxonConcept?.nameString ?: '', guid: guid]))}",
ausTraitsHomeUrl: "${grailsApplication.config.ausTraits.homeURL}",
ausTraitsSourceUrl:"${grailsApplication.config.ausTraits.sourceURL}",
showHiddenImages: false
showHiddenImages: false,
imageFilter: "${raw(grailsApplication.config.imageFilter)}"
};

$(function(){
Expand Down

0 comments on commit c7abb4f

Please sign in to comment.