@@ -9,9 +9,11 @@ import com.azure.storage.blob.BlobContainerClient
9
9
import com.azure.storage.blob.BlobServiceClient
10
10
import com.azure.storage.blob.BlobServiceClientBuilder
11
11
import com.nimbusds.jwt.JWT
12
+ import grails.converters.JSON
12
13
import grails.core.GrailsApplication
13
14
import groovy.util.logging.Slf4j
14
15
import com.azure.identity.ClientAssertionCredential
16
+ import net.sf.json.JSONArray
15
17
import org.pac4j.oidc.profile.OidcProfile
16
18
import software.amazon.awssdk.services.cognitoidentity.CognitoIdentityClient
17
19
import software.amazon.awssdk.services.cognitoidentity.model.GetIdRequest
@@ -38,12 +40,15 @@ class BdrService {
38
40
AccessTokenCache accessTokenCache
39
41
40
42
void downloadDataSet (String projectId , String dataSetId , String format , HttpServletResponse response ) {
41
- String bdrBaseUrl = grailsApplication . config . getProperty( ' bdr.api.url ' )
43
+ String azureToken = getAzureAccessToken( )
42
44
45
+ String bdrBaseUrl = grailsApplication. config. getProperty(' bdr.api.url' )
43
46
format = URLEncoder . encode(format, ' UTF-8' )
44
- // String url = bdrBaseUrl+'/collections/ns3:'+projectId+'/items?_mediatype='+format
45
- String url = ' https://bdr.azure-api.net/merit/v2/catalogs/bdr-cat:merit-datasets/collections/bdr-ds:dabc7e5d-81ce-40bf-8f74-8ecf3c7ce055/features/collections'
46
- String azureToken = getAzureAccessToken()
47
+ String url = bdrBaseUrl+ ' /cql?_mediatype=' + format
48
+ String query = (dataSetQuery(dataSetId) as JSON ). toString()
49
+ String encodedQuery = URLEncoder . encode(query, " UTF-8" )
50
+
51
+ url+ = " &filter=" + encodedQuery
47
52
48
53
log. info(" Downloading data set from BDR: $url " )
49
54
@@ -83,6 +88,16 @@ class BdrService {
83
88
accessToken. getToken()
84
89
}
85
90
91
+ private Map dataSetQuery (String dataSetId ) {
92
+ Map query = [
93
+ " op" : " and" ,
94
+ " args" : [
95
+ [" op" :" =" ," args" :[[" property" :" nrm-submission" ], dataSetId]],
96
+ [" op" :" =" ," args" :[[" property" :" http://www.w3.org/1999/02/22-rdf-syntax-ns#type" ]," http://www.opengis.net/ont/geosparql#Feature" ]]
97
+ ]
98
+ ]
99
+ }
100
+
86
101
87
102
String getTokenFromCognitoIdentityPool (String userToken ) {
88
103
0 commit comments