public ObjectValue(JsonObject json) throws EGraphQLException { super(); for (Entry<String, JsonElement> n : json.entrySet()) fields.add(new Argument(n.getKey(), n.getValue())); }
public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }
public Argument addField(String name, ArgumentListStatus listStatus) throws FHIRException { Argument result = null; for (Argument t : fields) if ((t.name.equals(name))) result = t; if (result == null) { result = new Argument(); result.setName(name); result.setListStatus(listStatus); fields.add(result); } else if (result.getListStatus() == ArgumentListStatus.SINGLETON) throw new FHIRException("Error: Attempt to make '+name+' into a repeating field when it is constrained by @singleton"); else result.setListStatus(ArgumentListStatus.REPEATING); return result; }
private void processVariables(Operation op) throws EGraphQLException { for (Variable varRef : op.getVariables()) { Argument varDef = null; for (Argument v : graphQL.getVariables()) if (v.getName().equals(varRef.getName())) varDef = v; if (varDef != null) workingVariables.put(varRef.getName(), varDef); // todo: check type? else if (varRef.getDefaultValue() != null) workingVariables.put(varRef.getName(), new Argument(varRef.getName(), varRef.getDefaultValue())); else throw new EGraphQLException("No value found for variable "); } }
private void processSearchFull(ObjectValue target, Field field, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException { if (services == null) throw new EGraphQLException("Resource Referencing services not provided"); List<Argument> params = new ArrayList<Argument>(); Argument carg = null; for ( Argument arg : field.getArguments()) if (arg.getName().equals("cursor")) carg = arg; else params.add(arg); if ((carg != null)) { params.clear();; String[] parts = getSingleValue(carg).split(":"); params.add(new Argument("search-id", new StringValue(parts[0]))); params.add(new Argument("search-offset", new StringValue(parts[1]))); } Bundle bnd = services.search(appInfo, field.getName().substring(0, field.getName().length()-10), params); SearchWrapper bndWrapper = new SearchWrapper(field.getName(), bnd); Argument arg = target.addField(field.getAlias()+suffix, listStatus(field, false)); ObjectValue obj = new ObjectValue(); arg.addValue(obj); processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix); }
private Argument parseArgument() throws EGraphQLException, IOException { Argument result = new Argument(); result.setName(consumeName()); consumePunctuation(":"); if (hasPunctuation("[")) { result.setListStatus(ArgumentListStatus.REPEATING); consumePunctuation("["); while (!hasPunctuation("]")) result.getValues().add(parseValue()); consumePunctuation("]"); } else result.getValues().add(parseValue()); return result; }
if (parg == null) throw new EGraphQLException("Missing parameter _reference"); Argument arg = new Argument(); params.add(arg); arg.setName(getSingleValue(parg));
private void processReverseReferenceSearch(Resource source, Field field, ObjectValue target, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException { if (services == null) throw new EGraphQLException("Resource Referencing services not provided"); List<Argument> params = new ArrayList<Argument>(); Argument parg = null; for (Argument a : field.getArguments()) if (!(a.getName().equals("_reference"))) params.add(a); else if ((parg == null)) parg = a; else throw new EGraphQLException("Duplicate parameter _reference"); if (parg == null) throw new EGraphQLException("Missing parameter _reference"); Argument arg = new Argument(); params.add(arg); arg.setName(getSingleValue(parg)); arg.addValue(new StringValue(source.fhirType()+"/"+source.getId())); Bundle bnd = services.search(appInfo, field.getName().substring(0, field.getName().length()-10), params); Base bndWrapper = new SearchWrapper(field.getName(), bnd); arg = target.addField(field.getAlias()+suffix, listStatus(field, false)); ObjectValue obj = new ObjectValue(); arg.addValue(obj); processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix); }
public ObjectValue(JsonObject json) throws EGraphQLException { super(); for (Entry<String, JsonElement> n : json.entrySet()) fields.add(new Argument(n.getKey(), n.getValue())); }
public static Package parseJson(InputStream source) throws EGraphQLException, IOException, EGraphEngine { JsonObject json = (JsonObject) new com.google.gson.JsonParser().parse(TextFile.streamToString(source)); Parser self = new Parser(); self.reader = new StringReader(json.get("query").getAsString()); self.next(); Package result = new Package(self.parseDocument()); result.setOperationName(json.get("operationName").getAsString()); if (json.has("variables")) { JsonObject vl = json.getAsJsonObject("variables"); for (Entry<String, JsonElement> n : vl.entrySet()) result.getVariables().add(new Argument(n.getKey(), n.getValue())); } return result; }
public Argument addField(String name, ArgumentListStatus listStatus) throws FHIRException { Argument result = null; for (Argument t : fields) if ((t.name.equals(name))) result = t; if (result == null) { result = new Argument(); result.setName(name); result.setListStatus(listStatus); fields.add(result); } else if (result.getListStatus() == ArgumentListStatus.SINGLETON) throw new FHIRException("Error: Attempt to make '+name+' into a repeating field when it is constrained by @singleton"); else result.setListStatus(ArgumentListStatus.REPEATING); return result; }
private void processVariables(Operation op) throws EGraphQLException { for (Variable varRef : op.getVariables()) { Argument varDef = null; for (Argument v : graphQL.getVariables()) if (v.getName().equals(varRef.getName())) varDef = v; if (varDef != null) workingVariables.put(varRef.getName(), varDef); // todo: check type? else if (varRef.getDefaultValue() != null) workingVariables.put(varRef.getName(), new Argument(varRef.getName(), varRef.getDefaultValue())); else throw new EGraphQLException("No value found for variable "); } }
private void processSearchFull(ObjectValue target, Field field, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException { if (services == null) throw new EGraphQLException("Resource Referencing services not provided"); List<Argument> params = new ArrayList<Argument>(); Argument carg = null; for ( Argument arg : field.getArguments()) if (arg.getName().equals("cursor")) carg = arg; else params.add(arg); if ((carg != null)) { params.clear();; String[] parts = getSingleValue(carg).split(":"); params.add(new Argument("search-id", new StringValue(parts[0]))); params.add(new Argument("search-offset", new StringValue(parts[1]))); } Bundle bnd = services.search(appInfo, field.getName().substring(0, field.getName().length()-10), params); SearchWrapper bndWrapper = new SearchWrapper(field.getName(), bnd); Argument arg = target.addField(field.getAlias()+suffix, listStatus(field, false)); ObjectValue obj = new ObjectValue(); arg.addValue(obj); processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix); }
private Argument parseArgument() throws EGraphQLException, IOException { Argument result = new Argument(); result.setName(consumeName()); consumePunctuation(":"); if (hasPunctuation("[")) { result.setListStatus(ArgumentListStatus.REPEATING); consumePunctuation("["); while (!hasPunctuation("]")) result.getValues().add(parseValue()); consumePunctuation("]"); } else result.getValues().add(parseValue()); return result; }
if (parg == null) throw new EGraphQLException("Missing parameter _reference"); Argument arg = new Argument(); params.add(arg); arg.setName(getSingleValue(parg));
private void processReverseReferenceSearch(Resource source, Field field, ObjectValue target, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException { if (services == null) throw new EGraphQLException("Resource Referencing services not provided"); List<Argument> params = new ArrayList<Argument>(); Argument parg = null; for (Argument a : field.getArguments()) if (!(a.getName().equals("_reference"))) params.add(a); else if ((parg == null)) parg = a; else throw new EGraphQLException("Duplicate parameter _reference"); if (parg == null) throw new EGraphQLException("Missing parameter _reference"); Argument arg = new Argument(); params.add(arg); arg.setName(getSingleValue(parg)); arg.addValue(new StringValue(source.fhirType()+"/"+source.getId())); Bundle bnd = services.search(appInfo, field.getName().substring(0, field.getName().length()-10), params); Base bndWrapper = new SearchWrapper(field.getName(), bnd); arg = target.addField(field.getAlias()+suffix, listStatus(field, false)); ObjectValue obj = new ObjectValue(); arg.addValue(obj); processObject(null, bndWrapper, obj, field.getSelectionSet(), inheritedList, suffix); }