diff --git a/grails-app/assets/javascripts/dataSets.js b/grails-app/assets/javascripts/dataSets.js index c820d6af0..b0833d65f 100644 --- a/grails-app/assets/javascripts/dataSets.js +++ b/grails-app/assets/javascripts/dataSets.js @@ -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 */ @@ -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'; } - } } } diff --git a/grails-app/conf/application.groovy b/grails-app/conf/application.groovy index 1eea485be..63ae8d1a5 100644 --- a/grails-app/conf/application.groovy +++ b/grails-app/conf/application.groovy @@ -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" diff --git a/grails-app/controllers/au/org/ala/merit/DataSetController.groovy b/grails-app/controllers/au/org/ala/merit/DataSetController.groovy index e2b7e4ae0..f4c57155a 100644 --- a/grails-app/controllers/au/org/ala/merit/DataSetController.groovy +++ b/grails-app/controllers/au/org/ala/merit/DataSetController.groovy @@ -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) { diff --git a/grails-app/services/au/org/ala/merit/BdrService.groovy b/grails-app/services/au/org/ala/merit/BdrService.groovy index ffc07b91d..da0b6d254 100644 --- a/grails-app/services/au/org/ala/merit/BdrService.groovy +++ b/grails-app/services/au/org/ala/merit/BdrService.groovy @@ -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() diff --git a/src/main/scripts/releases/4.2/tagDownloadableProtocols.js b/src/main/scripts/releases/4.2/tagDownloadableProtocols.js new file mode 100644 index 000000000..4ca0fc339 --- /dev/null +++ b/src/main/scripts/releases/4.2/tagDownloadableProtocols.js @@ -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); + } +}); \ No newline at end of file