Search in sources :

Example 1 with VariableValue

use of org.hl7.fhir.utilities.graphql.VariableValue in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngine method resolveValues.

private List<Value> resolveValues(Argument arg, int max, String vars) throws EGraphQLException {
    List<Value> result = new ArrayList<Value>();
    for (Value v : arg.getValues()) {
        if (!(v instanceof VariableValue))
            result.add(v);
        else {
            if (vars.contains(":" + v.toString() + ":"))
                throw new EGraphQLException("Recursive reference to variable " + v.toString());
            Argument a = workingVariables.get(v.toString());
            if (a == null)
                throw new EGraphQLException("No value found for variable \"" + v.toString() + "\" in \"" + arg.getName() + "\"");
            List<Value> vl = resolveValues(a, -1, vars + ":" + v.toString() + ":");
            result.addAll(vl);
        }
    }
    if ((max != -1 && result.size() > max))
        throw new EGraphQLException("Only " + Integer.toString(max) + " values are allowed for \"" + arg.getName() + "\", but " + Integer.toString(result.size()) + " enoucntered");
    return result;
}
Also used : Argument(org.hl7.fhir.utilities.graphql.Argument) VariableValue(org.hl7.fhir.utilities.graphql.VariableValue) StringValue(org.hl7.fhir.utilities.graphql.StringValue) ObjectValue(org.hl7.fhir.utilities.graphql.ObjectValue) VariableValue(org.hl7.fhir.utilities.graphql.VariableValue) Value(org.hl7.fhir.utilities.graphql.Value) NameValue(org.hl7.fhir.utilities.graphql.NameValue) NumberValue(org.hl7.fhir.utilities.graphql.NumberValue) EGraphQLException(org.hl7.fhir.utilities.graphql.EGraphQLException)

Example 2 with VariableValue

use of org.hl7.fhir.utilities.graphql.VariableValue in project org.hl7.fhir.core by hapifhir.

the class GraphQLEngine method resolveValues.

private List<Value> resolveValues(Argument arg, int max, String vars) throws EGraphQLException {
    List<Value> result = new ArrayList<Value>();
    for (Value v : arg.getValues()) {
        if (!(v instanceof VariableValue))
            result.add(v);
        else {
            if (vars.contains(":" + v.toString() + ":"))
                throw new EGraphQLException("Recursive reference to variable " + v.toString());
            Argument a = workingVariables.get(v.toString());
            if (a == null)
                throw new EGraphQLException("No value found for variable \"" + v.toString() + "\" in \"" + arg.getName() + "\"");
            List<Value> vl = resolveValues(a, -1, vars + ":" + v.toString() + ":");
            result.addAll(vl);
        }
    }
    if ((max != -1 && result.size() > max))
        throw new EGraphQLException("Only " + Integer.toString(max) + " values are allowed for \"" + arg.getName() + "\", but " + Integer.toString(result.size()) + " enoucntered");
    return result;
}
Also used : Argument(org.hl7.fhir.utilities.graphql.Argument) VariableValue(org.hl7.fhir.utilities.graphql.VariableValue) StringValue(org.hl7.fhir.utilities.graphql.StringValue) ObjectValue(org.hl7.fhir.utilities.graphql.ObjectValue) VariableValue(org.hl7.fhir.utilities.graphql.VariableValue) Value(org.hl7.fhir.utilities.graphql.Value) NameValue(org.hl7.fhir.utilities.graphql.NameValue) NumberValue(org.hl7.fhir.utilities.graphql.NumberValue) ArrayList(java.util.ArrayList) EGraphQLException(org.hl7.fhir.utilities.graphql.EGraphQLException)

Aggregations

Argument (org.hl7.fhir.utilities.graphql.Argument)2 EGraphQLException (org.hl7.fhir.utilities.graphql.EGraphQLException)2 NameValue (org.hl7.fhir.utilities.graphql.NameValue)2 NumberValue (org.hl7.fhir.utilities.graphql.NumberValue)2 ObjectValue (org.hl7.fhir.utilities.graphql.ObjectValue)2 StringValue (org.hl7.fhir.utilities.graphql.StringValue)2 Value (org.hl7.fhir.utilities.graphql.Value)2 VariableValue (org.hl7.fhir.utilities.graphql.VariableValue)2 ArrayList (java.util.ArrayList)1