Package ca.uhn.fhir.model.api.annotation

Examples of ca.uhn.fhir.model.api.annotation.SearchParamDefinition


  }

  private void scanResourceForSearchParams(Class<? extends IResource> theClass, RuntimeResourceDefinition theResourceDef) {

    for (Field nextField : theClass.getFields()) {
      SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
      if (searchParam != null) {
        SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
        if (paramType == null) {
          throw new ConfigurationException("Searc param " + searchParam.name() + " has an invalid type: " + searchParam.type());
        }
        RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType);
        theResourceDef.addSearchParam(param);
      }
    }

  }
View Full Code Here


    Map<String, RuntimeSearchParam> nameToParam = new HashMap<String, RuntimeSearchParam>();
    Map<Field, SearchParamDefinition> compositeFields = new LinkedHashMap<Field, SearchParamDefinition>();

    for (Field nextField : theClass.getFields()) {
      SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
      if (searchParam != null) {
        SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
        if (paramType == null) {
          throw new ConfigurationException("Searc param " + searchParam.name() + " has an invalid type: " + searchParam.type());
        }
        if (paramType == SearchParamTypeEnum.COMPOSITE) {
          compositeFields.put(nextField, searchParam);
          continue;
        }
        RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType);
        theResourceDef.addSearchParam(param);
        nameToParam.put(param.getName(), param);
      }
    }

    for (Entry<Field, SearchParamDefinition> nextEntry : compositeFields.entrySet()) {
      SearchParamDefinition searchParam = nextEntry.getValue();

      List<RuntimeSearchParam> compositeOf = new ArrayList<RuntimeSearchParam>();
      for (String nextName : searchParam.compositeOf()) {
        RuntimeSearchParam param = nameToParam.get(nextName);
        if (param == null) {
          ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}", new Object[] { theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
          continue;
        }
        compositeOf.add(param);
      }

      RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), SearchParamTypeEnum.COMPOSITE, compositeOf);
      theResourceDef.addSearchParam(param);
    }
  }
View Full Code Here

  }

  private void scanResourceForSearchParams(Class<? extends IResource> theClass, RuntimeResourceDefinition theResourceDef) {

    for (Field nextField : theClass.getFields()) {
      SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
      if (searchParam != null) {
        RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path());
        theResourceDef.addSearchParam(param);
      }
    }

  }
View Full Code Here

    Map<String, RuntimeSearchParam> nameToParam = new HashMap<String, RuntimeSearchParam>();
    Map<Field, SearchParamDefinition> compositeFields = new LinkedHashMap<Field, SearchParamDefinition>();

    for (Field nextField : theClass.getFields()) {
      SearchParamDefinition searchParam = nextField.getAnnotation(SearchParamDefinition.class);
      if (searchParam != null) {
        SearchParamTypeEnum paramType = SearchParamTypeEnum.valueOf(searchParam.type().toUpperCase());
        if (paramType == null) {
          throw new ConfigurationException("Searc param " + searchParam.name() + " has an invalid type: " + searchParam.type());
        }
        if(paramType==SearchParamTypeEnum.COMPOSITE) {
          compositeFields.put(nextField, searchParam);
          continue;
        }
        RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType);
        theResourceDef.addSearchParam(param);
        nameToParam.put(param.getName(), param);
      }
    }

    for (Entry<Field, SearchParamDefinition> nextEntry : compositeFields.entrySet()) {
      Field nextField = nextEntry.getKey();
      SearchParamDefinition searchParam = nextEntry.getValue();
     
      List<RuntimeSearchParam> compositeOf = new ArrayList<RuntimeSearchParam>();
      for (String nextName:searchParam.compositeOf()) {
        RuntimeSearchParam param = nameToParam.get(nextName);
        if (param==null) {
          ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}",
              new Object[] {theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet()});
          continue;
        }
        compositeOf.add(param);
      }

      RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), SearchParamTypeEnum.COMPOSITE, compositeOf);
      theResourceDef.addSearchParam(param);
    }
  }
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.model.api.annotation.SearchParamDefinition

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.