View Javadoc
1   package org.kuali.rice.krad.service;
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,findAll,findAllOrderBy,findMatching,findMatchingOrderBy,BusinessObjectDaoOjb
17   * Changes description : Modified the return type of method from '<T extends BusinessObject>' to  '<T>'.
18   */
19  @Deprecated
20  @LegacyDataFramework
21  public interface BusinessObjectService {
22  
23      /**
24       * Saves the passed in object via the persistence layer.
25       *
26       * This will throw an IllegalArgumentException (runtime exception) if the object passed in is not a descendent of
27       * BusinessObject.
28       *
29       * @param bo A BusinessObject instance or descendent that you wish to be stored.
30       */
31      public <T extends PersistableBusinessObject> T save(T bo);
32  
33      /**
34       * Saves the businessObjects on the list via the persistence layer.
35       *
36       * This will throw an IllegalArgumentException (runtime exception) if any of the objects passed in is not a descendent of
37       * BusinessObject.
38       *
39       * @param businessObjects A List<PersistableBusinessObject> of objects to persist.
40       */
41      public List<? extends PersistableBusinessObject> save(List<? extends PersistableBusinessObject> businessObjects);
42  
43      /**
44       * Links up any contained objects, and then Saves the passed in object via the persistence layer.
45       *
46       * This will throw an IllegalArgumentException (runtime exception) if the object passed in is not a descendent of
47       * BusinessObject.
48       *
49       * @param bo A BusinessObject instance or descendent that you wish to be stored.
50       */
51      public PersistableBusinessObject linkAndSave(PersistableBusinessObject bo);
52  
53      /**
54       * Links up any contained objects, and Saves the businessObjects on the list via the persistence layer.
55       *
56       * This will throw an IllegalArgumentException (runtime exception) if any of the objects passed in is not a descendent of
57       * BusinessObject.
58       *
59       * @param businessObjects A List<BusinessObject> of objects to persist.
60       *
61       */
62      public List<? extends PersistableBusinessObject> linkAndSave(List<? extends PersistableBusinessObject> businessObjects);
63  
64      /**
65       * Retrieves an object instance identified by its primary key. For composite keys, use {@link #findByPrimaryKey(Class, java.util.Map)}
66       *
67       * @param clazz
68       * @param primaryKey
69       * @return
70       */
71      public <T> T findBySinglePrimaryKey(Class<T> clazz, Object primaryKey);
72  
73      /**
74       * Retrieves an object instance identified by its primary keys and values. This can be done by constructing a map where the key
75       * to the map entry is the primary key attribute and the value of the entry being the primary key value. For composite keys,
76       * pass in each primaryKey attribute and its value as a map entry.
77       *
78       * @param clazz
79       * @param primaryKeys
80       * @return
81       */
82      public <T> T findByPrimaryKey(Class<T> clazz, Map<String, ?> primaryKeys);
83  
84      /**
85       * Retrieves an object instance identified by the class of the given object and the object's primary key values.
86       *
87       * @param object
88       * @return
89       */
90      public Object retrieve(Object object);
91  
92      /**
93       * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
94       * instance. This will only retrieve business objects by class type.
95       *
96       * @param clazz
97       * @return
98       */
99      public <T> Collection<T> findAll(Class<T> clazz);
100 
101     /**
102      * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
103      * instance. This will only retrieve business objects by class type.
104      *
105      * @param clazz
106      * @return
107      */
108     public <T> Collection<T> findAllOrderBy( Class<T> clazz, String sortField, boolean sortAscending );
109 
110     /**
111      * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
112      * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
113      * specifically attribute name and its expected value.
114      *
115      * @param clazz
116      * @param fieldValues
117      * @return
118      */
119     public <T> Collection<T> findMatching(Class<T> clazz, Map<String, ?> fieldValues);
120 
121     /**
122      * Finds all entities matching the passed in Rice JPA criteria
123      *
124      * @param <T> the type of the entity that will be returned
125      * @param criteria the criteria to form the query with
126      * @return a Collection (most likely a List) of all matching entities
127      */
128     //public abstract <T> Collection<T> findMatching(Criteria criteria);
129 
130     /**
131      * This method retrieves a count of the business objects populated with data which match the criteria in the given Map.
132      *
133      * @param clazz
134      * @param fieldValues
135      * @return number of businessObjects of the given class whose fields match the values in the given expected-value Map
136      */
137     public int countMatching(Class clazz, Map<String, ?> fieldValues);
138 
139     /**
140      * This method retrieves a count of the business objects populated with data which match both the positive criteria
141      * and the negative criteria in the given Map.
142      *
143      * @param clazz
144      * @param positiveFieldValues
145      * @param negativeFieldValues
146      * @return number of businessObjects of the given class whose fields match the values in the given expected-value Maps
147      */
148     public int countMatching(Class clazz, Map<String, ?> positiveFieldValues, Map<String, ?> negativeFieldValues);
149 
150     /**
151      * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
152      * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
153      * specifically attribute name and its expected value. Performs an order by on sort field.
154      *
155      * @param clazz
156      * @param fieldValues
157      * @return
158      */
159     public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField, boolean sortAscending);
160 
161     /**
162      * Deletes a business object from the database.
163      *
164      * @param bo
165      */
166     public void delete(Object bo);
167 
168     /**
169      * Deletes each business object in the given List.
170      *
171      * @param boList
172      */
173     public void delete(List<? extends PersistableBusinessObject> boList);
174 
175     /**
176      * Deletes the object(s) matching the given field values
177      *
178      * @param clazz
179      * @param fieldValues
180      */
181     public void deleteMatching(Class clazz, Map<String, ?> fieldValues);
182 
183     /**
184      *
185      * This method attempts to retrieve the reference from a BO if it exists.
186      *
187      * @param bo - populated BusinessObject instance that includes the referenceName property
188      * @param referenceName - name of the member/property to load
189      * @return A populated object from the DB, if it exists
190      *
191      */
192     public BusinessObject getReferenceIfExists(BusinessObject bo, String referenceName);
193 
194     /**
195      *
196      * Updates all KualiUser or Person objects contained within this BO, based on the UserID as the authoritative key. The
197      * appropriate foreign-key field in the BO itself is also updated.
198      *
199      * This allows UserIDs to be entered on forms, and the back-end will link up correctly based on this non-key field.
200      *
201      * @param bo The populated BO (or descendent) instance to be linked & updated
202      *
203      */
204     public void linkUserFields(Object bo);
205 
206     /**
207      * Merges the given business object, but tells the ORM that the object is to be treated as Read Only,
208      * and even if it has changes, it will not be persisted to the database
209      *
210      * @param bo the business object to managed
211      * @return the managed copied of the business object
212      */
213     public PersistableBusinessObject manageReadOnly(PersistableBusinessObject bo);
214 
215 }
216 
217