public Query buildQuery() { Query query = new Query(); TermQueryCriteria crit = new TermQueryCriteria(PRODUCT_NAME, this.prodName); query.addCriterion(crit); 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()); } }
public static Query getQueryFromXmlRpc(Map<String, Object> queryHash) { Query query = new Query(); @SuppressWarnings("unchecked") List<QueryCriteria> criteria = getQueryCriteriaListFromXmlRpc((Vector<Map<String, Object>>) queryHash .get("criteria")); query.setCriteria(criteria); return query; }
/** * 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; }
public int getNumProducts(ProductType type) throws CatalogException { Query query = new Query(); return getNumHits(query, type); }
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; }
Term t = ((TermQuery) luceneQuery).getTerm(); if (!t.field().equals(freeTextBlock)) { casQuery.addCriterion(new TermQueryCriteria(t.field(), t.text())); if (!t[0].field().equals(freeTextBlock)) { for (Term aT : t) { casQuery.addCriterion(new TermQueryCriteria( aT.field(), aT.text())); BytesRef startT = ((TermRangeQuery) luceneQuery).getLowerTerm(); BytesRef endT = ((TermRangeQuery) luceneQuery).getUpperTerm(); casQuery.addCriterion(new RangeQueryCriteria(((TermRangeQuery) luceneQuery).getField(), startT.utf8ToString(), endT.utf8ToString())); } else if (luceneQuery instanceof BooleanQuery) { List<BooleanClause> clauses = ((BooleanQuery) luceneQuery).clauses();
public int getNumProducts(ProductType type) throws CatalogException { Query query = new Query(); return getNumHits(query, type); }
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; }
Term t = ((TermQuery) luceneQuery).getTerm(); if (!t.field().equals(freeTextBlock)) { casQuery.addCriterion(new TermQueryCriteria(t.field(), t.text())); if (!t[0].field().equals(freeTextBlock)) { for (Term aT : t) { casQuery.addCriterion(new TermQueryCriteria( aT.field(), aT.text())); BytesRef startT = ((TermRangeQuery) luceneQuery).getLowerTerm(); BytesRef endT = ((TermRangeQuery) luceneQuery).getUpperTerm(); casQuery.addCriterion(new RangeQueryCriteria(((TermRangeQuery) luceneQuery).getField(), startT.utf8ToString(), endT.utf8ToString())); } else if (luceneQuery instanceof BooleanQuery) { List<BooleanClause> clauses = ((BooleanQuery) luceneQuery).clauses();
/** * 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; }
public Query buildQuery() { Query query = new Query(); TermQueryCriteria crit = new TermQueryCriteria(INPUT_FILES, this.origInputFile); query.addCriterion(crit); return query; }
public synchronized List<Product> getTopNProducts(int n, ProductType type) throws CatalogException { int numPages = 1; if (n > this.pageSize) { numPages = n / this.pageSize + (n % this.pageSize == 0 ? 0 : 1); } List<Product> products = new Vector<Product>(n); Query query = new Query(); for (int pageNum = 1; pageNum < numPages + 1; pageNum++) { List<Product> pageProducts = paginateQuery(query, type, pageNum, null); if(pageProducts!=null) { products.addAll(pageProducts); } } if(n<=products.size()) { return products.subList(0, n); } return products; }
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()); } }
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); }
public static Query getQueryFromXmlRpc(Map<String, Object> queryHash) { Query query = new Query(); @SuppressWarnings("unchecked") List<QueryCriteria> criteria = getQueryCriteriaListFromXmlRpc((Vector<Map<String, Object>>) queryHash .get("criteria")); query.setCriteria(criteria); return query; }
if (!t.field().equals(freeTextBlock)) { casQuery .addCriterion(new TermQueryCriteria(t.field(), t.text())); if (!t[0].field().equals(freeTextBlock)) { for (Term aT : t) { casQuery.addCriterion(new TermQueryCriteria(aT.field(), aT.text())); casQuery.addCriterion(new RangeQueryCriteria(((TermRangeQuery) luceneQuery).getField(), startT.utf8ToString(), endT.utf8ToString())); } else if (luceneQuery instanceof BooleanQuery) { List<BooleanClause> clauses = ((BooleanQuery) luceneQuery).clauses();
public Query buildQuery() { Query query = new Query(); TermQueryCriteria crit = new TermQueryCriteria(FILENAME, this.fileName); query.addCriterion(crit); return query; }
public synchronized List<Product> getTopNProducts(int n, ProductType type) throws CatalogException { int numPages = 1; if (n > this.pageSize) { numPages = n / this.pageSize + (n % this.pageSize == 0 ? 0 : 1); } List<Product> products = new Vector<Product>(n); Query query = new Query(); for (int pageNum = 1; pageNum < numPages + 1; pageNum++) { List<Product> pageProducts = paginateQuery(query, type, pageNum, null); if(pageProducts!=null) { products.addAll(pageProducts); } } if(n<=products.size()) { return products.subList(0, n); } return products; }
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; }