Package org.z3950.zing.cql

Examples of org.z3950.zing.cql.CQLParser


             * Query node operators are 0 = none, 1 = and, 2 = or, 3 = andnot, 4 = prox.
             */
            switch (((QueryModelComplexNode) node).getOp())
            {
            case 1:
                result = new CQLAndNode(createCQLNode(((QueryModelComplexNode) node).getLhs(), sourceNamespace, targetNamespace, complexSupport), createCQLNode(((QueryModelComplexNode) node).getRhs(), sourceNamespace, targetNamespace, complexSupport));

                break;

            case 2:
                result = new CQLOrNode(createCQLNode(((QueryModelComplexNode) node).getLhs(), sourceNamespace, targetNamespace, complexSupport), createCQLNode(((QueryModelComplexNode) node).getRhs(), sourceNamespace, targetNamespace, complexSupport));
View Full Code Here


    }

    private OperandType toOperandType(CQLNode node) {
        OperandType ot=new OperandType();
        if(node instanceof CQLBooleanNode) {
            CQLBooleanNode cbn=(CQLBooleanNode)node;
            TripleType tt=new TripleType();
            if(cbn instanceof CQLAndNode)
                tt.set_boolean(new BooleanType("and", null));
            else if(cbn instanceof CQLOrNode)
                tt.set_boolean(new BooleanType("or", null));
View Full Code Here

        return resultSetIds;
    }
   
    public static void getResultSetIds(CQLNode root, ArrayList<String> resultSetIds) throws SRWDiagnostic {
        if(root instanceof CQLBooleanNode) {
            CQLBooleanNode cbn=(CQLBooleanNode)root;
            getResultSetIds(cbn.left, resultSetIds);
            getResultSetIds(cbn.right, resultSetIds);
        }
        else {
            CQLTermNode ctn=(CQLTermNode)root;
View Full Code Here

    {
        QueryModelNode result = null;

        if (node instanceof CQLBooleanNode)
        {
            CQLBooleanNode cbn = (CQLBooleanNode) node;

            if (cbn instanceof CQLAndNode)
            {
                result = new QueryModelComplexNode(translate(cbn.left), translate(cbn.right), QueryModelComplexNode.COMPLEX_OP_AND);
            }
View Full Code Here

    }

    public QueryResult getQueryResult(String queryStr,
      SearchRetrieveRequestType request) {
        BasicQueryResult result=new BasicQueryResult();
        CQLNode query;
        try {
            query=parser.parse(queryStr);
        }
        catch(Exception e) {
            result.addDiagnostic(SRWDiagnostic.QuerySyntaxError, queryStr);
View Full Code Here

        ert.setMaximumRecords(request.getMaximumRecords());
        String query=request.getQuery();
        if(query!=null && query.length()>0) {
            ert.setQuery(query);
            try {
                CQLNode root=cqlparser.parse(query);
                ert.setXQuery(toOperandType(root));
            }
            catch (CQLParseException e) {
                log.error("parse problem: \""+query+"\"",e);
                RelationType rt=new RelationType("", null);
View Full Code Here

    /**
     * Test of getFirstTerm method, of class ORG.oclc.os.SRW.Utilities.
     */
    public void testGetFirstTerm() throws Exception {
        CQLParser parser = new CQLParser();       
        CQLNode rootNode=parser.parse("dog");
        assertEquals("dog", Utilities.getFirstTerm(rootNode).getTerm());

        rootNode=parser.parse("dog or cat and mouse");
        assertEquals("dog", Utilities.getFirstTerm(rootNode).getTerm());
    }
View Full Code Here

       
          try {
        CQLParser parser = new CQLParser(CQLParser.V1POINT2);
//          String local_full_query_string = query;
//          local_full_query_string = local_full_query_string.replace("-", "%2D");
          CQLNode query_cql = parser.parse(query);
          if (output.equals(OutputTypeXCQL)) {
        String xmlContent = query_cql.toXCQL();
        if (xmlContent.length() == 0) {
      return Sequence.EMPTY_SEQUENCE;
        }
        StringReader reader = new StringReader(xmlContent);
        SAXAdapter adapter = new SAXAdapter(context);
        SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setNamespaceAware(true);
        InputSource src = new InputSource(reader);
       
        SAXParser saxParser = factory.newSAXParser();
        XMLReader xr = saxParser.getXMLReader();
       
        xr.setContentHandler(adapter);
        xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
        xr.parse(src);
        ret = (DocumentImpl) adapter.getDocument();

          } else if (output.equals(OutputTypeString)) {
        ret = new StringValue(query_cql.toString());
          } else {
        ret = new StringValue(query_cql.toCQL());
          }
          return ret;
          }
    catch (CQLParseException e) {
        throw new XPathException(this, "An error occurred while parsing the query expression (CQLParseException): " + e.getMessage(), e);         
View Full Code Here

  @Override
  protected ModelAndView handleQueryRequest(HttpServletRequest request,HttpServletResponse response,BindException errors, String query) throws CQLParseException, IOException, InstantiationException {
    //String query = request.getParameter("query");       
    CQLParser parser = new CQLParser();
    CQLNode root = parser.parse(query);
    root = normalizeParseTree(root);
    Set<Matrix> queryResults = doCQLQuery(root, new HashSet<Matrix>(),request, response, errors);
    MatrixSearchResults tsr = new MatrixSearchResults(queryResults);
    saveSearchResults(request, tsr);
    if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {
View Full Code Here

  protected ModelAndView handleQueryRequest(HttpServletRequest request,
      HttpServletResponse response, BindException errors, String query)
      throws CQLParseException, IOException, InstantiationException {
    //String query = request.getParameter("query");
    CQLParser parser = new CQLParser();
    CQLNode root = parser.parse(query);
    root = normalizeParseTree(root);
    Set<PhyloTree> queryResults = doCQLQuery(root, new HashSet<PhyloTree>(),request, response, errors);
    TreeSearchResults tsr = new TreeSearchResults(queryResults);
    saveSearchResults(request, tsr);
    if ( TreebaseUtil.isEmpty(request.getParameter("format")) || ! request.getParameter("format").equals("rss1") ) {     
View Full Code Here

TOP

Related Classes of org.z3950.zing.cql.CQLParser

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.