public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
     throws Exception {
   SearchResultsFrozen frozenResults =
       (SearchResultsFrozen) request.getSession().getAttribute("searchResults");
   if (null != frozenResults) {
     String phyloWSPath = request.getSession().getAttribute("originalSection") + "/find";
     SearchResults<?> searchResults = frozenResults.thaw();
     request.getSession().setAttribute("searchResultsThawed", searchResults);
     request
         .getSession()
         .setAttribute("recordSchema", request.getSession().getAttribute("recordSchema"));
     request.getSession().setAttribute("format", "rss1");
     request.getSession().setAttribute("baseURL", TreebaseUtil.getPurlBase());
     request.getSession().setAttribute("phyloWSPath", phyloWSPath);
     if (null != request.getParameter("query")) {
       String query = request.getParameter("query");
       if (!TreebaseUtil.isEmpty(query)) {
         CQLParser parser = new CQLParser();
         CQLNode root = parser.parse(query);
         request
             .getSession()
             .setAttribute("normalizedCQLQuery", URLEncoder.encode(root.toCQL(), "UTF-8"));
       }
     }
   }
   return new ModelAndView("searchResultsAsRDF");
 }
Ejemplo n.º 2
0
  /**
   * Parse the given CQL query and create a corresponding Hibernate query to filter for OAI set
   * definitions from it.
   *
   * @param query CQL query
   * @throws InvalidSearchQueryException thrown if the given search query could not be translated
   *     into a SQL query
   */
  public SetDefinitionFilter(final String query) throws InvalidSearchQueryException {
    // Adding or Removal of values has also to be done in Method evaluate
    // and in the Hibernate-Class-Method retrieveSetDefinitions
    // URI-style filters/////////////////////////////////////////////////////
    // Filter-Names
    criteriaMap.put(Constants.DC_IDENTIFIER_URI, new Object[] {COMPARE_EQ, "id"});
    criteriaMap.put(TripleStoreUtility.PROP_NAME, new Object[] {COMPARE_LIKE, "name"});
    criteriaMap.put(TripleStoreUtility.PROP_CREATED_BY_ID, new Object[] {COMPARE_EQ, "creator_id"});
    criteriaMap.put(
        TripleStoreUtility.PROP_MODIFIED_BY_ID, new Object[] {COMPARE_EQ, "modified_by_id"});
    criteriaMap.put(
        Constants.SET_DEFINITION_NS_URI + '/' + XmlUtility.NAME_SPECIFICATION,
        new Object[] {COMPARE_LIKE, "specification"});

    // Sortby-Names
    propertyNamesMap.put("specification", "specification");
    propertyNamesMap.put(TripleStoreUtility.PROP_NAME, "name");
    propertyNamesMap.put(TripleStoreUtility.PROP_CREATED_BY_ID, "creator_id");
    propertyNamesMap.put(TripleStoreUtility.PROP_MODIFIED_BY_ID, "modified_by_id");
    propertyNamesMap.put(Constants.DC_IDENTIFIER_URI, "id");
    // //////////////////////////////////////////////////////////////////////

    // Path-style filters////////////////////////////////////////////////////
    // Filter-Names
    criteriaMap.put(Constants.FILTER_PATH_ID, new Object[] {COMPARE_EQ, "id"});
    criteriaMap.put(Constants.FILTER_PATH_NAME, new Object[] {COMPARE_LIKE, "name"});
    criteriaMap.put(Constants.FILTER_PATH_CREATED_BY_ID, new Object[] {COMPARE_EQ, "creator_id"});
    criteriaMap.put(
        Constants.FILTER_PATH_MODIFIED_BY_ID, new Object[] {COMPARE_EQ, "modified_by_id"});
    criteriaMap.put(
        Constants.FILTER_PATH_SPECIFICATION, new Object[] {COMPARE_LIKE, "specification"});

    // Sortby-Names
    propertyNamesMap.put("specification", "specification");
    propertyNamesMap.put(Constants.FILTER_PATH_SPECIFICATION, "specification");
    propertyNamesMap.put(Constants.FILTER_PATH_NAME, "name");
    propertyNamesMap.put(Constants.FILTER_PATH_CREATED_BY_ID, "creator_id");
    propertyNamesMap.put(Constants.FILTER_PATH_MODIFIED_BY_ID, "modified_by_id");
    propertyNamesMap.put(Constants.FILTER_PATH_ID, "id");
    // //////////////////////////////////////////////////////////////////////

    if (query != null) {
      try {
        final CQLParser parser = new CQLParser();

        this.detachedCriteria = DetachedCriteria.forClass(SetDefinition.class, "sd");

        final Criterion criterion = evaluate(parser.parse(query));

        if (criterion != null) {
          detachedCriteria.add(criterion);
        }
      } catch (final Exception e) {
        throw new InvalidSearchQueryException(e);
      }
    }
  }