public Query buildQuery() { Query query = new Query(); RangeQueryCriteria crit = new RangeQueryCriteria(); crit.setElementName(this.temporalFld); crit.setInclusive(true); if (this.startDateTime != null) { crit.setStartValue(this.startDateTime); } if (this.endDateTime != null) { crit.setEndValue(this.endDateTime); } query.addCriterion(crit); return query; }
String opString = rqc.getInclusive() ? "=" : ""; if (rqc.getStartValue() != null) { opString = ">" + opString + " '" + rqc.getStartValue() + "'"; }else { opString = "<" + opString + " '" + rqc.getEndValue() + "'"; returnString.append(rqc.getElementName()).append(" ").append(opString); }else if (criteria instanceof TermQueryCriteria) { TermQueryCriteria tqc = (TermQueryCriteria) criteria;
/** * {@inheritDoc} */ @Override protected QueryCriteria handleRangeQueryCriteria(RangeQueryCriteria rqc) { if (rqc.getEndValue() != null) { rqc.setEndValue(this.getCatalogValue(rqc.getEndValue())); } if (rqc.getStartValue() != null) { rqc.setStartValue(this.getCatalogValue(rqc.getStartValue())); } return rqc; }
public static Map<String, Object> getXmlRpcQueryCriteria(QueryCriteria criteria) { Map<String, Object> criteriaHash = new Hashtable<String, Object>(); criteriaHash.put("class", criteria.getClass().getCanonicalName()); if (criteria instanceof TermQueryCriteria) { criteriaHash.put("elementName", criteria.getElementName()); criteriaHash.put("elementValue", ((TermQueryCriteria) criteria).getValue()); } else if (criteria instanceof RangeQueryCriteria) { criteriaHash.put("elementName", criteria.getElementName()); criteriaHash.put("elementStartValue", ((RangeQueryCriteria) criteria).getStartValue() != null ? ((RangeQueryCriteria) criteria).getStartValue() : ""); criteriaHash.put("elementEndValue", ((RangeQueryCriteria) criteria).getEndValue() != null ? ((RangeQueryCriteria) criteria).getEndValue() : ""); criteriaHash.put("inclusive", Boolean.toString(((RangeQueryCriteria) criteria).getInclusive())); } else if (criteria instanceof BooleanQueryCriteria) { BooleanQueryCriteria boolQuery = (BooleanQueryCriteria) criteria; criteriaHash.put("operator", boolQuery.getOperator()); Vector<Map<String, Object>> termsHash = new Vector<Map<String, Object>>(); List<QueryCriteria> terms = boolQuery.getTerms(); for (QueryCriteria term : terms) { Map<String, Object> termHash = getXmlRpcQueryCriteria(term); termsHash.add(termHash); } criteriaHash.put("terms", termsHash); } return criteriaHash; }
public QueryCriteria convertToQueryCriteria() throws QueryFormulationException { switch (this.op) { case GREATER_THAN: return new RangeQueryCriteria(this.key, this.val, null, false); case LESS_THAN: return new RangeQueryCriteria(this.key, null, this.val, false); case EQUAL_TO: return new TermQueryCriteria(this.key, this.val); case NOT_EQUAL_TO: BooleanQueryCriteria notEqBQC = new BooleanQueryCriteria(); notEqBQC.setOperator(BooleanQueryCriteria.NOT); notEqBQC.addTerm(new TermQueryCriteria(this.key, this.val)); return notEqBQC; case GREATER_THAN_OR_EQUAL_TO: return new RangeQueryCriteria(this.key, this.val, null, true); case LESS_THAN_OR_EQUAL_TO: return new RangeQueryCriteria(this.key, null, this.val, true); } throw new QueryFormulationException( "Was not able to form query . . . probably an invalid operator -- " + this.toString()); }
public static Map<String, Object> getXmlRpcQueryCriteria(QueryCriteria criteria) { Map<String, Object> criteriaHash = new Hashtable<String, Object>(); criteriaHash.put("class", criteria.getClass().getCanonicalName()); if (criteria instanceof TermQueryCriteria) { criteriaHash.put("elementName", criteria.getElementName()); criteriaHash.put("elementValue", ((TermQueryCriteria) criteria).getValue()); } else if (criteria instanceof RangeQueryCriteria) { criteriaHash.put("elementName", criteria.getElementName()); criteriaHash.put("elementStartValue", ((RangeQueryCriteria) criteria).getStartValue() != null ? ((RangeQueryCriteria) criteria).getStartValue() : ""); criteriaHash.put("elementEndValue", ((RangeQueryCriteria) criteria).getEndValue() != null ? ((RangeQueryCriteria) criteria).getEndValue() : ""); criteriaHash.put("inclusive", Boolean.toString(((RangeQueryCriteria) criteria).getInclusive())); } else if (criteria instanceof BooleanQueryCriteria) { BooleanQueryCriteria boolQuery = (BooleanQueryCriteria) criteria; criteriaHash.put("operator", boolQuery.getOperator()); Vector<Map<String, Object>> termsHash = new Vector<Map<String, Object>>(); List<QueryCriteria> terms = boolQuery.getTerms(); for (QueryCriteria term : terms) { Map<String, Object> termHash = getXmlRpcQueryCriteria(term); termsHash.add(termHash); } criteriaHash.put("terms", termsHash); } return criteriaHash; }
/** * {@inheritDoc} */ @Override protected QueryCriteria handleRangeQueryCriteria(RangeQueryCriteria rqc) { if (rqc.getEndValue() != null) { rqc.setEndValue(this.getCatalogValue(rqc.getEndValue())); } if (rqc.getStartValue() != null) { rqc.setStartValue(this.getCatalogValue(rqc.getStartValue())); } return rqc; }
private List<Product> getProductsOverDateRange(String elementName, String productType, String startOfQuery, String endOfQuery) throws CacheException { List<Product> products = new Vector<Product>(); try { Query query = new Query(); query.addCriterion(new RangeQueryCriteria(elementName, startOfQuery, endOfQuery)); if(this.uniqueElementProductTypeNames != null && this.uniqueElementProductTypeNames.size() > 0){ for (String productTypeName : this.uniqueElementProductTypeNames) { products.addAll(getProducts(query, productTypeName)); } } } catch (Exception e) { throw new CacheException("Failed to query for product via element " + elementName + " and range " + startOfQuery + " to " + endOfQuery + " : " + e.getMessage(), e); } return products; }
public Query buildQuery() { Query query = new Query(); RangeQueryCriteria crit = new RangeQueryCriteria(); crit.setElementName(this.temporalFld); crit.setInclusive(true); if (this.startDateTime != null) { crit.setStartValue(this.startDateTime); } if (this.endDateTime != null) { crit.setEndValue(this.endDateTime); } query.addCriterion(crit); return query; }
RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria; String rangeSubQuery = null; if (rqc.getStartValue() != null) { rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'"; if (rqc.getEndValue() != null) { rangeSubQuery = rangeSubQuery == null ? "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc .getEndValue() + "'" : "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
public QueryCriteria convertToQueryCriteria() throws QueryFormulationException { switch (this.op) { case GREATER_THAN: return new RangeQueryCriteria(this.key, this.val, null, false); case LESS_THAN: return new RangeQueryCriteria(this.key, null, this.val, false); case EQUAL_TO: return new TermQueryCriteria(this.key, this.val); case NOT_EQUAL_TO: BooleanQueryCriteria notEqBQC = new BooleanQueryCriteria(); notEqBQC.setOperator(BooleanQueryCriteria.NOT); notEqBQC.addTerm(new TermQueryCriteria(this.key, this.val)); return notEqBQC; case GREATER_THAN_OR_EQUAL_TO: return new RangeQueryCriteria(this.key, this.val, null, true); case LESS_THAN_OR_EQUAL_TO: return new RangeQueryCriteria(this.key, null, this.val, true); } throw new QueryFormulationException( "Was not able to form query . . . probably an invalid operator -- " + this.toString()); }
String opString = rqc.getInclusive() ? "=" : ""; if (rqc.getStartValue() != null) { opString = ">" + opString + " '" + rqc.getStartValue() + "'"; }else { opString = "<" + opString + " '" + rqc.getEndValue() + "'"; returnString.append(rqc.getElementName()).append(" ").append(opString); }else if (criteria instanceof TermQueryCriteria) { TermQueryCriteria tqc = (TermQueryCriteria) criteria;
((TermQueryCriteria) criteria).setValue((String) criteriaHash.get("elementValue")); } else if (criteriaHash.get("class").equals(RangeQueryCriteria.class.getCanonicalName())) { criteria = new RangeQueryCriteria(); criteria.setElementName((String) criteriaHash.get("elementName")); String startVal = criteriaHash.get("elementStartValue").equals("") ? String endVal = criteriaHash.get("elementEndValue").equals("") ? null : (String) criteriaHash.get("elementEndValue"); ((RangeQueryCriteria) criteria).setStartValue(startVal); ((RangeQueryCriteria) criteria).setEndValue(endVal); ((RangeQueryCriteria) criteria).setInclusive(Boolean.parseBoolean((String) criteriaHash.get("inclusive"))); } else if (criteriaHash.get("class").equals(BooleanQueryCriteria.class.getCanonicalName())) { criteria = new BooleanQueryCriteria();
RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria; String rangeSubQuery = null; if (rqc.getStartValue() != null) { rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'"; if (rqc.getEndValue() != null) { rangeSubQuery = rangeSubQuery == null ? "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc .getEndValue() + "'" : "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
private List<Product> getProductsOverDateRange(String elementName, String productType, String startOfQuery, String endOfQuery) throws CacheException { List<Product> products = new Vector<Product>(); try { Query query = new Query(); query.addCriterion(new RangeQueryCriteria(elementName, startOfQuery, endOfQuery)); if(this.uniqueElementProductTypeNames != null && this.uniqueElementProductTypeNames.size() > 0){ for (String productTypeName : this.uniqueElementProductTypeNames) { products.addAll(getProducts(query, productTypeName)); } } } catch (Exception e) { throw new CacheException("Failed to query for product via element " + elementName + " and range " + startOfQuery + " to " + endOfQuery + " : " + e.getMessage(), e); } return products; }
((TermQueryCriteria) criteria).setValue((String) criteriaHash.get("elementValue")); } else if (criteriaHash.get("class").equals(RangeQueryCriteria.class.getCanonicalName())) { criteria = new RangeQueryCriteria(); criteria.setElementName((String) criteriaHash.get("elementName")); String startVal = criteriaHash.get("elementStartValue").equals("") ? String endVal = criteriaHash.get("elementEndValue").equals("") ? null : (String) criteriaHash.get("elementEndValue"); ((RangeQueryCriteria) criteria).setStartValue(startVal); ((RangeQueryCriteria) criteria).setEndValue(endVal); ((RangeQueryCriteria) criteria).setInclusive(Boolean.parseBoolean((String) criteriaHash.get("inclusive"))); } else if (criteriaHash.get("class").equals(BooleanQueryCriteria.class.getCanonicalName())) { criteria = new BooleanQueryCriteria();
} else if (criteria instanceof RangeQueryCriteria) { String startVal = ((RangeQueryCriteria) criteria) .getStartValue(); String endVal = ((RangeQueryCriteria) criteria) .getEndValue(); boolean inclusive = ((RangeQueryCriteria) criteria) .getInclusive(); } else if (criteria instanceof RangeQueryCriteria) { String startVal = ((RangeQueryCriteria) criteria) .getStartValue(); String endVal = ((RangeQueryCriteria) criteria) .getEndValue();
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();
((TermQueryCriteria)queryCriteria).setValue(avroQueryCriteria.getElementValue()); }else if (avroQueryCriteria.getClassName().equals(RangeQueryCriteria.class.getCanonicalName())){ queryCriteria = new RangeQueryCriteria(); queryCriteria.setElementName(avroQueryCriteria.getElementName()); ((RangeQueryCriteria)queryCriteria).setStartValue(avroQueryCriteria.getElementStartValue()); ((RangeQueryCriteria)queryCriteria).setEndValue(avroQueryCriteria.getElementEndValue()); ((RangeQueryCriteria)queryCriteria).setInclusive(avroQueryCriteria.getInclusive()); }else if(avroQueryCriteria.getClassName().equals(BooleanQueryCriteria.class.getCanonicalName())){ queryCriteria = new BooleanQueryCriteria();
} else if (criteria instanceof RangeQueryCriteria) { String startVal = ((RangeQueryCriteria) criteria) .getStartValue(); String endVal = ((RangeQueryCriteria) criteria) .getEndValue(); boolean inclusive = ((RangeQueryCriteria) criteria) .getInclusive(); } else if (criteria instanceof RangeQueryCriteria) { String startVal = ((RangeQueryCriteria) criteria) .getStartValue(); String endVal = ((RangeQueryCriteria) criteria) .getEndValue();