Skip to content

Commit

Permalink
DATAWAVE-1666: Use query-metric-api 4.0.1, use QueryGeometryResponse … (
Browse files Browse the repository at this point in the history
#2402)

* DATAWAVE-1666: Use QueryGeometryResponse from query-metric-api, use redirect for remote query metric GET calls

* Code formatting fixes
  • Loading branch information
billoley authored Jun 5, 2024
1 parent 8e9e106 commit c5a0f3a
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

import datawave.microservice.querymetric.BaseQueryMetric;
import datawave.webservice.query.map.QueryGeometryResponse;
import datawave.microservice.querymetric.QueryGeometryResponse;

public interface QueryGeometryHandler {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.locationtech.jts.io.WKTReader;

import datawave.core.common.logging.ThreadConfigurableLogger;
import datawave.microservice.querymetric.QueryGeometry;
import datawave.query.jexl.functions.GeoFunctionsDescriptor;
import datawave.query.jexl.functions.GeoWaveFunctionsDescriptor;
import datawave.query.jexl.functions.JexlFunctionArgumentDescriptorFactory;
import datawave.query.jexl.functions.arguments.JexlArgumentDescriptor;
import datawave.webservice.query.map.QueryGeometry;

/**
* This visitor will traverse the query tree, and extract both the geo function and associated query geometry (as GeoJSON).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import org.apache.commons.jexl3.parser.JexlNode;
import org.junit.Test;

import datawave.microservice.querymetric.QueryGeometry;
import datawave.query.jexl.JexlASTHelper;
import datawave.webservice.query.map.QueryGeometry;

public class GeoFeatureVisitorTest {
private static final String GEO_FIELD_QUERY = "(((GEO_FIELD >= '0208' && GEO_FIELD <= '020d') || GEO_FIELD == '0202') && (geowave:intersects(GEO_FIELD, 'POLYGON((10 10, -10 10, -10 -10, 10 -10, 10 10 ))')))";
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import datawave.configuration.RefreshableScope;
import datawave.microservice.querymetric.BaseQueryMetric;
import datawave.microservice.querymetric.BaseQueryMetricListResponse;
import datawave.microservice.querymetric.QueryGeometryResponse;
import datawave.microservice.querymetric.QueryMetricsSummaryResponse;
import datawave.security.authorization.DatawavePrincipal;
import datawave.security.system.CallerPrincipal;
import datawave.webservice.common.remote.RemoteHttpService;
import datawave.webservice.query.map.QueryGeometryResponse;
import datawave.webservice.result.VoidResponse;

/**
Expand All @@ -43,13 +43,13 @@
@Priority(Interceptor.Priority.APPLICATION)
public class RemoteQueryMetricService extends RemoteHttpService {

private static final String UPDATE_METRIC_SUFFIX = "updateMetric";
private static final String UPDATE_METRICS_SUFFIX = "updateMetrics";
private static final String ID_METRIC_SUFFIX = "id/%s";
private static final String MAP_METRIC_SUFFIX = "id/%s/map";
private static final String SUMMARY_ALL_SUFFIX = "summary/all";
private static final String SUMMARY_USER_SUFFIX = "summary/user";
private static final String AUTH_HEADER_NAME = "Authorization";
public static final String UPDATE_METRIC_SUFFIX = "updateMetric";
public static final String UPDATE_METRICS_SUFFIX = "updateMetrics";
public static final String ID_METRIC_SUFFIX = "id/%s";
public static final String MAP_METRIC_SUFFIX = "id/%s/map";
public static final String SUMMARY_ALL_SUFFIX = "summary/all";
public static final String SUMMARY_USER_SUFFIX = "summary/user";
public static final String AUTH_HEADER_NAME = "Authorization";
private ObjectReader baseQueryMetricListResponseReader;
private ObjectReader queryGeometryResponseReader;
private ObjectReader queryMetricsSummaryResponseReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;

import datawave.microservice.querymetric.BaseQueryMetricListResponse;
import datawave.microservice.querymetric.QueryMetricsDetailListResponse;
import datawave.microservice.querymetric.QueryMetricListResponse;
import datawave.webservice.response.objects.DefaultKey;
import datawave.webservice.response.objects.KeyBase;

Expand All @@ -38,7 +38,7 @@ public ObjectMapper decorate(ObjectMapper mapper) {
protected void registerAbstractTypes(ObjectMapper mapper) {
SimpleModule module = new SimpleModule(KeyBase.class.getName());
module.addAbstractTypeMapping(KeyBase.class, DefaultKey.class);
module.addAbstractTypeMapping(BaseQueryMetricListResponse.class, QueryMetricsDetailListResponse.class);
module.addAbstractTypeMapping(BaseQueryMetricListResponse.class, QueryMetricListResponse.class);
mapper.registerModule(module);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import datawave.core.query.map.QueryGeometryHandler;
import datawave.microservice.query.QueryImpl;
import datawave.microservice.querymetric.BaseQueryMetric;
import datawave.microservice.querymetric.QueryGeometry;
import datawave.microservice.querymetric.QueryGeometryResponse;
import datawave.query.jexl.JexlASTHelper;
import datawave.query.jexl.visitors.GeoFeatureVisitor;
import datawave.query.language.parser.ParseException;
import datawave.query.language.parser.jexl.LuceneToJexlQueryParser;
import datawave.query.metrics.ShardTableQueryMetricHandler;
import datawave.webservice.query.map.QueryGeometry;
import datawave.webservice.query.map.QueryGeometryResponse;

/**
* This class is used to extract query geometries from the query metrics in an effort to provide those geometries for subsequent display to the user.
Expand All @@ -47,8 +47,9 @@ public class SimpleQueryGeometryHandler implements QueryGeometryHandler {

@Override
public QueryGeometryResponse getQueryGeometryResponse(String id, List<? extends BaseQueryMetric> metrics) {
QueryGeometryResponse response = new QueryGeometryResponse(id, basemaps);

QueryGeometryResponse response = new QueryGeometryResponse();
response.setQueryId(id);
response.setBasemaps(basemaps);
if (metrics != null) {
Set<QueryGeometry> queryGeometries = new LinkedHashSet<>();
for (BaseQueryMetric metric : metrics) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
import datawave.microservice.querymetric.QueryMetric;
import datawave.microservice.querymetric.QueryMetricFactory;
import datawave.microservice.querymetric.QueryMetricListResponse;
import datawave.microservice.querymetric.QueryMetricsDetailListResponse;
import datawave.microservice.querymetric.QueryMetricsSummaryResponse;
import datawave.query.iterator.QueryOptions;
import datawave.query.jexl.visitors.JexlFormattedStringBuildingVisitor;
Expand Down Expand Up @@ -521,8 +520,8 @@ private List<QueryMetric> getQueryMetrics(BaseResponse response, Query query, Da
}

@Override
public QueryMetricsDetailListResponse query(String user, String queryId, DatawavePrincipal datawavePrincipal) {
QueryMetricsDetailListResponse response = new QueryMetricsDetailListResponse();
public QueryMetricListResponse query(String user, String queryId, DatawavePrincipal datawavePrincipal) {
QueryMetricListResponse response = new QueryMetricListResponse();

try {
enableLogs(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
import org.junit.Test;

import datawave.microservice.query.QueryImpl;
import datawave.microservice.querymetric.QueryGeometry;
import datawave.microservice.querymetric.QueryGeometryResponse;
import datawave.microservice.querymetric.QueryMetric;
import datawave.webservice.query.exception.QueryExceptionType;
import datawave.webservice.query.map.QueryGeometry;
import datawave.webservice.query.map.QueryGeometryResponse;

public class SimpleQueryGeometryHandlerTest {

Expand Down
Loading

0 comments on commit c5a0f3a

Please sign in to comment.