From c7f01267d89ad314582974fbb83e5515005ef9de Mon Sep 17 00:00:00 2001 From: "Dennis J. McWherter, Jr" Date: Tue, 23 Jan 2018 18:53:21 -0600 Subject: [PATCH] Minor code tweaks. --- .../src/main/java/com/yahoo/elide/core/RequestScope.java | 4 ++-- elide-graphql/pom.xml | 6 ++++++ .../src/main/java/com/yahoo/elide/graphql/ModelBuilder.java | 1 + .../yahoo/elide/graphql/containers/HistoryContainer.java | 5 +++-- .../com/yahoo/elide/graphql/containers/RootContainer.java | 5 +++++ 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/elide-core/src/main/java/com/yahoo/elide/core/RequestScope.java b/elide-core/src/main/java/com/yahoo/elide/core/RequestScope.java index cd70ba3e1f..abdde16b1f 100644 --- a/elide-core/src/main/java/com/yahoo/elide/core/RequestScope.java +++ b/elide-core/src/main/java/com/yahoo/elide/core/RequestScope.java @@ -75,8 +75,8 @@ public class RequestScope implements com.yahoo.elide.security.RequestScope { @Getter private final boolean useFilterExpressions; @Getter private final int updateStatusCode; @Getter private final boolean mutatingMultipleEntities; - @Getter @Setter private String historicalVersion = null; - @Getter @Setter private String historicalDate = null; + @Getter @Setter private Long historicalRevision = null; + @Getter @Setter private Long historicalDatestamp = null; @Getter private final MultipleFilterDialect filterDialect; private final Map expressionsByType; diff --git a/elide-graphql/pom.xml b/elide-graphql/pom.xml index ab622735f9..0533a48cdd 100644 --- a/elide-graphql/pom.xml +++ b/elide-graphql/pom.xml @@ -42,6 +42,12 @@ + + + org.hibernate + hibernate-envers + 5.0.2.Final + com.yahoo.elide elide-core diff --git a/elide-graphql/src/main/java/com/yahoo/elide/graphql/ModelBuilder.java b/elide-graphql/src/main/java/com/yahoo/elide/graphql/ModelBuilder.java index 5a4cc8e9a5..a804dc30f8 100644 --- a/elide-graphql/src/main/java/com/yahoo/elide/graphql/ModelBuilder.java +++ b/elide-graphql/src/main/java/com/yahoo/elide/graphql/ModelBuilder.java @@ -201,6 +201,7 @@ public GraphQLSchema build() { root.field(newFieldDefinition() .name("__history") + .dataFetcher(dataFetcher) .argument(newArgument() .name("revision") .type(new GraphQLList(Scalars.GraphQLLong)) diff --git a/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/HistoryContainer.java b/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/HistoryContainer.java index 689dfe6009..434598bb4a 100644 --- a/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/HistoryContainer.java +++ b/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/HistoryContainer.java @@ -7,6 +7,7 @@ import com.yahoo.elide.graphql.Environment; +import java.util.List; import java.util.Map; public class HistoryContainer extends RootContainer { @@ -22,8 +23,8 @@ public class HistoryContainer extends RootContainer { HistoryContainer(Environment context) { Map args = context.arguments; if (args != null) { - context.requestScope.setHistoricalDate((String) args.get(DATE_KEY)); - context.requestScope.setHistoricalVersion((String) args.get(REVISION_KEY)); + context.requestScope.setHistoricalDatestamp((Long) ((List) args.get(DATE_KEY)).get(0)); + context.requestScope.setHistoricalRevision((Long) ((List) args.get(REVISION_KEY)).get(0)); } } } diff --git a/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/RootContainer.java b/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/RootContainer.java index 41b32fc225..b5165ea281 100644 --- a/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/RootContainer.java +++ b/elide-graphql/src/main/java/com/yahoo/elide/graphql/containers/RootContainer.java @@ -21,6 +21,11 @@ public class RootContainer implements GraphQLContainer { public Object processFetch(Environment context, PersistentResourceFetcher fetcher) { if (isHistorySelection(context.field)) { return new HistoryContainer(context); + } else { + // Not a revision request + // TODO: Clean this up. + context.requestScope.setHistoricalRevision(null); + context.requestScope.setHistoricalDatestamp(null); } EntityDictionary dictionary = context.requestScope.getDictionary(); Class entityClass = dictionary.getEntityClass(context.field.getName());