Skip to content

Commit

Permalink
Minor code tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis J. McWherter, Jr committed Jan 24, 2018
1 parent f8a1fd4 commit c7f0126
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, FilterExpression> expressionsByType;
Expand Down
6 changes: 6 additions & 0 deletions elide-graphql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
</scm>

<dependencies>
<!-- TODO: Refactor to remove this dep from graphql -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>com.yahoo.elide</groupId>
<artifactId>elide-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public GraphQLSchema build() {

root.field(newFieldDefinition()
.name("__history")
.dataFetcher(dataFetcher)
.argument(newArgument()
.name("revision")
.type(new GraphQLList(Scalars.GraphQLLong))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import com.yahoo.elide.graphql.Environment;

import java.util.List;
import java.util.Map;

public class HistoryContainer extends RootContainer {
Expand All @@ -22,8 +23,8 @@ public class HistoryContainer extends RootContainer {
HistoryContainer(Environment context) {
Map<String, Object> 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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit c7f0126

Please sign in to comment.