/** * @return A String representation of this Query. */ public String toString() { StringBuilder rStr = new StringBuilder(); rStr.append("q="); int numCriteria = criteria.size(); for (int i = 0; i < numCriteria; i++) { QueryCriteria c = (QueryCriteria) criteria.get(i); rStr.append(c.toString()); if (i != numCriteria - 1) { rStr.append(" AND "); } } return rStr.toString(); }
/** * @return A String representation of this Query. */ public String toString() { StringBuilder rStr = new StringBuilder(); rStr.append("q="); int numCriteria = criteria.size(); for (int i = 0; i < numCriteria; i++) { QueryCriteria c = (QueryCriteria) criteria.get(i); rStr.append(c.toString()); if (i != numCriteria - 1) { rStr.append(" AND "); } } return rStr.toString(); }
/** * Method to convert the query to a string. * * @return string equivement of the query */ public String toString() { StringBuilder query = new StringBuilder(); if (operator == AND) { query.append("AND("); } else if (operator == OR) { query.append("OR("); } else { query.append("NOT("); } for (int i = 0; i < terms.size(); i++) { query.append(terms.get(i).toString()); if (i < (terms.size() - 1)) { query.append(", "); } } query.append(")"); return query.toString(); } }
/** * Method to convert the query to a string. * * @return string equivement of the query */ public String toString() { StringBuilder query = new StringBuilder(); if (operator == AND) { query.append("AND("); } else if (operator == OR) { query.append("OR("); } else { query.append("NOT("); } for (int i = 0; i < terms.size(); i++) { query.append(terms.get(i).toString()); if (i < (terms.size() - 1)) { query.append(", "); } } query.append(")"); return query.toString(); } }
/** * Common utility to retrieve a range of products matching the specified {@link Query} and {@link ProductType}. * This method transforms the given constraints in a map of HTTP (name, value) pairs and delegates to the following method. * * @param query * @param type * @param offset * @param limit * @return * @throws CatalogException */ private QueryResponse getProducts(Query query, ProductType type, int offset, int limit) throws CatalogException { // build HTTP request ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>(); // product type constraint params.put("q", new String[]{Parameters.PRODUCT_TYPE_NAME+":"+type.getName()} ); // convert filemgr query into a Solr query List<String> qc = new ArrayList<String>(); for (QueryCriteria queryCriteria : query.getCriteria()) { LOG.info("Query criteria="+queryCriteria.toString()); qc.add(queryCriteria.toString()); } params.put("fq", qc.toArray( new String[ qc.size() ] )); // sort params.put("sort", new String[]{ Parameters.PRODUCT_RECEIVED_TIME+" desc"} ); return this.getProducts(params, offset, limit); }
/** * Common utility to retrieve a range of products matching the specified {@link Query} and {@link ProductType}. * This method transforms the given constraints in a map of HTTP (name, value) pairs and delegates to the following method. * * @param query * @param type * @param offset * @param limit * @return * @throws CatalogException */ private QueryResponse getProducts(Query query, ProductType type, int offset, int limit) throws CatalogException { // build HTTP request ConcurrentHashMap<String, String[]> params = new ConcurrentHashMap<String, String[]>(); // product type constraint params.put("q", new String[]{Parameters.PRODUCT_TYPE_NAME+":"+type.getName()} ); // convert filemgr query into a Solr query List<String> qc = new ArrayList<String>(); for (QueryCriteria queryCriteria : query.getCriteria()) { LOG.info("Query criteria="+queryCriteria.toString()); qc.add(queryCriteria.toString()); } params.put("fq", qc.toArray( new String[ qc.size() ] )); // sort params.put("sort", new String[]{ Parameters.PRODUCT_RECEIVED_TIME+" desc"} ); return this.getProducts(params, offset, limit); }