Examples of QueryCriteria


Examples of com.esri.ontology.service.control.QueryCriteria

    // gets writer
    PrintWriter out = response.getWriter();

    // parses query
    QueryCriteria queryCriteria = extractQueryCriteria(request);
    Selection selection = extractSelection(request);
    Format format = extractFormat(request);

    // sets response attributes
    response.setCharacterEncoding("UTF-8");
    response.setContentType(format.isOwl() ? "text/html" : "text/plain");

    // creates ontology context
    Context ontContext = Context.extract(this.getServletContext());
    OntologyProcessor ontProcessor = new OntologyProcessor(ontContext,
      request.getLocale());

    // checks if ontology context is ready
    if (!ontContext.isReady()) {
      log.info("Ontology context not ready.");
      response.setStatus(response.SC_SERVICE_UNAVAILABLE);
      return;
    }

    // checks if query criteria are correct
    if (queryCriteria.getTerm().length() == 0) {
      log.info("No search term entered.");
      response.setStatus(response.SC_BAD_REQUEST);
      return;
    }

    // performs ontology search
    log.info(
      "Performing ontology search. query criteria: " + queryCriteria + "; selection: " + selection + "; format: " + format);
    Date start = new Date();
    Terms terms = ontProcessor.search(queryCriteria, selection);
    Date end = new Date();
    log.info("Ontology search has been completed in " + (end.getTime() - start.
      getTime()) + " milliseconds.");

    OntologyWriter ontWriter = new OntologyWriter(out, ontContext, queryCriteria.getTerm(), format);
    ontWriter.write(terms);

  }
View Full Code Here

Examples of com.esri.ontology.service.control.QueryCriteria

    float threshold = Val.chkFloat(request.getParameter("threshold"), 0);
    int level = Val.chkInt(request.getParameter("level"), 1);

    level = Math.min(2, Math.max(1, level));

    QueryCriteria queryCriteria = new QueryCriteria();

    queryCriteria.setTerm(searchTerm.toLowerCase());
    queryCriteria.setSeeAlsoWeight(seeAlso);
    queryCriteria.setSubClassWeight(subClassOf);
    queryCriteria.setLevel(level);
    queryCriteria.setThreshold(threshold);

    return queryCriteria;
  }
View Full Code Here

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

            boolean gotFirstClause = false;
            int clauseNum = 0;

            if (query.getCriteria() != null && query.getCriteria().size() > 0) {
                for (Iterator<QueryCriteria> i = query.getCriteria().iterator(); i.hasNext();) {
                    QueryCriteria criteria = i.next();
                    clauseNum++;

                    String elementIdStr = null;

                    if (fieldIdStringFlag) {
                        elementIdStr = "'" + this.validationLayer.getElementByName(criteria.getElementName()).getElementId() + "'";
                    } else {
                        elementIdStr = this.validationLayer.getElementByName(criteria.getElementName()).getElementId();
                    }

                    String clause = null;

                    if (!gotFirstClause) {
View Full Code Here

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

                for (int i = 1; i < terms.size(); i++)
                    returnString += " OR " + getInfixCriteriaString((QueryCriteria) terms.get(i));
                returnString += ")";
                break;
            case 2:
                QueryCriteria qc = bqc.getTerms().get(0);
                if (qc instanceof TermQueryCriteria) {
                    TermQueryCriteria tqc = (TermQueryCriteria) qc;
                    returnString = tqc.getElementName() + " != '" + tqc.getValue() + "'";
                }else {
                    returnString = "NOT(" + getInfixCriteriaString(qc) + ")";
View Full Code Here

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

    }

    public static Vector<Hashtable<String, Object>> getXmlRpcQueryCriteriaList(List<QueryCriteria> criteriaList) {
        Vector<Hashtable<String, Object>> criteriaVector = new Vector<Hashtable<String, Object>>(criteriaList.size());
        for (Iterator<QueryCriteria> i = criteriaList.iterator(); i.hasNext();) {
            QueryCriteria criteria = i.next();
            Hashtable<String, Object> criteriaHash = getXmlRpcQueryCriteria(criteria);
            criteriaVector.add(criteriaHash);
        }

        return criteriaVector;
View Full Code Here

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

    public static List<QueryCriteria> getQueryCriteriaListFromXmlRpc(Vector<Hashtable<String, Object>> criteriaVector) {

        List<QueryCriteria> criteriaList = new Vector<QueryCriteria>(criteriaVector.size());
        for (Iterator<Hashtable<String, Object>> i = criteriaVector.iterator(); i.hasNext();) {
            Hashtable<String, Object> criteriaHash = i.next();
            QueryCriteria criteria = getQueryCriteriaFromXmlRpc(criteriaHash);
            criteriaList.add(criteria);
        }
        return criteriaList;
    }
View Full Code Here

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

            criteriaHash.put("operator", new Integer(boolQuery.getOperator()));
            Vector<Hashtable<String, Object>> termsHash = new Vector<Hashtable<String, Object>>();
            List<QueryCriteria> terms = boolQuery.getTerms();
           
            for(int i=0;i<terms.size();i++){
                QueryCriteria term = terms.get(i);
                Hashtable<String, Object> termHash = getXmlRpcQueryCriteria(term);
                termsHash.add(termHash);
            }
            criteriaHash.put("terms", termsHash);
           
View Full Code Here

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

        }
        return criteriaHash;
    }
   
    public static QueryCriteria getQueryCriteriaFromXmlRpc(Hashtable<String, Object> criteriaHash) {
        QueryCriteria criteria = null;
        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");
            ((RangeQueryCriteria)criteria).setStartValue(startVal);
            ((RangeQueryCriteria)criteria).setEndValue(endVal);
            ((RangeQueryCriteria)criteria).setInclusive(Boolean.parseBoolean((String) criteriaHash.get("inclusive")));
        } else if(((String)criteriaHash.get("class")).equals(BooleanQueryCriteria.class.getCanonicalName())){
            criteria = new BooleanQueryCriteria();
            try{
              ((BooleanQueryCriteria)criteria).setOperator( ((Integer)criteriaHash.get("operator")).intValue() );
            } catch (QueryFormulationException e){
                System.out.println("Error generating Boolean Query.");
            }
            List<Hashtable<String, Object>> terms = (List<Hashtable<String, Object>>) criteriaHash.get("terms");
            for(int i=0;i<terms.size();i++){
                Hashtable<String, Object> term = terms.get(i);
                QueryCriteria termCriteria = getQueryCriteriaFromXmlRpc(term);
                try{
                    ((BooleanQueryCriteria)criteria).addTerm(termCriteria);
                } catch (QueryFormulationException e){
                    System.out.println("Error generating Boolean Query.");
                }
View Full Code Here

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

                    "product_type_id", type.getProductTypeId()));
            booleanQuery.add(prodTypeTermQuery, BooleanClause.Occur.MUST);

            for (Iterator<QueryCriteria> i = query.getCriteria().iterator(); i.hasNext();) {
                // add a new query for each of the query criteria
                QueryCriteria crit = i.next();
                Element termElem = null;

                try {
                    termElem = valLayer.getElementByName(crit.getElementName());
                } catch (ValidationLayerException e) {
                    LOG.log(Level.WARNING,
                            "ValidationLayer exception when looking up element definition for: ["
                                    + crit.getElementName() + "]: Message: "
                                    + e.getMessage());
                    continue;
                }

                if (crit instanceof TermQueryCriteria) {
View Full Code Here

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

                if (query.getCriteria() != null
                        && query.getCriteria().size() > 0) {
                    for (Iterator i = query.getCriteria().iterator(); i
                            .hasNext();) {
                        QueryCriteria criteria = (QueryCriteria) i.next();
                        clauseNum++;

                        String elementIdStr = null;

                        if (fieldIdStringFlag) {
                            elementIdStr = "'" + this.getValidationLayer().getElementByName(criteria.getElementName()).getElementId() + "'";
                        } else {
                            elementIdStr = this.getValidationLayer().getElementByName(criteria.getElementName()).getElementId();
                        }

                        String clause = null;

                        if (!gotFirstClause) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.