001: package org.julp.misc.search;
002:
003: import java.io.Reader;
004: import java.net.URL;
005:
006: public class BasicSearchCriteriaBuilder extends SearchCriteriaBuilder {
007:
008: protected XPathSQLQueryReader queryReader = new XPathSQLQueryReader();
009:
010: public BasicSearchCriteriaBuilder() {
011: }
012:
013: public BasicSearchCriteriaBuilder(URL queryURL) {
014: queryReader.setQueryURL(queryURL);
015: }
016:
017: public BasicSearchCriteriaBuilder(String queryFilePath) {
018: queryReader.setQueryFilePath(queryFilePath);
019: }
020:
021: public BasicSearchCriteriaBuilder(Reader reader) {
022: queryReader.setReader(reader);
023: }
024:
025: public void loadQuery(String queryId, boolean reloadDocument) {
026: reset();
027: queryReader.loadQuery(queryId, reloadDocument);
028: }
029:
030: public void loadQuery(String queryId) {
031: this .loadQuery(queryId, true);
032: }
033:
034: public void loadExecutable(String queryId) {
035: this .loadExecutable(queryId, true);
036: }
037:
038: public void loadExecutable(String queryId, boolean reloadDocument) {
039: reset();
040: queryReader.loadExecutable(queryId, reloadDocument);
041: }
042:
043: public String getExecutable() {
044: this .executable = queryReader.getExecutable();
045: return executable;
046: }
047:
048: public void setExecutable(String executable) {
049: this .executable = executable;
050: }
051:
052: public XPathSQLQueryReader getQueryReader() {
053: return queryReader;
054: }
055:
056: public void setQueryReader(XPathSQLQueryReader queryReader) {
057: this .queryReader = queryReader;
058: }
059:
060: public String getQueryFilePath() {
061: return queryReader.getQueryFilePath();
062: }
063:
064: public void setQueryFilePath(String queryFilePath) {
065: queryReader.setQueryFilePath(queryFilePath);
066: }
067:
068: public URL getQueryURL() {
069: return queryReader.getQueryURL();
070: }
071:
072: public void setQueryURL(URL queryURL) {
073: queryReader.setQueryURL(queryURL);
074: }
075:
076: public Reader getReader() {
077: return queryReader.getReader();
078: }
079:
080: public void setReader(Reader reader) {
081: queryReader.setReader(reader);
082: }
083:
084: // override ancestor
085: public String getQuery() {
086: try {
087: queryReader.setAdhocColumns(adhocColumns);
088: setSelect(queryReader.getSelect());
089: setFrom(queryReader.getFrom());
090: setJoins(queryReader.getJoins());
091: setWhere(queryReader.getWhere());
092: setGroupBy(queryReader.getGroupBy());
093: setHaving(queryReader.getHaving());
094: if (this .orderBy == null
095: || this .orderBy.trim().length() == 0) {
096: if (queryReader.getOrderBy() != null
097: && queryReader.getOrderBy().trim().length() > 0) {
098: setOrderBy(queryReader.getOrderBy());
099: }
100: }
101: } catch (Exception e) {
102: e.printStackTrace();
103: throw new RuntimeException(e);
104: }
105: return super.getQuery();
106: }
107:
108: }
|