Revision 2654
Added by sgarg about 19 years ago
src/edu/ucsb/nceas/metacat/QueryTerm.java | ||
---|---|---|
128 | 128 |
// Uppercase the search string if case match is not important |
129 | 129 |
String casevalue = null; |
130 | 130 |
String nodedataterm = null; |
131 |
|
|
131 |
boolean notEqual = false; |
|
132 | 132 |
if (casesensitive) { |
133 | 133 |
nodedataterm = "nodedata"; |
134 | 134 |
casevalue = value; |
... | ... | |
152 | 152 |
percentageSymbol = true; |
153 | 153 |
} |
154 | 154 |
} else if (searchmode.equals("not-contains")) { |
155 |
searchexpr = nodedataterm + " NOT LIKE '%" + casevalue + "%' "; |
|
155 |
notEqual = true; |
|
156 |
searchexpr = nodedataterm + " LIKE '%" + casevalue + "%' "; |
|
156 | 157 |
} else if (searchmode.equals("equals")) { |
157 | 158 |
searchexpr = nodedataterm + " = '" + casevalue + "' "; |
158 | 159 |
} else if (searchmode.equals("isnot-equal")) { |
159 |
searchexpr = nodedataterm + " != '" + casevalue + "' "; |
|
160 |
notEqual = true; |
|
161 |
searchexpr = nodedataterm + " = '" + casevalue + "' "; |
|
160 | 162 |
} else { |
161 | 163 |
String oper = null; |
162 | 164 |
if (searchmode.equals("greater-than")) { |
... | ... | |
202 | 204 |
|
203 | 205 |
if(usePathIndex){ |
204 | 206 |
// using xml_path_index table..... |
205 |
self.append("SELECT DISTINCT docid FROM xml_path_index WHERE "); |
|
206 |
self.append(searchexpr); |
|
207 |
self.append("AND path LIKE '" + pathexpr + "' "); |
|
207 |
if(notEqual == true){ |
|
208 |
self.append("SELECT DISTINCT docid from xml_path_index WHERE"); |
|
209 |
self.append(" docid NOT IN (Select docid FROM xml_path_index WHERE "); |
|
210 |
self.append(searchexpr); |
|
211 |
self.append("AND path LIKE '" + pathexpr + "') "); |
|
212 |
} else { |
|
213 |
self.append("SELECT DISTINCT docid FROM xml_path_index WHERE "); |
|
214 |
self.append(searchexpr); |
|
215 |
self.append("AND path LIKE '" + pathexpr + "' "); |
|
216 |
} |
|
208 | 217 |
|
209 | 218 |
} else { |
210 | 219 |
// using xml_nodes and xml_index tables |
211 | 220 |
|
212 |
self.append("SELECT DISTINCT docid FROM xml_nodes WHERE "); |
|
213 |
self.append(searchexpr); |
|
221 |
if(notEqual == true){ |
|
222 |
self.append("SELECT DISTINCT docid from xml_nodes WHERE"); |
|
223 |
self.append(" docid NOT IN (Select docid FROM xml_nodes WHERE "); |
|
224 |
} else { |
|
225 |
self.append("SELECT DISTINCT docid FROM xml_nodes WHERE "); |
|
226 |
} |
|
227 |
self.append(searchexpr); |
|
228 |
|
|
214 | 229 |
if (pathexpr != null) { |
215 | 230 |
|
216 | 231 |
// use XML Index |
... | ... | |
218 | 233 |
if (!hasAttributeInPath(pathexpr)) { |
219 | 234 |
// without attributes in path |
220 | 235 |
self.append("AND parentnodeid IN "); |
221 |
} |
|
222 |
else { |
|
236 |
} else { |
|
223 | 237 |
// has a attribute in path |
224 | 238 |
String attributeName = QuerySpecification |
225 | 239 |
.getAttributeName(pathexpr); |
... | ... | |
257 | 271 |
countPercentageSearchItem++; |
258 | 272 |
|
259 | 273 |
} |
274 |
self.append(") "); |
|
260 | 275 |
} |
261 | 276 |
|
262 | 277 |
return self.toString(); |
Also available in: Unified diff
Fix for bug 2222. So that correct query is generated when searchmode is 'not-contains'.