public static Map<String, Object> getXmlRpcQuery(Query query) { Map<String, Object> queryHash = new Hashtable<String, Object>(); Vector<Map<String, Object>> criteriaVector = getXmlRpcQueryCriteriaList(query.getCriteria()); queryHash.put("criteria", criteriaVector); return queryHash; }
public static Map<String, Object> getXmlRpcQuery(Query query) { Map<String, Object> queryHash = new Hashtable<String, Object>(); Vector<Map<String, Object>> criteriaVector = getXmlRpcQueryCriteriaList(query.getCriteria()); queryHash.put("criteria", criteriaVector); return queryHash; }
public static AvroQuery getAvroQuery(Query query){ List<AvroQueryCriteria> avroQueryCriterias = new ArrayList<AvroQueryCriteria>(); for (QueryCriteria qc : query.getCriteria()){ avroQueryCriterias.add(getAvroQueryCriteria(qc)); } return new AvroQuery(avroQueryCriterias); }
/** * Converts this TypeHandler's element in the given Query into a Query * with the necessary elements and values so the Catalog can be queried. * * NOTE: Original Query is modified . . . the argument query becomes * equal to the returned query (return of query is a convenience). * * @param query Query for which the Catalog Query will be returned * @return A Query with Catalog element values * @throws QueryFormulationException * @throws IllegalAccessException * @throws InstantiationException */ public Query preQueryHandle(Query query) throws QueryFormulationException { LinkedList<QueryCriteria> qcList = new LinkedList<QueryCriteria>(); for (QueryCriteria qc : query.getCriteria()) { qcList.add(this.handleQueryCriteria(qc)); } query.setCriteria(qcList); return query; }
/** * 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); }
/** * Converts this TypeHandler's element in the given Query into a Query * with the necessary elements and values so the Catalog can be queried. * * NOTE: Original Query is modified . . . the argument query becomes * equal to the returned query (return of query is a convenience). * * @param query Query for which the Catalog Query will be returned * @return A Query with Catalog element values * @throws QueryFormulationException * @throws IllegalAccessException * @throws InstantiationException */ public Query preQueryHandle(Query query) throws QueryFormulationException { LinkedList<QueryCriteria> qcList = new LinkedList<QueryCriteria>(); for (QueryCriteria qc : query.getCriteria()) { qcList.add(this.handleQueryCriteria(qc)); } query.setCriteria(qcList); return query; }
private void refreshProductPage() { Query query = new Query(); System.out.println("CALLING REFRESH PRODUCT PAGE, CRITERIA:"); for (TermQueryCriteria crit : this.criteria) { System.out.println(crit); } query.getCriteria().addAll(this.criteria); try { this.productPage = fm.getFm().pagedQuery(query, type, this.pageNum); } catch (CatalogException e) { LOG.log(Level.SEVERE, "Unable to obtain page products: type: [" + type.getName() + "]: Reason: " + e.getMessage()); } }
/** * 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); }
private void refreshProductPage() { Query query = new Query(); System.out.println("CALLING REFRESH PRODUCT PAGE, CRITERIA:"); for (TermQueryCriteria crit : this.criteria) { System.out.println(crit); } query.getCriteria().addAll(this.criteria); try { this.productPage = fm.getFm().pagedQuery(query, type, this.pageNum); } catch (CatalogException e) { LOG.log(Level.SEVERE, "Unable to obtain page products: type: [" + type.getName() + "]: Reason: " + e.getMessage()); } }
@SuppressWarnings("unchecked") public static ComplexQuery getComplexQueryFromXmlRpc(Map<String, Object> complexQueryHash) { ComplexQuery complexQuery = new ComplexQuery(); complexQuery.setCriteria(getQueryFromXmlRpc(complexQueryHash).getCriteria()); if (((Vector<String>) complexQueryHash.get("reducedProductTypeNames")).size() > 0) { complexQuery.setReducedProductTypeNames((Vector<String>) complexQueryHash.get("reducedProductTypeNames")); } if (((Vector<String>) complexQueryHash.get("reducedMetadata")).size() > 0) { complexQuery.setReducedMetadata((Vector<String>) complexQueryHash.get("reducedMetadata")); } complexQuery.setSortByMetKey((String) complexQueryHash.get("sortByMetKey")); complexQuery.setToStringResultFormat((String) complexQueryHash.get("toStringResultFormat")); if (complexQueryHash.get("queryFilter") != null) { complexQuery.setQueryFilter( getQueryFilterFromXmlRpc((Map<String, Object>) complexQueryHash.get("queryFilter"))); } return complexQuery; }
@SuppressWarnings("unchecked") public static ComplexQuery getComplexQueryFromXmlRpc(Map<String, Object> complexQueryHash) { ComplexQuery complexQuery = new ComplexQuery(); complexQuery.setCriteria(getQueryFromXmlRpc(complexQueryHash).getCriteria()); if (((Vector<String>) complexQueryHash.get("reducedProductTypeNames")).size() > 0) { complexQuery.setReducedProductTypeNames((Vector<String>) complexQueryHash.get("reducedProductTypeNames")); } if (((Vector<String>) complexQueryHash.get("reducedMetadata")).size() > 0) { complexQuery.setReducedMetadata((Vector<String>) complexQueryHash.get("reducedMetadata")); } complexQuery.setSortByMetKey((String) complexQueryHash.get("sortByMetKey")); complexQuery.setToStringResultFormat((String) complexQueryHash.get("toStringResultFormat")); if (complexQueryHash.get("queryFilter") != null) { complexQuery.setQueryFilter( getQueryFilterFromXmlRpc((Map<String, Object>) complexQueryHash.get("queryFilter"))); } return complexQuery; }
if (query.getCriteria().size() == 0) { getProductSql.append("SELECT DISTINCT product_id FROM ").append(type.getName()).append("_metadata"); }else if (query.getCriteria().size() == 1) { getProductSql.append(this.getSqlQuery(query.getCriteria().get(0), type)); }else { getProductSql.append(this.getSqlQuery(new BooleanQueryCriteria(query.getCriteria(), BooleanQueryCriteria .AND), type)); if (query.getCriteria().size() == 0) { getProductSql.append("SELECT DISTINCT products.product_id FROM products, ").append(type.getName()) .append("_metadata").append(" WHERE products.product_id=").append(type.getName()) .append("_metadata.product_id"); } else if (query.getCriteria().size() == 1) { getProductSql.append(this.getSqlQuery(query.getCriteria().get(0), type)); } else { getProductSql.append(this.getSqlQuery(new BooleanQueryCriteria(query.getCriteria(), BooleanQueryCriteria .AND), type));
int clauseNum = 0; if (query.getCriteria() != null && query.getCriteria().size() > 0) { for (QueryCriteria criteria : query.getCriteria()) { clauseNum++;
int clauseNum = 0; if (query.getCriteria() != null && query.getCriteria().size() > 0) { for (QueryCriteria criteria : query.getCriteria()) { clauseNum++;
for (QueryCriteria queryCriteria : query.getCriteria()) { booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
for (QueryCriteria queryCriteria : query.getCriteria()) { booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
private void computeStartEndIdx() { if (this.productPage.getTotalPages() == 1) { this.totalProducts = this.productPage.getPageProducts().size(); this.pageNum = 1; } else if (productPage.getTotalPages() == 0) { this.totalProducts = 0; this.pageNum = 1; } else { this.totalProducts = (productPage.getTotalPages() - 1) * PAGE_SIZE; this.pageNum = this.productPage.getPageNum(); // get the last page ProductPage lastPage; Query query = new Query(); query.getCriteria().addAll(this.criteria); try { lastPage = fm.getFm().pagedQuery(query, this.type, this.productPage.getTotalPages()); this.totalProducts += lastPage.getPageProducts().size(); } catch (Exception ignore) { } } this.endIdx = this.totalProducts != 0 ? Math.min(this.totalProducts, (PAGE_SIZE) * (this.pageNum)) : 0; this.startIdx = this.totalProducts != 0 ? ((this.pageNum - 1) * PAGE_SIZE) + 1 : 0; }
for (QueryCriteria queryCriteria : query.getCriteria()) { booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
for (QueryCriteria queryCriteria : query.getCriteria()) { booleanQuery.add(this.getQuery(queryCriteria), BooleanClause.Occur.MUST);
private void computeStartEndIdx() { if (this.productPage.getTotalPages() == 1) { this.totalProducts = this.productPage.getPageProducts().size(); this.pageNum = 1; } else if (productPage.getTotalPages() == 0) { this.totalProducts = 0; this.pageNum = 1; } else { this.totalProducts = (productPage.getTotalPages() - 1) * PAGE_SIZE; this.pageNum = this.productPage.getPageNum(); // get the last page ProductPage lastPage; Query query = new Query(); query.getCriteria().addAll(this.criteria); try { lastPage = fm.getFm().pagedQuery(query, this.type, this.productPage.getTotalPages()); this.totalProducts += lastPage.getPageProducts().size(); } catch (Exception ignore) { } } this.endIdx = this.totalProducts != 0 ? Math.min(this.totalProducts, (PAGE_SIZE) * (this.pageNum)) : 0; this.startIdx = this.totalProducts != 0 ? ((this.pageNum - 1) * PAGE_SIZE) + 1 : 0; }