Package org.z3950.zing.cql

Examples of org.z3950.zing.cql.CQLParser


            {
                logger.debug("Using default qualifier: " + DEFAULT_QUALIFIER);
                attributePlusTermNode.setAttribute("bib-1.1", DEFAULT_QUALIFIER);
            }

            CQLRelation relation = cqlTermNode.getRelation();

            if (relation != null)
            {
                if (relation.getBase() != null)
                {
                    if (relation.getBase().equalsIgnoreCase("src"))
                    {
                        attributePlusTermNode.setAttribute("bib-1.2", new AttributeValue("="));
                    }
                    else if (relation.getBase().equalsIgnoreCase("exact"))
                    {
                        attributePlusTermNode.setAttribute("bib-1.2", new AttributeValue("="));
                    }
                    else if (relation.getBase().equalsIgnoreCase("all"))
                    {
                        attributePlusTermNode.setAttribute("bib-1.2", new AttributeValue("="));
                    }
                    else if (relation.getBase().equalsIgnoreCase("any"))
                    {
                        attributePlusTermNode.setAttribute("bib-1.2", new AttributeValue("="));
                    }
                    else
                    {
                        attributePlusTermNode.setAttribute("bib-1.2", new AttributeValue(relation.getBase()));
                    }

                    logger.debug("Modifiers: " + relation.getModifiers());
                }
            }

            result = attributePlusTermNode;
        }
View Full Code Here


        }
        else if (node instanceof QueryModelAPTNode)
        {
            QueryModelAPTNode attributPlusTermNode = (QueryModelAPTNode) node;

            CQLRelation relation = null;

            if (attributPlusTermNode.getAttribute("bib-1.2") != null)
            {
                relation = new CQLRelation(attributPlusTermNode.getAttribute("bib-1.2").toString());
            }
            else
            {
                relation = new CQLRelation("=");
            }

            String qualifier = null;
            Object accessPointNode = attributPlusTermNode.getAttribute("bib-1.1");
View Full Code Here

      results = resultsLeft;
    }   
    else if ( node instanceof CQLTermNode ) {
      CQLTermNode term = (CQLTermNode)node;
      boolean exactMatch = term.getRelation().getBase().equals("==");
      CQLRelation relation = term.getRelation();
      String index = term.getIndex();
      if ( index.startsWith("tb.title") ) {
        results.addAll(doSearch(request, response, SearchType.byTitle, errors, term.getTerm(),exactMatch,relation));
      } else if ( index.equals("tb.identifier.study") ) {
        results.addAll(doSearch(request, response, SearchType.byID, errors, term.getTerm(),exactMatch,relation));
View Full Code Here

      return node;
    }
    else if ( node instanceof CQLTermNode ) {
      String index = ((CQLTermNode)node).getIndex();
      String term = ((CQLTermNode)node).getTerm();
      CQLRelation relation = ((CQLTermNode)node).getRelation();
      Map<String,String> mapping = getPredicateMapping();
      for ( String key : mapping.keySet() ) {
        index = index.replaceAll(key, mapping.get(key));
      }
      return new CQLTermNode(index,relation,term);
View Full Code Here

            return result;
        }
        if(!(query instanceof CQLTermNode)) {
            result.addDiagnostic(SRWDiagnostic.UnsupportedBooleanOperator, null);
        }
        CQLTermNode term=(CQLTermNode) query;
        String index;
        index=term.getIndex();
        if(index.equals("oai.identifier") || index.equals("identifier")) {
            int filenameOffset=Collections.binarySearch(filenames, term.getTerm());
            if(filenameOffset>=0) {
                result.setNumberOfRecords(1);
                try {
                    byte[] b;
                    InputStream recStream=Utilities.openInputStream(filenames.get(filenameOffset), dbHome, null);
View Full Code Here

        String scanClause=request.getScanClause();
        log.info("scanClause="+scanClause);
        if(scanClause!=null) {
            ert.setScanClause(scanClause);
            try {
                CQLTermNode node=Utilities.getFirstTerm(new CQLParser(CQLParser.V1POINT1).parse(scanClause));
                if(node!=null) {
                    SearchClauseType sct=new SearchClauseType();
                    sct.setTerm(node.getTerm());
                    RelationType rt=new RelationType();
                    rt.setValue(node.getRelation().getBase());
                    sct.setRelation(rt);
                    sct.setIndex(getQualifier(node));
                    ert.setXScanClause(sct);
                }
                else {
View Full Code Here

            tt.setLeftOperand(toOperandType(cbn.left));
            tt.setRightOperand(toOperandType(cbn.right));
            ot.setTriple(tt);
        }
        else if(node instanceof CQLTermNode) {
            CQLTermNode ctn=(CQLTermNode)node;
            SearchClauseType sct=new SearchClauseType();
            sct.setIndex(getQualifier(ctn));
            RelationType rt=new RelationType();
            rt.setValue(ctn.getRelation().getBase());
            sct.setRelation(rt);
            sct.setTerm(ctn.getTerm());
            ot.setSearchClause(sct);
        }
        else {
            log.error("Found a node on the parse tree of type: "+node);
        }
View Full Code Here

        ScanResponseType scanResponse = new ScanResponseType();
        String version=request.getVersion();
        if(version!=null && !version.equals("1.1"))
            return diagnostic(SRWDiagnostic.UnsupportedVersion, version, scanResponse);

        CQLTermNode root = null;
        int max = maxTerms,  pos = position;
        long startTime = System.currentTimeMillis();
        PositiveInteger pi = request.getMaximumTerms();
        if(pi!=null) {
            max=pi.intValue();
            pos=max/2+1;
        }
        NonNegativeInteger nni = request.getResponsePosition();
        if(nni!=null)
            pos=nni.intValue();
        String scanTerm = request.getScanClause();
        try{
            if (scanTerm!=null)
                log.info("scanTerm:\n" + Utilities.byteArrayToString(scanTerm.getBytes("UTF-8")));
        } catch (Exception e){}
        log.info("maxTerms="+max+", position="+pos);
        try {
            root = Utilities.getFirstTerm(parser.parse(scanTerm));
        } catch (CQLParseException e) {
            log.error(e);
            return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(),
                scanResponse);
        } catch (IOException e) {
            log.error(e);
            return diagnostic(SRWDiagnostic.QuerySyntaxError, e.getMessage(),
                scanResponse);
        }
        if (root.getTerm().length()==0)
            // The method getQualifier() was replaced by getIndex() in version
            // 1.0 of the parser. This code ensures that either one works.
            //root = new CQLTermNode(root.getQualifier(), root.getRelation(), "$");
            root = new CQLTermNode(SRWSoapBindingImpl.getQualifier(root), root.getRelation(), "$");
        String resultSetID = root.getResultSetName();
        if (resultSetID!=null) { // you can't scan on resultSetId!
            return diagnostic(SRWDiagnostic.UnsupportedIndex,
                    "cql.resultSetId", scanResponse);
        }
        TermsType terms = new TermsType();
View Full Code Here

            CQLBooleanNode cbn=(CQLBooleanNode)root;
            getResultSetIds(cbn.left, resultSetIds);
            getResultSetIds(cbn.right, resultSetIds);
        }
        else {
            CQLTermNode ctn=(CQLTermNode)root;
            //if(ctn.getQualifier().equals("cql.resultSetId")) {
            if(SRWSoapBindingImpl.getQualifier(ctn).equals("cql.resultSetId")) {
                String resultSetId=ctn.getTerm();
                if(oldResultSets.get(resultSetId)==null)
                    throw new SRWDiagnostic(SRWDiagnostic.ResultSetDoesNotExist, resultSetId);
                resultSetIds.add(resultSetId);
                resetTimer(resultSetId);
                log.info("added resultSetId "+ctn.getTerm());
            }
        }
    }
View Full Code Here

        resultsLeft = resultsUnion;
      }
      results = resultsLeft;
    }   
    else if ( node instanceof CQLTermNode ) {
      CQLTermNode term = (CQLTermNode)node;
      String index = term.getIndex();       
      if ( index.startsWith("tb.title") ) {
        results.addAll(doSearch(request, response, SearchType.byTitle, errors, term.getTerm()));
      } else if ( index.equals("tb.identifier.matrix") ) {
        results.addAll(doSearch(request, response, SearchType.byID, errors, term.getTerm()));
      } else if ( index.equals("tb.identifier.matrix.tb1") ) {
        results.addAll(doSearch(request, response, SearchType.byTB1ID, errors, term.getTerm()));
      } else if ( index.startsWith("tb.type") ) {
        results.addAll(doSearch(request, response, SearchType.byType, errors, term.getTerm()));
      } else if ( index.startsWith("tb.ntax") ) {
        results.addAll(doSearch(request, response, SearchType.byNTAX, errors, term.getTerm()));
      } else if ( index.startsWith("tb.nchar") ) {
        results.addAll(doSearch(request, response, SearchType.byNTAX, errors, term.getTerm()));
      } else {
        // issue warnings
        addMessage(request, "Unsupported index: " + index);
     
    }
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.