Package org.apache.oodt.cas.filemgr.structs

Examples of org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria


                            t[i].field(), t[i].text()));
            }
        } else if (luceneQuery instanceof RangeQuery) {
            Term startT = ((RangeQuery) luceneQuery).getLowerTerm();
            Term endT = ((RangeQuery) luceneQuery).getUpperTerm();
            casQuery.addCriterion(new RangeQueryCriteria(startT
                    .field(), startT.text(), endT.text()));
        } else if (luceneQuery instanceof BooleanQuery) {
            BooleanClause[] clauses = ((BooleanQuery) luceneQuery).getClauses();
            for (int i = 0; i < clauses.length; i++) {
                generateCASQuery(casQuery, (clauses[i]).getQuery());
View Full Code Here


                elementIdStr = "'" + elementIdStr + "'";
            sqlQuery = "SELECT DISTINCT product_id FROM " + type.getName() + "_metadata WHERE element_id = " + elementIdStr + " AND ";
            if (queryCriteria instanceof TermQueryCriteria) {
                sqlQuery += "metadata_value = '" + ((TermQueryCriteria) queryCriteria).getValue() + "'";
            } else if (queryCriteria instanceof RangeQueryCriteria) {
                RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria;
                String rangeSubQuery = null;
                if (rqc.getStartValue() != null)
                    rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
                if (rqc.getEndValue() != null) {
                    if (rangeSubQuery == null)
                        rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
                    else
                        rangeSubQuery = "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
                }
                sqlQuery += rangeSubQuery;
            } else {
                throw new CatalogException("Invalid QueryCriteria [" + queryCriteria.getClass().getCanonicalName() + "]");
            }
View Full Code Here

                            t[i].text()));
            }
        } else if (luceneQuery instanceof RangeQuery) {
            Term startT = ((RangeQuery) luceneQuery).getLowerTerm();
            Term endT = ((RangeQuery) luceneQuery).getUpperTerm();
            casQuery.addCriterion(new RangeQueryCriteria(startT.field(), startT
                    .text(), endT.text()));
        } else if (luceneQuery instanceof BooleanQuery) {
            BooleanClause[] clauses = ((BooleanQuery) luceneQuery).getClauses();
            for (int i = 0; i < clauses.length; i++) {
                GenerateCASQuery(casQuery, (clauses[i]).getQuery());
View Full Code Here

                    returnString = "NOT(" + getInfixCriteriaString(qc) + ")";
                }
                break;
            }
        }else if (criteria instanceof RangeQueryCriteria) {
            RangeQueryCriteria rqc = (RangeQueryCriteria) criteria;
            String opString = rqc.getInclusive() ? "=" : "";
            if (rqc.getStartValue() != null) {
                opString = ">" + opString + " '" + rqc.getStartValue() + "'";
            }else
                opString = "<" + opString + " '" + rqc.getEndValue() + "'";
            returnString = rqc.getElementName() + " " + opString;
        }else if (criteria instanceof TermQueryCriteria) {
            TermQueryCriteria tqc = (TermQueryCriteria) criteria;
            returnString = tqc.getElementName() + " == '" + tqc.getValue() + "'";
        }
        return returnString;
View Full Code Here

        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());
        }
View Full Code Here

        if(((String)criteriaHash.get("class")).equals(TermQueryCriteria.class.getCanonicalName())){
            criteria = new TermQueryCriteria();
            criteria.setElementName((String) criteriaHash.get("elementName"));
            ((TermQueryCriteria)criteria).setValue((String) criteriaHash.get("elementValue"));
        } else if(((String)criteriaHash.get("class")).equals(RangeQueryCriteria.class.getCanonicalName())){
            criteria = new RangeQueryCriteria();
            criteria.setElementName((String) criteriaHash.get("elementName"));
            String startVal = criteriaHash.get("elementStartValue").equals("") ?
                    null : (String)criteriaHash.get("elementStartValue");
            String endVal = criteriaHash.get("elementEndValue").equals("") ?
                    null : (String)criteriaHash.get("elementEndValue");
View Full Code Here

    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(Iterator<String> i = this.uniqueElementProductTypeNames.iterator(); i.hasNext(); ){
                    String productTypeName = i.next();
View Full Code Here

        if(((String)criteriaHash.get("class")).equals(TermQueryCriteria.class.getCanonicalName())){
            criteria = new TermQueryCriteria();
            criteria.setElementName((String) criteriaHash.get("elementName"));
            ((TermQueryCriteria)criteria).setValue((String) criteriaHash.get("elementValue"));
        } else if(((String)criteriaHash.get("class")).equals(RangeQueryCriteria.class.getCanonicalName())){
            criteria = new RangeQueryCriteria();
            criteria.setElementName((String) criteriaHash.get("elementName"));
            String startVal = criteriaHash.get("elementStartValue").equals("") ?
                    null : (String)criteriaHash.get("elementStartValue");
            String endVal = criteriaHash.get("elementEndValue").equals("") ?
                    null : (String)criteriaHash.get("elementEndValue");
View Full Code Here

                       + " AND element_id = " + elementIdStr + " AND ";
            }
            if (queryCriteria instanceof TermQueryCriteria) {
                sqlQuery += "metadata_value = '" + ((TermQueryCriteria) queryCriteria).getValue() + "'";
            } else if (queryCriteria instanceof RangeQueryCriteria) {
                RangeQueryCriteria rqc = (RangeQueryCriteria) queryCriteria;
                String rangeSubQuery = null;
                if (rqc.getStartValue() != null)
                    rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " >= " : " > ") + "'" + rqc.getStartValue() + "'";
                if (rqc.getEndValue() != null) {
                    if (rangeSubQuery == null)
                        rangeSubQuery = "metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "'";
                    else
                        rangeSubQuery = "(" + rangeSubQuery + " AND metadata_value" + (rqc.getInclusive() ? " <= " : " < ") + "'" + rqc.getEndValue() + "')";
                }
                sqlQuery += rangeSubQuery;
            } else {
                throw new CatalogException("Invalid QueryCriteria [" + queryCriteria.getClass().getCanonicalName() + "]");
            }
View Full Code Here

                            t[i].field(), t[i].text()));
            }
        } else if (luceneQuery instanceof RangeQuery) {
            Term startT = ((RangeQuery) luceneQuery).getLowerTerm();
            Term endT = ((RangeQuery) luceneQuery).getUpperTerm();
            casQuery.addCriterion(new RangeQueryCriteria(startT
                    .field(), startT.text(), endT.text()));
        } else if (luceneQuery instanceof BooleanQuery) {
            BooleanClause[] clauses = ((BooleanQuery) luceneQuery).getClauses();
            for (int i = 0; i < clauses.length; i++) {
                generateCASQuery(casQuery, (clauses[i]).getQuery());
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.filemgr.structs.RangeQueryCriteria

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.