Package com.esri.gpt.catalog.discovery.rest

Examples of com.esri.gpt.catalog.discovery.rest.RestQueryParser


  }
 
  @Override
  protected RestQuery parseRequest(HttpServletRequest request, RequestContext context) {
    RestQuery query = new RestQuery();
    RestQueryParser parser = new ErosQueryParser(request,context,query,defaultParameters);
  
    parser.parseResponseFormat("f");
    String requestURI = Val.chkStr(request.getRequestURI());
    if (requestURI.toLowerCase().endsWith("/sitemap")) {
      String tmp = Val.chkStr(query.getResponseFormat());
      if (tmp.length() == 0) {
        query.setResponseFormat("sitemap");
      }
    }
   
    parser.parseRepositoryId("rid");
    parser.parseResponseFormat("f");
    parser.parseResponseGeometry("geometryType");
    parser.parseResponseStyle("style");
    parser.parseResponseTarget("target");
    parser.parseStartRecord("start",1);
    parser.parseMaxRecords("max",10);
    parser.parsePropertyIsEqualTo("uuid","uuid");
    parser.parsePropertyIsLike("searchText","anytext");
    parser.parsePropertyList("contentType","dc:type",",",true);
    parser.parsePropertyList("dataCategory","dc:subject",",",true);
    parser.parsePropertyRange("after","before","dct:modified");
    parser.parseSpatialClause("bbox","spatialRel","geometry");
    parser.parseSortables("orderBy");
   
    //parser.parsePropertyRange("validAfter","validBefore","dct:valid"); // date valid
    parser.parsePropertyIsEqualTo("publisher","dc:publisher"); // publisher
    parser.parsePropertyIsEqualTo("source","dc:source"); // harvesting id (uuid)
    parser.parsePropertyIsEqualTo("isPartOf","dct:isPartOf"); // collection subset
    //parser.parsePropertyList("hasFormat","dct:hasFormat",",",true);
   
    return query;
  }
View Full Code Here


private static String REST_PARAM_KEY1 = "hierarchy";
//Relate the rest queryable to the CSW queryables
protected RestQuery parseRequest(HttpServletRequest request, RequestContext context) {
Logger LOG = Logger.getLogger(RestQuery.class.getCanonicalName());
  RestQuery query = super.parseRequest(request, context);
RestQueryParser parser = new RestQueryParser(request,context,query);
// "hierarchy" will be the name of the rest queryable
parser.parsePropertyIsLike(REST_PARAM_KEY1, "apiso.Type");
/** The below is shown as an example
parser.parseRepositoryId("rid");
parser.parseResponseFormat("f");
parser.parseResponseGeometry("geometryType");
parser.parseResponseStyle("style");
View Full Code Here

}
//Populate the searchCriteria with the rest queryable hierarchy
protected SearchCriteria toSearchCriteria(HttpServletRequest request,
RequestContext context, RestQuery query) {
SearchCriteria criteria = super.toSearchCriteria(request, context, query);
RestQueryParser parser = new RestQueryParser(request,context, query);
String sHierarchy = Val.chkStr(parser.getRequestParameter(REST_PARAM_KEY1));
if (sHierarchy.length() > 0) {
SearchFilterHierarchy filterHierarchy = new SearchFilterHierarchy();
filterHierarchy.setHierarchy(sHierarchy);
criteria.getMiscelleniousFilters().add(filterHierarchy);
}
View Full Code Here

   * @param context the request context
   * @return the populated rest query
   */
  protected RestQuery parseRequest(HttpServletRequest request, RequestContext context) {
    RestQuery query = new RestQuery();
    RestQueryParser parser = new RestQueryParser(request, context, query);

    parser.parseResponseFormat("f");
    String requestURI = Val.chkStr(request.getRequestURI());
    if (requestURI.toLowerCase().endsWith("/sitemap")) {
      String tmp = Val.chkStr(query.getResponseFormat());
      if (tmp.length() == 0) {
        query.setResponseFormat("sitemap");
      }
    }

    parser.parseRepositoryId("rid");
    parser.parseResponseFormat("f");
    parser.parseResponseGeometry("geometryType");
    parser.parseResponseStyle("style");
    parser.parseResponseTarget("target");
    parser.parseStartRecord("start", 1);
    parser.parseMaxRecords("max", 10);
    parser.parsePropertyIsEqualTo("uuid", "uuid");
    parser.parsePropertyIsLike("searchText", "anytext");
    parser.parsePropertyList("contentType", "dc:type", ",", true);
    parser.parsePropertyList("dataCategory", "dc:subject", ",", true);
    parser.parsePropertyRange("after", "before", "dct:modified");
    parser.parseSpatialClause("bbox", "spatialRel", "geometry");
    parser.parseSortables("orderBy");

    //parser.parsePropertyRange("validAfter","validBefore","dct:valid"); // date valid
    parser.parsePropertyIsEqualTo("publisher", "dc:publisher"); // publisher
    parser.parsePropertyIsEqualTo("source", "dc:source"); // harvesting id (uuid)
    parser.parsePropertyIsEqualTo("isPartOf", "dct:isPartOf"); // collection subset
    //parser.parsePropertyList("hasFormat","dct:hasFormat",",",true);
 
    //parameter &filter
  parser.parsePropertyIsLike("filter","anytext");

    return query;
  }
View Full Code Here

   * @return the search criteria object
   */
  protected SearchCriteria toSearchCriteria(HttpServletRequest request,
          RequestContext context, RestQuery query) {
    SearchCriteria criteria = new SearchCriteria();
    RestQueryParser parser = new RestQueryParser(request, context, new RestQuery());

    // keyword filter
    String sKeyword = Val.chkStr(parser.getRequestParameter("searchText"));
    if (sKeyword.length() > 0) {
      SearchFilterKeyword fKeyword = new SearchFilterKeyword();
      fKeyword.setSearchText(sKeyword);
      criteria.setSearchFilterKeyword(fKeyword);
    }

    // spatial filter
    SpatialClause bbox = parser.extractSpatialClause("bbox", "spatialRel", "geometry");
    if (bbox != null) {
      SearchFilterSpatial fSpatial = new SearchFilterSpatial();
      fSpatial.setSelectedEnvelope(bbox.getBoundingEnvelope());
      if (bbox instanceof SpatialClause.GeometryIsWithin) {
        fSpatial.setSelectedBounds(ISearchFilterSpatialObj.OptionsBounds.dataWithinExtent.name());
      } else {
        fSpatial.setSelectedBounds(ISearchFilterSpatialObj.OptionsBounds.useGeogExtent.name());
      }
      criteria.setSearchFilterSpatial(fSpatial);
    }

    // content type filter
    String sContentType = Val.chkStr(parser.getRequestParameter("contentType"));
    try {
      if (sContentType.length() > 0) {
        SearchFilterContentTypes fContentTypes = new SearchFilterContentTypes();
        fContentTypes.setSelectedContentType(
                SearchEngineCSW.AimsContentTypes.valueOf(sContentType).name());
        criteria.setSearchFilterContentTypes(fContentTypes);
      }
    } catch (IllegalArgumentException ex) {
      // if invalid content type simply do not create filter
    }

    // data category filter
    String delimitedThemes = Val.chkStr(parser.getRequestParameter("dataCategory"));
    String[] themes = Val.tokenize(delimitedThemes, ",");
    if (themes != null && themes.length > 0) {
      ArrayList<String> alThemes = new ArrayList<String>();
      for (String theme : themes) {
        alThemes.add(theme);
      }
      SearchFilterThemeTypes fThemes = new SearchFilterThemeTypes();
      fThemes.setSelectedThemes(alThemes);
      criteria.setSearchFilterThemes(fThemes);
    }

    // temporal filter
    String sAfter = Val.chkStr(parser.getRequestParameter("after"));
    String sBefore = Val.chkStr(parser.getRequestParameter("before"));
    if ((sAfter.length() > 0) || (sBefore.length() > 0)) {
      SearchFilterTemporal fTemporal = new SearchFilterTemporal();
      fTemporal.setDateModifiedFrom(sAfter);
      fTemporal.setDateModifiedTo(sBefore);
      fTemporal.setSelectedModifiedDateOption(
              SearchFilterTemporal.SelectedTimePeriod.beforeAndOrAfterPeriod.name());
      criteria.setSearchFilterTemporal(fTemporal);
    }

    // pagination filter
    SearchFilterPagination fPagination = new SearchFilterPagination();
    fPagination.setStartPostion(query.getFilter().getStartRecord());
    fPagination.setRecordsPerPage(query.getFilter().getMaxRecords());
    int startRecord = query.getFilter().getStartRecord();
    int maxRecords = query.getFilter().getMaxRecords();
    double page = (((double) startRecord) / ((double) maxRecords));
    fPagination.setCurrentPage((new Double(Math.ceil(page))).intValue());
    criteria.setSearchFilterPageCursor(fPagination);

    // sort filter
    String sOrderBy = Val.chkStr(parser.getRequestParameter("orderBy"));
    try {
      if (sOrderBy.length() > 0) {
        SearchFilterSort fSort = new SearchFilterSort();
        fSort.setSelectedSort(SearchFilterSort.OptionsSort.valueOf(sOrderBy).name());
        criteria.setSearchFilterSort(fSort);
      }
    } catch (IllegalArgumentException ex) {
      // if invalid content type simply do not create filter
    }

    // Distributed search
    String rid = parser.getRequestParameter("rid");
    SearchFilterHarvestSites harvestSites = new SearchFilterHarvestSites();
    harvestSites.setSelectedHarvestSiteId(rid);
    SearchFiltersList filterList = new SearchFiltersList();
    filterList.add(harvestSites);
    criteria.setMiscelleniousFilters(filterList);
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.discovery.rest.RestQueryParser

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.