Skip to content

Commit

Permalink
Minor updates to BDR download #3169
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 20, 2024
1 parent dad817b commit bc2236c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 8 deletions.
20 changes: 16 additions & 4 deletions grails-app/assets/javascripts/dataSets.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,25 @@ var DataSetsViewModel =function(dataSets, projectService, config) {
}

function isDownloadableMonitorDataSet(dataSet) {

if (dataSet.createdIn !== MONITOR_APP) {
return false;
}
var protocolId = dataSet.protocol;
var downloadableProtocols = config.downloadableProtocols || [];

return downloadableProtocols.indexOf(protocolId) >= 0;
var isDownloadable = downloadableProtocols.indexOf(protocolId) >= 0;
if (isDownloadable) {
var now = moment();
var creationDate = moment(dataSet.dateCreated);
var minutesToInjestDataSet = options.minutesToInjestDataSet || 1;
if (dataSet.progress !== ActivityProgress.planned) {
if (creationDate.add(minutesToInjestDataSet, 'minutes').isBefore(now)) {
isDownloadable = true;
}
}
}
return isDownloadable;
}

/** View model backing for a single row in the data set summary table */
Expand Down Expand Up @@ -83,15 +98,12 @@ var DataSetsViewModel =function(dataSets, projectService, config) {

if (this.createdIn === MONITOR_APP) {
if (this.progress == ActivityProgress.planned) {
var now = moment();
var creationDate = moment(dataSet.dateCreated);
if (creationDate.add(1, 'minutes').isBefore(now)) {
this.progress = 'sync error';
}
else {
this.progress = 'sync in progress';
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion grails-app/conf/application.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bdr.jwtScopes="read"
bdr.azure.clientId='changeMe'
bdr.azure.tenantId='changeMe'
bdr.azure.apiScope='api://changeme/.default'
bdr.dataSet.formats=["application/geo+json","text/turtle","application/rdf+xml","application/ld+json", "application/n-triples"]
bdr.dataSet.formats=["application/geo+json","application/rdf+xml"]

webservice.jwt = true
webservice['jwt-scopes'] = "ala/internal users/read ala/attrs ecodata/read_test ecodata/write_test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class DataSetController {
else {
if (isMonitorDataSet(dataSet)) {
if (isProtocolSupportedForDownload(dataSet)) {
bdrService.downloadDataSet(dataSet.dataSetId, format, response)
bdrService.downloadDataSet(id, dataSet.dataSetId, format, response)
}
}
else if (dataSet.url) {
Expand Down
4 changes: 2 additions & 2 deletions grails-app/services/au/org/ala/merit/BdrService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class BdrService {

AccessTokenCache accessTokenCache

void downloadDataSet(String dataSetId, String format, HttpServletResponse response) {
void downloadDataSet(String projectId, String dataSetId, String format, HttpServletResponse response) {
String bdrBaseUrl = grailsApplication.config.getProperty('bdr.api.url')

format = URLEncoder.encode(format, 'UTF-8')
String url = bdrBaseUrl+'/collections/ns3:'+dataSetId+'/items?_mediatype='+format
String url = bdrBaseUrl+'/collections/ns3:'+projectId+'/items?_mediatype='+format

String azureToken = getAzureAccessToken()

Expand Down
24 changes: 24 additions & 0 deletions src/main/scripts/releases/4.2/tagDownloadableProtocols.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const downloadableProtocols = [
'Cover - Standard',
'Cover - Enhanced',
'Floristics - Standard',
'Floristics - Enhanced',
'Plot Layout and Visit',
'Vegetation Mapping',
'Plot Description - Standard',
'Plot Description - Enhanced',
'Plot Selection',
'Plant Tissue Vouchering - Standard',
'Plant Tissue Vouchering - Enhanced',
'Photo Points - DSLR Panorama',
'Photo Points - Compact Panorama',
'Photo Points - Device Panorama'

];

db.activityForm.find({name:{'$in':downloadableProtocols}}).forEach(function(form) {
if (!form.tags.indexOf("bdr_download_supported") > -1) {
form.tags.push("bdr_download_supported");
db.activityForm.replaceOne({_id:form._id}, form);
}
});

0 comments on commit bc2236c

Please sign in to comment.