Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.RuntimeResourceDefinition


    JsonValue resourceTypeObj = object.get("resourceType");
    assertObjectOfType(resourceTypeObj, JsonValue.ValueType.STRING, "resourceType");
    String resourceType = ((JsonString) resourceTypeObj).getString();

    RuntimeResourceDefinition def;
    if (theResourceType != null) {
      def = myContext.getResourceDefinition(theResourceType);
    } else {
      def = myContext.getResourceDefinition(resourceType);
    }

    ParserState<? extends IResource> state = ParserState.getPreResourceInstance(def.getImplementingClass(), myContext, true);
    state.enteringNewElement(null, def.getName());

    parseChildren(object, state);

    state.endingElement();
View Full Code Here


    BaseHttpClientInvocation invocation = ValidateMethodBinding.createValidateInvocation(theResource, null, myContext);
    if (isKeepResponses()) {
      myLastRequest = invocation.asHttpRequest(getServerBase(), createExtraParams(), getEncoding());
    }

    RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);
    final String resourceName = def.getName();

    OutcomeResponseHandler binding = new OutcomeResponseHandler(resourceName);
    MethodOutcome resp = invokeClient(binding, invocation, myLogRequestAndResponse);
    return resp;
  }
View Full Code Here

          String resourceName = foundMethodBinding.getResourceName();
          ResourceBinding resourceBinding;
          if (resourceName == null) {
            resourceBinding = myNullResourceBinding;
          } else {
            RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceName);
            if (myResourceNameToProvider.containsKey(definition.getName())) {
              resourceBinding = myResourceNameToProvider.get(definition.getName());
            } else {
              resourceBinding = new ResourceBinding();
              resourceBinding.setResourceName(resourceName);
              myResourceNameToProvider.put(resourceName, resourceBinding);
            }
View Full Code Here

      myResourceName = null;
    }

    public ForInternal(Class<? extends IResource> theResourceType) {
      myResourceType = theResourceType;
      RuntimeResourceDefinition definition = myContext.getResourceDefinition(theResourceType);
      myResourceName = definition.getName();
    }
View Full Code Here

      Set<RestfulOperationTypeEnum> resourceOps = new HashSet<RestfulOperationTypeEnum>();
      RestResource resource = rest.addResource();

      String resourceName = next.getResourceName();
      RuntimeResourceDefinition def = myRestfulServer.getFhirContext().getResourceDefinition(resourceName);
      resource.getType().setValue(def.getName());
      resource.getProfile().setReference(new IdDt(def.getResourceProfile()));

      TreeSet<String> includes = new TreeSet<String>();

      // Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String,
      // Conformance.RestResourceSearchParam>();
      for (BaseMethodBinding<?> nextMethodBinding : next.getMethodBindings()) {
        RestfulOperationTypeEnum resOp = nextMethodBinding.getResourceOperationType();
        if (resOp != null) {
          if (resourceOps.contains(resOp) == false) {
            resourceOps.add(resOp);
            resource.addOperation().setCode(resOp);
          }
        }

        RestfulOperationSystemEnum sysOp = nextMethodBinding.getSystemOperationType();
        if (sysOp != null) {
          if (systemOps.contains(sysOp) == false) {
            systemOps.add(sysOp);
            rest.addOperation().setCode(sysOp);
          }
        }

        if (nextMethodBinding instanceof SearchMethodBinding) {
          SearchMethodBinding searchMethodBinding = (SearchMethodBinding) nextMethodBinding;
          includes.addAll(searchMethodBinding.getIncludes());

          List<IParameter> params = searchMethodBinding.getParameters();
          List<SearchParameter> searchParameters = new ArrayList<SearchParameter>();
          for (IParameter nextParameter : params) {
            if ((nextParameter instanceof SearchParameter)) {
              searchParameters.add((SearchParameter) nextParameter);
            }
          }
          Collections.sort(searchParameters, new Comparator<SearchParameter>() {
            @Override
            public int compare(SearchParameter theO1, SearchParameter theO2) {
              if (theO1.isRequired() == theO2.isRequired()) {
                return theO1.getName().compareTo(theO2.getName());
              }
              if (theO1.isRequired()) {
                return -1;
              }
              return 1;
            }
          });
          if (searchParameters.isEmpty()) {
            continue;
          }
          boolean allOptional = searchParameters.get(0).isRequired() == false;

          RestQuery query = null;
          if (!allOptional) {
            query = rest.addQuery();
            query.getDocumentation().setValue(searchMethodBinding.getDescription());
            query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName));
            for (String nextInclude : searchMethodBinding.getIncludes()) {
              query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude));
            }
          }

          for (SearchParameter nextParameter : searchParameters) {

            String nextParamName = nextParameter.getName();
            String chain = null;
            if (nextParamName.contains(".")) {
              chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
              nextParamName = nextParamName.substring(0, nextParamName.indexOf('.'));
            }

            String nextParamDescription = nextParameter.getDescription();

            /*
             * If the parameter has no description, default to the one from the resource
             */
            if (StringUtils.isBlank(nextParamDescription)) {
              RuntimeSearchParam paramDef = def.getSearchParam(nextParamName);
              if (paramDef != null) {
                nextParamDescription = paramDef.getDescription();
              }
            }

View Full Code Here

    }

    IResource resource = entry.getResource();
    if (resource == null && id != null && isNotBlank(id.getResourceType())) {
      String resourceType = id.getResourceType();
      RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType);
      if (def == null) {
        throw new DataFormatException("Entry references unknown resource type: " + resourceType);
      }
      resource = def.newInstance();
      resource.setId(id);
      entry.setResource(resource);
    }

    if (resource != null) {
View Full Code Here

    return Profile.class;
  }
 
  @Read()
  public Profile getProfileById(@IdParam IdDt theId) {
    RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getValue());
    if (retVal==null) {
      return null;
    }
    return retVal.toProfile();
  }
View Full Code Here

  private void encodeResourceToXmlStreamWriter(IResource theResource, XMLStreamWriter theEventWriter, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
    if (!theIncludedResource) {
      super.containResourcesForEncoding(theResource);
    }

    RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theResource);
    if (resDef == null) {
      throw new ConfigurationException("Unknown resource type: " + theResource.getClass());
    }

    theEventWriter.writeStartElement(resDef.getName());
    theEventWriter.writeDefaultNamespace(FHIR_NS);

    if (theIncludedResource && StringUtils.isNotBlank(theResource.getId().getValue())) {
      theEventWriter.writeAttribute("id", theResource.getId().getValue());
    }
View Full Code Here

    return retVal;
  }

  public static HttpPostClientInvocation createCreateInvocation(IResource theResource, FhirContext theContext) {
    RuntimeResourceDefinition def = theContext.getResourceDefinition(theResource);
    String resourceName = def.getName();


    StringBuilder urlExtension = new StringBuilder();
    urlExtension.append(resourceName);
View Full Code Here

            throw new DataFormatException("Element '" + theLocalPart + "' is not a resource, expected a resource at this position");
          }
        }
      }

      RuntimeResourceDefinition def = (RuntimeResourceDefinition) definition;
      myInstance = def.newInstance();
      if (myEntry != null) {
        myEntry.setResource(myInstance);
      }

      if ("Binary".equals(def.getName())) {
        push(new BinaryResourceState(getRootPreResourceState(), (Binary) myInstance));
      } else {
        push(new ElementCompositeState(getRootPreResourceState(), def, myInstance));
      }
    }
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.context.RuntimeResourceDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.