01: /*
02: * Copyright 2006-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.module.financial.dao.ojb;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.apache.ojb.broker.PersistenceBroker;
22: import org.apache.ojb.broker.accesslayer.QueryCustomizer;
23: import org.apache.ojb.broker.metadata.CollectionDescriptor;
24: import org.apache.ojb.broker.query.Query;
25: import org.apache.ojb.broker.query.QueryByCriteria;
26: import org.kuali.kfs.KFSConstants;
27: import org.kuali.kfs.KFSPropertyConstants;
28:
29: /**
30: * Query customizer for to seperate out the pre-paid and non prepaid collections from the dv expense table.
31: */
32: public class OJBTravelExpenseQueryCustomizer implements QueryCustomizer {
33: private static final String prepaidAttributeName = "PREPAID";
34: private static final String prepaidIndicatorField = KFSPropertyConstants.DISB_VCHR_EXPENSE
35: + "." + KFSPropertyConstants.PREPAID_EXPENSE;
36: private Map attributes = new HashMap();
37:
38: /**
39: * @see org.apache.ojb.broker.accesslayer.QueryCustomizer#customizeQuery(java.lang.Object,
40: * org.apache.ojb.broker.PersistenceBroker, org.apache.ojb.broker.metadata.CollectionDescriptor,
41: * org.apache.ojb.broker.query.QueryByCriteria)
42: */
43: public Query customizeQuery(Object arg0, PersistenceBroker arg1,
44: CollectionDescriptor arg2, QueryByCriteria arg3) {
45: if ("TRUE".equals(getAttribute(prepaidAttributeName))) {
46: arg3.getCriteria().addEqualTo(prepaidIndicatorField,
47: KFSConstants.ACTIVE_INDICATOR);
48: } else {
49: arg3.getCriteria().addEqualTo(prepaidIndicatorField,
50: KFSConstants.NON_ACTIVE_INDICATOR);
51: }
52: return arg3;
53: }
54:
55: /**
56: * @see org.apache.ojb.broker.metadata.AttributeContainer#addAttribute(java.lang.String, java.lang.String)
57: */
58: public void addAttribute(String arg0, String arg1) {
59: attributes.put(arg0, arg1);
60: }
61:
62: /**
63: * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String, java.lang.String)
64: */
65: public String getAttribute(String arg0, String arg1) {
66: return (String) attributes.get(arg0);
67: }
68:
69: /**
70: * @see org.apache.ojb.broker.metadata.AttributeContainer#getAttribute(java.lang.String)
71: */
72: public String getAttribute(String arg0) {
73: return (String) attributes.get(arg0);
74: }
75:
76: }
|