Revision 795
Added by bojilova over 23 years ago
src/edu/ucsb/nceas/metacat/QuerySpecification.java | ||
---|---|---|
813 | 813 |
} |
814 | 814 |
|
815 | 815 |
// Add appropriate wildcards to search string |
816 |
String searchvalue = null; |
|
816 |
//String searchvalue = null; |
|
817 |
String searchexpr = null; |
|
817 | 818 |
if (searchmode.equals("starts-with")) { |
818 |
searchvalue = casevalue + "%"; |
|
819 |
//searchvalue = casevalue + "%"; |
|
820 |
searchexpr = nodedataterm + " LIKE '" + casevalue + "%' "; |
|
819 | 821 |
} else if (searchmode.equals("ends-with")) { |
820 |
searchvalue = "%" + casevalue; |
|
822 |
//searchvalue = "%" + casevalue; |
|
823 |
searchexpr = nodedataterm + " LIKE '%" + casevalue + "' "; |
|
821 | 824 |
} else if (searchmode.equals("contains")) { |
822 |
searchvalue = "%" + casevalue + "%"; |
|
823 |
} else { |
|
824 |
searchvalue = casevalue; |
|
825 |
//searchvalue = "%" + casevalue + "%"; |
|
826 |
searchexpr = nodedataterm + " LIKE '%" + casevalue + "%' "; |
|
827 |
} else if (searchmode.equals("equals")) { |
|
828 |
//searchvalue = casevalue; |
|
829 |
searchexpr = nodedataterm + " = '" + casevalue + "' "; |
|
830 |
} else if (searchmode.equals("isnot-equal")) { |
|
831 |
//searchvalue = casevalue; |
|
832 |
searchexpr = nodedataterm + " != '" + casevalue + "' "; |
|
833 |
} else { |
|
834 |
//searchvalue = casevalue; |
|
835 |
String oper = null; |
|
836 |
if (searchmode.equals("greater-than")) { |
|
837 |
oper = ">"; |
|
838 |
} else if (searchmode.equals("greater-than-equals")) { |
|
839 |
oper = ">="; |
|
840 |
} else if (searchmode.equals("less-than")) { |
|
841 |
oper = "<"; |
|
842 |
} else if (searchmode.equals("less-than-equals")) { |
|
843 |
oper = "<="; |
|
844 |
} else { |
|
845 |
System.out.println("NOT expected case. NOT recognized operator: " + |
|
846 |
searchmode); |
|
847 |
return null; |
|
848 |
} |
|
849 |
try { |
|
850 |
// it is number; numeric comparison |
|
851 |
searchexpr = nodedataterm + " " + oper + " " + |
|
852 |
new Double(casevalue) + " "; |
|
853 |
} catch (NumberFormatException nfe) { |
|
854 |
// these are characters; character comparison |
|
855 |
searchexpr = nodedataterm + " " + oper + " '" + casevalue + "' "; |
|
856 |
} |
|
825 | 857 |
} |
826 | 858 |
|
827 | 859 |
self.append("SELECT DISTINCT docid FROM xml_nodes WHERE \n"); |
860 |
//self.append(nodedataterm + " LIKE " + "'" + searchvalue + "' "); |
|
861 |
self.append(searchexpr); |
|
828 | 862 |
|
829 | 863 |
if (pathexpr != null) { |
830 |
self.append(nodedataterm + " LIKE " + "'" + searchvalue + "' "); |
|
831 | 864 |
self.append("AND parentnodeid IN "); |
832 | 865 |
// use XML Index |
833 | 866 |
if ( useXMLIndex ) { |
... | ... | |
837 | 870 |
} else { |
838 | 871 |
self.append(useNestedStatements(pathexpr)); |
839 | 872 |
} |
840 |
} else { |
|
841 |
self.append(nodedataterm + " LIKE " + "'" + searchvalue + "' "); |
|
842 | 873 |
} |
843 | 874 |
|
844 | 875 |
return self.toString(); |
Also available in: Unified diff
support for the new terms included in pathquery.dtd