Search in sources :

Example 26 with ObjectValue

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

the class GraphQLEngine method processSearchSingle.

private void processSearchSingle(ObjectValue target, Field field, boolean inheritedList, String suffix) throws EGraphQLException, FHIRException {
    if (services == null)
        throw new EGraphQLException("Resource Referencing services not provided");
    String id = "";
    for (Argument arg : field.getArguments()) if ((arg.getName().equals("id")))
        id = getSingleValue(arg);
    else
        throw new EGraphQLException("Unknown/invalid parameter " + arg.getName());
    if (Utilities.noString(id))
        throw new EGraphQLException("No id found");
    Resource res = (Resource) services.lookup(appInfo, field.getName(), id);
    if (res == null)
        throw new EGraphQLException("Resource " + field.getName() + "/" + id + " not found");
    Argument arg = target.addField(field.getAlias() + suffix, listStatus(field, false));
    ObjectValue obj = new ObjectValue();
    arg.addValue(obj);
    processObject(res, res, obj, field.getSelectionSet(), inheritedList, suffix);
}
Also used : IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Aggregations

Argument (org.hl7.fhir.utilities.graphql.Argument)16 EGraphQLException (org.hl7.fhir.utilities.graphql.EGraphQLException)16 ObjectValue (org.hl7.fhir.utilities.graphql.ObjectValue)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)12 ArrayList (java.util.ArrayList)8 ReferenceResolution (org.hl7.fhir.utilities.graphql.IGraphQLStorageServices.ReferenceResolution)8 StringValue (org.hl7.fhir.utilities.graphql.StringValue)8 DomainResource (org.hl7.fhir.r4b.model.DomainResource)3 Resource (org.hl7.fhir.r4b.model.Resource)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)2 Base (org.hl7.fhir.r4b.model.Base)2 Bundle (org.hl7.fhir.r4b.model.Bundle)2 Reference (org.hl7.fhir.r4b.model.Reference)2 Directive (org.hl7.fhir.utilities.graphql.Directive)2 CanonicalType (org.hl7.fhir.r4b.model.CanonicalType)1 ExpressionNode (org.hl7.fhir.r4b.model.ExpressionNode)1