Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.RuntimeResourceDefinition


      return getDefinition(cmp, theSubList.subList(1, theSubList.size()));
    }
  }

  public List<Object> getValues(IResource theResource, String thePath) {
    RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource);

    BaseRuntimeElementCompositeDefinition<?> currentDef = def;
    Object currentObj = theResource;

    List<String> parts = Arrays.asList(thePath.split("\\."));
View Full Code Here


    BaseHttpClientInvocation invocation = MethodUtil.createCreateInvocation(theResource, 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(myContext, binding, invocation, myLogRequestAndResponse);
    return resp;
View Full Code Here

    BaseHttpClientInvocation invocation = MethodUtil.createUpdateInvocation(theResource, null, theIdDt, 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(myContext, binding, invocation, myLogRequestAndResponse);
    return resp;
  }
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(myContext, binding, invocation, myLogRequestAndResponse);
    return resp;
  }
View Full Code Here

  public static HttpPostClientInvocation createCreateInvocation(IResource theResource, FhirContext theContext) {
    return createCreateInvocation(theResource, null, null, theContext);
  }

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

    StringBuilder urlExtension = new StringBuilder();
    urlExtension.append(resourceName);
    if (StringUtils.isNotBlank(theId)) {
      urlExtension.append('/');
View Full Code Here

    myCtx=theFhirContext;
  }

  public <T extends IResource> T newView(IResource theResource, Class<T> theTargetType) {
    Class<? extends IResource> sourceType = theResource.getClass();
    RuntimeResourceDefinition sourceDef = myCtx.getResourceDefinition(theResource);
    RuntimeResourceDefinition targetDef = myCtx.getResourceDefinition(theTargetType);

    if (sourceType.equals(theTargetType)) {
      @SuppressWarnings("unchecked")
      T resource = (T) theResource;
      return resource;
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;
            String nextParamUnchainedName = nextParamName;
            if (nextParamName.contains(".")) {
//              chain = nextParamName.substring(nextParamName.indexOf('.') + 1);
              nextParamUnchainedName = 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(nextParamUnchainedName);
              if (paramDef != null) {
                nextParamDescription = paramDef.getDescription();
              }
            }

            RestResourceSearchParam param;
            if (query == null) {
              param = resource.addSearchParam();
            } else {
              param = query.addParameter();
              param.addUndeclaredExtension(false, ExtensionConstants.PARAM_IS_REQUIRED, new BooleanDt(nextParameter.isRequired()));
            }

            param.setName(nextParamName);
//            if (StringUtils.isNotBlank(chain)) {
//              param.addChain(chain);
//            }
            param.setDocumentation(nextParamDescription);
            param.setType(nextParameter.getParamType());
            for (Class<? extends IResource> nextTarget : nextParameter.getDeclaredTypes()) {
              RuntimeResourceDefinition targetDef = myRestfulServer.getFhirContext().getResourceDefinition(nextTarget);
              if (targetDef != null) {
                ResourceTypeEnum code = ResourceTypeEnum.VALUESET_BINDER.fromCodeString(targetDef.getName());
                if (code != null) {
                  param.addTarget(code);
                }
              }
            }
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

      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().setId(new IdDt(def.getResourceProfile()));

      Map<String, Conformance.RestResourceSearchParam> nameToSearchParam = new HashMap<String, Conformance.RestResourceSearchParam>();
      for (BaseMethodBinding nextMethodBinding : next.getMethodBindings()) {
        RestfulOperationTypeEnum resOp = nextMethodBinding.getResourceOperationType();
        if (resOp != null) {
View Full Code Here

    myServerBase = theServerBase;
  }

  private RuntimeResourceDefinition getResourceType(HttpServletRequest theReq) throws ServletException {
    String resourceName = StringUtils.defaultString(theReq.getParameter("resourceName"));
    RuntimeResourceDefinition def = myCtx.getResourceDefinition(resourceName);
    if (def == null) {
      throw new ServletException("Invalid resourceName: " + resourceName);
    }
    return def;
  }
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.