Project

General

Profile

« Previous | Next » 

Revision 2068

Added by Matt Jones about 20 years ago

Created test class QuerySpecificationTest and started process of removing the xml_index from the QuerySpecification code. Reformatted some classes for readability.

View differences:

QuerySpecification.java
30 30

  
31 31
package edu.ucsb.nceas.metacat;
32 32

  
33
import java.io.File;
34
import java.io.FileReader;
35 33
import java.io.IOException;
36 34
import java.io.Reader;
37 35
import java.io.StringReader;
......
357 355
        return accessQuery;
358 356
    }
359 357

  
360
    /** Main routine for testing */
361
    static public void main(String[] args)
362
    {
363

  
364
        if (args.length < 1) {
365
            System.err.println("Wrong number of arguments!!!");
366
            System.err.println("USAGE: java QuerySpecification <xmlfile>");
367
            return;
368
        } else {
369
            int i = 0;
370
            boolean useXMLIndex = true;
371
            if (args[i].equals("-noindex")) {
372
                useXMLIndex = false;
373
                i++;
374
            }
375
            String xmlfile = args[i];
376

  
377
            try {
378
                MetaCatUtil util = new MetaCatUtil();
379
                FileReader xml = new FileReader(new File(xmlfile));
380
                QuerySpecification qspec = new QuerySpecification(xml, util
381
                        .getOption("saxparser"), util
382
                        .getOption("accNumberSeparator"));
383
                System.out.println(qspec.printSQL(useXMLIndex));
384

  
385
            } catch (IOException e) {
386
                System.err.println(e.getMessage());
387
            }
388

  
389
        }
390
    }
391

  
392 358
    /**
393 359
     * Returns true if the parsed query contains and extended xml query (i.e.
394 360
     * there is at least one &lt;returnfield&gt; in the pathquery document)
......
814 780
        sql.append(") AND startnodeid IS NOT NULL AND ");
815 781
        sql.append("(");
816 782
        sql.append("(");
817
        sql.append("startnodeid NOT IN (SELECT startnodeid from xml_access, xml_documents ");
783
        sql
784
                .append("startnodeid NOT IN (SELECT startnodeid from xml_access, xml_documents ");
818 785
        sql.append(" WHERE xml_access.docid = xml_documents.docid");
819 786
        sql.append(" AND lower(xml_documents.user_owner) ='");
820 787
        sql.append(userName);
......
822 789
        sql.append(")");
823 790
        sql.append(" AND ");
824 791
        sql.append("(");
825
        sql.append("(startnodeid NOT IN (SELECT startnodeid from xml_access where( ");
792
        sql
793
                .append("(startnodeid NOT IN (SELECT startnodeid from xml_access where( ");
826 794
        sql.append(allowString);
827 795
        sql.append(") AND (startnodeid IS NOT NULL))");
828 796
        sql.append(")");
829
        sql.append(" OR (startnodeid IN (SELECT startnodeid from xml_access where( ");
797
        sql
798
                .append(" OR (startnodeid IN (SELECT startnodeid from xml_access where( ");
830 799
        sql.append(denyString);
831 800
        sql.append(") AND (startnodeid IS NOT NULL))");
832 801
        sql.append(")");
......
851 820
            Hashtable unaccessableNodePair)
852 821
    {
853 822
        StringBuffer self = new StringBuffer();
854
        self
855
                .append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata, ");
823
        self.append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata, ");
856 824
        self.append("xml_nodes.parentnodeid ");
857 825
        self.append("from xml_index, xml_nodes where xml_index.nodeid=");
858 826
        self.append("xml_nodes.parentnodeid and (xml_index.path like '");

Also available in: Unified diff