001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.workflow.query;
009:
010: //base classes
011: import java.io.IOException;
012: import java.io.Reader;
013: import java.math.BigDecimal;
014: import java.sql.Connection;
015: import java.sql.PreparedStatement;
016: import java.sql.ResultSet;
017: import java.sql.SQLException;
018: import java.util.ArrayList;
019:
020: //project specific classes
021: import org.jfolder.common.UnexpectedSystemException;
022: import org.jfolder.common.utils.misc.MiscHelper;
023:
024: //other classes
025:
026: public class BaseDBQueryVendor implements QueryVendor {
027:
028: public final static String T_ATTRIBUTES = "T_ATTRIBUTES";
029: public final static String ID = "ID";
030: public final static String JF_ID = "JF_ID";
031: public final static String ATTR_NAME = "ATTR_NAME";
032: public final static String ATTR_TYPE = "ATTR_TYPE";
033: public final static String ATTR_CLASS = "ATTR_CLASS";
034: public final static String ATTR_ACCESS = "ATTR_ACCESS";
035: public final static String DECIMAL_VALUE = "DECIMAL_VALUE";
036: public final static String BOOLEAN_VALUE = "BOOLEAN_VALUE";
037: public final static String STRING_VALUE = "STRING_VALUE";
038: public final static String LONG_STRING_VALUE = "LONG_STRING_VALUE";
039:
040: //classes
041: public final static int DECIMAL = 1;
042: public final static int BOOLEAN = 2;
043: public final static int STRING = 3;
044:
045: //types
046: public final static int SYSTEM = 1;
047: public final static int APPLICATION = 2;
048:
049: //access
050: public final static int PUBLIC = 1;
051: public final static int PRIVATE = 2;
052:
053: //selector
054: private final static String SELECT_ID_FROM_PF_ATTRIBUTES = "select "
055: + JF_ID + " from " + T_ATTRIBUTES + " where ";
056: private final static String SELECT_ALL_FROM_PF_ATTRIBUTES = "select "
057: + ID
058: + ", "
059: + JF_ID
060: + ", "
061: + ATTR_NAME
062: + ", "
063: + ATTR_TYPE
064: + ", "
065: + ATTR_CLASS
066: + ", "
067: + ATTR_ACCESS
068: + ", "
069: + DECIMAL_VALUE
070: + ", "
071: + BOOLEAN_VALUE
072: + ", "
073: + STRING_VALUE
074: + ", "
075: + LONG_STRING_VALUE
076: + " from "
077: + T_ATTRIBUTES + " where ";
078:
079: //type conditions
080: private final static String WHERE_ATTR_TYPE_IS_SYSTEM = ATTR_TYPE
081: + " = " + SYSTEM + " and ";
082: private final static String WHERE_ATTR_TYPE_IS_APPLICATION = ATTR_TYPE
083: + " = " + APPLICATION + " and ";
084:
085: //order
086: private final static String ORDER_BY_PF_ID = " order by " + JF_ID;
087:
088: //class conditions
089: private final static String WHERE_ATTR_CLASS_IS_DECIMAL = ATTR_CLASS
090: + " = " + DECIMAL + " and ";
091: private final static String WHERE_ATTR_CLASS_IS_BOOLEAN = ATTR_CLASS
092: + " = " + BOOLEAN + " and ";
093: private final static String WHERE_ATTR_CLASS_IS_STRING = ATTR_CLASS
094: + " = " + STRING + " and ";
095:
096: //name conditions
097: private final static String WHERE_ATTR_NAME_EQUALS = ATTR_NAME
098: + " = ? and ";
099:
100: //private conditions
101: private final static String WHERE_ATTR_ACCESS_IS_PUBLIC = ATTR_ACCESS
102: + " = " + PUBLIC + " and ";
103:
104: //instance members
105: private BaseDBQueryVendorProprietarySyntax bdbqvps = null;
106: private boolean privateAccess = false;
107:
108: private BaseDBQueryVendor() {
109: }
110:
111: public final static BaseDBQueryVendor newBaseDBQueryVendor(
112: BaseDBQueryVendorProprietarySyntax inBdbqvps,
113: boolean inPrivateAccess) {
114:
115: BaseDBQueryVendor outValue = new BaseDBQueryVendor();
116:
117: outValue.bdbqvps = inBdbqvps;
118: outValue.privateAccess = inPrivateAccess;
119:
120: return outValue;
121: }
122:
123: public ResultSetContainer executeStatement(Connection inCon,
124: StatementContainer inSc) {
125:
126: try {
127: ResultSetContainer outValue = null;
128:
129: StringBuffer query = new StringBuffer();
130: ArrayList parameters = new ArrayList();
131: prepareStatement(query, parameters, inSc);
132:
133: //assemble prepared statement
134: PreparedStatement ps = inCon.prepareStatement(query
135: .toString());
136:
137: for (int i = 0; i < parameters.size(); i++) {
138:
139: Object nextParameter = parameters.get(i);
140:
141: if (MiscHelper.isClassNumber(nextParameter.getClass())) {
142:
143: ps.setBigDecimal(i + 1, MiscHelper
144: .fromNumberToBigDecimal(nextParameter));
145: } else if (nextParameter.getClass().getName().equals(
146: Boolean.class.getName())) {
147:
148: ps.setBoolean(i + 1, ((Boolean) nextParameter)
149: .booleanValue());
150: } else if (nextParameter.getClass().getName().equals(
151: String.class.getName())) {
152:
153: ps.setString(i + 1, nextParameter.toString());
154: } else {
155: throw new UnexpectedSystemException(
156: "Unknown SQL parameter type "
157: + nextParameter.getClass());
158: }
159: }
160:
161: ps.execute();
162: outValue = ResultSetContainer.createResultSet();
163: ResultSet rs = ps.getResultSet();
164:
165: BigDecimal presumedId = null;
166: ColumnContainer cc = inSc.getColumns();
167: ArrayList currentRow = null;
168:
169: while (rs.next()) {
170: //first thing, get all the rows from the table
171: //rs.getBigDecimal(ID);
172: BigDecimal currentId = rs.getBigDecimal(JF_ID);
173: if (presumedId == null || !currentId.equals(presumedId)) {
174: presumedId = currentId;
175: currentRow = outValue.createEmptyRow(cc);
176: }
177:
178: String attrName = rs.getString(ATTR_NAME);
179: int attrType = rs.getInt(ATTR_TYPE);
180: int attrClass = rs.getInt(ATTR_CLASS);
181:
182: int columnIndexes[] = cc.getColumnIndexes(attrName,
183: attrType, attrClass);
184: if (columnIndexes.length != 0) {
185: Object nextValue = null;
186:
187: if (attrClass == DECIMAL) {
188: nextValue = rs.getBigDecimal(DECIMAL_VALUE);
189: } else if (attrClass == BOOLEAN) {
190: boolean candidateValue = rs
191: .getBoolean(BOOLEAN_VALUE);
192: if (!rs.wasNull()) {
193: nextValue = new Boolean(candidateValue);
194: }
195: } else if (attrClass == STRING) {
196: String candidateValue1 = rs
197: .getString(STRING_VALUE);
198: /* for Oracle CLOB
199: Reader candidateValue2 =
200: rs.getCharacterStream(LONG_STRING_VALUE);
201: */
202: String candidateValue2 = rs
203: .getString(LONG_STRING_VALUE);
204:
205: if (candidateValue1 != null) {
206: nextValue = candidateValue1;
207: }
208: /* for Oracle CLOB
209: else if (candidateValue2 != null) {
210: StringBuffer tempString = new StringBuffer();
211: char textArray[] = new char[1024*8];
212: int readCount = 0;
213: while (
214: (readCount = candidateValue2.read(textArray))
215: != -1) {
216: tempString.append(textArray, 0, readCount);
217: }
218: nextValue = tempString.toString();
219: }
220: */
221: else if (candidateValue2 != null) {
222: nextValue = candidateValue2;
223: }
224: }
225:
226: for (int i = 0; i < columnIndexes.length; i++) {
227: currentRow.set(columnIndexes[i], nextValue);
228: }
229: }
230: }
231:
232: //TO DO: move finally block
233: ps.close();
234: rs.close();
235:
236: return outValue;
237: }
238: /* for Oracle CLOB
239: catch (IOException ioe) {
240: throw new UnexpectedSystemException(ioe);
241: }
242: */
243: catch (SQLException sqle) {
244: throw new UnexpectedSystemException(sqle);
245: }
246: }
247:
248: private void prepareStatement(StringBuffer inSb,
249: ArrayList inParameters, StatementContainer inSc) {
250:
251: //prepare query and parameters
252: prepareQuery(inSb, inParameters, inSc.getPredicate(), true);
253: //MiscHelper.println("BASE STATEMENT = " + inSb);
254: //inSb.insert(0, "select " + ID + ", " + PF_ID + ", " + ATTR_NAME + ", "
255: // + ATTR_TYPE + ", " + ATTR_CLASS + ", " + ATTR_ACCESS + ", "
256: // + DECIMAL_VALUE + ", " + BOOLEAN_VALUE + ", " + STRING_VALUE
257: // + ", " + LONG_STRING_VALUE + " from " + PF_ATTRIBUTES
258: // + " where " + PF_ID + " in (");
259: //inSb.append(") order by " + PF_ID);
260: //MiscHelper.println("COMPLETE STATEMENT = " + inSb);
261: }
262:
263: private void prepareQuery(StringBuffer inSb,
264: ArrayList inParameters, QueryContainer inQc,
265: boolean inParent) {
266:
267: //
268: if (inParent) {
269: inSb.append(SELECT_ALL_FROM_PF_ATTRIBUTES);
270: } else {
271: inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
272: }
273:
274: if (!this .privateAccess) {
275: inSb.append(WHERE_ATTR_ACCESS_IS_PUBLIC);
276: }
277:
278: if (inQc instanceof AndQC) {
279: AndQC qc = (AndQC) inQc;
280: //left query
281: StringBuffer leftQuery = new StringBuffer();
282: ArrayList leftParameters = new ArrayList();
283: this .prepareQuery(leftQuery, leftParameters, qc
284: .getLeftQuery(), false);
285: //right query
286: StringBuffer rightQuery = new StringBuffer();
287: ArrayList rightParameters = new ArrayList();
288: this .prepareQuery(rightQuery, rightParameters, qc
289: .getRightQuery(), false);
290: //aggregate query
291: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
292: inSb.append(JF_ID + " in (" + leftQuery.toString()
293: + ") and " + JF_ID + " in ("
294: + rightQuery.toString() + ")");
295: //aggregate parameters
296: inParameters.addAll(leftParameters);
297: inParameters.addAll(rightParameters);
298: } else if (inQc instanceof AppBooleanIsFalseQC) {
299: AppBooleanIsFalseQC qc = (AppBooleanIsFalseQC) inQc;
300: //construct query
301: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
302: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
303: inSb.append(WHERE_ATTR_CLASS_IS_BOOLEAN);
304: inSb.append(WHERE_ATTR_NAME_EQUALS);
305: inParameters.add(qc.getAttributeName().toUpperCase());
306: inSb.append(BOOLEAN_VALUE + " is false");
307: } else if (inQc instanceof AppBooleanIsTrueQC) {
308: AppBooleanIsTrueQC qc = (AppBooleanIsTrueQC) inQc;
309: //construct query
310: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
311: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
312: inSb.append(WHERE_ATTR_CLASS_IS_BOOLEAN);
313: inSb.append(WHERE_ATTR_NAME_EQUALS);
314: inParameters.add(qc.getAttributeName().toUpperCase());
315: inSb.append(BOOLEAN_VALUE + " is true");
316: } else if (inQc instanceof AppDecIsEqualQC) {
317: AppDecIsEqualQC qc = (AppDecIsEqualQC) inQc;
318: //construct query
319: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
320: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
321: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
322: inSb.append(WHERE_ATTR_NAME_EQUALS);
323: inParameters.add(qc.getAttributeName().toUpperCase());
324: inSb.append(DECIMAL_VALUE + " = ?");
325: inParameters.add(qc.getDecimalValue());
326: } else if (inQc instanceof AppDecIsGreaterThanOrEqualQC) {
327: AppDecIsGreaterThanOrEqualQC qc = (AppDecIsGreaterThanOrEqualQC) inQc;
328: //construct query
329: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
330: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
331: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
332: inSb.append(WHERE_ATTR_NAME_EQUALS);
333: inParameters.add(qc.getAttributeName().toUpperCase());
334: inSb.append(DECIMAL_VALUE + " >= ?");
335: inParameters.add(qc.getDecimalValue());
336: } else if (inQc instanceof AppDecIsGreaterThanQC) {
337: AppDecIsGreaterThanQC qc = (AppDecIsGreaterThanQC) inQc;
338: //construct query
339: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
340: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
341: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
342: inSb.append(WHERE_ATTR_NAME_EQUALS);
343: inParameters.add(qc.getAttributeName().toUpperCase());
344: inSb.append(DECIMAL_VALUE + " > ?");
345: inParameters.add(qc.getDecimalValue());
346: } else if (inQc instanceof AppDecIsLessThanOrEqualQC) {
347: AppDecIsLessThanOrEqualQC qc = (AppDecIsLessThanOrEqualQC) inQc;
348: //construct query
349: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
350: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
351: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
352: inSb.append(WHERE_ATTR_NAME_EQUALS);
353: inParameters.add(qc.getAttributeName().toUpperCase());
354: inSb.append(DECIMAL_VALUE + " <= ?");
355: inParameters.add(qc.getDecimalValue());
356: } else if (inQc instanceof AppDecIsLessThanQC) {
357: AppDecIsLessThanQC qc = (AppDecIsLessThanQC) inQc;
358: //construct query
359: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
360: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
361: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
362: inSb.append(WHERE_ATTR_NAME_EQUALS);
363: inParameters.add(qc.getAttributeName().toUpperCase());
364: inSb.append(DECIMAL_VALUE + " < ?");
365: inParameters.add(qc.getDecimalValue());
366: } else if (inQc instanceof AppDecIsNotEqualQC) {
367: AppDecIsNotEqualQC qc = (AppDecIsNotEqualQC) inQc;
368: //construct query
369: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
370: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
371: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
372: inSb.append(WHERE_ATTR_NAME_EQUALS);
373: inParameters.add(qc.getAttributeName().toUpperCase());
374: inSb.append(DECIMAL_VALUE + " <> ?");
375: inParameters.add(qc.getDecimalValue());
376: } else if (inQc instanceof AppStringIsEqualQC) {
377: AppStringIsEqualQC qc = (AppStringIsEqualQC) inQc;
378: //construct query
379: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
380: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
381: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
382: inSb.append(WHERE_ATTR_NAME_EQUALS);
383: inParameters.add(qc.getAttributeName().toUpperCase());
384: this .bdbqvps.constructStringIsEqualClause(inSb,
385: inParameters, qc);
386: } else if (inQc instanceof AppStringIsLikeQC) {
387: AppStringIsLikeQC qc = (AppStringIsLikeQC) inQc;
388: //construct query
389: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
390: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
391: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
392: inSb.append(WHERE_ATTR_NAME_EQUALS);
393: inParameters.add(qc.getAttributeName().toUpperCase());
394: this .bdbqvps.constructStringIsLikeClause(inSb,
395: inParameters, qc);
396: } else if (inQc instanceof AppStringIsNotEqualQC) {
397: AppStringIsNotEqualQC qc = (AppStringIsNotEqualQC) inQc;
398: //construct query
399: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
400: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
401: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
402: inSb.append(WHERE_ATTR_NAME_EQUALS);
403: inParameters.add(qc.getAttributeName().toUpperCase());
404: this .bdbqvps.constructStringIsNotEqualClause(inSb,
405: inParameters, qc);
406: } else if (inQc instanceof AppStringIsNotLikeQC) {
407: AppStringIsNotLikeQC qc = (AppStringIsNotLikeQC) inQc;
408: //construct query
409: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
410: inSb.append(WHERE_ATTR_TYPE_IS_APPLICATION);
411: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
412: inSb.append(WHERE_ATTR_NAME_EQUALS);
413: inParameters.add(qc.getAttributeName().toUpperCase());
414: this .bdbqvps.constructStringIsNotLikeClause(inSb,
415: inParameters, qc);
416: } else if (inQc instanceof NotQC) {
417: NotQC qc = (NotQC) inQc;
418: //sub query
419: StringBuffer subQuery = new StringBuffer();
420: ArrayList subParameters = new ArrayList();
421: this .prepareQuery(subQuery, subParameters,
422: qc.getSubQuery(), false);
423: //aggregate query
424: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
425: inSb
426: .append(JF_ID + " not in (" + subQuery.toString()
427: + ")");
428: //aggregate parameters
429: inParameters.addAll(subParameters);
430: } else if (inQc instanceof OrQC) {
431: OrQC qc = (OrQC) inQc;
432: //left query
433: StringBuffer leftQuery = new StringBuffer();
434: ArrayList leftParameters = new ArrayList();
435: this .prepareQuery(leftQuery, leftParameters, qc
436: .getLeftQuery(), false);
437: //right query
438: StringBuffer rightQuery = new StringBuffer();
439: ArrayList rightParameters = new ArrayList();
440: this .prepareQuery(rightQuery, rightParameters, qc
441: .getRightQuery(), false);
442: //aggregate query
443: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
444: inSb.append(JF_ID + " in (" + leftQuery.toString()
445: + ") or " + JF_ID + " in (" + rightQuery.toString()
446: + ")");
447: //aggregate parameters
448: inParameters.addAll(leftParameters);
449: inParameters.addAll(rightParameters);
450: } else if (inQc instanceof SysBooleanIsFalseQC) {
451: SysBooleanIsFalseQC qc = (SysBooleanIsFalseQC) inQc;
452: //construct query
453: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
454: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
455: inSb.append(WHERE_ATTR_CLASS_IS_BOOLEAN);
456: inSb.append(WHERE_ATTR_NAME_EQUALS);
457: inParameters.add(qc.getAttributeName().toUpperCase());
458: inSb.append(BOOLEAN_VALUE + " is false");
459: } else if (inQc instanceof SysBooleanIsTrueQC) {
460: SysBooleanIsTrueQC qc = (SysBooleanIsTrueQC) inQc;
461: //construct query
462: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
463: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
464: inSb.append(WHERE_ATTR_CLASS_IS_BOOLEAN);
465: inSb.append(WHERE_ATTR_NAME_EQUALS);
466: inParameters.add(qc.getAttributeName().toUpperCase());
467: inSb.append(BOOLEAN_VALUE + " is true");
468: } else if (inQc instanceof SysDecIsEqualQC) {
469: SysDecIsEqualQC qc = (SysDecIsEqualQC) inQc;
470: //construct query
471: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
472: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
473: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
474: inSb.append(WHERE_ATTR_NAME_EQUALS);
475: inParameters.add(qc.getAttributeName().toUpperCase());
476: inSb.append(DECIMAL_VALUE + " = ?");
477: inParameters.add(qc.getDecimalValue());
478: } else if (inQc instanceof SysDecIsGreaterThanOrEqualQC) {
479: SysDecIsGreaterThanOrEqualQC qc = (SysDecIsGreaterThanOrEqualQC) inQc;
480: //construct query
481: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
482: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
483: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
484: inSb.append(WHERE_ATTR_NAME_EQUALS);
485: inParameters.add(qc.getAttributeName().toUpperCase());
486: inSb.append(DECIMAL_VALUE + " >= ?");
487: inParameters.add(qc.getDecimalValue());
488: } else if (inQc instanceof SysDecIsGreaterThanQC) {
489: SysDecIsGreaterThanQC qc = (SysDecIsGreaterThanQC) inQc;
490: //construct query
491: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
492: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
493: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
494: inSb.append(WHERE_ATTR_NAME_EQUALS);
495: inParameters.add(qc.getAttributeName().toUpperCase());
496: inSb.append(DECIMAL_VALUE + " > ?");
497: inParameters.add(qc.getDecimalValue());
498: } else if (inQc instanceof SysDecIsLessThanOrEqualQC) {
499: SysDecIsLessThanOrEqualQC qc = (SysDecIsLessThanOrEqualQC) inQc;
500: //construct query
501: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
502: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
503: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
504: inSb.append(WHERE_ATTR_NAME_EQUALS);
505: inParameters.add(qc.getAttributeName().toUpperCase());
506: inSb.append(DECIMAL_VALUE + " <= ?");
507: inParameters.add(qc.getDecimalValue());
508: } else if (inQc instanceof SysDecIsLessThanQC) {
509: SysDecIsLessThanQC qc = (SysDecIsLessThanQC) inQc;
510: //construct query
511: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
512: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
513: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
514: inSb.append(WHERE_ATTR_NAME_EQUALS);
515: inParameters.add(qc.getAttributeName().toUpperCase());
516: inSb.append(DECIMAL_VALUE + " < ?");
517: inParameters.add(qc.getDecimalValue());
518: } else if (inQc instanceof SysDecIsNotEqualQC) {
519: SysDecIsNotEqualQC qc = (SysDecIsNotEqualQC) inQc;
520: //construct query
521: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
522: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
523: inSb.append(WHERE_ATTR_CLASS_IS_DECIMAL);
524: inSb.append(WHERE_ATTR_NAME_EQUALS);
525: inParameters.add(qc.getAttributeName().toUpperCase());
526: inSb.append(DECIMAL_VALUE + " <> ?");
527: inParameters.add(qc.getDecimalValue());
528: } else if (inQc instanceof SysStringIsEqualQC) {
529: SysStringIsEqualQC qc = (SysStringIsEqualQC) inQc;
530: //construct query
531: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
532: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
533: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
534: inSb.append(WHERE_ATTR_NAME_EQUALS);
535: inParameters.add(qc.getAttributeName().toUpperCase());
536: this .bdbqvps.constructStringIsEqualClause(inSb,
537: inParameters, qc);
538: } else if (inQc instanceof SysStringIsLikeQC) {
539: SysStringIsLikeQC qc = (SysStringIsLikeQC) inQc;
540: //construct query
541: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
542: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
543: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
544: inSb.append(WHERE_ATTR_NAME_EQUALS);
545: inParameters.add(qc.getAttributeName().toUpperCase());
546: this .bdbqvps.constructStringIsLikeClause(inSb,
547: inParameters, qc);
548: } else if (inQc instanceof SysStringIsNotEqualQC) {
549: SysStringIsNotEqualQC qc = (SysStringIsNotEqualQC) inQc;
550: //construct query
551: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
552: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
553: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
554: inSb.append(WHERE_ATTR_NAME_EQUALS);
555: inParameters.add(qc.getAttributeName().toUpperCase());
556: this .bdbqvps.constructStringIsNotEqualClause(inSb,
557: inParameters, qc);
558: } else if (inQc instanceof SysStringIsNotLikeQC) {
559: SysStringIsNotLikeQC qc = (SysStringIsNotLikeQC) inQc;
560: //construct query
561: //inSb.append(SELECT_ID_FROM_PF_ATTRIBUTES);
562: inSb.append(WHERE_ATTR_TYPE_IS_SYSTEM);
563: inSb.append(WHERE_ATTR_CLASS_IS_STRING);
564: inSb.append(WHERE_ATTR_NAME_EQUALS);
565: inParameters.add(qc.getAttributeName().toUpperCase());
566: this .bdbqvps.constructStringIsNotLikeClause(inSb,
567: inParameters, qc);
568: } else {
569: throw new UnexpectedSystemException(
570: "Unknown QueryContainer - " + inQc.getClass());
571: }
572:
573: if (inParent) {
574: inSb.append(ORDER_BY_PF_ID);
575: }
576: }
577: }
|