Revision 2357
Added by sgarg about 20 years ago
src/edu/ucsb/nceas/metacat/QueryTerm.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* '$RCSfile$' |
3 |
* Purpose: A Class that represents a structured query, and can be
|
|
4 |
* constructed from an XML serialization conforming to
|
|
5 |
* pathquery.dtd. The printSQL() method can be used to print
|
|
3 |
* Purpose: A Class that represents a structured query, and can be |
|
4 |
* constructed from an XML serialization conforming to |
|
5 |
* pathquery.dtd. The printSQL() method can be used to print |
|
6 | 6 |
* a SQL serialization of the query. |
7 | 7 |
* Copyright: 2000 Regents of the University of California and the |
8 | 8 |
* National Center for Ecological Analysis and Synthesis |
... | ... | |
51 | 51 |
/** |
52 | 52 |
* Construct a new instance of a query term for a free text search (using |
53 | 53 |
* the value only) |
54 |
*
|
|
54 |
* |
|
55 | 55 |
* @param casesensitive |
56 | 56 |
* flag indicating whether case is used to match |
57 | 57 |
* @param searchmode |
... | ... | |
70 | 70 |
/** |
71 | 71 |
* Construct a new instance of a query term for a structured search |
72 | 72 |
* (matching the value only for those nodes in the pathexpr) |
73 |
*
|
|
73 |
* |
|
74 | 74 |
* @param casesensitive |
75 | 75 |
* flag indicating whether case is used to match |
76 | 76 |
* @param searchmode |
... | ... | |
161 | 161 |
String oper = null; |
162 | 162 |
if (searchmode.equals("greater-than")) { |
163 | 163 |
oper = ">"; |
164 |
nodedataterm = "nodedata"; |
|
164 |
nodedataterm = "nodedatanumerical";
|
|
165 | 165 |
} else if (searchmode.equals("greater-than-equals")) { |
166 | 166 |
oper = ">="; |
167 |
nodedataterm = "nodedata"; |
|
167 |
nodedataterm = "nodedatanumerical";
|
|
168 | 168 |
} else if (searchmode.equals("less-than")) { |
169 | 169 |
oper = "<"; |
170 |
nodedataterm = "nodedata"; |
|
170 |
nodedataterm = "nodedatanumerical";
|
|
171 | 171 |
} else if (searchmode.equals("less-than-equals")) { |
172 | 172 |
oper = "<="; |
173 |
nodedataterm = "nodedata"; |
|
173 |
nodedataterm = "nodedatanumerical";
|
|
174 | 174 |
} else { |
175 | 175 |
System.out |
176 | 176 |
.println("NOT expected case. NOT recognized operator: " |
... | ... | |
180 | 180 |
try { |
181 | 181 |
// it is number; numeric comparison |
182 | 182 |
// but we need to make sure there is no string in node data |
183 |
String getRidOfString = " AND UPPER(nodedata) = LOWER(nodedata)" |
|
184 |
+ " AND LTRIM(nodedata) != ' ' " |
|
185 |
+ " AND nodedata IS NOT NULL "; |
|
186 | 183 |
searchexpr = nodedataterm + " " + oper + " " |
187 |
+ new Double(casevalue) + " " + getRidOfString;
|
|
184 |
+ new Double(casevalue) + " "; |
|
188 | 185 |
} catch (NumberFormatException nfe) { |
189 | 186 |
// these are characters; character comparison |
190 | 187 |
searchexpr = nodedataterm + " " + oper + " '" + casevalue |
Also available in: Unified diff
Modified handling of greater-than and less-than so that comparison is done against nodedatanumerical column.