1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.fp.document.dataaccess;
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.ole.sys.OLEConstants;
27 import org.kuali.ole.sys.OLEPropertyConstants;
28
29
30
31
32 public class OJBTravelExpenseQueryCustomizer implements QueryCustomizer {
33 private static final String prepaidAttributeName = "PREPAID";
34 private static final String prepaidIndicatorField = OLEPropertyConstants.DISB_VCHR_EXPENSE + "." + OLEPropertyConstants.PREPAID_EXPENSE;
35 private Map attributes = new HashMap();
36
37
38
39
40
41
42 public Query customizeQuery(Object arg0, PersistenceBroker arg1, CollectionDescriptor arg2, QueryByCriteria arg3) {
43 if ("TRUE".equals(getAttribute(prepaidAttributeName))) {
44 arg3.getCriteria().addEqualTo(prepaidIndicatorField, OLEConstants.ACTIVE_INDICATOR);
45 }
46 else {
47 arg3.getCriteria().addEqualTo(prepaidIndicatorField, OLEConstants.NON_ACTIVE_INDICATOR);
48 }
49 return arg3;
50 }
51
52
53
54
55 public void addAttribute(String arg0, String arg1) {
56 attributes.put(arg0, arg1);
57 }
58
59
60
61
62 public String getAttribute(String arg0, String arg1) {
63 return (String) attributes.get(arg0);
64 }
65
66
67
68
69 public String getAttribute(String arg0) {
70 return (String) attributes.get(arg0);
71 }
72
73 }