Skip to content

Commit

Permalink
Updated BDR query #3169
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Jan 10, 2025
1 parent 9b6463b commit 50f044f
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions grails-app/services/au/org/ala/merit/BdrService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import com.azure.storage.blob.BlobContainerClient
import com.azure.storage.blob.BlobServiceClient
import com.azure.storage.blob.BlobServiceClientBuilder
import com.nimbusds.jwt.JWT
import grails.converters.JSON
import grails.core.GrailsApplication
import groovy.util.logging.Slf4j
import com.azure.identity.ClientAssertionCredential
import net.sf.json.JSONArray
import org.pac4j.oidc.profile.OidcProfile
import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient
import software.amazon.awssdk.services.cognitoidentity.model.GetIdRequest
Expand All @@ -38,12 +40,15 @@ class BdrService {
AccessTokenCache accessTokenCache

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

String bdrBaseUrl = grailsApplication.config.getProperty('bdr.api.url')
format = URLEncoder.encode(format, 'UTF-8')
//String url = bdrBaseUrl+'/collections/ns3:'+projectId+'/items?_mediatype='+format
String url = 'https://bdr.azure-api.net/merit/v2/catalogs/bdr-cat:merit-datasets/collections/bdr-ds:dabc7e5d-81ce-40bf-8f74-8ecf3c7ce055/features/collections'
String azureToken = getAzureAccessToken()
String url = bdrBaseUrl+'/cql?_mediatype='+format
String query = (dataSetQuery(dataSetId) as JSON).toString()
String encodedQuery = URLEncoder.encode(query, "UTF-8")

url+="&filter="+encodedQuery

log.info("Downloading data set from BDR: $url")

Expand Down Expand Up @@ -83,6 +88,16 @@ class BdrService {
accessToken.getToken()
}

private Map dataSetQuery(String dataSetId) {
Map query = [
"op": "and",
"args": [
["op":"=","args":[["property":"nrm-submission"], dataSetId]],
["op":"=","args":[["property":"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"],"http://www.opengis.net/ont/geosparql#Feature"]]
]
]
}


String getTokenFromCognitoIdentityPool(String userToken) {

Expand Down

0 comments on commit 50f044f

Please sign in to comment.