Revision 3008
Added by Duane Costa over 18 years ago
src/edu/ucsb/nceas/metacat/advancedsearch/AdvancedSearch.java | ||
---|---|---|
28 | 28 |
import java.io.Reader; |
29 | 29 |
import java.io.StringReader; |
30 | 30 |
import java.util.ArrayList; |
31 |
import java.util.StringTokenizer; |
|
32 | 31 |
|
33 | 32 |
import edu.ucsb.nceas.metacat.client.*; |
34 | 33 |
import edu.ucsb.nceas.utilities.*; |
... | ... | |
71 | 70 |
public AdvancedSearch(final AdvancedSearchBean advancedSearchBean) { |
72 | 71 |
int allAny = AdvancedSearchBean.MATCH_ALL; |
73 | 72 |
String indent = getIndent(indentLevel * 1); |
74 |
final String operator; |
|
75 | 73 |
|
76 | 74 |
if (advancedSearchBean != null) { |
77 | 75 |
allAny = advancedSearchBean.getFormAllAny(); |
... | ... | |
664 | 662 |
* |
665 | 663 |
* @param metacatURL URL to the metacat servlet |
666 | 664 |
* @param metacat A metacat client object, possible null. |
665 |
* @param qformat The qformat (skin) to use when displaying results. |
|
667 | 666 |
* @param xslPath File path to the resultset.xsl stylesheet. |
668 | 667 |
* @return htmlString HTML string representation of the search results. |
669 | 668 |
*/ |
670 | 669 |
public String executeAdvancedSearch(final String metacatURL, |
671 | 670 |
final Metacat metacat, |
671 |
final String qformat, |
|
672 | 672 |
final String xslPath) { |
673 | 673 |
String htmlString = ""; |
674 | 674 |
int searchTypes; |
... | ... | |
693 | 693 |
} |
694 | 694 |
|
695 | 695 |
queryString = pathQuery.toString(); |
696 |
htmlString = this.runQuery(metacatURL, metacat, xslPath); |
|
696 |
htmlString = this.runQuery(metacatURL, metacat, qformat, xslPath);
|
|
697 | 697 |
return htmlString; |
698 | 698 |
} |
699 | 699 |
|
... | ... | |
705 | 705 |
* |
706 | 706 |
* @param metacatURL URL to the metacat servlet |
707 | 707 |
* @param metacat A metacat client object, possible null. |
708 |
* @param qformat The qformat (skin) to use when displaying results. |
|
708 | 709 |
* @param xslPath File path to the resultset.xsl stylesheet. |
709 | 710 |
* @param value String value to search on. |
710 | 711 |
* |
... | ... | |
712 | 713 |
*/ |
713 | 714 |
public String executeSearch(final String metacatURL, |
714 | 715 |
final Metacat metacat, |
716 |
final String qformat, |
|
715 | 717 |
final String xslPath, |
716 | 718 |
String value) { |
717 | 719 |
String emlField = ""; |
718 | 720 |
String htmlString = ""; |
719 | 721 |
String indent = getIndent(indentLevel * 2); |
720 |
String operator = "UNION"; |
|
721 | 722 |
AdvancedSearchQueryTerm qt; |
722 | 723 |
String searchMode = "contains"; |
723 | 724 |
|
... | ... | |
733 | 734 |
value, indent); |
734 | 735 |
queryGroup.addQueryTerm(qt); |
735 | 736 |
queryString = pathQuery.toString(); |
736 |
htmlString = this.runQuery(metacatURL, metacat, xslPath); |
|
737 |
htmlString = this.runQuery(metacatURL, metacat, qformat, xslPath);
|
|
737 | 738 |
return htmlString; |
738 | 739 |
} |
739 | 740 |
|
... | ... | |
799 | 800 |
* |
800 | 801 |
* @return terms An ArrayList of String objects. Each space-separated |
801 | 802 |
* token is a single term. |
802 |
*/
|
|
803 |
* |
|
803 | 804 |
private ArrayList parseTerms(final String value) { |
804 | 805 |
StringTokenizer st; |
805 | 806 |
ArrayList terms = new ArrayList(); |
... | ... | |
816 | 817 |
|
817 | 818 |
return terms; |
818 | 819 |
} |
820 |
*/ |
|
819 | 821 |
|
820 | 822 |
|
821 | 823 |
/** |
... | ... | |
830 | 832 |
char c; |
831 | 833 |
StringBuffer currentTerm = new StringBuffer(100); |
832 | 834 |
boolean keepSpaces = false; |
833 |
StringTokenizer st; |
|
834 | 835 |
final int stringLength; |
835 | 836 |
ArrayList terms = new ArrayList(); |
836 |
String token; |
|
837 |
int tokenCount; |
|
838 | 837 |
|
839 | 838 |
value = value.trim(); |
840 | 839 |
stringLength = value.length(); |
... | ... | |
882 | 881 |
* |
883 | 882 |
* @param metacatURL URL to the metacat servlet |
884 | 883 |
* @param metacat A metacat client object, possible null. |
884 |
* @param qformat The qformat (skin) to use when displaying results. |
|
885 | 885 |
* @param xslPath File path to the resultset.xsl stylesheet. |
886 | 886 |
* @return htmlString HTML string representation of the search results. |
887 | 887 |
*/ |
888 | 888 |
private String runQuery(final String metacatURL, |
889 | 889 |
Metacat metacat, |
890 |
final String qformat, |
|
890 | 891 |
final String xslPath) { |
891 | 892 |
String htmlString = ""; |
892 | 893 |
Reader reader; |
... | ... | |
913 | 914 |
resultset = IOUtil.getAsString(reader, true); |
914 | 915 |
System.err.println("Query result:\n" + resultset); |
915 | 916 |
htmlString = stylizer.resultsetToHTML(resultset, sessionId, |
916 |
metacatURL, xslPath); |
|
917 |
metacatURL, qformat, xslPath);
|
|
917 | 918 |
} |
918 | 919 |
catch (Exception e) { |
919 | 920 |
System.err.println("General exception:\n" + e.getMessage()); |
... | ... | |
941 | 942 |
AdvancedSearch advancedSearch; |
942 | 943 |
AdvancedSearchBean advancedSearchBean = new AdvancedSearchBean(); |
943 | 944 |
String contextString = argv[2]; |
944 |
String htmlString = ""; |
|
945 | 945 |
MetacatHelper metacatHelper = new MetacatHelper(); |
946 | 946 |
String metacatURL; |
947 |
String qformat = "lter"; |
|
947 | 948 |
final String serverName = argv[0]; |
948 | 949 |
final Integer serverPortInteger = new Integer(argv[1]); |
949 | 950 |
final int serverPort = serverPortInteger.intValue(); |
... | ... | |
966 | 967 |
advancedSearch = new AdvancedSearch(advancedSearchBean); |
967 | 968 |
metacatURL = |
968 | 969 |
metacatHelper.constructMetacatURL(serverName, serverPort, contextString); |
969 |
htmlString =advancedSearch.executeAdvancedSearch(metacatURL, null, xslPath);
|
|
970 |
advancedSearch.executeAdvancedSearch(metacatURL, null, qformat, xslPath);
|
|
970 | 971 |
} |
971 | 972 |
|
972 | 973 |
} |
Also available in: Unified diff
Add qformat parameter to runQuery() and executeAdvancedSearch() methods.
Omit unused StringTokenizer objects.