Project

General

Profile

« Previous | Next » 

Revision 3311

Added by Jing Tao over 17 years ago

Add new variable indicate if this query term in a union group.

View differences:

src/edu/ucsb/nceas/metacat/QueryTerm.java
49 49

  
50 50
    private int countPercentageSearchItem = 0;
51 51
    
52
    private boolean inUnionGroup = false;
53
    
52 54
    public static final String CONTAINS = "contains";
53 55
    
54 56
    public static final String EQUALS = "equals";
......
122 124
    {
123 125
        return countPercentageSearchItem;
124 126
    }
127
    
128
    /**
129
     * Set the query term in a union group
130
     * @param inUnionGroup
131
     */
132
    public void setInUnionGroup (boolean inUnionGroup)
133
    {
134
    	this.inUnionGroup = inUnionGroup;
135
    }
136
    
137
    /**
138
     * If this query group in Union group
139
     * @return
140
     */
141
    public boolean isInUnionGroup()
142
    {
143
    	return this.inUnionGroup;
144
    }
125 145

  
126 146
    /**
127 147
     * create a SQL serialization of the query that this instance represents
......
292 312
        }
293 313
    }
294 314

  
295
    /**
296
     * Constraint the query with @pathexp without using the XML Index, but
297
     * nested SQL statements instead. The query migth be slower.
315
   
298 316
    public static String useNestedStatements(String pathexpr)
299 317
    {
300
      System.out.println("pathexpr: " + pathexpr);
301
        StringBuffer nestedStmts = new StringBuffer();
302
        Vector nodes = new Vector();
303
        String path = pathexpr;
304
        int inx = 0;
305

  
306
        do {
307
            inx = path.lastIndexOf("/");
308

  
309
            nodes.addElement(path.substring(inx + 1));
310
            path = path.substring(0, Math.abs(inx));
311
        } while (inx > 0);
312

  
313
        // nested statements
314
        int i = 0;
315
        for (i = 0; i < nodes.size() - 1; i++) {
316
            nestedStmts.append("(SELECT nodeid FROM xml_nodes"
317
                    + " WHERE nodename LIKE '" + (String) nodes.elementAt(i)
318
                    + "' AND parentnodeid IN ");
319
        }
320
        // for the last statement: it is without " AND parentnodeid IN "
321
        nestedStmts.append("(SELECT nodeid FROM xml_nodes"
322
                + " WHERE nodename LIKE '" + (String) nodes.elementAt(i) + "'");
323
        // node.size() number of closing brackets
324
        for (i = 0; i < nodes.size(); i++) {
325
            nestedStmts.append(")");
326
        }
327

  
328
        return nestedStmts.toString();
329
    }
330
     */
331
    public static String useNestedStatements(String pathexpr)
332
    {
333 318
        log.info("useNestedStatements()");
334 319
        log.info("pathexpr: " + pathexpr);
335 320
        StringBuffer nestedStmts = new StringBuffer();

Also available in: Unified diff