Skip to content

Commit

Permalink
Async ID change from UUID to String and Dynamic Config FIx (#1325)
Browse files Browse the repository at this point in the history
* Async UUID to String, Dynamic Config NPE

* Update DefaultAsyncQueryDAOTest.java
  • Loading branch information
moizarafat authored and aklish committed Dec 11, 2020
1 parent bdd399a commit b55b769
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

import lombok.Data;

import java.util.UUID;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrePersist;
import javax.validation.constraints.Pattern;

/**
* Model for Async Query.
Expand All @@ -35,7 +35,9 @@
public class AsyncQuery extends AsyncBase implements PrincipalOwned {
@Id
@Column(columnDefinition = "varchar(36)")
private UUID id; //Provided.
@Pattern(regexp = "^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
message = "id not of pattern UUID")
private String id; //Provided.

private String query; //JSON-API PATH or GraphQL payload.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import lombok.Data;

import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
Expand All @@ -34,7 +32,7 @@
public class AsyncQueryResult extends AsyncBase implements PrincipalOwned {
@Id
@Column(columnDefinition = "varchar(36)")
private UUID id; //Matches UUID in query.
private String id; //Matches id in query.

private Integer contentLength;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.yahoo.elide.async.models.QueryStatus;

import java.util.Collection;
import java.util.UUID;

/**
* Utility interface which uses the elide datastore to modify and create AsyncQuery and AsyncQueryResult Objects.
Expand All @@ -34,7 +33,7 @@ public interface AsyncQueryDAO {
* @return AsyncQueryResult Object
*/
public AsyncQueryResult createAsyncQueryResult(Integer status, String responseBody, AsyncQuery asyncQuery,
UUID asyncQueryId);
String asyncQueryId);

/**
* This method deletes a collection of AsyncQuery and its associated AsyncQueryResult objects from database and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;

import javax.inject.Singleton;
import javax.ws.rs.core.MultivaluedHashMap;
Expand Down Expand Up @@ -165,7 +164,7 @@ public Collection<AsyncQuery> deleteAsyncQueryAndResultCollection(String filterE

@Override
public AsyncQueryResult createAsyncQueryResult(Integer status, String responseBody,
AsyncQuery asyncQuery, UUID asyncQueryId) {
AsyncQuery asyncQuery, String asyncQueryId) {
log.debug("createAsyncQueryResult");
AsyncQueryResult queryResultObj = (AsyncQueryResult) executeInTransaction(dataStore, (tx, scope) -> {
AsyncQueryResult asyncQueryResult = new AsyncQueryResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import java.util.UUID;

public class DefaultAsyncQueryDAOTest {

Expand Down Expand Up @@ -111,7 +110,7 @@ public void testDeleteAsyncQueryAndResultCollection() {
public void testCreateAsyncQueryResult() {
Integer status = 200;
String responseBody = "responseBody";
UUID uuid = UUID.fromString("ba31ca4e-ed8f-4be0-a0f3-12088fa9263e");
String uuid = "ba31ca4e-ed8f-4be0-a0f3-12088fa9263e";
AsyncQueryResult result = asyncQueryDAO.createAsyncQueryResult(status, "responseBody", asyncQuery, uuid);

assertEquals(status, result.getStatus());
Expand Down
8 changes: 3 additions & 5 deletions elide-contrib/elide-dynamic-config-helpers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<handlebars.version>4.2.0</handlebars.version>
<json-schema-validator.version>2.2.12</json-schema-validator.version>
<mdkt.compiler.version>1.3.0</mdkt.compiler.version>
<google.collections.version>1.0</google.collections.version>
<commons-io.version>2.6</commons-io.version>
</properties>

Expand Down Expand Up @@ -116,10 +115,9 @@
<version>${mdkt.compiler.version}</version>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
<version>${google.collections.version}</version>
</dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public ElideDynamicEntityCompiler buildElideDynamicEntityCompiler(ElideConfigPro

ElideDynamicEntityCompiler compiler = null;

if (settings.getDynamicConfig().isEnabled()) {
if (isDynamicConfigEnabled(settings)) {
compiler = new ElideDynamicEntityCompiler(settings.getDynamicConfig().getPath());
}
return compiler;
Expand Down Expand Up @@ -121,7 +121,7 @@ public <T> T instantiate(Class<T> cls) {

dictionary.scanForSecurityChecks();

if (settings.getDynamicConfig().isEnabled()) {
if (isDynamicConfigEnabled(settings)) {
ElideDynamicEntityCompiler compiler = dynamicCompiler.getIfAvailable();
Set<Class<?>> annotatedClass = compiler.findAnnotatedClasses(SecurityCheck.class);
dictionary.addSecurityChecks(annotatedClass);
Expand All @@ -146,7 +146,7 @@ public QueryEngine buildQueryEngine(EntityManagerFactory entityManagerFactory,

MetaDataStore metaDataStore = null;

if (settings.getDynamicConfig().isEnabled()) {
if (isDynamicConfigEnabled(settings)) {
metaDataStore = new MetaDataStore(dynamicCompiler.getIfAvailable());
} else {
metaDataStore = new MetaDataStore();
Expand All @@ -171,7 +171,7 @@ public DataStore buildDataStore(EntityManagerFactory entityManagerFactory, Query
throws ClassNotFoundException {
AggregationDataStore aggregationDataStore = null;

if (settings.getDynamicConfig().isEnabled()) {
if (isDynamicConfigEnabled(settings)) {
ElideDynamicEntityCompiler compiler = dynamicCompiler.getIfAvailable();
Set<Class<?>> annotatedClass = compiler.findAnnotatedClasses(FromTable.class);
annotatedClass.addAll(compiler.findAnnotatedClasses(FromSubquery.class));
Expand Down Expand Up @@ -207,4 +207,15 @@ public Swagger buildSwagger(EntityDictionary dictionary, ElideConfigProperties s

return swagger;
}

private boolean isDynamicConfigEnabled(ElideConfigProperties settings) {

boolean enabled = false;
if (settings.getDynamicConfig() != null) {
enabled = settings.getDynamicConfig().isEnabled();
}

return enabled;

}
}

0 comments on commit b55b769

Please sign in to comment.