Project

General

Profile

« Previous | Next » 

Revision 6361

handle more than "contains" searchmode when using the path index for queries
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5443

View differences:

src/edu/ucsb/nceas/metacat/QueryGroup.java
195 195
    {
196 196
    	String sql ="";
197 197
    	String value ="";
198
    	boolean casesensitive = false;
199 198
    	StringBuffer sqlBuff = new StringBuffer();
200
    	Vector pathVector = new Vector();
201 199
    	int index =0;
202 200
    	if (queryTermsWithSameValue != null && queryTermsInPathIndex != null)
203 201
    	{
......
211 209
	    	   		Vector queryTermVector = (Vector)queryTermsWithSameValue.elementAt(j);
212 210
		    		QueryTerm term1 = (QueryTerm)queryTermVector.elementAt(0);
213 211
		        	value = term1.getValue();
214
		        	casesensitive = term1.isCaseSensitive();
215 212
		        	boolean first = true;
216 213
		        	if (firstVector)
217 214
		        	{
......
221 218
		        	{
222 219
		        		sqlBuff.append(" "+"OR"+" ");
223 220
		        	}
224
		        	if (casesensitive) {
225
			        	sqlBuff.append(" (nodedata");
226
		        	} else {
227
		        		sqlBuff.append(" (UPPER(nodedata)");
228
		        	}
229
		        	sqlBuff.append(" LIKE '%");
230
		        	if (value != null && !casesensitive)
231
		        	{
232
		        	    sqlBuff.append(value.toUpperCase());
233
		        	}
234
		        	else
235
		        	{
236
		        		sqlBuff.append(value);
237
		        	}
238
					sqlBuff.append("%' AND path IN (");
221
		        	
222
					sqlBuff.append(" (");
223
		        	
224
		        	// get the general search criteria (no path info)
225
		        	String searchTermSQL = term1.printSearchExprSQL();
226
					sqlBuff.append(searchTermSQL);
227
					
228
					sqlBuff.append("AND path IN (");
229

  
239 230
		    		//gets every path in query term object
240 231
		    		for (int i=0; i<queryTermVector.size(); i++)
241 232
		    		{
src/edu/ucsb/nceas/metacat/QueryTerm.java
150 150
    	return this.inUnionGroup;
151 151
    }
152 152

  
153
    /**
154
     * create a SQL serialization of the query that this instance represents
155
     */
156
    public String printSQL(boolean useXMLIndex)
157
    {
158
        StringBuffer self = new StringBuffer();
153
    
154
    public String printSearchExprSQL() {
159 155

  
160 156
        // Uppercase the search string if case match is not important
161 157
        String casevalue = null;
......
231 227
            	}
232 228
            }
233 229
        }
230
        return searchexpr;
231
    }
232
    
233
    public boolean isNotEqualTerm() {
234 234

  
235
        boolean notEqual = false;
235 236

  
237
        if (searchmode.equals("not-contains")) {
238
        	notEqual = true;
239
        } else if (searchmode.equals("isnot-equal")) {
240
        	notEqual = true;
241
        }
242
        return notEqual;
243
    }
244
    
245
    /**
246
     * create a SQL serialization of the query that this instance represents
247
     */
248
    public String printSQL(boolean useXMLIndex)
249
    {
250
        StringBuffer self = new StringBuffer();
251
        
252
        // does it contain a not equals?
253
        boolean notEqual = isNotEqualTerm();
254

  
255
        // get the general search expression
256
        String searchexpr = printSearchExprSQL();
257
       
236 258
        // to check xml_path_index can be used
237 259
        boolean usePathIndex = false;
238 260

  
......
657 679
    		{
658 680
    			if (searchValue.equalsIgnoreCase(this.value))
659 681
    			{
660
    				same = true;
682
    				if (this.getSearchMode().equals(term.getSearchMode())) {
683
        				same = true;
684
    				}
661 685
    			}
662 686
    		}
663 687
    	}

Also available in: Unified diff