1 package org.kuali.rice.krad.dao;
2
3 import org.kuali.rice.krad.bo.BusinessObject;
4 import org.kuali.rice.krad.bo.PersistableBusinessObject;
5 import org.kuali.rice.krad.util.LegacyDataFramework;
6
7 import java.util.Collection;
8 import java.util.List;
9 import java.util.Map;
10
11 /**
12 * Created by angelind on 11/6/14.
13 *
14 * Overridden by 'Sheik Salahudeen'
15 * Overridden for fixing the document fetching issue in KRAD Transaction document with OJB.
16 * Modified method names: findBySinglePrimaryKey,findByPrimaryKey,findByPrimaryKeyUsingKeyObject,findAll,findAllActive,findAllInactive,findAllOrderBy,findAllActiveOrderBy,findMatching,findMatchingActive,findMatchingOrderBy
17 * Changes description : Modified the return type of method from '<T extends BusinessObject>' to '<T>'.
18 */
19 @Deprecated
20 @LegacyDataFramework
21 public interface BusinessObjectDao {
22 /**
23 * Saves any object that implements the BusinessObject interface.
24 *
25 * @param bo
26 */
27 public PersistableBusinessObject save(PersistableBusinessObject bo);
28
29 /**
30 * Saves a List of BusinessObjects.
31 *
32 * @param businessObjects
33 */
34 public List<? extends PersistableBusinessObject> save(List businessObjects);
35
36 /**
37 * Retrieves an object instance identified by its primary key. For composite keys, use {@link #findByPrimaryKey(Class, java.util.Map)}
38 *
39 * @param clazz
40 * @param primaryKey
41 * @return
42 */
43 public <T> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey);
44
45 /**
46 * Retrieves an object instance identified bys it primary keys and values. This can be done by constructing a map where the key
47 * to the map entry is the primary key attribute and the value of the entry being the primary key value. For composite keys,
48 * pass in each primaryKey attribute and its value as a map entry.
49 *
50 * @param clazz
51 * @param primaryKeys
52 * @return
53 */
54 public <T> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys);
55
56 /**
57 * Retrieves an object, based on its PK object
58 *
59 * @param clazz the class of the object to retrieve
60 * @param pkObject the value of the primary key
61 * @return the retrieved PersistableBusinessObject
62 */
63 public abstract <T > T findByPrimaryKeyUsingKeyObject(Class<T> clazz, Object pkObject);
64
65 /**
66 * Retrieves an object instance identified by the class of the given object and the object's primary key values.
67 *
68 * @param object
69 * @return
70 */
71 public Object retrieve(Object object);
72
73 /**
74 * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
75 * instance. This will only retrieve business objects by class type.
76 *
77 * @param clazz
78 * @return
79 */
80 public <T> Collection<T> findAll(Class<T> clazz);
81
82 /**
83 * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
84 * instance. This will only retrieve business objects by class type.
85 *
86 * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
87 *
88 * @param clazz
89 * @return
90 */
91 public <T> Collection<T> findAllActive(Class<T> clazz);
92
93 public <T> Collection<T> findAllInactive(Class<T> clazz);
94
95 /**
96 * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
97 * instance. This will only retrieve business objects by class type. Orders the results by the given field.
98 *
99 * @param clazz
100 * @return
101 */
102 public <T> Collection<T> findAllOrderBy(Class<T> clazz, String sortField, boolean sortAscending);
103
104 /**
105 * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
106 * instance. This will only retrieve business objects by class type. Orders the results by the given field.
107 *
108 * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
109 * @param clazz
110 * @return
111 */
112 public <T> Collection<T> findAllActiveOrderBy(Class<T> clazz, String sortField, boolean sortAscending);
113
114 /**
115 * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
116 * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
117 * specifically attribute name-expected value.
118 *
119 * @param clazz
120 * @param fieldValues
121 * @return
122 */
123 public <T> Collection<T> findMatching(Class<T> clazz, Map<String, ?> fieldValues);
124
125 /**
126 * Finds all entities matching the passed in Rice JPA criteria
127 *
128 * @param <T> the type of the entity that will be returned
129 * @param criteria the criteria to form the query with
130 * @return a Collection (most likely a List) of all matching entities
131 */
132 //public abstract <T> Collection<T> findMatching(Criteria criteria);
133
134 /**
135 * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
136 * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
137 * specifically attribute name-expected value.
138 *
139 * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
140 *
141 * @param clazz
142 * @param fieldValues
143 * @return
144 */
145 public <T> Collection<T> findMatchingActive(Class<T> clazz, Map<String, ?> fieldValues);
146
147 /**
148 * @param clazz
149 * @param fieldValues
150 * @return count of BusinessObjects of the given class whose fields match the values in the given Map.
151 */
152 public int countMatching(Class clazz, Map<String, ?> fieldValues);
153
154
155 /**
156 *
157 * This method returns the number of matching result given the positive criterias and
158 * negative criterias. The negative criterias are the ones that will be set to
159 * "notEqualTo" or "notIn"
160 *
161 * @param clazz
162 * @param positiveFieldValues Map of fields and values for positive criteria
163 * @param negativeFieldValues Map of fields and values for negative criteria
164 * @return
165 */
166 public int countMatching(Class clazz, Map<String, ?> positiveFieldValues, Map<String, ?> negativeFieldValues);
167
168 /**
169 * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
170 * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
171 * specifically attribute name-expected value. Orders the results by the given field.
172 *
173 * @param clazz
174 * @param fieldValues
175 * @return
176 */
177 public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField, boolean sortAscending);
178
179 /**
180 * Deletes a business object from the database.
181 *
182 * @param bo
183 */
184 public void delete(Object bo);
185
186 /**
187 * Deletes each business object in the given List from the database.
188 *
189 * @param boList
190 */
191 public void delete(List<? extends PersistableBusinessObject> boList);
192
193 /**
194 * Deletes the business objects matching the given fieldValues
195 *
196 * @param clazz
197 * @param fieldValues
198 */
199 public void deleteMatching(Class clazz, Map<String, ?> fieldValues);
200
201 /**
202 * Merges the given business object, but tells the ORM that the object is to be treated as Read Only,
203 * and even if it has changes, it will not be persisted to the database
204 *
205 * @param bo the business object to managed
206 * @return the managed copied of the business object
207 */
208 public PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo);
209 }
210