Date: Tue, 1 Dec 2020 13:06:00 +1100
Subject: [PATCH 04/22] AtlasOfLivingAustralia/DataQuality#187 Add duplicate
reason to duplicate record assertion
---
grails-app/assets/javascripts/show.js | 42 ++++++++++++++-----
.../biocache/hubs/AssertionsController.groovy | 7 +++-
grails-app/i18n/messages_en.properties | 3 ++
.../biocache/hubs/WebServicesService.groovy | 4 +-
.../views/occurrence/_recordSidebar.gsp | 9 ++++
5 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 2264ddac2..1c3281c9a 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -39,50 +39,67 @@ $(document).ready(function() {
}, 1000);
// alert("Copied");
});
+ var recordIdValid = false;
+ function validateIssueForm() {
+ var issueCode = $('#issue').val();
+ var relatedRecordReason = $('#relatedRecordReason').val();
+ if (issueCode == '20020') {
+ return recordIdValid && relatedRecordReason;
+ }
+ return true;
+ }
+ function setIssueFormButtonState() {
+ $('#issueForm input[type=submit]').prop('disabled', !validateIssueForm());
+ }
$('#issue').on('change', function(e) {
var $this = $(this);
var val = $this.val();
var $submit = $('#issueForm input[type=submit]');
- var $p = $('#related-record-p');
+ var $p = $('#related-record-p, #related-record-reason-p');
if (val == '20020') {
$('#relatedRecordId').val('');
- $submit.prop('disabled', true);
+ recordIdValid = false;
$p.show();
} else {
- $submit.prop('disabled', false);
$p.hide();
$('#related-record-id-not-found').hide();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
}
+ setIssueFormButtonState();
});
+ $('#relatedRecordReason').on('change', function(e) {
+ setIssueFormButtonState();
+ })
$('#relatedRecordId').on('change', function(e) {
var $this = $(this);
var $submit = $('#issueForm input[type=submit]');
var val = $this.val().trim();
if (val == OCC_REC.recordUuid) {
alert("You can't mark this record as a duplicate of itself!");
+ recordIdValid = false;
} else if (val == '') {
$('#related-record-id-not-found').hide();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
- $submit.prop('disabled', true);
+ recordIdValid = false;
} else {
-
$('#related-record-id-loading').show();
- $.get( OCC_REC.contextPath + "/occurrence/exists/" + val, function(data) {
+ $.get( OCC_REC.contextPath + "/occurrence/exists/" + val).success(function(data) {
$('#related-record-id-not-found').hide();
$('#related-record-id-found').text(data).show();
$('#related-record-id-loading').hide();
- $submit.prop('disabled', false);
+ recordIdValid = true;
}).error(function () {
$('#related-record-id-not-found').show();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
- $submit.prop('disabled', true);
+ recordIdValid = false;
+ }).always(function() {
+ setIssueFormButtonState();
});
}
-
+ setIssueFormButtonState();
});
jQuery.i18n.properties({
@@ -103,6 +120,7 @@ $(document).ready(function() {
var comment = $("#issueComment").val();
var code = $("#issue").val();
var relatedRecordId = $('#relatedRecordId').val();
+ var relatedRecordReason = $('#relatedRecordReason').val();
var userDisplayName = OCC_REC.userDisplayName //'${userDisplayName}';
var recordUuid = OCC_REC.recordUuid //'${ala:escapeJS(record.raw.rowKey)}';
if(code!=""){
@@ -126,6 +144,9 @@ $(document).ready(function() {
} else if (code == '20020' && !relatedRecordId) {
alert("You must provide a duplicate record id to mark this as a duplicate");
return;
+ } else if (code == '20020' && !relatedRecordReason) {
+ alert("You must select a reason to mark this record as a duplicate");
+ return;
} else if (code == '20020' && relatedRecordId == recordUuid) {
alert("You can't mark a record as a duplicate of itself");
return;
@@ -139,7 +160,8 @@ $(document).ready(function() {
userAssertionStatus: 'Open issue',
userId: OCC_REC.userId,
userDisplayName: userDisplayName,
- relatedRecordId: relatedRecordId
+ relatedRecordId: relatedRecordId,
+ relatedRecordReason: relatedRecordReason,
},
function (data) {
$('#assertionSubmitProgress').css({'display': 'none'});
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/AssertionsController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/AssertionsController.groovy
index 8da413570..58cc5690f 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/AssertionsController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/AssertionsController.groovy
@@ -41,6 +41,7 @@ class AssertionsController {
String userAssertionStatus = params.userAssertionStatus?: ""
String assertionUuid = params.assertionUuid?: ""
String relatedRecordId = params.relatedRecordId ?: ''
+ String relatedRecordReason = params.relatedRecordReason ?: ''
UserDetails userDetails = authService?.userDetails() // will return null if not available/not logged in
if (recordUuid && code && userDetails) {
@@ -49,8 +50,12 @@ class AssertionsController {
render(status: 400, text: 'Duplicate record id not provided')
}
+ if (code == '20020' && !relatedRecordReason) {
+ render(status: 400, text: 'Duplicate record reason not provided')
+ }
+
log.info("Adding assertion to UUID: ${recordUuid}, code: ${code}, comment: ${comment}, userAssertionStatus: ${userAssertionStatus}, userId: ${userDetails.userId}, userEmail: ${userDetails.email}")
- Map postResponse = webServicesService.addAssertion(recordUuid, code, comment, userDetails.userId, userDetails.displayName, userAssertionStatus, assertionUuid, relatedRecordId)
+ Map postResponse = webServicesService.addAssertion(recordUuid, code, comment, userDetails.userId, userDetails.displayName, userAssertionStatus, assertionUuid, relatedRecordId, relatedRecordReason)
if (postResponse.statusCode == 201) {
log.info("Called REST service. Assertion should be added" )
diff --git a/grails-app/i18n/messages_en.properties b/grails-app/i18n/messages_en.properties
index fe696efc8..99282a06e 100644
--- a/grails-app/i18n/messages_en.properties
+++ b/grails-app/i18n/messages_en.properties
@@ -1149,3 +1149,6 @@ dq.warning.dataprofile.content.line1 = Search results are now filtered by defaul
dq.warning.dataprofile.buttonleft.text = Learn More
dq.warning.dataprofile.buttonright.text = Got it
+related.record.reason.sameoccurence=Same occurence
+related.record.reason.tissuesample=Tissue sample
+related.record.reason.splitspecimen=Split specimen
\ No newline at end of file
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index ccaba2c43..1dcb6b42c 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -182,7 +182,8 @@ class WebServicesService {
* @return Map postResponse
*/
Map addAssertion(String recordUuid, String code, String comment, String userId, String userDisplayName,
- String userAssertionStatus, String assertionUuid, String relatedRecordId) {
+ String userAssertionStatus, String assertionUuid, String relatedRecordId,
+ String relatedRecordReason) {
Map postBody = [
recordUuid: recordUuid,
code: code,
@@ -190,6 +191,7 @@ class WebServicesService {
userAssertionStatus: userAssertionStatus,
assertionUuid: assertionUuid,
relatedRecordId: relatedRecordId,
+ relatedRecordReason: relatedRecordReason,
userId: userId,
userDisplayName: userDisplayName,
apiKey: grailsApplication.config.biocache.apiKey
diff --git a/grails-app/views/occurrence/_recordSidebar.gsp b/grails-app/views/occurrence/_recordSidebar.gsp
index 6ef5c65ff..a1c016e80 100644
--- a/grails-app/views/occurrence/_recordSidebar.gsp
+++ b/grails-app/views/occurrence/_recordSidebar.gsp
@@ -334,6 +334,15 @@
The record id can be found.
+
+
+
+
From 1e4bd595fcba16a138e1b57eb204005bc5bc568f Mon Sep 17 00:00:00 2001
From: Simon Bear
Date: Tue, 1 Dec 2020 13:07:25 +1100
Subject: [PATCH 05/22] AtlasOfLivingAustralia/DataQuality#208 Add duplicate
reason display
---
grails-app/assets/javascripts/show.js | 4 ++++
grails-app/views/occurrence/show.gsp | 1 +
2 files changed, 5 insertions(+)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 1c3281c9a..2e93fb8eb 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -447,6 +447,10 @@ function refreshUserAnnotations(){
$clone.find('.related-record-span-default').show();
}
}
+ if (userAssertion.relatedRecordReason) {
+ $clone.find('.related-record-reason').show();
+ $clone.find('.related-record-reason-span').text(jQuery.i18n.prop('related.record.reason.'+userAssertion.relatedRecordReason));
+ }
if (userAssertion.userRole != null) {
$clone.find('.userRole').text(', ' + userAssertion.userRole);
}
diff --git a/grails-app/views/occurrence/show.gsp b/grails-app/views/occurrence/show.gsp
index faae37ddb..e385bf0da 100644
--- a/grails-app/views/occurrence/show.gsp
+++ b/grails-app/views/occurrence/show.gsp
@@ -700,6 +700,7 @@
-
-
+
From 34c49b7b1da53e1d724c868624ff0d3474fe37b8 Mon Sep 17 00:00:00 2001
From: Simon Bear
Date: Tue, 1 Dec 2020 14:38:03 +1100
Subject: [PATCH 06/22] AtlasOfLivingAustralia/DataQuality#187 Lower logging
level for exists action
---
.../au/org/ala/biocache/hubs/OccurrenceController.groovy | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index a0a527ed5..bcfa7f21d 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -608,7 +608,7 @@ class OccurrenceController {
def exists(String id) {
def record = webServicesService.getRecord(id, false)
if (record.keySet()) {
- log.error("{}", record)
+ log.trace("{}", record)
render text: record?.processed?.classification?.vernacularName ?: record?.raw?.classification?.vernacularName ?: record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName
} else {
render status: SC_NOT_FOUND, text: ''
From cf43901c08b345cf1c14b2e68607c5483049e356 Mon Sep 17 00:00:00 2001
From: Simon Bear
Date: Fri, 4 Dec 2020 10:54:36 +1100
Subject: [PATCH 07/22] AtlasOfLivingAustralia/DataQuality#214 preview record
when flagging a duplicate record
---
grails-app/assets/javascripts/show.js | 3 ++-
.../au/org/ala/biocache/hubs/OccurrenceController.groovy | 3 ++-
grails-app/i18n/messages_en.properties | 2 ++
grails-app/views/occurrence/_recordSidebar.gsp | 6 +++++-
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 2e93fb8eb..6ebac7dc4 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -87,7 +87,8 @@ $(document).ready(function() {
$('#related-record-id-loading').show();
$.get( OCC_REC.contextPath + "/occurrence/exists/" + val).success(function(data) {
$('#related-record-id-not-found').hide();
- $('#related-record-id-found').text(data).show();
+ $('#related-record-id-found').show();
+ $('#related-record-id-found-other').text(data);
$('#related-record-id-loading').hide();
recordIdValid = true;
}).error(function () {
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index bcfa7f21d..4452b5db5 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -609,7 +609,8 @@ class OccurrenceController {
def record = webServicesService.getRecord(id, false)
if (record.keySet()) {
log.trace("{}", record)
- render text: record?.processed?.classification?.vernacularName ?: record?.raw?.classification?.vernacularName ?: record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName
+ def result = "${record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName ?: ''}, ${record?.processed?.location?.stateProvince ?: record?.raw?.location?.stateProvince ?: ''}, ${record?.processed?.location?.decimalLongitude ?: record?.raw?.location?.decimalLongitude ?: ''}, ${record?.processed?.location?.decimalLatitude ?: record?.raw?.location?.decimalLatitude ?: ''}, ${record?.processed?.event?.eventDate ?: record?.raw?.event?.eventDate ?: ''}"
+ render text: result
} else {
render status: SC_NOT_FOUND, text: ''
}
diff --git a/grails-app/i18n/messages_en.properties b/grails-app/i18n/messages_en.properties
index 99282a06e..839283691 100644
--- a/grails-app/i18n/messages_en.properties
+++ b/grails-app/i18n/messages_en.properties
@@ -134,6 +134,8 @@ show.loginorflag.div02.label = You are logged in as
show.issueform.label01 = Issue type:
show.issueform.label02 = Comment:
show.issueform.label03 = Duplicate Record ID:
+show.issueform.relatedrecord.found.this = You are indicating this record (the one you are viewing):
+show.issueform.relatedrecord.found.other = is a duplicate of this record (the id you provided):
show.issueform.button.submit = Submit
show.issueform.button.cancel = Cancel
show.issueform.button.close = Close
diff --git a/grails-app/views/occurrence/_recordSidebar.gsp b/grails-app/views/occurrence/_recordSidebar.gsp
index a1c016e80..de47dce47 100644
--- a/grails-app/views/occurrence/_recordSidebar.gsp
+++ b/grails-app/views/occurrence/_recordSidebar.gsp
@@ -331,7 +331,11 @@
The record id can't be found.
- The record id can be found.
+
+ ${record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName ?: ''}, ${record?.processed?.location?.stateProvince ?: record?.raw?.location?.stateProvince ?: ''}, ${record?.processed?.location?.decimalLongitude ?: record?.raw?.location?.decimalLongitude ?: ''}, ${record?.processed?.location?.decimalLatitude ?: record?.raw?.location?.decimalLatitude ?: ''}, ${record?.processed?.event?.eventDate ?: record?.raw?.event?.eventDate ?: ''}
+
+
+
From b313e76b75894f3dcd3fe9196a91cccfba98ff25 Mon Sep 17 00:00:00 2001
From: Simon Bear
Date: Mon, 14 Dec 2020 17:46:20 +1100
Subject: [PATCH 08/22] AtlasOfLivingAustralia/DataQuality#187 Review feedback
---
grails-app/i18n/messages_en.properties | 1 +
grails-app/views/occurrence/_recordSidebar.gsp | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/grails-app/i18n/messages_en.properties b/grails-app/i18n/messages_en.properties
index 839283691..1c8d74379 100644
--- a/grails-app/i18n/messages_en.properties
+++ b/grails-app/i18n/messages_en.properties
@@ -134,6 +134,7 @@ show.loginorflag.div02.label = You are logged in as
show.issueform.label01 = Issue type:
show.issueform.label02 = Comment:
show.issueform.label03 = Duplicate Record ID:
+show.issueform.label04 = Duplicate Reason:
show.issueform.relatedrecord.found.this = You are indicating this record (the one you are viewing):
show.issueform.relatedrecord.found.other = is a duplicate of this record (the id you provided):
show.issueform.button.submit = Submit
diff --git a/grails-app/views/occurrence/_recordSidebar.gsp b/grails-app/views/occurrence/_recordSidebar.gsp
index de47dce47..36479f7f2 100644
--- a/grails-app/views/occurrence/_recordSidebar.gsp
+++ b/grails-app/views/occurrence/_recordSidebar.gsp
@@ -339,8 +339,8 @@
-
-
+
+
+
+
+
" class="btn btn-primary" />
" class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
diff --git a/grails-app/views/occurrence/show.gsp b/grails-app/views/occurrence/show.gsp
index e385bf0da..e85deb52f 100644
--- a/grails-app/views/occurrence/show.gsp
+++ b/grails-app/views/occurrence/show.gsp
@@ -59,7 +59,8 @@
status="s">'${sds}': '${grailsApplication.config.sensitiveDatasets[sds]}'${s < (sensitiveDatasets.size() - 1) ? ',' : ''}
},
- hasGoogleKey: ${grailsApplication.config.google.apikey as Boolean}
+ hasGoogleKey: ${grailsApplication.config.google.apikey as Boolean},
+ alertName: "${grailsApplication.config.myannotation.name}"
}
// Google charts
From e4c4e1dbda9a9e617becd277bf41fa2af68673a8 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Mon, 21 Dec 2020 10:41:22 +1100
Subject: [PATCH 10/22] removed unused param from processUserFQInteraction
---
.../au/org/ala/biocache/hubs/OccurrenceController.groovy | 2 +-
.../au/org/ala/biocache/hubs/PostProcessingService.groovy | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index b31c993f6..e7106e02a 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -168,7 +168,7 @@ class OccurrenceController {
def groupedEnabledFilters = time("get grouped enabled filters") { qualityService.getGroupedEnabledFilters(requestParams.qualityProfile) }
def qualityFilterDescriptionsByLabel = groupedEnabledFilters.collectEntries {[(it.key) : it.value*.description.join(' and ')] }
- def (fqInteract, dqInteract, UserFQColors, DQColors) = time("process user fq interactions") { postProcessingService.processUserFQInteraction(requestParams, searchResults?.activeFacetObj) }
+ def (fqInteract, dqInteract, UserFQColors, DQColors) = time("process user fq interactions") { postProcessingService.processUserFQInteraction(requestParams) }
def messagePropertiesFile = time("message properties file") { webServicesService.getMessagesPropertiesFile() }
def assertionCodeMap = time("assertionCodeMap") { webServicesService.getAssertionCodeMap() }
diff --git a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
index 657c784ea..b3e3e7452 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
@@ -504,7 +504,7 @@ class PostProcessingService {
layerObjects
}
- def processUserFQInteraction(SpatialSearchRequestParams requestParams, activeFacetObj) {
+ def processUserFQInteraction(SpatialSearchRequestParams requestParams) {
def disabled = requestParams.disableQualityFilter as Set
// map from category label to filter names
From 1feef6fafbf557771c40bcc363fa7eda81469e92 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Tue, 22 Dec 2020 16:02:37 +1100
Subject: [PATCH 11/22] updated biocache-hubs to use dq-client 1.1.0 with user
profile feature
---
build.gradle | 2 +-
.../biocache/hubs/OccurrenceController.groovy | 4 +--
.../ala/biocache/hubs/QualityService.groovy | 26 +++++++++++--------
.../biocache/hubs/WebServicesService.groovy | 4 +--
4 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/build.gradle b/build.gradle
index 99c9346ae..d92a43007 100644
--- a/build.gradle
+++ b/build.gradle
@@ -76,7 +76,7 @@ dependencies {
//compile 'com.google.guava:guava:19.0' // replaces ehcache
compile "com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1"
- compile "au.org.ala:data-quality-filter-service-client:1.0.0", noCache
+ compile "au.org.ala:data-quality-filter-service-client:1.1.0", noCache
//plugins
//compile 'org.grails.plugins:cache-ehcache:3.0.0.M1'
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index e7106e02a..06ab92425 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -65,7 +65,7 @@ class OccurrenceController {
def list(SpatialSearchRequestParams requestParams) {
def start = System.currentTimeMillis()
- def activeProfile = time("active profile") { qualityService.activeProfile(requestParams.qualityProfile) }
+ def activeProfile = time("active profile") { qualityService.activeProfile(requestParams.qualityProfile, authService?.getUserId()) }
normaliseRequestParams(requestParams)
@@ -217,7 +217,7 @@ class OccurrenceController {
UserFQColors: UserFQColors,
DQColors: DQColors,
activeProfile: activeProfile,
- qualityProfiles: time("findAllEnabledProfiles") { qualityService.findAllEnabledProfiles(true) },
+ qualityProfiles: time("findAllEnabledProfiles") { qualityService.findAllEnabledProfiles(true, authService?.getUserId()) },
inverseFilters: inverseFilters
]
diff --git a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
index e8c5d1833..38471dd94 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
@@ -25,6 +25,9 @@ class QualityService {
@Value('${dataquality.baseUrl}')
def dataQualityBaseUrl
+ @Value('${dataquality.apiKey}')
+ String dataQualityAPIKey
+
@Value('${dataquality.recordCountCacheSpec}')
String recordCountCacheSpec
@@ -39,6 +42,7 @@ class QualityService {
def init() {
if (dataQualityEnabled) {
def apiClient = new ApiClient()
+ apiClient.setApiKey(dataQualityAPIKey)
apiClient.adapterBuilder.baseUrl(dataQualityBaseUrl)
apiClient.okBuilder.addInterceptor { chain ->
def request = chain.request().newBuilder().addHeader('User-Agent', "${grailsApplication.config.info.app.name}/${grailsApplication.config.info.app.version}").build()
@@ -50,9 +54,9 @@ class QualityService {
recordCountCache = CacheBuilder.from(recordCountCacheSpec).build { webServicesService.fullTextSearch(it)?.totalRecords }
}
- Map getEnabledFiltersByLabel(String profileName) {
+ Map getEnabledFiltersByLabel(String profileName, userId = null) {
if (dataQualityEnabled) {
- return responseOrThrow(api.getEnabledFiltersByLabel(profileName))
+ return responseOrThrow(api.getEnabledFiltersByLabel(profileName, userId))
} else {
return [:]
}
@@ -66,26 +70,26 @@ class QualityService {
}
}
- Map> getGroupedEnabledFilters(String profileName) {
+ Map> getGroupedEnabledFilters(String profileName, String userId = null) {
if (dataQualityEnabled) {
- return responseOrThrow(api.getGroupedEnabledFilters(profileName))
+ return responseOrThrow(api.getGroupedEnabledFilters(profileName, userId))
} else {
return [:]
}
-
}
- List findAllEnabledCategories(String profileName) {
+ List findAllEnabledCategories(String profileName, String userId = null) {
if (dataQualityEnabled) {
- return responseOrThrow(api.findAllEnabledCategories(profileName))
+ return responseOrThrow(api.findAllEnabledCategories(profileName, userId))
} else {
return []
}
}
- QualityProfile activeProfile(String profileName) {
+ QualityProfile activeProfile(String profileName, String userId = null) {
if (dataQualityEnabled) {
- return responseOrThrow(api.activeProfile(profileName))
+ QualityProfile qp = responseOrThrow(api.activeProfile(profileName, userId))
+ return qp
} else {
return null
}
@@ -115,9 +119,9 @@ class QualityService {
}
}
- List findAllEnabledProfiles(boolean enabled) {
+ List findAllEnabledProfiles(boolean enabled, String userId = null) {
if (dataQualityEnabled) {
- return responseOrThrow(dataProfilesApi.dataProfiles(null, null, null, null, enabled, null, null))
+ return responseOrThrow(dataProfilesApi.dataProfiles(null, null, null, null, enabled, null, null, userId))
} else {
return []
}
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index 7034056c9..9bfb9f5ae 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -29,7 +29,7 @@ class WebServicesService {
public static final String ENVIRONMENTAL = "Environmental"
public static final String CONTEXTUAL = "Contextual"
- def grailsApplication, facetsCacheServiceBean
+ def grailsApplication, facetsCacheServiceBean, authService
QualityService qualityService
@Value('${dataquality.enabled}')
@@ -665,7 +665,7 @@ class WebServicesService {
def populateProfile(requestParams) {
// force set the profile if none provided
if (dataQualityEnabled && !requestParams.qualityProfile && !requestParams.disableAllQualityFilters) {
- def activeProfile = qualityService.activeProfile(requestParams.qualityProfile)
+ def activeProfile = qualityService.activeProfile(requestParams.qualityProfile, authService?.getUserId())
requestParams.qualityProfile = activeProfile?.shortName
}
}
From a787499f537fb8a4dd1170987508928734801948 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Wed, 23 Dec 2020 16:47:28 +1100
Subject: [PATCH 12/22] changes needed for my annotation changes on alerts side
---
grails-app/assets/javascripts/show.js | 31 ++++++-------------
.../hubs/BiocacheHubsUrlMappings.groovy | 4 +--
.../biocache/hubs/OccurrenceController.groovy | 10 +++---
.../biocache/hubs/WebServicesService.groovy | 8 ++---
4 files changed, 20 insertions(+), 33 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 03597f2ce..5906a7327 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -165,14 +165,14 @@ $(document).ready(function() {
},
function (data) {
// when add assertion succeeds, we update alert settings
- if (myAnnotationQueryId) {
+ if (myAnnotationAvailable) {
var orig_state = $('#notifyChangeCheckbox').prop('data-origstate');
var new_state = $('#notifyChangeCheckbox').prop('checked');
// only update when user changed preference
if (orig_state !== new_state) {
- var actionpath = new_state ? ("/occurrences/addAlert?queryId=" + myAnnotationQueryId) : ("/occurrences/deleteAlert?queryId=" + myAnnotationQueryId)
- $.post(OCC_REC.contextPath + actionpath)
+ var actionpath = new_state ? "/occurrences/addMyAnnotationAlert" : "/occurrences/deleteMyAnnotationAlert";
+ $.post(OCC_REC.contextPath + actionpath);
}
}
@@ -208,7 +208,7 @@ $(document).ready(function() {
$(el).html(replaceURLWithHTMLLinks(html)); // convert it
});
- var myAnnotationQueryId = null
+ var myAnnotationAvailable = false
$('#assertionButton').click(function (e) {
var getAlerts = OCC_REC.contextPath + "/occurrences/alerts";
@@ -217,28 +217,17 @@ $(document).ready(function() {
$.getJSON(getAlerts, function (data) {
// init status
- myAnnotationQueryId = null
+ myAnnotationAvailable = false
var myAnnotationEnabled = false
- if (data.enabledQueries) {
- for (var i = 0; i < data.enabledQueries.length; i++) {
- if (data.enabledQueries[i].name.indexOf(OCC_REC.alertName) !== -1) {
- myAnnotationEnabled = true;
- myAnnotationQueryId = data.enabledQueries[i].id
- }
- }
- }
-
- if (data.disabledQueries) {
- for (var i = 0; i < data.disabledQueries.length; i++) {
- if (data.disabledQueries[i].name.indexOf(OCC_REC.alertName) !== -1) {
- myAnnotationEnabled = false;
- myAnnotationQueryId = data.disabledQueries[i].id
- }
+ if (data && data.myannotation) {
+ myAnnotationAvailable = true
+ if (data.myannotation.length > 0) {
+ myAnnotationEnabled = true
}
}
// if find 'my annotation' show the check box
- if (myAnnotationQueryId !== null) {
+ if (myAnnotationAvailable) {
$("#notifyChange").show();
$("#notifyChangeCheckbox").prop('checked', myAnnotationEnabled);
$("#notifyChangeCheckbox").prop('data-origstate', myAnnotationEnabled);
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
index 2e9b8b646..92c3471a5 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
@@ -25,8 +25,8 @@ class BiocacheHubsUrlMappings {
"/occurrences/previous"(controller: 'occurrence', action: 'previous')
"/occurrences/dataQualityExcludeCounts"(controller: 'occurrence', action: 'dataQualityExcludeCounts')
"/occurrences/alerts"(controller: 'occurrence', action: [GET: 'getAlerts'])
- "/occurrences/addAlert"(controller: 'occurrence', action: [POST: 'addAlert'])
- "/occurrences/deleteAlert"(controller: 'occurrence', action: [POST: 'deleteAlert'])
+ "/occurrences/addMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'addMyAnnotationAlert'])
+ "/occurrences/deleteMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'deleteMyAnnotationAlert'])
"/occurrences/$id"(controller: 'occurrence', action: 'show')
"/occurrence/$id"(controller: 'occurrence', action: 'show')
"/assertions/$id"(controller: 'assertions', action: 'assertions')
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index e7106e02a..232057467 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -24,12 +24,10 @@ import org.grails.web.json.JSONArray
import org.grails.web.json.JSONElement
import org.grails.web.json.JSONObject
-import javax.servlet.http.HttpServletResponse
import java.text.SimpleDateFormat
import static au.org.ala.biocache.hubs.TimingUtils.time
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND
-import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT
/**
* Controller for occurrence searches and records
@@ -649,23 +647,23 @@ class OccurrenceController {
}
}
- def addAlert() {
+ def addMyAnnotationAlert() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to add alert'] as JSON)
} else {
- render webServicesService.addAlert(userId, params.queryId) as JSON
+ render webServicesService.addMyAnnotationAlert(userId) as JSON
}
}
- def deleteAlert() {
+ def deleteMyAnnotationAlert() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to delete alert'] as JSON)
} else {
- render webServicesService.deleteAlert(userId, params.queryId) as JSON
+ render webServicesService.deleteMyAnnotationAlert(userId) as JSON
}
}
}
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index 7034056c9..8b86700a5 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -105,13 +105,13 @@ class WebServicesService {
return getJsonElements(url, "${grailsApplication.config.alerts.apiKey}")
}
- def addAlert(String userId, String queryId) {
- String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/subscribe/" + queryId
+ def addMyAnnotationAlert(String userId) {
+ String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/addMyAnnotationAlert"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}
- def deleteAlert(String userId, String queryId) {
- String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/unsubscribe/" + queryId
+ def deleteMyAnnotationAlert(String userId) {
+ String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/deleteMyAnnotationAlert"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}
From 1157eae6238c0e6405c1c0535681161f027e1dec Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Thu, 7 Jan 2021 20:43:44 +1100
Subject: [PATCH 13/22] to use dq-service-client 1.2.0-SNAPSHOT for
user-specific profile
---
build.gradle | 2 +-
.../ala/biocache/hubs/QualityService.groovy | 25 ++++++++++++-------
.../biocache/hubs/WebServicesService.groovy | 2 +-
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/build.gradle b/build.gradle
index d92a43007..5b5371d22 100644
--- a/build.gradle
+++ b/build.gradle
@@ -76,7 +76,7 @@ dependencies {
//compile 'com.google.guava:guava:19.0' // replaces ehcache
compile "com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20180219.1"
- compile "au.org.ala:data-quality-filter-service-client:1.1.0", noCache
+ compile "au.org.ala:data-quality-filter-service-client:1.2.0-SNAPSHOT", noCache
//plugins
//compile 'org.grails.plugins:cache-ehcache:3.0.0.M1'
diff --git a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
index 38471dd94..a233c113a 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
@@ -54,9 +54,9 @@ class QualityService {
recordCountCache = CacheBuilder.from(recordCountCacheSpec).build { webServicesService.fullTextSearch(it)?.totalRecords }
}
- Map getEnabledFiltersByLabel(String profileName, userId = null) {
+ Map getEnabledFiltersByLabel(String profileName) {
if (dataQualityEnabled) {
- return responseOrThrow(api.getEnabledFiltersByLabel(profileName, userId))
+ return responseOrThrow(api.getEnabledFiltersByLabel(profileName))
} else {
return [:]
}
@@ -70,26 +70,33 @@ class QualityService {
}
}
- Map> getGroupedEnabledFilters(String profileName, String userId = null) {
+ Map> getGroupedEnabledFilters(String profileName) {
if (dataQualityEnabled) {
- return responseOrThrow(api.getGroupedEnabledFilters(profileName, userId))
+ return responseOrThrow(api.getGroupedEnabledFilters(profileName))
} else {
return [:]
}
}
- List findAllEnabledCategories(String profileName, String userId = null) {
+ List findAllEnabledCategories(String profileName) {
if (dataQualityEnabled) {
- return responseOrThrow(api.findAllEnabledCategories(profileName, userId))
+ return responseOrThrow(api.findAllEnabledCategories(profileName))
} else {
return []
}
}
- QualityProfile activeProfile(String profileName, String userId = null) {
+ QualityProfile activeProfile(String profileName = null, String userId = null) {
if (dataQualityEnabled) {
- QualityProfile qp = responseOrThrow(api.activeProfile(profileName, userId))
- return qp
+ return responseOrThrow(api.activeProfile(profileName, userId))
+ } else {
+ return null
+ }
+ }
+
+ QualityProfile getDefaultProfile(String userId = null) {
+ if (dataQualityEnabled) {
+ return responseOrThrow(api.getDefaultProfile(userId))
} else {
return null
}
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index b0a7dfa2d..2ebbd353d 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -665,7 +665,7 @@ class WebServicesService {
def populateProfile(requestParams) {
// force set the profile if none provided
if (dataQualityEnabled && !requestParams.qualityProfile && !requestParams.disableAllQualityFilters) {
- def activeProfile = qualityService.activeProfile(requestParams.qualityProfile, authService?.getUserId())
+ def activeProfile = qualityService.getDefaultProfile(authService?.getUserId())
requestParams.qualityProfile = activeProfile?.shortName
}
}
From a037da34a46e26ef55db804235ae16074455e503 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Fri, 8 Jan 2021 15:55:05 +1100
Subject: [PATCH 14/22] Refined the way apiKey is set in ApiClient
---
.../ala/biocache/hubs/OccurrenceController.groovy | 2 +-
.../ala/biocache/hubs/PostProcessingService.groovy | 2 +-
.../au/org/ala/biocache/hubs/QualityService.groovy | 12 +++++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index 979b1cc4a..c76cee203 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -632,7 +632,7 @@ class OccurrenceController {
def getExcluded(SpatialSearchRequestParams requestParams) {
def data = [:]
- QualityProfile profile = qualityService.activeProfile(requestParams.qualityProfile)
+ QualityProfile profile = qualityService.activeProfile(requestParams.qualityProfile, authService?.getUserId())
data.count = qualityService.getExcludeCount(params.categoryLabel, profile.getCategories(), requestParams)
render data as JSON
}
diff --git a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
index b3e3e7452..c7df4360d 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
@@ -522,7 +522,7 @@ class PostProcessingService {
}
}
- def profile = qualityService.activeProfile(requestParams.qualityProfile)
+ def profile = qualityService.getProfile(requestParams.qualityProfile)
// label to name map
def labelToNameMap = profile?.categories?.collectEntries{ [(it.label): it.name] } ?: [:]
diff --git a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
index a233c113a..4eb9665d6 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/QualityService.groovy
@@ -3,6 +3,7 @@ package au.org.ala.biocache.hubs
import au.org.ala.dataquality.api.DataProfilesApi
import au.org.ala.dataquality.api.QualityServiceRpcApi
import au.org.ala.dataquality.client.ApiClient
+import au.org.ala.dataquality.client.auth.ApiKeyAuth
import au.org.ala.dataquality.model.QualityCategory
import au.org.ala.dataquality.model.QualityFilter
import au.org.ala.dataquality.model.QualityProfile
@@ -42,8 +43,9 @@ class QualityService {
def init() {
if (dataQualityEnabled) {
def apiClient = new ApiClient()
- apiClient.setApiKey(dataQualityAPIKey)
apiClient.adapterBuilder.baseUrl(dataQualityBaseUrl)
+ apiClient.addAuthorization('apiKeyAuth', new ApiKeyAuth('header', 'apiKey'))
+ apiClient.setApiKey(dataQualityAPIKey)
apiClient.okBuilder.addInterceptor { chain ->
def request = chain.request().newBuilder().addHeader('User-Agent', "${grailsApplication.config.info.app.name}/${grailsApplication.config.info.app.version}").build()
chain.proceed(request)
@@ -94,6 +96,14 @@ class QualityService {
}
}
+ QualityProfile getProfile(String profileName) {
+ if (dataQualityEnabled) {
+ return responseOrThrow(dataProfilesApi.dataProfilesId(profileName))
+ } else {
+ return null
+ }
+ }
+
QualityProfile getDefaultProfile(String userId = null) {
if (dataQualityEnabled) {
return responseOrThrow(api.getDefaultProfile(userId))
From 72bc1367fa6abeadeb44a4dfab5ed1553a5285dd Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Wed, 20 Jan 2021 09:42:03 +1100
Subject: [PATCH 15/22] removed 'myannotation.name' which is never used.
---
grails-app/conf/plugin.groovy | 1 -
grails-app/views/occurrence/show.gsp | 1 -
2 files changed, 2 deletions(-)
diff --git a/grails-app/conf/plugin.groovy b/grails-app/conf/plugin.groovy
index 4b3575609..3446b61da 100644
--- a/grails-app/conf/plugin.groovy
+++ b/grails-app/conf/plugin.groovy
@@ -143,7 +143,6 @@ alwaysshow.imagetab = false
facets.defaultSelected = "data_resource_uid,taxon_name,year,multimedia"
-myannotation.name="My Annotations"
mapdownloads {
baseLayers {
default_layer {
diff --git a/grails-app/views/occurrence/show.gsp b/grails-app/views/occurrence/show.gsp
index e85deb52f..41ccb14ab 100644
--- a/grails-app/views/occurrence/show.gsp
+++ b/grails-app/views/occurrence/show.gsp
@@ -60,7 +60,6 @@
},
hasGoogleKey: ${grailsApplication.config.google.apikey as Boolean},
- alertName: "${grailsApplication.config.myannotation.name}"
}
// Google charts
From b9fad6d89bff02e7710f311e05765d7eb53d3f59 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Mon, 1 Feb 2021 14:31:41 +1100
Subject: [PATCH 16/22] fixed an issue when disableAllQualityFilters = true
when disableAllQualityFilters == true, requestParams.qualityProfile won't be populated so it could be null.
When it's null, lots existing calls to dq-service failed since dq-service expects not-null profileName
---
.../biocache/hubs/OccurrenceController.groovy | 25 +++++++++++++------
.../hubs/PostProcessingService.groovy | 16 ++++++------
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index c76cee203..9ebd9ad10 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -160,14 +160,25 @@ class OccurrenceController {
hasImages = true
}
- def qualityCategories = time("quality categories") { qualityService.findAllEnabledCategories(requestParams.qualityProfile) }
- def qualityFiltersByLabel = time("quality filters by label") { qualityService.getEnabledFiltersByLabel(requestParams.qualityProfile) }
- def qualityTotalCount = time("quality total count") { qualityService.countTotalRecords(requestParams) }
- def groupedEnabledFilters = time("get grouped enabled filters") { qualityService.getGroupedEnabledFilters(requestParams.qualityProfile) }
- def qualityFilterDescriptionsByLabel = groupedEnabledFilters.collectEntries {[(it.key) : it.value*.description.join(' and ')] }
-
- def (fqInteract, dqInteract, UserFQColors, DQColors) = time("process user fq interactions") { postProcessingService.processUserFQInteraction(requestParams) }
+ def qualityCategories = []
+ def qualityFiltersByLabel = [:]
+ def groupedEnabledFilters = [:]
+ def qualityFilterDescriptionsByLabel = [:]
+ def fqInteract = [:]
+ def dqInteract = [:]
+ def UserFQColors = [:]
+ def DQColors = [:]
+
+ // if disable all quality filters, we don't need to retrieve them, it saves time
+ if (!requestParams.disableAllQualityFilters) {
+ qualityCategories = time("quality categories") { qualityService.findAllEnabledCategories(requestParams.qualityProfile) }
+ qualityFiltersByLabel = time("quality filters by label") { qualityService.getEnabledFiltersByLabel(requestParams.qualityProfile) }
+ groupedEnabledFilters = time("get grouped enabled filters") { qualityService.getGroupedEnabledFilters(requestParams.qualityProfile) }
+ qualityFilterDescriptionsByLabel = groupedEnabledFilters.collectEntries { [(it.key): it.value*.description.join(' and ')] }
+ (fqInteract, dqInteract, UserFQColors, DQColors) = time("process user fq interactions") { postProcessingService.processUserFQInteraction(requestParams) }
+ }
+ def qualityTotalCount = time("quality total count") { qualityService.countTotalRecords(requestParams) }
def messagePropertiesFile = time("message properties file") { webServicesService.getMessagesPropertiesFile() }
def assertionCodeMap = time("assertionCodeMap") { webServicesService.getAssertionCodeMap() }
def translatedFilterMap = postProcessingService.translateValues(groupedEnabledFilters, messagePropertiesFile, assertionCodeMap)
diff --git a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
index c7df4360d..477e76413 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/PostProcessingService.groovy
@@ -505,6 +505,10 @@ class PostProcessingService {
}
def processUserFQInteraction(SpatialSearchRequestParams requestParams) {
+ if (requestParams.disableAllQualityFilters) {
+ return [[:], [:], [:], [:]]
+ }
+
def disabled = requestParams.disableQualityFilter as Set
// map from category label to filter names
@@ -513,13 +517,11 @@ class PostProcessingService {
// This means a user filter can interact with a DQ filter even when its exclude count == 0
def categoryToKeyMap = [:]
- if (!requestParams.disableAllQualityFilters) {
- categoryToKeyMap = qualityService.getGroupedEnabledFilters(requestParams.qualityProfile).findAll { label, list ->
- !disabled.contains(label)
- }.collectEntries { label, list ->
- def keys = list*.filter.collect { getKeysFromFilter(it) }.flatten()
- keys.isEmpty() ? [:] : [(label): keys as Set]
- }
+ categoryToKeyMap = qualityService.getGroupedEnabledFilters(requestParams.qualityProfile).findAll { label, list ->
+ !disabled.contains(label)
+ }.collectEntries { label, list ->
+ def keys = list*.filter.collect { getKeysFromFilter(it) }.flatten()
+ keys.isEmpty() ? [:] : [(label): keys as Set]
}
def profile = qualityService.getProfile(requestParams.qualityProfile)
From bebd0213c1ff0dcc53a8cf50e0c9d3ae50eeae30 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Wed, 3 Feb 2021 16:08:18 +1100
Subject: [PATCH 17/22] UI update for flag a duplicate record & DQ#217
DQ#217 formatting duplicate record preview
---
grails-app/assets/javascripts/show.js | 43 ++++++++++++++++---
.../biocache/hubs/OccurrenceController.groovy | 12 ++++--
grails-app/i18n/messages_en.properties | 11 +++--
.../views/occurrence/_recordSidebar.gsp | 34 ++++++++++++---
4 files changed, 82 insertions(+), 18 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 5906a7327..5dcce3366 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -56,7 +56,8 @@ $(document).ready(function() {
var val = $this.val();
var $submit = $('#issueForm input[type=submit]');
var $p = $('#related-record-p, #related-record-reason-p');
- if (val == '20020') {
+ // if duplicate record
+ if (val === '20020') {
$('#relatedRecordId').val('');
recordIdValid = false;
$p.show();
@@ -65,37 +66,67 @@ $(document).ready(function() {
$('#related-record-id-not-found').hide();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
+ // hide the records table
+ $('#records_comparison_table').hide();
+ $('#records_comparison_heading').hide();
}
setIssueFormButtonState();
});
+
$('#relatedRecordReason').on('change', function(e) {
+ var col_reason = $('#col_duplicate_reason');
+ var relatedRecordReason = $('#relatedRecordReason').val();
+ if (relatedRecordReason === '') {
+ $(col_reason).text('');
+ } else if (relatedRecordReason === 'sameoccurence') {
+ $(col_reason).text(jQuery.i18n.prop('related.record.reason.sameoccurrence.description'));
+ } else if (relatedRecordReason === 'tissuesample') {
+ $(col_reason).text(jQuery.i18n.prop('related.record.reason.tissuesample.description'));
+ } else if (relatedRecordReason === 'splitspecimen') {
+ $(col_reason).text(jQuery.i18n.prop('related.record.reason.splitspecimen.description'));
+ }
setIssueFormButtonState();
})
+
$('#relatedRecordId').on('change', function(e) {
var $this = $(this);
var $submit = $('#issueForm input[type=submit]');
var val = $this.val().trim();
- if (val == OCC_REC.recordUuid) {
+ if (val === OCC_REC.recordUuid) {
alert("You can't mark this record as a duplicate of itself!");
recordIdValid = false;
- } else if (val == '') {
+ } else if (val === '') {
$('#related-record-id-not-found').hide();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
+ $('#records_comparison_table').hide();
+ $('#records_comparison_heading').hide();
+ $('#relatedRecordReason').val("");
+ $('#col_duplicate_reason').text('');
recordIdValid = false;
} else {
$('#related-record-id-loading').show();
$.get( OCC_REC.contextPath + "/occurrence/exists/" + val).success(function(data) {
+ $('#related-record-id-loading').hide();
$('#related-record-id-not-found').hide();
$('#related-record-id-found').show();
- $('#related-record-id-found-other').text(data);
- $('#related-record-id-loading').hide();
+ $('#records_comparison_table').show();
+ $('#records_comparison_heading').show();
+ // populate the table
+ $('#t_scientificName').text(data.scientificName ? data.scientificName : '');
+ $('#t_stateProvince').text(data.stateProvince ? data.stateProvince : '');
+ $('#t_decimalLongitude').text(data.decimalLongitude ? data.decimalLongitude : '');
+ $('#t_decimalLatitude').text(data.decimalLatitude ? data.decimalLatitude : '');
+ $('#t_eventDate').text(data.eventDate ? data.eventDate : '');
recordIdValid = true;
}).error(function () {
$('#related-record-id-not-found').show();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
- recordIdValid = false;
+ $('#records_comparison_table').hide();
+ $('#records_comparison_heading').hide();
+ $('#relatedRecordReason').val("");
+ $('#col_duplicate_reason').text('');
}).always(function() {
setIssueFormButtonState();
});
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index 9ebd9ad10..81fffad98 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -616,14 +616,18 @@ class OccurrenceController {
def exists(String id) {
def record = webServicesService.getRecord(id, false)
if (record.keySet()) {
- log.trace("{}", record)
- def result = "${record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName ?: ''}, ${record?.processed?.location?.stateProvince ?: record?.raw?.location?.stateProvince ?: ''}, ${record?.processed?.location?.decimalLongitude ?: record?.raw?.location?.decimalLongitude ?: ''}, ${record?.processed?.location?.decimalLatitude ?: record?.raw?.location?.decimalLatitude ?: ''}, ${record?.processed?.event?.eventDate ?: record?.raw?.event?.eventDate ?: ''}"
- render text: result
+ def rslt = [:]
+ rslt.scientificName = record?.processed?.classification?.scientificName ?: (record?.raw?.classification?.scientificName ?: '')
+ rslt.stateProvince = record?.processed?.location?.stateProvince ?: (record?.raw?.location?.stateProvince ?: '')
+ rslt.decimalLongitude = record?.processed?.location?.decimalLongitude ?: (record?.raw?.location?.decimalLongitude ?: '')
+ rslt.decimalLatitude = record?.processed?.location?.decimalLatitude ?: (record?.raw?.location?.decimalLatitude ?: '')
+ rslt.eventDate = record?.processed?.event?.eventDate ?: (record?.raw?.event?.eventDate ?: '')
+ render rslt as JSON
} else {
render status: SC_NOT_FOUND, text: ''
}
}
-
+
/**
* JSON webservices for debugging/testing
*/
diff --git a/grails-app/i18n/messages_en.properties b/grails-app/i18n/messages_en.properties
index 8f6509d65..ff8b72227 100644
--- a/grails-app/i18n/messages_en.properties
+++ b/grails-app/i18n/messages_en.properties
@@ -136,8 +136,6 @@ show.issueform.label02 = Comment:
show.issueform.label03 = Duplicate Record ID:
show.issueform.label04 = Duplicate Reason:
show.issueform.notifyme = Notify me when records I have annotated are updated
-show.issueform.relatedrecord.found.this = You are indicating this record (the one you are viewing):
-show.issueform.relatedrecord.found.other = is a duplicate of this record (the id you provided):
show.issueform.button.submit = Submit
show.issueform.button.cancel = Cancel
show.issueform.button.close = Close
@@ -1153,6 +1151,13 @@ dq.warning.dataprofile.content.line1 = Search results are now filtered by defaul
dq.warning.dataprofile.buttonleft.text = Learn More
dq.warning.dataprofile.buttonright.text = Got it
+record.compare_table.heading = You are indicating that
+record.compare_table.source_record.heading = This record you are viewing
+record.compare_table.target_record.heading = This record ID provided
+related.record.reason.select=-- Select a reason --
related.record.reason.sameoccurence=Same occurence
related.record.reason.tissuesample=Tissue sample
-related.record.reason.splitspecimen=Split specimen
\ No newline at end of file
+related.record.reason.splitspecimen=Split specimen
+related.record.reason.sameoccurrence.description=Is the same occurrence as
+related.record.reason.tissuesample.description=Is a tissue sample of
+related.record.reason.splitspecimen.description=Is a duplicate specimen of
diff --git a/grails-app/views/occurrence/_recordSidebar.gsp b/grails-app/views/occurrence/_recordSidebar.gsp
index 5a2565613..1bd21067c 100644
--- a/grails-app/views/occurrence/_recordSidebar.gsp
+++ b/grails-app/views/occurrence/_recordSidebar.gsp
@@ -332,15 +332,39 @@
The record id can't be found.
- ${record?.processed?.classification?.scientificName ?: record?.raw?.classification?.scientificName ?: ''}, ${record?.processed?.location?.stateProvince ?: record?.raw?.location?.stateProvince ?: ''}, ${record?.processed?.location?.decimalLongitude ?: record?.raw?.location?.decimalLongitude ?: ''}, ${record?.processed?.location?.decimalLatitude ?: record?.raw?.location?.decimalLatitude ?: ''}, ${record?.processed?.event?.eventDate ?: record?.raw?.event?.eventDate ?: ''}
-
-
+ :
+
-
@@ -358,7 +382,7 @@
" class="btn btn-primary" />
- " class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
+ " class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
" class="btn btn-default" style="display:none;"/>
From 12e7113001085d0711513a1d51f3e81f33290ff3 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Fri, 5 Feb 2021 13:59:22 +1100
Subject: [PATCH 18/22] DQ#217, handle 'user input id retrieves more than 1
record'
---
grails-app/assets/javascripts/show.js | 35 ++++++++++++-------
.../biocache/hubs/OccurrenceController.groovy | 6 +++-
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 5dcce3366..789d54b3b 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -108,19 +108,30 @@ $(document).ready(function() {
$('#related-record-id-loading').show();
$.get( OCC_REC.contextPath + "/occurrence/exists/" + val).success(function(data) {
$('#related-record-id-loading').hide();
- $('#related-record-id-not-found').hide();
- $('#related-record-id-found').show();
- $('#records_comparison_table').show();
- $('#records_comparison_heading').show();
- // populate the table
- $('#t_scientificName').text(data.scientificName ? data.scientificName : '');
- $('#t_stateProvince').text(data.stateProvince ? data.stateProvince : '');
- $('#t_decimalLongitude').text(data.decimalLongitude ? data.decimalLongitude : '');
- $('#t_decimalLatitude').text(data.decimalLatitude ? data.decimalLatitude : '');
- $('#t_eventDate').text(data.eventDate ? data.eventDate : '');
- recordIdValid = true;
+ if (data.error) {
+ // show error
+ $('#related-record-id-not-found').text('More than 1 record found with specified id, please use a more specific id').show();
+ // hide compare table
+ $('#records_comparison_heading').hide();
+ $('#records_comparison_table').hide();
+ recordIdValid = false;
+ } else {
+ // hide error
+ $('#related-record-id-not-found').hide();
+ // show compare table
+ $('#related-record-id-found').show();
+ $('#records_comparison_table').show();
+ $('#records_comparison_heading').show();
+ // populate the table
+ $('#t_scientificName').text(data.scientificName ? data.scientificName : '');
+ $('#t_stateProvince').text(data.stateProvince ? data.stateProvince : '');
+ $('#t_decimalLongitude').text(data.decimalLongitude ? data.decimalLongitude : '');
+ $('#t_decimalLatitude').text(data.decimalLatitude ? data.decimalLatitude : '');
+ $('#t_eventDate').text(data.eventDate ? data.eventDate : '');
+ recordIdValid = true;
+ }
}).error(function () {
- $('#related-record-id-not-found').show();
+ $('#related-record-id-not-found').text("The record id can't be found.").show();
$('#related-record-id-found').hide();
$('#related-record-id-loading').hide();
$('#records_comparison_table').hide();
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index 81fffad98..3765642ec 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -614,8 +614,12 @@ class OccurrenceController {
}
def exists(String id) {
+ // getRecord can return either 1 record or a list of records
+ // if a list returned, asking user to be more specific
def record = webServicesService.getRecord(id, false)
- if (record.keySet()) {
+ if (record.occurrences) {
+ render ([error: 'id not unique'] as JSON)
+ } else if (record.keySet()) {
def rslt = [:]
rslt.scientificName = record?.processed?.classification?.scientificName ?: (record?.raw?.classification?.scientificName ?: '')
rslt.stateProvince = record?.processed?.location?.stateProvince ?: (record?.raw?.location?.stateProvince ?: '')
From 3db615c3c3a11e45ff63f93794a4e0e2a65f66ad Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Mon, 8 Feb 2021 09:59:24 +1100
Subject: [PATCH 19/22] fixed an issue in displaying comment.
Old code displayed 'undefined' when comment is empty.
---
grails-app/assets/javascripts/show.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 789d54b3b..390a475ab 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -490,7 +490,9 @@ function refreshUserAnnotations(){
var $clone = $('#userAnnotationTemplate').clone();
$clone.find('.issue').text(data.assertionQueries[i].assertionType);
$clone.find('.user').text(data.assertionQueries[i].userName);
- $clone.find('.comment').text('Comment: ' + data.assertionQueries[i].comment);
+ if (data.assertionQueries[i].hasOwnProperty('comment')) {
+ $clone.find('.comment').text('Comment: ' + data.assertionQueries[i].comment);
+ }
$clone.find('.created').text('Date created: ' + (moment(data.assertionQueries[i].createdDate).format('YYYY-MM-DD')));
if(data.assertionQueries[i].recordCount > 1){
$clone.find('.viewMore').css({display:'block'});
@@ -513,7 +515,9 @@ function refreshUserAnnotations(){
$clone.prop('id', "userAnnotation_" + userAssertion.uuid);
$clone.find('.issue').text(jQuery.i18n.prop(userAssertion.name));
$clone.find('.user').text(userAssertion.userDisplayName);
- $clone.find('.comment').text('Comment: ' + userAssertion.comment);
+ if (userAssertion.hasOwnProperty('comment')) {
+ $clone.find('.comment').text('Comment: ' + userAssertion.comment);
+ }
$clone.find('.userRole').text(userAssertion.userRole != null ? userAssertion.userRole : '');
$clone.find('.userEntity').text(userAssertion.userEntityName != null ? userAssertion.userEntityName : '');
$clone.find('.created').text('Date created: ' + (moment(userAssertion.created, "YYYY-MM-DDTHH:mm:ssZ").format('YYYY-MM-DD HH:mm:ss')));
From fed9e317c5c019f3b10dcc734ddd173fd28cc2dd Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Thu, 8 Apr 2021 15:08:24 +1000
Subject: [PATCH 20/22] do alerts related url mappings conditionally
---
.../ala/biocache/hubs/BiocacheHubsUrlMappings.groovy | 3 ---
grails-app/init/biocache/hubs/BootStrap.groovy | 12 ++++++++++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
index 92c3471a5..49f0f4e23 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/BiocacheHubsUrlMappings.groovy
@@ -24,9 +24,6 @@ class BiocacheHubsUrlMappings {
"/occurrences/next"(controller: 'occurrence', action: 'next')
"/occurrences/previous"(controller: 'occurrence', action: 'previous')
"/occurrences/dataQualityExcludeCounts"(controller: 'occurrence', action: 'dataQualityExcludeCounts')
- "/occurrences/alerts"(controller: 'occurrence', action: [GET: 'getAlerts'])
- "/occurrences/addMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'addMyAnnotationAlert'])
- "/occurrences/deleteMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'deleteMyAnnotationAlert'])
"/occurrences/$id"(controller: 'occurrence', action: 'show')
"/occurrence/$id"(controller: 'occurrence', action: 'show')
"/assertions/$id"(controller: 'assertions', action: 'assertions')
diff --git a/grails-app/init/biocache/hubs/BootStrap.groovy b/grails-app/init/biocache/hubs/BootStrap.groovy
index 78264cd69..f410236a9 100644
--- a/grails-app/init/biocache/hubs/BootStrap.groovy
+++ b/grails-app/init/biocache/hubs/BootStrap.groovy
@@ -3,8 +3,20 @@ package biocache.hubs
class BootStrap {
def messageSource
def application
+ def grailsApplication
+ def grailsUrlMappingsHolder
def init = { servletContext ->
+
+ // if my annotation feature turned on, add url mapping to handle add/remove my annotation alert requests
+ if (grailsApplication.config.getProperty('alerts.myannotation.enabled', Boolean, false)) {
+ grailsUrlMappingsHolder.addMappings({
+ "/occurrences/alerts"(controller: 'occurrence', action: [GET: 'getAlerts'])
+ "/occurrences/addMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'addMyAnnotationAlert'])
+ "/occurrences/deleteMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'deleteMyAnnotationAlert'])
+ })
+ }
+
messageSource.setBasenames(
"file:///var/opt/atlas/i18n/downloads-plugin/messages",
"file:///opt/atlas/i18n/downloads-plugin/messages",
From 9e244592dcdf496017eeb4b50f07fd4eb72bba16 Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Fri, 9 Apr 2021 12:17:33 +1000
Subject: [PATCH 21/22] fixed typo
---
grails-app/assets/javascripts/show.js | 14 +++++---------
.../ala/biocache/hubs/WebServicesService.groovy | 6 +++---
grails-app/views/occurrence/_recordSidebar.gsp | 2 +-
3 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 0257fe6a1..43ef12f3d 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -199,20 +199,15 @@ $(document).ready(function() {
function (data) {
// when add assertion succeeds, we update alert settings (only when myannotation is enabled)
if (OCC_REC.myAnnotationEnabled) {
- var orig_state = $('#notifyChangeCheckbox').prop('data-origstate');
var new_state = $('#notifyChangeCheckbox').prop('checked');
-
- // only update when user changed preference
- if (orig_state !== new_state) {
- var actionpath = new_state ? "/occurrences/addMyAnnotationAlert" : "/occurrences/deleteMyAnnotationAlert";
- $.post(OCC_REC.contextPath + actionpath);
- }
+ var actionpath = new_state ? "/occurrences/addMyAnnotationAlert" : "/occurrences/deleteMyAnnotationAlert";
+ $.post(OCC_REC.contextPath + actionpath);
}
$('#assertionSubmitProgress').css({'display': 'none'});
$("#submitSuccess").html("Thanks for flagging the problem!");
$("#issueFormSubmit").hide();
- $("input:reset").hide();
+ $("input#cancel").hide();
$("input#close").show();
//retrieve all assertions
$.get(OCC_REC.contextPath + '/assertions/' + OCC_REC.recordUuid, function (data) { // recordUuid=${record.raw.uuid}
@@ -244,11 +239,12 @@ $(document).ready(function() {
$('#assertionButton').click(function (e) {
// if myannotation enabled, to retrieve current settings
if (OCC_REC.myAnnotationEnabled) {
+ // by default off
+ $("#notifyChangeCheckbox").prop('checked', false);
var getAlerts = OCC_REC.contextPath + "/occurrences/alerts";
$.getJSON(getAlerts, function (data) {
var myAnnotationEnabled = data && data.myannotation && data.myannotation.length > 0;
$("#notifyChangeCheckbox").prop('checked', myAnnotationEnabled);
- $("#notifyChangeCheckbox").prop('data-origstate', myAnnotationEnabled);
})
}
})
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index b2532177e..b23995ded 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -113,17 +113,17 @@ class WebServicesService {
}
def getAlerts(String userId) {
- def url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId
+ def url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId
return getJsonElements(url, "${grailsApplication.config.alerts.apiKey}")
}
def addMyAnnotationAlert(String userId) {
- String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/addMyAnnotationAlert"
+ String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/addMyAnnotationAlert"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}
def deleteMyAnnotationAlert(String userId) {
- String url = "${grailsApplication.config.alerts.baseURL}" + "/api/alerts/user/" + userId + "/deleteMyAnnotationAlert"
+ String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/deleteMyAnnotationAlert"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}
diff --git a/grails-app/views/occurrence/_recordSidebar.gsp b/grails-app/views/occurrence/_recordSidebar.gsp
index 48d98a90e..abed77be5 100644
--- a/grails-app/views/occurrence/_recordSidebar.gsp
+++ b/grails-app/views/occurrence/_recordSidebar.gsp
@@ -384,7 +384,7 @@
" class="btn btn-primary" />
- " class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
+ " class="btn btn-default" onClick="$('#loginOrFlag').modal('hide');"/>
" class="btn btn-default" style="display:none;"/>
From 5bb0a83474d9a68b2fbbd75d38692e28b64ec44f Mon Sep 17 00:00:00 2001
From: alexhuang091
Date: Mon, 12 Apr 2021 14:43:54 +1000
Subject: [PATCH 22/22] alerts API names changed so we need to update
accordingly
---
grails-app/assets/javascripts/show.js | 2 +-
.../au/org/ala/biocache/hubs/OccurrenceController.groovy | 8 ++++----
grails-app/init/biocache/hubs/BootStrap.groovy | 4 ++--
.../au/org/ala/biocache/hubs/WebServicesService.groovy | 8 ++++----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/grails-app/assets/javascripts/show.js b/grails-app/assets/javascripts/show.js
index 43ef12f3d..83f86132c 100644
--- a/grails-app/assets/javascripts/show.js
+++ b/grails-app/assets/javascripts/show.js
@@ -200,7 +200,7 @@ $(document).ready(function() {
// when add assertion succeeds, we update alert settings (only when myannotation is enabled)
if (OCC_REC.myAnnotationEnabled) {
var new_state = $('#notifyChangeCheckbox').prop('checked');
- var actionpath = new_state ? "/occurrences/addMyAnnotationAlert" : "/occurrences/deleteMyAnnotationAlert";
+ var actionpath = new_state ? "/occurrences/subscribeMyAnnotation" : "/occurrences/unsubscribeMyAnnotation";
$.post(OCC_REC.contextPath + actionpath);
}
diff --git a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
index 7e30b9355..4c2ecc683 100644
--- a/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
+++ b/grails-app/controllers/au/org/ala/biocache/hubs/OccurrenceController.groovy
@@ -736,23 +736,23 @@ class OccurrenceController {
}
}
- def addMyAnnotationAlert() {
+ def subscribeMyAnnotation() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to add alert'] as JSON)
} else {
- render webServicesService.addMyAnnotationAlert(userId) as JSON
+ render webServicesService.subscribeMyAnnotation(userId) as JSON
}
}
- def deleteMyAnnotationAlert() {
+ def unsubscribeMyAnnotation() {
String userId = authService?.getUserId()
if (userId == null) {
response.status = 404
render ([error: 'userId must be supplied to delete alert'] as JSON)
} else {
- render webServicesService.deleteMyAnnotationAlert(userId) as JSON
+ render webServicesService.unsubscribeMyAnnotation(userId) as JSON
}
}
}
diff --git a/grails-app/init/biocache/hubs/BootStrap.groovy b/grails-app/init/biocache/hubs/BootStrap.groovy
index f410236a9..8df5a2a0a 100644
--- a/grails-app/init/biocache/hubs/BootStrap.groovy
+++ b/grails-app/init/biocache/hubs/BootStrap.groovy
@@ -12,8 +12,8 @@ class BootStrap {
if (grailsApplication.config.getProperty('alerts.myannotation.enabled', Boolean, false)) {
grailsUrlMappingsHolder.addMappings({
"/occurrences/alerts"(controller: 'occurrence', action: [GET: 'getAlerts'])
- "/occurrences/addMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'addMyAnnotationAlert'])
- "/occurrences/deleteMyAnnotationAlert"(controller: 'occurrence', action: [POST: 'deleteMyAnnotationAlert'])
+ "/occurrences/subscribeMyAnnotation"(controller: 'occurrence', action: [POST: 'subscribeMyAnnotation'])
+ "/occurrences/unsubscribeMyAnnotation"(controller: 'occurrence', action: [POST: 'unsubscribeMyAnnotation'])
})
}
diff --git a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
index b23995ded..434f3f53e 100644
--- a/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
+++ b/grails-app/services/au/org/ala/biocache/hubs/WebServicesService.groovy
@@ -117,13 +117,13 @@ class WebServicesService {
return getJsonElements(url, "${grailsApplication.config.alerts.apiKey}")
}
- def addMyAnnotationAlert(String userId) {
- String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/addMyAnnotationAlert"
+ def subscribeMyAnnotation(String userId) {
+ String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/subscribeMyAnnotation"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}
- def deleteMyAnnotationAlert(String userId) {
- String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/deleteMyAnnotationAlert"
+ def unsubscribeMyAnnotation(String userId) {
+ String url = "${grailsApplication.config.alerts.baseUrl}" + "/api/alerts/user/" + userId + "/unsubscribeMyAnnotation"
postFormData(url, [:], grailsApplication.config.alerts.apiKey as String)
}