From 6ae209c838162baa1095a1ea60be9c4996efdaec Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Wed, 11 Oct 2023 15:59:17 -0400 Subject: [PATCH] [ALS-5056] Create sumtype for QueryRequest - Interface, implementations for general use, GIC --- .../edu/harvard/dbmi/avillach/PicsureRS.java | 9 +- .../dbmi/avillach/security/JWTFilter.java | 4 +- .../avillach/service/PicsureInfoService.java | 3 +- .../avillach/service/PicsureQueryService.java | 20 ++- .../service/PicsureSearchService.java | 5 +- .../dbmi/avillach/service/SystemService.java | 4 +- .../dbmi/avillach/PicsureInfoServiceTest.java | 4 +- .../avillach/PicsureQueryServiceTest.java | 29 ++-- .../avillach/PicsureSearchServiceTest.java | 4 +- .../dbmi/avillach/AggregateResourceIT.java | 12 +- .../dbmi/avillach/GnomeI2B2ResourceIT.java | 6 +- .../dbmi/avillach/HSAPIResourceIT.java | 8 +- .../harvard/dbmi/avillach/IRCTResourceIT.java | 10 +- .../dbmi/avillach/PicsureInfoServiceIT.java | 2 +- .../dbmi/avillach/PicsureQueryServiceIT.java | 6 +- .../dbmi/avillach/PicsureSearchServiceIT.java | 2 +- .../AggregateDataSharingResourceRS.java | 14 +- ...eDataSharingResourceRSAcceptanceTests.java | 26 ++-- .../hms/dbmi/avillach/GA4GHResourceRS.java | 6 - .../passthru/PassThroughResourceRS.java | 20 +-- .../passthru/PassThroughResourceRSTest.java | 28 ++-- .../dbmi/avillach/domain/GICQueryRequest.java | 124 ++++++++++++++++++ .../avillach/domain/GeneralQueryRequest.java | 105 +++++++++++++++ .../dbmi/avillach/domain/QueryRequest.java | 99 ++------------ ...uestTest.java => GICQueryRequestTest.java} | 12 +- .../service/ResourceWebClientTest.java | 11 +- .../VisualizationResourceTests.java | 4 +- .../service/DataServiceTests.java | 22 ++-- .../service/HpdsServiceTests.java | 10 +- 29 files changed, 369 insertions(+), 240 deletions(-) create mode 100644 pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GICQueryRequest.java create mode 100644 pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GeneralQueryRequest.java rename pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/{QueryRequestTest.java => GICQueryRequestTest.java} (77%) diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java index 0bb2db3f..8103063e 100644 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/PicsureRS.java @@ -87,7 +87,7 @@ public Map resources(@Context HttpHeaders headers){ @Consumes("*/*") public PaginatedSearchResult searchGenomicConceptValues( @PathParam("resourceId") UUID resourceId, - QueryRequest searchQueryRequest, + GeneralQueryRequest searchQueryRequest, @QueryParam("genomicConceptPath") String genomicConceptPath, @QueryParam("query") String query, @QueryParam("page") Integer page, @@ -155,10 +155,11 @@ public QueryStatus query( @Context SecurityContext context ) { - if (isInstitutionQuery == null || !isInstitutionQuery) { + if (dataQueryRequest instanceof GeneralQueryRequest) { return queryService.query(dataQueryRequest, headers); } else { - return queryService.institutionalQuery(dataQueryRequest, headers, context.getUserPrincipal().getName()); + String email = context.getUserPrincipal().getName(); + return queryService.institutionalQuery((GICQueryRequest) dataQueryRequest, headers, email); } } @@ -187,7 +188,7 @@ public QueryStatus queryStatus( UUID queryId, @Parameter - QueryRequest credentialsQueryRequest, + GeneralQueryRequest credentialsQueryRequest, @Context HttpHeaders headers, diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/security/JWTFilter.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/security/JWTFilter.java index 82709920..fcb16b4a 100755 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/security/JWTFilter.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/security/JWTFilter.java @@ -8,7 +8,7 @@ import edu.harvard.dbmi.avillach.data.entity.AuthUser; import edu.harvard.dbmi.avillach.data.repository.QueryRepository; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.service.ResourceWebClient; import edu.harvard.dbmi.avillach.util.exception.ApplicationException; import edu.harvard.dbmi.avillach.util.response.PICSUREResponse; @@ -204,7 +204,7 @@ private AuthUser callTokenIntroEndpoint(ContainerRequestContext requestContext, edu.harvard.dbmi.avillach.data.entity.Resource resource = resourceRepo.getById(resourceUUID); //logger.info("resource obj: " + resource + " path: " + resource.getResourceRSPath()); if (resource != null && resource.getResourceRSPath() != null){ - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.getResourceCredentials().put(ResourceWebClient.BEARER_TOKEN_KEY, resource.getToken()); queryRequest.setResourceUUID(resourceUUID); queryRequest.setQuery(((Map)queryObject).get("query")); diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureInfoService.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureInfoService.java index 71bfe125..922746f8 100644 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureInfoService.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureInfoService.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.QueryRequest; import edu.harvard.dbmi.avillach.domain.ResourceInfo; import edu.harvard.dbmi.avillach.util.Utilities; @@ -46,7 +47,7 @@ public ResourceInfo info(UUID resourceId, QueryRequest credentialsQueryRequest, throw new ApplicationException(ApplicationException.MISSING_RESOURCE_PATH); } if (credentialsQueryRequest == null){ - credentialsQueryRequest = new QueryRequest(); + credentialsQueryRequest = new GeneralQueryRequest(); } if (credentialsQueryRequest.getResourceCredentials() == null){ credentialsQueryRequest.setResourceCredentials(new HashMap()); diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureQueryService.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureQueryService.java index 96dd3151..027a0e2b 100644 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureQueryService.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureQueryService.java @@ -7,13 +7,14 @@ import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.QueryRepository; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; +import edu.harvard.dbmi.avillach.domain.GICQueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.QueryRequest; import edu.harvard.dbmi.avillach.domain.QueryStatus; import edu.harvard.dbmi.avillach.security.JWTFilter; import edu.harvard.dbmi.avillach.util.Utilities; import edu.harvard.dbmi.avillach.util.exception.ApplicationException; import edu.harvard.dbmi.avillach.util.exception.ProtocolException; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,7 +94,7 @@ public QueryStatus query(QueryRequest dataQueryRequest, HttpHeaders headers) { * @return {@link QueryStatus} */ @Transactional - public QueryStatus queryStatus(UUID queryId, QueryRequest credentialsQueryRequest, HttpHeaders headers) { + public QueryStatus queryStatus(UUID queryId, GeneralQueryRequest credentialsQueryRequest, HttpHeaders headers) { if (queryId == null){ throw new ProtocolException(ProtocolException.MISSING_QUERY_ID); } @@ -282,7 +283,7 @@ public QueryStatus queryMetadata(UUID queryId, HttpHeaders headers){ * and resource specific query (could be a string or a json object) * @return {@link QueryStatus} */ - public QueryStatus institutionalQuery(QueryRequest dataQueryRequest, HttpHeaders headers, String email) { + public QueryStatus institutionalQuery(GICQueryRequest dataQueryRequest, HttpHeaders headers, String email) { String siteCode = siteParsingService.parseSiteOfOrigin(email).orElseThrow(() -> new RuntimeException("Bad email")); dataQueryRequest.setInstitutionOfOrigin(siteCode); Resource resource = verifyQueryRequest(dataQueryRequest, headers); @@ -314,19 +315,16 @@ private Query copyQuery(QueryRequest dataQueryRequest, Resource resource, QueryS throw new ProtocolException(ProtocolException.INCORRECTLY_FORMATTED_REQUEST); } } - Map metaData = response.getResultMetadata(); metaData = metaData == null ? new HashMap<>() : metaData; - if (dataQueryRequest.getCommonAreaUUID() != null) { - metaData.put("commonAreaUUID", dataQueryRequest.getCommonAreaUUID()); - } - if (!StringUtils.isEmpty(dataQueryRequest.getInstitutionOfOrigin())) { - metaData.put("site", dataQueryRequest.getInstitutionOfOrigin()); + if (dataQueryRequest instanceof GICQueryRequest) { + GICQueryRequest gicRequest = (GICQueryRequest) dataQueryRequest; + metaData.put("commonAreaUUID", gicRequest.getCommonAreaUUID()); + metaData.put("site", gicRequest.getInstitutionOfOrigin()); + metaData.put("sharingStatus", DataSharingStatus.Unknown); } - metaData.put("sharingStatus", DataSharingStatus.Unknown); - queryEntity.setQuery(queryJson); if (!metaData.isEmpty()) { diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureSearchService.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureSearchService.java index f2f327c5..c0017335 100644 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureSearchService.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/PicsureSearchService.java @@ -4,6 +4,7 @@ import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; import edu.harvard.dbmi.avillach.domain.PaginatedSearchResult; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.QueryRequest; import edu.harvard.dbmi.avillach.domain.SearchResults; import edu.harvard.dbmi.avillach.util.Utilities; @@ -33,7 +34,7 @@ public class PicsureSearchService { * Executes a concept search against a target resource * * @param resourceId - UUID of target resource - * @param searchQueryRequest - {@link QueryRequest} containing resource specific credentials object + * @param searchQueryRequest - {@link GeneralQueryRequest} containing resource specific credentials object * and resource specific query (could be a string or a json object) * @param headers * @return {@link SearchResults} @@ -65,7 +66,7 @@ public SearchResults search(UUID resourceId, QueryRequest searchQueryRequest, Ht return resourceWebClient.search(resource.getResourceRSPath(), searchQueryRequest); } - public PaginatedSearchResult searchGenomicConceptValues(UUID resourceId, QueryRequest queryRequest, String conceptPath, String query, Integer page, Integer size + public PaginatedSearchResult searchGenomicConceptValues(UUID resourceId, GeneralQueryRequest queryRequest, String conceptPath, String query, Integer page, Integer size , HttpHeaders headers) { Resource resource = resourceRepo.getById(resourceId); if (resource == null){ diff --git a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/SystemService.java b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/SystemService.java index 4902448d..2d6328d9 100755 --- a/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/SystemService.java +++ b/pic-sure-api-war/src/main/java/edu/harvard/dbmi/avillach/service/SystemService.java @@ -24,7 +24,7 @@ import edu.harvard.dbmi.avillach.PicSureWarInit; import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.ResourceInfo; import edu.harvard.dbmi.avillach.util.exception.ApplicationException; @@ -126,7 +126,7 @@ private boolean testPSAMAResponds() throws UnsupportedOperationException, IOExce private boolean testResourcesRespond(List resourcesToTest) { for(Resource resource : resourcesToTest) { - ResourceInfo info = new ResourceWebClient().info(resource.getResourceRSPath(), new QueryRequest()); + ResourceInfo info = new ResourceWebClient().info(resource.getResourceRSPath(), new GeneralQueryRequest()); if(info==null) { return false; } diff --git a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceTest.java b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceTest.java index e26470cd..f667c313 100644 --- a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceTest.java +++ b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceTest.java @@ -2,7 +2,7 @@ import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.ResourceInfo; import edu.harvard.dbmi.avillach.service.PicsureInfoService; import edu.harvard.dbmi.avillach.service.ResourceWebClient; @@ -60,7 +60,7 @@ public void setUp() { @Test public void testInfoEndpoints() { - QueryRequest infoRequest = new QueryRequest(); + GeneralQueryRequest infoRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); infoRequest.setResourceCredentials(clientCredentials); diff --git a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceTest.java b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceTest.java index b00b96d1..dfddf854 100644 --- a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceTest.java +++ b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceTest.java @@ -12,7 +12,6 @@ import java.nio.charset.StandardCharsets; import java.util.*; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; @@ -32,7 +31,7 @@ import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.QueryRepository; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.QueryStatus; import edu.harvard.dbmi.avillach.service.PicsureQueryService; import edu.harvard.dbmi.avillach.service.ResourceWebClient; @@ -111,7 +110,7 @@ public void testQueryEmptyRequest() { @Test public void testQueryMissingResourceId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); @@ -134,7 +133,7 @@ public void testQueryMissingResourceId() { @Test public void testQueryInvalidResourceId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); @@ -155,7 +154,7 @@ public void testQueryInvalidResourceId() { @Test public void testQueryValidRequest() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map exists Map clientCredentials = new HashMap(); dataQueryRequest.setResourceCredentials(clientCredentials); @@ -184,7 +183,7 @@ public void testQueryValidRequest() { @Test public void testQueryStatusNoId() { - QueryRequest statusRequest = new QueryRequest(); + GeneralQueryRequest statusRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); statusRequest.setResourceCredentials(clientCredentials); try { @@ -201,7 +200,7 @@ public void testQueryStatusNoId() { @Test public void testQueryStatusInvalidId() { - QueryRequest statusRequest = new QueryRequest(); + GeneralQueryRequest statusRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); statusRequest.setResourceCredentials(clientCredentials); @@ -220,7 +219,7 @@ public void testQueryStatusInvalidId() { @Test public void testQueryStatusValid() { - QueryRequest statusRequest = new QueryRequest(); + GeneralQueryRequest statusRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); statusRequest.setResourceCredentials(clientCredentials); // Setup a pre-existing query Entity @@ -253,7 +252,7 @@ public void testQueryStatusValid() { public void testQueryResultNoId() { - QueryRequest resultRequest = new QueryRequest(); + GeneralQueryRequest resultRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); resultRequest.setResourceCredentials(clientCredentials); try { @@ -271,7 +270,7 @@ public void testQueryResultNoId() { public void testQueryResultInvalidId() { - QueryRequest resultRequest = new QueryRequest(); + GeneralQueryRequest resultRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); resultRequest.setResourceCredentials(clientCredentials); try { @@ -290,7 +289,7 @@ public void testQueryResultInvalidId() { public void testQueryResultValid() { - QueryRequest resultRequest = new QueryRequest(); + GeneralQueryRequest resultRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); resultRequest.setResourceCredentials(clientCredentials); @@ -331,7 +330,7 @@ public void testQuerySyncNoQuery() { @Test public void testQuerySyncNoResourceId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); @@ -353,7 +352,7 @@ public void testQuerySyncNoResourceId() { @Test public void testQuerySyncInvalidResourceId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); @@ -374,7 +373,7 @@ public void testQuerySyncInvalidResourceId() { @Test public void testQuerySyncValidNoResponseId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); @@ -446,7 +445,7 @@ public void testShouldQueryMetadata() { @Test public void testQuerySyncValidWithResponseId() { - QueryRequest dataQueryRequest = new QueryRequest(); + GeneralQueryRequest dataQueryRequest = new GeneralQueryRequest(); // At this level we don't check the credentials themselves, just that the map // exists Map clientCredentials = new HashMap(); diff --git a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceTest.java b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceTest.java index 52c11478..0abebaa1 100644 --- a/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceTest.java +++ b/pic-sure-api-war/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceTest.java @@ -12,7 +12,7 @@ import java.util.UUID; import edu.harvard.dbmi.avillach.data.entity.Resource; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; @@ -58,7 +58,7 @@ public void setUp() { @Test public void testSearch() { - QueryRequest searchQueryRequest = new QueryRequest(); + GeneralQueryRequest searchQueryRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); clientCredentials.put("bearer key", "bearer token"); searchQueryRequest.setResourceCredentials(clientCredentials); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java index 5fe2be09..1138fc44 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/AggregateResourceIT.java @@ -123,8 +123,8 @@ public void testQuery() throws IOException { //Create multiple queries and add them to a main query as a list - QueryRequest queryRequest1 = new QueryRequest(); - QueryRequest queryRequest2 = new QueryRequest(); + QueryRequest queryRequest1 = new GeneralQueryRequest(); + QueryRequest queryRequest2 = new GeneralQueryRequest(); Map credentials = new HashMap(); queryRequest1.setResourceCredentials(credentials); queryRequest1.setQuery(queryString); @@ -136,7 +136,7 @@ public void testQuery() throws IOException { queryList.add(queryRequest1); queryList.add(queryRequest2); - QueryRequest topQuery = new QueryRequest(); + QueryRequest topQuery = new GeneralQueryRequest(); topQuery.setQuery(queryList); topQuery.setResourceUUID(aggregateUUID); @@ -234,7 +234,7 @@ public void testQueryStatus() throws IOException { .withStatus(200) .withBody(objectMapper.writeValueAsString(resourceResponse)))); - QueryRequest request = new QueryRequest(); + QueryRequest request = new GeneralQueryRequest(); Map credentials = new HashMap(); request.setResourceCredentials(credentials); String body = objectMapper.writeValueAsString(request); @@ -309,12 +309,12 @@ public void testResult() throws IOException, InterruptedException { .withStatus(200) .withBody(objectMapper.writeValueAsString(resultResponse)))); - QueryRequest resultRequest = new QueryRequest(); + QueryRequest resultRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); credentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token); - QueryRequest request = new QueryRequest(); + QueryRequest request = new GeneralQueryRequest(); request.setResourceCredentials(credentials); String body = objectMapper.writeValueAsString(request); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/GnomeI2B2ResourceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/GnomeI2B2ResourceIT.java index 83a283aa..14216d7e 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/GnomeI2B2ResourceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/GnomeI2B2ResourceIT.java @@ -160,7 +160,7 @@ public void testQuery() throws IOException { .withBody(objectMapper.writeValueAsString(gnomeResponse)))); //Create a query - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); Map queryMap = new HashMap<>(); queryRequest.setResourceCredentials(credentials); @@ -282,7 +282,7 @@ public void testQueryStatus() throws IOException { .withStatus(200) .withBody(objectMapper.writeValueAsString(errorResponse)))); - QueryRequest statusQuery = new QueryRequest(); + QueryRequest statusQuery = new GeneralQueryRequest(); Map credentials = new HashMap(); statusQuery.setResourceCredentials(credentials); String body = objectMapper.writeValueAsString(statusQuery); @@ -392,7 +392,7 @@ public void testResult() throws IOException, InterruptedException { .withStatus(200) .withBody(objectMapper.writeValueAsString(i2b2Response)))); - QueryRequest resultRequest = new QueryRequest(); + QueryRequest resultRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); credentials.put(GnomeI2B2CountResourceRS.I2B2_BEARER_TOKEN_KEY, token); credentials.put(GnomeI2B2CountResourceRS.GNOME_BEARER_TOKEN_KEY, token); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/HSAPIResourceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/HSAPIResourceIT.java index 3ae95b9e..b4d174af 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/HSAPIResourceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/HSAPIResourceIT.java @@ -33,7 +33,7 @@ public void testStatus() throws UnsupportedOperationException { @Test public void testInfo() throws UnsupportedOperationException, IOException { - QueryRequest request = new QueryRequest(); + QueryRequest request = new GeneralQueryRequest(); String body = objectMapper.writeValueAsString(request); HttpResponse response = retrievePostResponse(composeURL(hsapiEndpointUrl,"pic-sure/hsapi/info"), headers, body); @@ -51,7 +51,7 @@ public void testInfo() throws UnsupportedOperationException, IOException { @Test public void testSearch() throws UnsupportedOperationException, IOException { - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); String body = objectMapper.writeValueAsString(queryRequest); @@ -65,7 +65,7 @@ public void testSearch() throws UnsupportedOperationException, IOException { @Test public void testQuery() throws UnsupportedOperationException, IOException { - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); String body = objectMapper.writeValueAsString(queryRequest); @@ -111,7 +111,7 @@ public void testQuerySync() throws UnsupportedOperationException, IOException { .withStatus(200) .withBody(objectMapper.writeValueAsString(resourceResponse)))); - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); String body = objectMapper.writeValueAsString(queryRequest); //Should throw an error if missing query object diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/IRCTResourceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/IRCTResourceIT.java index 5a50a396..97f85611 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/IRCTResourceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/IRCTResourceIT.java @@ -76,7 +76,7 @@ public void testInfo() throws UnsupportedOperationException, IOException { .withStatus(200) .withBody(objectMapper.writeValueAsString(qfs)))); - QueryRequest request = new QueryRequest(); + QueryRequest request = new GeneralQueryRequest(); //Should throw an error if credentials missing or wrong Map credentials = new HashMap(); @@ -147,7 +147,7 @@ public void testSearch() throws UnsupportedOperationException, IOException { .withBody(objectMapper.writeValueAsString(emptyResult)))); - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); queryRequest.setResourceCredentials(credentials); queryRequest.setQuery("%antibody%"); @@ -254,7 +254,7 @@ public void testQuery() throws UnsupportedOperationException, IOException { .withBody(objectMapper.writeValueAsString(resourceResponse)))); - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); queryRequest.setResourceCredentials(credentials); queryRequest.setQuery(queryString); @@ -363,7 +363,7 @@ public void testQueryResult() throws UnsupportedOperationException, IOException .withStatus(200) .withBody(objectMapper.writeValueAsString(resultResponse)))); - QueryRequest queryRequest = new QueryRequest(); + QueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap(); queryRequest.setResourceCredentials(credentials); String body = objectMapper.writeValueAsString(queryRequest); @@ -433,7 +433,7 @@ public void testQueryStatus() throws UnsupportedOperationException, IOException .withStatus(200) .withBody(objectMapper.writeValueAsString(resourceResponse)))); - QueryRequest request = new QueryRequest(); + QueryRequest request = new GeneralQueryRequest(); Mapcredentials = new HashMap(); request.setResourceCredentials(credentials); String body = objectMapper.writeValueAsString(request); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceIT.java index 0c2b8282..921092b6 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureInfoServiceIT.java @@ -34,7 +34,7 @@ public void testInfoEndpoints() throws Exception { HttpResponse response = retrievePostResponse(uri, headers, ""); assertEquals("Missing credentials should return 401", 401, response.getStatusLine().getStatusCode()); - QueryRequest infoRequest = new QueryRequest(); + QueryRequest infoRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); //TODO I guess we need some way to identify the token key? Maybe V1.4_BEARER_TOKEN clientCredentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, "testToken"); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceIT.java index 3567d5ed..cae7641e 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureQueryServiceIT.java @@ -51,7 +51,7 @@ public void testQuery() throws Exception { //Test missing info String uri = composeURL(endpointUrl, "/query/"); - QueryRequest dataQueryRequest = new QueryRequest(); + QueryRequest dataQueryRequest = new GeneralQueryRequest(); HttpResponse response = retrievePostResponse(uri, headers, ""); assertEquals("Missing query request info should return 500", 500, response.getStatusLine().getStatusCode()); EntityUtils.consume(response.getEntity()); @@ -88,7 +88,7 @@ public void testQuery() throws Exception { @Test public void testQueryStatus() throws Exception { - QueryRequest statusRequest = new QueryRequest(); + QueryRequest statusRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); clientCredentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token); statusRequest.setResourceCredentials(clientCredentials); @@ -137,7 +137,7 @@ public void testResult() throws Exception { .withStatus(200) .withBody("anyOldResultWillDo"))); - QueryRequest resultRequest = new QueryRequest(); + QueryRequest resultRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); clientCredentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, token); resultRequest.setResourceCredentials(clientCredentials); diff --git a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceIT.java b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceIT.java index ce22643d..9538d463 100644 --- a/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceIT.java +++ b/pic-sure-api-wildfly/src/test/java/edu/harvard/dbmi/avillach/PicsureSearchServiceIT.java @@ -36,7 +36,7 @@ public void testSearch() throws Exception { assertEquals("Missing query request info should return 500", 500, response.getStatusLine().getStatusCode()); EntityUtils.consume(response.getEntity()); - QueryRequest searchQueryRequest = new QueryRequest(); + QueryRequest searchQueryRequest = new GeneralQueryRequest(); Map clientCredentials = new HashMap(); //TODO This needs to not assume which resource is being used/what the token is... what to do!!... maybe we don't need to test this because it's tested by individual resourceRs tests? clientCredentials.put(IRCTResourceRS.IRCT_BEARER_TOKEN_KEY, "testToken"); diff --git a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java index 0e2efafc..fcc3f9ff 100644 --- a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java +++ b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/main/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRS.java @@ -8,10 +8,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; import edu.harvard.dbmi.avillach.data.entity.Resource; import edu.harvard.dbmi.avillach.data.repository.ResourceRepository; -import edu.harvard.dbmi.avillach.domain.QueryRequest; -import edu.harvard.dbmi.avillach.domain.QueryStatus; -import edu.harvard.dbmi.avillach.domain.ResourceInfo; -import edu.harvard.dbmi.avillach.domain.SearchResults; +import edu.harvard.dbmi.avillach.domain.*; import edu.harvard.dbmi.avillach.service.IResourceRS; import edu.harvard.dbmi.avillach.util.HttpClientUtil; import edu.harvard.dbmi.avillach.util.VisualizationUtil; @@ -33,7 +30,6 @@ import java.io.IOException; import java.util.*; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -107,7 +103,7 @@ public ResourceInfo info(QueryRequest infoRequest) { String pathName = "/info"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); if (infoRequest != null) { chainRequest.setQuery(infoRequest.getQuery()); chainRequest.setResourceCredentials(infoRequest.getResourceCredentials()); @@ -395,7 +391,7 @@ private JsonNode addStudyConsentsToQuery(JsonNode jsonNode) { private SearchResults getAllStudyConsents() { logger.debug("Calling Aggregate Data Sharing Resource getAllStudyConsents()"); - QueryRequest studiesConsents = new QueryRequest(); + QueryRequest studiesConsents = new GeneralQueryRequest(); studiesConsents.setQuery("\\_studies_consents\\"); return this.search(studiesConsents); } @@ -527,7 +523,7 @@ protected String processContinuousCrossCounts(String continuousCrossCountRespons }); // Create Query for Visualization /bin/continuous - QueryRequest visualizationBinRequest = new QueryRequest(); + QueryRequest visualizationBinRequest = new GeneralQueryRequest(); visualizationBinRequest.setResourceUUID(properties.getVisualizationResourceId()); visualizationBinRequest.setQuery(continuousCrossCounts); visualizationBinRequest.setResourceCredentials(queryRequest.getResourceCredentials()); @@ -688,7 +684,7 @@ private boolean isCrossCountObfuscated(Map crossCounts, int gene * @return int The variance for the request */ private QueryRequest createChainRequest(QueryRequest queryRequest) { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(queryRequest.getQuery()); chainRequest.setResourceCredentials(queryRequest.getResourceCredentials()); diff --git a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java index 81c8e169..59bddec9 100644 --- a/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java +++ b/pic-sure-resources/pic-sure-aggregate-data-sharing-resource/src/test/java/edu/harvard/hms/dbmi/avillach/AggregateDataSharingResourceRSAcceptanceTests.java @@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.junit.WireMockClassRule; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import static com.github.tomakehurst.wiremock.client.WireMock.*; import static org.junit.Assert.*; @@ -270,8 +270,8 @@ public void testMinimumThreshold() throws IOException { assertTrue(numericResult >= 10); } - private QueryRequest getTestQuery() throws JsonProcessingException, JsonMappingException, IOException { - return mapper.readValue(getTestJson("test_cross_count_query"), QueryRequest.class); + private GeneralQueryRequest getTestQuery() throws JsonProcessingException, JsonMappingException, IOException { + return mapper.readValue(getTestJson("test_cross_count_query"), GeneralQueryRequest.class); } private String getTestJson(String json_file_name) throws IOException { @@ -313,9 +313,9 @@ private String getObfuscatedResponseForResult(String originalResult) @Test public void shouldPostQuery() { UUID targetResourceId = UUID.fromString(mockProperties.getTargetResourceId()); - QueryRequest originalRequest = + GeneralQueryRequest originalRequest = createRequest("I seek the holy grail.", Map.of("name", "Sir Lancelot"), UUID.randomUUID()); - QueryRequest postedRequest = + GeneralQueryRequest postedRequest = createRequest("I seek the holy grail.", Map.of("name", "Sir Lancelot"), targetResourceId); QueryStatus expectedResponse = new QueryStatus(); @@ -338,9 +338,9 @@ public void shouldPostQuery() { @Test public void shouldPostQueryStatus() { UUID targetResourceId = UUID.fromString(mockProperties.getTargetResourceId()); - QueryRequest originalRequest = + GeneralQueryRequest originalRequest = createRequest("I seek the holy grail.", Map.of("name", "King Arthur"), UUID.randomUUID()); - QueryRequest postedRequest = + GeneralQueryRequest postedRequest = createRequest("I seek the holy grail.", Map.of("name", "King Arthur"), targetResourceId); QueryStatus expectedResponse = new QueryStatus(); @@ -366,9 +366,9 @@ public void shouldPostQueryStatus() { @Test public void shouldPostQueryResult() { UUID targetResourceId = UUID.fromString(mockProperties.getTargetResourceId()); - QueryRequest originalRequest = + GeneralQueryRequest originalRequest = createRequest("I seek the holy grail.", Map.of("name", "King Arthur"), UUID.randomUUID()); - QueryRequest postedRequest = + GeneralQueryRequest postedRequest = createRequest("I seek the holy grail.", Map.of("name", "King Arthur"), targetResourceId); Response expectedResponse = new OutboundJaxrsResponse(Response.Status.OK, new OutboundMessageContext()); @@ -391,9 +391,9 @@ public void shouldPostQueryResult() { @Test public void shouldHandleErrorResponse() { UUID targetResourceId = UUID.fromString(mockProperties.getTargetResourceId()); - QueryRequest originalRequest = + GeneralQueryRequest originalRequest = createRequest("I seek the holy grail.", Map.of("name", "Sir Lancelot"), UUID.randomUUID()); - QueryRequest postedRequest = + GeneralQueryRequest postedRequest = createRequest("I seek the holy grail.", Map.of("name", "Sir Lancelot"), targetResourceId); QueryStatus expectedResponse = new QueryStatus(); @@ -418,8 +418,8 @@ public void shouldHandleErrorResponse() { assertNotNull(exception); } - private static QueryRequest createRequest(String query, Map credentials, UUID resourceUUID) { - QueryRequest originalRequest = new QueryRequest(); + private static GeneralQueryRequest createRequest(String query, Map credentials, UUID resourceUUID) { + GeneralQueryRequest originalRequest = new GeneralQueryRequest(); originalRequest.setQuery(query); originalRequest.setResourceCredentials(credentials); originalRequest.setResourceUUID(resourceUUID); diff --git a/pic-sure-resources/pic-sure-ga4gh-dos/src/main/java/edu/harvard/hms/dbmi/avillach/GA4GHResourceRS.java b/pic-sure-resources/pic-sure-ga4gh-dos/src/main/java/edu/harvard/hms/dbmi/avillach/GA4GHResourceRS.java index 357b1940..d83935c5 100644 --- a/pic-sure-resources/pic-sure-ga4gh-dos/src/main/java/edu/harvard/hms/dbmi/avillach/GA4GHResourceRS.java +++ b/pic-sure-resources/pic-sure-ga4gh-dos/src/main/java/edu/harvard/hms/dbmi/avillach/GA4GHResourceRS.java @@ -2,13 +2,8 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; -import java.lang.annotation.Annotation; -import java.net.URI; -import java.net.URLEncoder; import java.util.*; -import javax.lang.model.type.ArrayType; -import javax.persistence.NoResultException; import javax.ws.rs.*; import javax.ws.rs.core.*; @@ -21,7 +16,6 @@ import edu.harvard.dbmi.avillach.util.exception.ProtocolException; import edu.harvard.dbmi.avillach.util.exception.ResourceInterfaceException; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.SerializationUtils; import org.apache.http.Header; import org.apache.http.HttpResponse; import org.apache.commons.lang3.StringUtils; diff --git a/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java b/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java index fdcb93f4..e6c557ee 100644 --- a/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java +++ b/pic-sure-resources/pic-sure-passthrough-resource/src/main/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRS.java @@ -5,10 +5,8 @@ import javax.inject.Inject; import javax.ws.rs.*; -import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.Response; -import javax.ws.rs.core.SecurityContext; import org.apache.http.Header; import org.apache.http.HttpResponse; @@ -54,7 +52,7 @@ public ResourceInfo info(QueryRequest infoRequest) { String pathName = "/info"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); if (infoRequest != null) { chainRequest.setQuery(infoRequest.getQuery()); chainRequest.setResourceCredentials(infoRequest.getResourceCredentials()); @@ -99,12 +97,8 @@ public QueryStatus query(QueryRequest queryRequest) { String pathName = "/query"; try { - QueryRequest chainRequest = new QueryRequest(); - chainRequest.setQuery(queryRequest.getQuery()); - chainRequest.setResourceCredentials(queryRequest.getResourceCredentials()); + QueryRequest chainRequest = queryRequest.copy(); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); - chainRequest.setCommonAreaUUID(queryRequest.getCommonAreaUUID()); - chainRequest.setInstitutionOfOrigin(queryRequest.getInstitutionOfOrigin()); String payload = objectMapper.writeValueAsString(chainRequest); HttpResponse response = httpClient.retrievePostResponse( @@ -137,7 +131,7 @@ public Response queryResult(@PathParam("resourceQueryId") String queryId, QueryR String pathName = "/query/" + queryId + "/result"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(resultRequest.getQuery()); chainRequest.setResourceCredentials(resultRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); @@ -173,7 +167,7 @@ public QueryStatus queryStatus(@PathParam("resourceQueryId") String queryId, Que String pathName = "/query/" + queryId + "/status"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(statusRequest.getQuery()); chainRequest.setResourceCredentials(statusRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); @@ -214,7 +208,7 @@ public Response querySync(QueryRequest queryRequest) { String pathName = "/query/sync"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(queryRequest.getQuery()); chainRequest.setResourceCredentials(queryRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); @@ -259,7 +253,7 @@ public SearchResults search(QueryRequest searchRequest) { String pathName = "/search/" + properties.getTargetResourceId(); try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(searchRequest.getQuery()); chainRequest.setResourceCredentials(searchRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); @@ -294,7 +288,7 @@ public Response queryFormat(QueryRequest queryRequest) { String pathName = "/query/format"; try { - QueryRequest chainRequest = new QueryRequest(); + QueryRequest chainRequest = new GeneralQueryRequest(); chainRequest.setQuery(queryRequest.getQuery()); chainRequest.setResourceCredentials(queryRequest.getResourceCredentials()); chainRequest.setResourceUUID(UUID.fromString(properties.getTargetResourceId())); diff --git a/pic-sure-resources/pic-sure-passthrough-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRSTest.java b/pic-sure-resources/pic-sure-passthrough-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRSTest.java index 578fba9e..c1466b99 100644 --- a/pic-sure-resources/pic-sure-passthrough-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRSTest.java +++ b/pic-sure-resources/pic-sure-passthrough-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/passthru/PassThroughResourceRSTest.java @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableList; import edu.harvard.dbmi.avillach.domain.QueryFormat; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.dbmi.avillach.domain.QueryStatus; import edu.harvard.dbmi.avillach.domain.ResourceInfo; import edu.harvard.dbmi.avillach.domain.SearchResults; @@ -75,19 +75,19 @@ void testInfo() throws Exception { when(statusLine.getStatusCode()).thenReturn(500); assertThrows(ResourceInterfaceException.class, () -> { - resource.info(new QueryRequest()); + resource.info(new GeneralQueryRequest()); }, "Downstream Resource returned 500 and should cause 'ResourceInterfaceException'"); when(statusLine.getStatusCode()).thenReturn(401); assertThrows(NotAuthorizedException.class, () -> { - resource.info(new QueryRequest()); + resource.info(new GeneralQueryRequest()); }, "Downstream Resource returned 401 and should cause 'NotAuthorizedException'"); when(statusLine.getStatusCode()).thenReturn(200); ResourceInfo resourceInfo = newResourceInfo(); httpResponseEntity = new StringEntity(new String(objectMapper.writeValueAsBytes(resourceInfo))); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - ResourceInfo returnVal = resource.info(new QueryRequest()); + ResourceInfo returnVal = resource.info(new GeneralQueryRequest()); assertEquals(resourceInfo.getId(), returnVal.getId(), "Downstream ResourceInfo Id should match output"); assertEquals(resourceInfo.getName(), returnVal.getName(), "Downstream ResourceInfo Name should match output"); assertEquals(resourceInfo.getQueryFormats().size(), returnVal.getQueryFormats().size(), @@ -110,7 +110,7 @@ void testQuery() throws Exception { }, "QueryRequest is required"); assertThrows(ProtocolException.class, () -> { - resource.query(new QueryRequest()); + resource.query(new GeneralQueryRequest()); }, "Query is required"); when(statusLine.getStatusCode()).thenReturn(500); @@ -127,7 +127,7 @@ void testQuery() throws Exception { QueryStatus queryStatus = newQueryStatus(null); httpResponseEntity = new StringEntity(new String(objectMapper.writeValueAsBytes(queryStatus))); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - QueryRequest queryRequest = newQueryRequest("test"); + GeneralQueryRequest queryRequest = newQueryRequest("test"); QueryStatus returnVal = resource.query(queryRequest); assertEquals(queryRequest.getResourceUUID(), returnVal.getResourceID()); } @@ -167,7 +167,7 @@ void testQueryResult() throws Exception { lenient().when(httpResponse.getFirstHeader("resultId")).thenReturn(newHeader("resultId", resultId)); httpResponseEntity = new StringEntity("4"); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - QueryRequest queryRequest = newQueryRequest(null); + GeneralQueryRequest queryRequest = newQueryRequest(null); javax.ws.rs.core.Response returnVal = resource.queryResult(queryId.toString(), queryRequest); assertEquals("4", IOUtils.toString((InputStream) returnVal.getEntity(), StandardCharsets.UTF_8)); //assertEquals(resultId, returnVal.getHeaderString("resultId")); @@ -207,7 +207,7 @@ void testQueryStatus() throws Exception { QueryStatus queryStatus = newQueryStatus(queryId); httpResponseEntity = new StringEntity(new String(objectMapper.writeValueAsBytes(queryStatus))); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - QueryRequest queryRequest = newQueryRequest(null); + GeneralQueryRequest queryRequest = newQueryRequest(null); QueryStatus returnVal = resource.queryStatus(queryId.toString(), queryRequest); assertEquals(queryId, returnVal.getPicsureResultId()); assertEquals(queryStatus.getStatus(), returnVal.getStatus()); @@ -230,7 +230,7 @@ void testQuerySync() throws Exception { }, "QueryRequest is required"); assertThrows(ProtocolException.class, () -> { - resource.querySync(new QueryRequest()); + resource.querySync(new GeneralQueryRequest()); }, "Query is required"); when(statusLine.getStatusCode()).thenReturn(500); @@ -248,7 +248,7 @@ void testQuerySync() throws Exception { lenient().when(httpResponse.getFirstHeader("resultId")).thenReturn(newHeader("resultId", resultId)); httpResponseEntity = new StringEntity("4"); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - QueryRequest queryRequest = newQueryRequest(newQuery()); + GeneralQueryRequest queryRequest = newQueryRequest(newQuery()); javax.ws.rs.core.Response returnVal = resource.querySync(queryRequest); assertEquals("4", IOUtils.toString((InputStream) returnVal.getEntity(), StandardCharsets.UTF_8)); //assertEquals(resultId, returnVal.getHeaderString("resultId")); @@ -270,7 +270,7 @@ void testSearch() throws Exception { }, "QueryRequest is required"); assertThrows(ProtocolException.class, () -> { - resource.search(new QueryRequest()); + resource.search(new GeneralQueryRequest()); }, "Query is required"); when(statusLine.getStatusCode()).thenReturn(500); @@ -289,7 +289,7 @@ void testSearch() throws Exception { searchResults.setSearchQuery(queryText); httpResponseEntity = new StringEntity(new String(objectMapper.writeValueAsBytes(searchResults))); when(httpResponse.getEntity()).thenReturn(httpResponseEntity); - QueryRequest queryRequest = newQueryRequest(queryText); + GeneralQueryRequest queryRequest = newQueryRequest(queryText); SearchResults returnVal = resource.search(queryRequest); assertEquals(queryText, returnVal.getSearchQuery()); } @@ -313,8 +313,8 @@ private QueryStatus newQueryStatus(UUID picsureResultId) { return status; } - private QueryRequest newQueryRequest(Object query) { - QueryRequest request = new QueryRequest(); + private GeneralQueryRequest newQueryRequest(Object query) { + GeneralQueryRequest request = new GeneralQueryRequest(); request.setResourceUUID(UUID.randomUUID()); request.setQuery(query); return request; diff --git a/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GICQueryRequest.java b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GICQueryRequest.java new file mode 100644 index 00000000..c5b4987e --- /dev/null +++ b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GICQueryRequest.java @@ -0,0 +1,124 @@ +package edu.harvard.dbmi.avillach.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Schema(name = "QueryRequest", description = "Object containing credentials map under 'resourceCredentials' and query" + + " object under 'query'. The query object expectedResultType can be on of the following " + + "\"COUNT\", \"CROSS_COUNT\", \"INFO_COLUMN_LISTING\", \"OBSERVATION_COUNT\", \"OBSERVATION_CROSS_COUNT\", \"DATAFRAME\". ", + example = "{\n" + + " \"resourceUUID\": \"\",\n" + + " \"query\": {\n" + + " \"categoryFilters\": {\n" + + " \"\\\\demographics\\\\SEX\\\\\": [\n" + + " \"female\",\n" + + " \"male\"\n" + + " ]\n" + + " },\n" + + " \"numericFilters\": {\n" + + " \"\\\\demographics\\\\AGE\\\\\": {\n" + + " \"min\": \"0\",\n" + + " \"max\": \"85\"\n" + + " }\n" + + " },\n" + + " \"requiredFields\": [],\n" + + " \"anyRecordOf\": [\n" + + " \"\\\\demographics\\\\RACE\\\\\"\n" + + " ],\n" + + " \"variantInfoFilters\": [\n" + + " {\n" + + " \"categoryVariantInfoFilters\": {},\n" + + " \"numericVariantInfoFilters\": {}\n" + + " }\n" + + " ],\n" + + " \"expectedResultType\": \"DATAFRAME\",\n" + + " \"fields\": []\n" + + " }\n" + + "}") + +/* + * QueryRequests for vanilla GIC PIC-SURE. Includes details about the source + * of the request, the requester, and any unifying identifiers for sharing + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GICQueryRequest implements QueryRequest { + + @Schema(hidden = true) + private Map resourceCredentials = new HashMap<>(); + + @Schema(hidden = true) + private Object query; + + @Schema(hidden = true) + private UUID resourceUUID; + + @Schema(hidden = true) + private UUID commonAreaUUID; + + @Schema(hidden = true) + private String institutionOfOrigin; + + @Override + public Map getResourceCredentials() { + return resourceCredentials; + } + + @Override + public GICQueryRequest setResourceCredentials(Map resourceCredentials) { + this.resourceCredentials = resourceCredentials; + return this; + } + + @Override + public Object getQuery() { + return query; + } + + @Override + public GICQueryRequest setQuery(Object query) { + this.query = query; + return this; + } + + @Override + public UUID getResourceUUID() { + return resourceUUID; + } + + @Override + public void setResourceUUID(UUID resourceUUID) { + this.resourceUUID = resourceUUID; + } + + @Override + public GICQueryRequest copy() { + GICQueryRequest request = new GICQueryRequest(); + request.setQuery(getQuery()); + request.setResourceCredentials(getResourceCredentials()); + request.setResourceUUID(getResourceUUID()); + request.setCommonAreaUUID(getCommonAreaUUID()); + request.setInstitutionOfOrigin(getInstitutionOfOrigin()); + + return request; + } + + public UUID getCommonAreaUUID() { + return commonAreaUUID; + } + + public void setCommonAreaUUID(UUID commonAreaUUID) { + this.commonAreaUUID = commonAreaUUID; + } + + public String getInstitutionOfOrigin() { + return institutionOfOrigin; + } + + public void setInstitutionOfOrigin(String institutionOfOrigin) { + this.institutionOfOrigin = institutionOfOrigin; + } +} diff --git a/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GeneralQueryRequest.java b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GeneralQueryRequest.java new file mode 100644 index 00000000..4f4aca6b --- /dev/null +++ b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/GeneralQueryRequest.java @@ -0,0 +1,105 @@ +package edu.harvard.dbmi.avillach.domain; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +@Schema(name = "QueryRequest", description = "Object containing credentials map under 'resourceCredentials' and query" + + " object under 'query'. The query object expectedResultType can be on of the following " + + "\"COUNT\", \"CROSS_COUNT\", \"INFO_COLUMN_LISTING\", \"OBSERVATION_COUNT\", \"OBSERVATION_CROSS_COUNT\", \"DATAFRAME\". ", + example = "{\n" + + " \"resourceUUID\": \"\",\n" + + " \"query\": {\n" + + " \"categoryFilters\": {\n" + + " \"\\\\demographics\\\\SEX\\\\\": [\n" + + " \"female\",\n" + + " \"male\"\n" + + " ]\n" + + " },\n" + + " \"numericFilters\": {\n" + + " \"\\\\demographics\\\\AGE\\\\\": {\n" + + " \"min\": \"0\",\n" + + " \"max\": \"85\"\n" + + " }\n" + + " },\n" + + " \"requiredFields\": [],\n" + + " \"anyRecordOf\": [\n" + + " \"\\\\demographics\\\\RACE\\\\\"\n" + + " ],\n" + + " \"variantInfoFilters\": [\n" + + " {\n" + + " \"categoryVariantInfoFilters\": {},\n" + + " \"numericVariantInfoFilters\": {}\n" + + " }\n" + + " ],\n" + + " \"expectedResultType\": \"DATAFRAME\",\n" + + " \"fields\": []\n" + + " }\n" + + "}") + +/* + * QueryRequests for vanilla PIC-SURE + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class GeneralQueryRequest implements QueryRequest { + + @Schema(hidden = true) + private Map resourceCredentials = new HashMap<>(); + + @Schema(hidden = true) + private Object query; + + @Schema(hidden = true) + private UUID resourceUUID; + + @Schema(hidden = true) + private UUID commonAreaUUID; + + @Schema(hidden = true) + private String institutionOfOrigin; + + @Override + public Map getResourceCredentials() { + return resourceCredentials; + } + + @Override + public GeneralQueryRequest setResourceCredentials(Map resourceCredentials) { + this.resourceCredentials = resourceCredentials; + return this; + } + + @Override + public Object getQuery() { + return query; + } + + @Override + public GeneralQueryRequest setQuery(Object query) { + this.query = query; + return this; + } + + @Override + public UUID getResourceUUID() { + return resourceUUID; + } + + @Override + public void setResourceUUID(UUID resourceUUID) { + this.resourceUUID = resourceUUID; + } + + @Override + public GeneralQueryRequest copy() { + GeneralQueryRequest request = new GeneralQueryRequest(); + request.setQuery(getQuery()); + request.setResourceCredentials(getResourceCredentials()); + request.setResourceUUID(getResourceUUID()); + + return request; + } +} diff --git a/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/QueryRequest.java b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/QueryRequest.java index 3a8ee942..36e267cf 100644 --- a/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/QueryRequest.java +++ b/pic-sure-resources/pic-sure-resource-api/src/main/java/edu/harvard/dbmi/avillach/domain/QueryRequest.java @@ -1,101 +1,18 @@ package edu.harvard.dbmi.avillach.domain; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import io.swagger.v3.oas.annotations.media.Schema; -import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.UUID; -@Schema(name = "QueryRequest", description = "Object containing credentials map under 'resourceCredentials' and query" + - " object under 'query'. The query object expectedResultType can be on of the following " + - "\"COUNT\", \"CROSS_COUNT\", \"INFO_COLUMN_LISTING\", \"OBSERVATION_COUNT\", \"OBSERVATION_CROSS_COUNT\", \"DATAFRAME\". ", - example = "{\n" + - " \"resourceUUID\": \"\",\n" + - " \"query\": {\n" + - " \"categoryFilters\": {\n" + - " \"\\\\demographics\\\\SEX\\\\\": [\n" + - " \"female\",\n" + - " \"male\"\n" + - " ]\n" + - " },\n" + - " \"numericFilters\": {\n" + - " \"\\\\demographics\\\\AGE\\\\\": {\n" + - " \"min\": \"0\",\n" + - " \"max\": \"85\"\n" + - " }\n" + - " },\n" + - " \"requiredFields\": [],\n" + - " \"anyRecordOf\": [\n" + - " \"\\\\demographics\\\\RACE\\\\\"\n" + - " ],\n" + - " \"variantInfoFilters\": [\n" + - " {\n" + - " \"categoryVariantInfoFilters\": {},\n" + - " \"numericVariantInfoFilters\": {}\n" + - " }\n" + - " ],\n" + - " \"expectedResultType\": \"DATAFRAME\",\n" + - " \"fields\": []\n" + - " }\n" + - "}") +public interface QueryRequest { + public Map getResourceCredentials(); + public QueryRequest setResourceCredentials(Map resourceCredentials); -@JsonIgnoreProperties(ignoreUnknown = true) -public class QueryRequest { + public Object getQuery(); + public QueryRequest setQuery(Object query); - @Schema(hidden = true) - private Map resourceCredentials = new HashMap<>(); + public UUID getResourceUUID(); + public void setResourceUUID(UUID resourceUUID); - @Schema(hidden = true) - private Object query; - - @Schema(hidden = true) - private UUID resourceUUID; - - @Schema(hidden = true) - private UUID commonAreaUUID; - - @Schema(hidden = true) - private String institutionOfOrigin; - - public Map getResourceCredentials() { - return resourceCredentials; - } - public QueryRequest setResourceCredentials(Map resourceCredentials) { - this.resourceCredentials = resourceCredentials; - return this; - } - - public Object getQuery() { - return query; - } - public QueryRequest setQuery(Object query) { - this.query = query; - return this; - } - - public UUID getResourceUUID() { - return resourceUUID; - } - - public void setResourceUUID(UUID resourceUUID) { - this.resourceUUID = resourceUUID; - } - - public UUID getCommonAreaUUID() { - return commonAreaUUID; - } - - public void setCommonAreaUUID(UUID commonAreaUUID) { - this.commonAreaUUID = commonAreaUUID; - } - - public String getInstitutionOfOrigin() { - return institutionOfOrigin; - } - - public void setInstitutionOfOrigin(String institutionOfOrigin) { - this.institutionOfOrigin = institutionOfOrigin; - } + public QueryRequest copy(); } diff --git a/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/QueryRequestTest.java b/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/GICQueryRequestTest.java similarity index 77% rename from pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/QueryRequestTest.java rename to pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/GICQueryRequestTest.java index 60c8a68c..0edd37f6 100644 --- a/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/QueryRequestTest.java +++ b/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/domain/GICQueryRequestTest.java @@ -8,10 +8,10 @@ import java.util.Objects; import java.util.UUID; -public class QueryRequestTest extends TestCase { +public class GICQueryRequestTest extends TestCase { public void testShouldIgnoreMissingQueryId() throws JsonProcessingException { - QueryRequest expected = new QueryRequestWithEq(); + GICQueryRequest expected = new GeneralQueryRequestWithEq(); expected.setQuery("{}"); expected.setResourceCredentials(new HashMap<>()); expected.setResourceUUID(UUID.fromString("364c958e-53bb-4be7-bd5b-44fcda1592bc")); @@ -20,7 +20,7 @@ public void testShouldIgnoreMissingQueryId() throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); String jsonWithNoCUUID = "{\"resourceCredentials\":{},\"query\":\"{}\",\"resourceUUID\":\"364c958e-53bb-4be7-bd5b-44fcda1592bc\"}"; - QueryRequest actual = mapper.readValue(jsonWithNoCUUID, QueryRequestWithEq.class); + GICQueryRequest actual = mapper.readValue(jsonWithNoCUUID, GeneralQueryRequestWithEq.class); assertEquals(expected, actual); } @@ -28,12 +28,12 @@ public void testShouldIgnoreMissingQueryId() throws JsonProcessingException { /** * This is just to get comparison to work for the test. */ - private static final class QueryRequestWithEq extends QueryRequest { + private static final class GeneralQueryRequestWithEq extends GICQueryRequest { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof QueryRequestWithEq)) return false; - QueryRequestWithEq that = (QueryRequestWithEq) o; + if (!(o instanceof GICQueryRequest)) return false; + GICQueryRequest that = (GICQueryRequest) o; return Objects.equals(getResourceCredentials(), that.getResourceCredentials()) && Objects.equals(getQuery(), that.getQuery()) && Objects.equals(getResourceUUID(), that.getResourceUUID()) && Objects.equals(getCommonAreaUUID(), that.getCommonAreaUUID()); } diff --git a/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/service/ResourceWebClientTest.java b/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/service/ResourceWebClientTest.java index 493311a1..bac8e462 100644 --- a/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/service/ResourceWebClientTest.java +++ b/pic-sure-resources/pic-sure-resource-api/src/test/java/edu/harvard/dbmi/avillach/service/ResourceWebClientTest.java @@ -6,7 +6,6 @@ import edu.harvard.dbmi.avillach.domain.*; import edu.harvard.dbmi.avillach.util.PicSureStatus; import edu.harvard.dbmi.avillach.util.exception.ApplicationException; -import edu.harvard.dbmi.avillach.util.exception.NotAuthorizedException; import edu.harvard.dbmi.avillach.util.exception.ProtocolException; import org.apache.commons.io.IOUtils; import org.glassfish.jersey.internal.RuntimeDelegateImpl; @@ -66,7 +65,7 @@ public void testInfo() throws JsonProcessingException{ } catch (ProtocolException e) { assertEquals(ProtocolException.MISSING_DATA, e.getContent()); } - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap<>(); credentials.put(ResourceWebClient.BEARER_TOKEN_KEY, token); queryRequest.setResourceCredentials(credentials); @@ -138,7 +137,7 @@ public void testSearch() throws JsonProcessingException{ assertEquals(ProtocolException.MISSING_DATA, e.getContent()); } - QueryRequest request = new QueryRequest(); + GeneralQueryRequest request = new GeneralQueryRequest(); try { cut.search(testURL, request); fail(); @@ -249,7 +248,7 @@ public void testQuery() throws JsonProcessingException{ } catch (ProtocolException e) { assertEquals(ProtocolException.MISSING_DATA, e.getContent()); } - QueryRequest request = new QueryRequest(); + GeneralQueryRequest request = new GeneralQueryRequest(); // request.setTargetURL("/query"); try { @@ -332,7 +331,7 @@ public void testQueryResult() throws JsonProcessingException{ // } catch (ProtocolException e) { // assertEquals(ProtocolException.MISSING_DATA, e.getContent()); // } - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap<>(); credentials.put(ResourceWebClient.BEARER_TOKEN_KEY, token); queryRequest.setResourceCredentials(credentials); @@ -407,7 +406,7 @@ public void testQueryStatus() throws JsonProcessingException{ } catch (ProtocolException e) { assertEquals(ProtocolException.MISSING_DATA, e.getContent()); } - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); Map credentials = new HashMap<>(); credentials.put(ResourceWebClient.BEARER_TOKEN_KEY, token); queryRequest.setResourceCredentials(credentials); diff --git a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/VisualizationResourceTests.java b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/VisualizationResourceTests.java index 2f3dd818..c40d2235 100644 --- a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/VisualizationResourceTests.java +++ b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/VisualizationResourceTests.java @@ -1,6 +1,6 @@ package edu.harvard.hms.dbmi.avillach.resource.visualization; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.domain.Query; import edu.harvard.hms.dbmi.avillach.resource.visualization.service.DataProcessingService; import edu.harvard.hms.dbmi.avillach.resource.visualization.service.HpdsService; @@ -31,7 +31,7 @@ public VisualizationResourceTests() { @Test @DisplayName("Test Empty Query") void TestEmptyQuery() { - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.setQuery(new Query()); Response response = querySync(queryRequest); assertNull(response.getEntity()); diff --git a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/DataServiceTests.java b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/DataServiceTests.java index 17a962d6..9fedf61e 100644 --- a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/DataServiceTests.java +++ b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/DataServiceTests.java @@ -1,6 +1,6 @@ package edu.harvard.hms.dbmi.avillach.resource.visualization.service; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.CategoricalData; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.ContinuousData; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.domain.Filter; @@ -27,7 +27,7 @@ class CategoricalTests { @Test @DisplayName("Var name is the title") void TestSingleSmallCategoryHasCorrectResults() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -64,7 +64,7 @@ void TestSingleSmallCategoryHasCorrectResults() { @Test @DisplayName("Correct order and other bar is last") void TestSingleRequiredLargeCategoryHasCorrectOrder() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -111,7 +111,7 @@ void TestSingleRequiredLargeCategoryHasCorrectOrder() { @Test @DisplayName("Ensure large category has other bar and correct count") void TestSingleRequiredLargeCategoryHasCorrectResults() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -151,7 +151,7 @@ void TestSingleRequiredLargeCategoryHasCorrectResults() { @Test @DisplayName("Test Other bar NOT there for 8 categories") void TestSingleRequired8CategoryWithCorrectResults() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -186,7 +186,7 @@ void TestSingleRequired8CategoryWithCorrectResults() { @Test @DisplayName("Test Many filters") void TestManyRequiredCategoricalFilters() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -260,7 +260,7 @@ class continuousPathTests { @Test @DisplayName("Test Many filters") void TestManyRequiredContinuousFilters() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -314,7 +314,7 @@ void TestManyRequiredContinuousFilters() { @Test @DisplayName("Data accuracy test, no extra zeros added") void TestSingleDataAccuracyForNoExtraZero() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -363,7 +363,7 @@ void TestSingleDataAccuracyForNoExtraZero() { @Test @DisplayName("Make Sure last value has plus and isn't a value of zero") void TestSingleDataAccuracyForPlusNotLastZero() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -481,7 +481,7 @@ void TestSingleDataAccuracyForPlusNotLastZero() { @Test @DisplayName("Make Sure Empty buckets are added") void TestSingleDataAccuracyForAddingMissingBucketsWithZeroValues() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); @@ -586,7 +586,7 @@ void TestSingleDataAccuracyForAddingMissingBucketsWithZeroValues() { @Test @DisplayName("Test Big data set has more than 1 column when max-min>numBins") void TestBigDataSetHasMoreThenOneColumnWhenNumBinsGreaterThanMaxMinusMin() { - QueryRequest goodQueryRequest = new QueryRequest(); + GeneralQueryRequest goodQueryRequest = new GeneralQueryRequest(); goodQueryRequest.setResourceUUID(UUID.randomUUID()); goodQueryRequest.getResourceCredentials().put("Authorization", "some token"); Query query = new Query(); diff --git a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/HpdsServiceTests.java b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/HpdsServiceTests.java index 4923c9ee..a68f3d4a 100644 --- a/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/HpdsServiceTests.java +++ b/pic-sure-resources/pic-sure-visualization-resource/src/test/java/edu/harvard/hms/dbmi/avillach/resource/visualization/service/HpdsServiceTests.java @@ -1,6 +1,6 @@ package edu.harvard.hms.dbmi.avillach.resource.visualization.service; -import edu.harvard.dbmi.avillach.domain.QueryRequest; +import edu.harvard.dbmi.avillach.domain.GeneralQueryRequest; import edu.harvard.hms.dbmi.avillach.resource.visualization.ApplicationProperties; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.domain.Query; import edu.harvard.hms.dbmi.avillach.resource.visualization.model.domain.ResultType; @@ -30,7 +30,7 @@ static void setUp() { @Test @DisplayName("Test Query Has Null Authorization token") void TestNullAuthHeader() { - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.getResourceCredentials().put("Authorization", null); queryRequest.setQuery(new Query()); Map> crossCountsMap = service.getAuthCrossCountsMap(queryRequest, ResultType.CATEGORICAL_CROSS_COUNT); @@ -41,7 +41,7 @@ void TestNullAuthHeader() { @Test @DisplayName("Test Query Has No Authorization header") void TestNoAuthHeader() { - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.setQuery(new Query()); Map> crossCountsMap = service.getAuthCrossCountsMap(queryRequest, ResultType.CATEGORICAL_CROSS_COUNT); assertNotNull(crossCountsMap); @@ -51,7 +51,7 @@ void TestNoAuthHeader() { @Test @DisplayName("Test Query Null Result type") void TestNullResultType() { - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.setQuery(new Query()); Map> crossCountsMap = service.getAuthCrossCountsMap(queryRequest, null); assertNotNull(crossCountsMap); @@ -61,7 +61,7 @@ void TestNullResultType() { @Test @DisplayName("Test Query Wrong Result type") void TestWrongResultType() { - QueryRequest queryRequest = new QueryRequest(); + GeneralQueryRequest queryRequest = new GeneralQueryRequest(); queryRequest.setQuery(new Query()); Map> crossCountsMap = service.getAuthCrossCountsMap(queryRequest, ResultType.CROSS_COUNT); assertNotNull(crossCountsMap);