Skip to content

Commit

Permalink
Merge branch 'main' into version-property-names
Browse files Browse the repository at this point in the history
  • Loading branch information
foster33 authored Jul 19, 2024
2 parents 369409a + 970847b commit 6d6264c
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<relativePath>../../microservice-service-parent/pom.xml</relativePath>
</parent>
<artifactId>spring-boot-starter-datawave-query</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>1.0.2-SNAPSHOT</version>
<url>https://github.com/NationalSecurityAgency/datawave-spring-boot-starter-query</url>
<licenses>
<license>
Expand All @@ -24,11 +24,11 @@
</scm>
<properties>
<datawave.webservice.namespace>http://webservice.datawave/v1</datawave.webservice.namespace>
<version.datawave>7.0.0</version.datawave>
<version.datawave.hazelcast-client>4.0.0</version.datawave.hazelcast-client>
<version.datawave.starter>4.0.0</version.datawave.starter>
<version.datawave.starter-metadata>3.0.0</version.datawave.starter-metadata>
<version.datawave.starter-metrics>3.0.0</version.datawave.starter-metrics>
<version.datawave>7.1.2</version.datawave>
<version.datawave.hazelcast-client>4.0.1</version.datawave.hazelcast-client>
<version.datawave.starter>4.0.1</version.datawave.starter>
<version.datawave.starter-metadata>3.0.1</version.datawave.starter-metadata>
<version.datawave.starter-metrics>3.0.2</version.datawave.starter-metrics>
<version.guava>31.0.1-jre</version.guava>
</properties>
<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -35,7 +34,7 @@ public class QueryLogicFactoryConfiguration {
private final Logger log = LoggerFactory.getLogger(this.getClass());

@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty(name = "datawave.defaults.ResponseObjectFactory.enabled", havingValue = "true", matchIfMissing = true)
public ResponseObjectFactory responseObjectFactory() {
return new DefaultResponseObjectFactory();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import datawave.webservice.results.mr.MapReduceInfoResponse;

public class MapReduceQueryStatus implements Serializable {

private static final long serialVersionUID = -8731070243293603952L;

public enum MapReduceQueryState {
DEFINED, SUBMITTED, RUNNING, SUCCEEDED, CLOSED, CANCELED, FAILED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import org.locationtech.jts.geom.Geometry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.MessageProperties;
Expand All @@ -16,11 +17,15 @@
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;

import datawave.microservice.query.messaging.ClaimCheck;
import datawave.microservice.query.messaging.QueryResultsPublisher;
import datawave.microservice.query.messaging.Result;
import datawave.microservice.query.messaging.config.MessagingProperties;
import datawave.microservice.query.util.GeometryDeserializer;
import datawave.microservice.query.util.GeometrySerializer;

class RabbitMQQueryResultsPublisher implements QueryResultsPublisher {
private final Logger log = LoggerFactory.getLogger(this.getClass());
Expand Down Expand Up @@ -52,7 +57,14 @@ public RabbitMQQueryResultsPublisher(MessagingProperties.RabbitMQProperties rabb
latchMap.get(correlationData.getId()).countDown();
}
});
this.rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());

// set a custom module for (de)serializing Geometry objects
ObjectMapper objectMapper = new ObjectMapper();
SimpleModule geometryModule = new SimpleModule(Geometry.class.getName());
geometryModule.addSerializer(Geometry.class, new GeometrySerializer());
geometryModule.addDeserializer(Geometry.class, new GeometryDeserializer());

this.rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter(objectMapper));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import datawave.webservice.query.exception.DatawaveErrorCode;

public class QueryStatus implements Serializable {
private static final long serialVersionUID = -1633953472983032183L;

/**
* These are the possible query states correlating with the activity that the user is requesting.<br>
* DEFINE: define a query<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
import datawave.util.StringUtils;

public class TaskStates implements Serializable {
private static final long serialVersionUID = 1361359960334155427L;

/**
* The possible task states: <br>
* READY: ready to run <br>
* RUNNING: currently running <br>
* COMPLETED: completed successfully <br>
* FAILED: failed to execute successfully <br>
*/
public enum TASK_STATE implements Serializable {
public enum TASK_STATE {
READY, RUNNING, COMPLETED, FAILED
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package datawave.microservice.query.util;

import java.io.IOException;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;

import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

public class GeometryDeserializer extends JsonDeserializer<Geometry> {
private WKTReader wktReader = new WKTReader();

@Override
public Geometry deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
try {
return wktReader.read(jsonParser.getValueAsString());
} catch (ParseException e) {
throw new IOException("Failed to deserialize wkt to Geometry: " + jsonParser.getValueAsString(), e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package datawave.microservice.query.util;

import java.io.IOException;

import org.locationtech.jts.geom.Geometry;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

public class GeometrySerializer extends JsonSerializer<Geometry> {
@Override
public void serialize(Geometry geometry, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeString(geometry.toText());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void testCheckpoint() {
query.setQuery("foo == bar");
ShardQueryConfiguration config = new ShardQueryConfiguration();
config.setQuery(query);
QueryData queryData = new QueryData("table", "logic", Collections.singletonList(new Range()),
QueryData queryData = new QueryData("table", "logic", Collections.singletonList(new Range()), Collections.emptyList(),
Collections.singletonList(new IteratorSetting(10, "test", "test")));
config.setQueries(Collections.singletonList(queryData));
QueryCheckpoint qcp = new QueryCheckpoint(queryPool, uuid, queryLogic, config.getQueries());
Expand Down Expand Up @@ -169,7 +169,7 @@ public void testTask() {
query.setQuery("foo == bar");
ShardQueryConfiguration config = new ShardQueryConfiguration();
config.setQuery(query);
QueryData queryData = new QueryData("table", "logic", Collections.singletonList(new Range()),
QueryData queryData = new QueryData("table", "logic", Collections.singletonList(new Range()), Collections.emptyList(),
Collections.singletonList(new IteratorSetting(10, "test", "test")));
config.setQueries(Collections.singletonList(queryData));
QueryCheckpoint qcp = new QueryCheckpoint(queryPool, uuid, queryLogic, config.getQueries());
Expand Down Expand Up @@ -220,7 +220,7 @@ public void testTaskDescription() throws JsonProcessingException {
config.setQuery(query);
QueryData queryData = new QueryData("table", "logic",
Collections.singletonList(new Range(new Key("row1", "cf1", "cq1", "(FOO)"), true, new Key("row2", "cf2", "cq2", "(BAR)"), false)),
Collections.singletonList(new IteratorSetting(10, "test", "test", Collections.singletonMap("key", "value"))));
Collections.emptyList(), Collections.singletonList(new IteratorSetting(10, "test", "test", Collections.singletonMap("key", "value"))));
config.setQueries(Collections.singletonList(queryData));
TaskDescription desc = new TaskDescription(key, config.getQueries());

Expand Down

0 comments on commit 6d6264c

Please sign in to comment.