diff --git a/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/formats/XmlParser.java_406349766775915 b/org.hl7.fhir.dstu2/src/main/java/org/hl7/fhir/dstu2/formats/XmlParser.java_406349766775915 new file mode 100644 index 000000000..e69de29bb diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/GraphQLEngine.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/GraphQLEngine.java index cbc8b18d6..d460f3bd2 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/GraphQLEngine.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/GraphQLEngine.java @@ -198,7 +198,7 @@ public class GraphQLEngine implements IGraphQLEngine { /** * where the output from executing the query instanceof going to go */ - private ObjectValue output; + private GraphQLResponse output; /** * Application provided reference resolution services @@ -218,7 +218,7 @@ public class GraphQLEngine implements IGraphQLEngine { fpe = new FHIRPathEngine(this.context); magicExpression = new ExpressionNode(0); - output = new ObjectValue(); + output = new GraphQLResponse(); Operation op = null; // todo: initial conditions @@ -801,7 +801,7 @@ public class GraphQLEngine implements IGraphQLEngine { this.graphQL = graphQL; } - public ObjectValue getOutput() { + public GraphQLResponse getOutput() { return output; } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java index 047fbcffc..62999b83d 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/test/utils/TestingUtilities.java @@ -441,12 +441,12 @@ public class TestingUtilities { public static String resourceNameToFile(String name) throws IOException { - return Utilities.path(System.getProperty("user.dir"), "src", "main", "resources", name); + return Utilities.path(System.getProperty("user.dir"), "src", "test", "resources", name); } public static String resourceNameToFile(String subFolder, String name) throws IOException { - return Utilities.path(System.getProperty("user.dir"), "src", "main", "resources", subFolder, name); + return Utilities.path(System.getProperty("user.dir"), "src", "test", "resources", subFolder, name); } } diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/GraphQLEngine.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/GraphQLEngine.java index 68f73dee9..223ac7984 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/GraphQLEngine.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/GraphQLEngine.java @@ -60,7 +60,7 @@ public class GraphQLEngine implements IGraphQLEngine { /** * where the output from executing the query instanceof going to go */ - private ObjectValue output; + private GraphQLResponse output; /** * Application provided reference resolution services */ @@ -81,7 +81,7 @@ public class GraphQLEngine implements IGraphQLEngine { fpe = new FHIRPathEngine(this.context); magicExpression = new ExpressionNode(0); - output = new ObjectValue(); + output = new GraphQLResponse(); Operation op = null; // todo: initial conditions @@ -662,7 +662,7 @@ public class GraphQLEngine implements IGraphQLEngine { this.graphQL = graphQL; } - public ObjectValue getOutput() { + public GraphQLResponse getOutput() { return output; } diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/GraphQLEngineTests.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/GraphQLEngineTests.java index 30fde8d67..4aa667fa8 100644 --- a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/GraphQLEngineTests.java +++ b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/GraphQLEngineTests.java @@ -104,6 +104,7 @@ public class GraphQLEngineTests implements IGraphQLStorageServices { if (ok) { assertTrue("Expected to fail, but didn't", !output.equals("$error")); StringBuilder str = new StringBuilder(); + gql.getOutput().setWriteWrapper(false); gql.getOutput().write(str, 0); TextFile.stringToFile(str.toString(), TestingUtilities.resourceNameToFile("graphql", output+".out")); msg = TestingUtilities.checkJsonIsSame(TestingUtilities.resourceNameToFile("graphql", output+".out"), TestingUtilities.resourceNameToFile("graphql", output)); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java index 42c36d2f2..cd01a4615 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLEngine.java @@ -198,7 +198,7 @@ public class GraphQLEngine implements IGraphQLEngine { /** * where the output from executing the query instanceof going to go */ - private ObjectValue output; + private GraphQLResponse output; /** * Application provided reference resolution services @@ -219,7 +219,7 @@ public class GraphQLEngine implements IGraphQLEngine { fpe = new FHIRPathEngine(this.context); magicExpression = new ExpressionNode(0); - output = new ObjectValue(); + output = new GraphQLResponse(); Operation op = null; // todo: initial conditions @@ -806,7 +806,7 @@ public class GraphQLEngine implements IGraphQLEngine { } @Override - public ObjectValue getOutput() { + public GraphQLResponse getOutput() { return output; } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java index bf045ab80..bb2c7de57 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/GraphQLEngineTests.java @@ -103,6 +103,7 @@ public class GraphQLEngineTests implements IGraphQLStorageServices { if (ok) { assertTrue("Expected to fail, but didn't", !output.equals("$error")); StringBuilder str = new StringBuilder(); + gql.getOutput().setWriteWrapper(false); gql.getOutput().write(str, 0); TextFile.stringToFile(str.toString(), TestingUtilities.resourceNameToFile("graphql", output+".out")); msg = TestingUtilities.checkJsonIsSame(TestingUtilities.resourceNameToFile("graphql", output+".out"), TestingUtilities.resourceNameToFile("graphql", output)); diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/GraphQLResponse.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/GraphQLResponse.java new file mode 100644 index 000000000..281c7943b --- /dev/null +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/GraphQLResponse.java @@ -0,0 +1,29 @@ +package org.hl7.fhir.utilities.graphql; + +public class GraphQLResponse extends ObjectValue { + private boolean writeWrapper = true; + + /** + * Should the "data" wrapper br written along with the output + */ + public void setWriteWrapper(boolean theWriteWrapper) { + writeWrapper = theWriteWrapper; + } + + @Override + public void write(StringBuilder b, Integer indent, String lineSeparator) throws EGraphQLException, EGraphEngine { + + if (writeWrapper) { + // Write the wrapper + b.append("{ \"data\": "); + } + + super.write(b, indent, lineSeparator); + + if (writeWrapper) { + // Terminate the wrapper + b.append("}"); + } + + } +} diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/ObjectValue.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/ObjectValue.java index 8b75cbdda..c10dac1d3 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/ObjectValue.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/graphql/ObjectValue.java @@ -86,6 +86,8 @@ public class ObjectValue extends Value { * @param lineSeparator The line separator */ public void write(StringBuilder b, Integer indent, String lineSeparator) throws EGraphQLException, EGraphEngine { + + // Write the GraphQL output b.append("{"); String s = ""; String se = ""; @@ -103,6 +105,5 @@ public class ObjectValue extends Value { } b.append(se); b.append("}"); - } }