001: /*
002: * Copyright 2005-2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.core.dao;
017:
018: import java.util.Collection;
019: import java.util.List;
020: import java.util.Map;
021:
022: import org.kuali.core.bo.PersistableBusinessObject;
023:
024: /**
025: * This is the generic data access interface for business objects. This should be used for unit testing purposes only.
026: *
027: *
028: */
029: public interface BusinessObjectDao {
030: /**
031: * Saves any object that implements the BusinessObject interface.
032: *
033: * @param bo
034: */
035: public void save(PersistableBusinessObject bo);
036:
037: /**
038: * Saves a List of BusinessObjects.
039: *
040: * @param businessObjects
041: */
042: public void save(List businessObjects);
043:
044: /**
045: * Retrieves an object instance identified bys it primary keys and values. This can be done by constructing a map where the key
046: * to the map entry is the primary key attribute and the value of the entry being the primary key value. For composite keys,
047: * pass in each primaryKey attribute and its value as a map entry.
048: *
049: * @param clazz
050: * @param primaryKeys
051: * @return
052: */
053: public PersistableBusinessObject findByPrimaryKey(Class clazz,
054: Map primaryKeys);
055:
056: /**
057: * Retrieves an object instance identified by the class of the given object and the object's primary key values.
058: *
059: * @param object
060: * @return
061: */
062: public PersistableBusinessObject retrieve(
063: PersistableBusinessObject object);
064:
065: /**
066: * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
067: * instance. This will only retrieve business objects by class type.
068: *
069: * @param clazz
070: * @return
071: */
072: public Collection findAll(Class clazz);
073:
074: /**
075: * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
076: * instance. This will only retrieve business objects by class type.
077: *
078: * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
079: *
080: * @param clazz
081: * @return
082: */
083: public Collection findAllActive(Class clazz);
084:
085: /**
086: * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
087: * instance. This will only retrieve business objects by class type. Orders the results by the given field.
088: *
089: * @param clazz
090: * @return
091: */
092: public Collection findAllOrderBy(Class clazz, String sortField,
093: boolean sortAscending);
094:
095: /**
096: * Retrieves a collection of business objects populated with data, such that each record in the database populates a new object
097: * instance. This will only retrieve business objects by class type. Orders the results by the given field.
098: *
099: * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
100: * @param clazz
101: * @return
102: */
103: public Collection findAllActiveOrderBy(Class clazz,
104: String sortField, boolean sortAscending);
105:
106: /**
107: * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
108: * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
109: * specifically attribute name-expected value.
110: *
111: * @param clazz
112: * @param fieldValues
113: * @return
114: */
115: public Collection findMatching(Class clazz, Map fieldValues);
116:
117: /**
118: * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
119: * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
120: * specifically attribute name-expected value.
121: *
122: * Adds criteria on active column to return only active records. Assumes there exist a mapping for PropertyConstants.Active
123: *
124: * @param clazz
125: * @param fieldValues
126: * @return
127: */
128: public Collection findMatchingActive(Class clazz, Map fieldValues);
129:
130: /**
131: * @param clazz
132: * @param fieldValues
133: * @return count of BusinessObjects of the given class whose fields match the values in the given Map.
134: */
135: public int countMatching(Class clazz, Map fieldValues);
136:
137: /**
138: *
139: * This method returns the number of matching result given the positive criterias and
140: * negative criterias. The negative criterias are the ones that will be set to
141: * "notEqualTo" or "notIn"
142: *
143: * @param clazz
144: * @param positiveFieldValues Map of fields and values for positive criteria
145: * @param negativeFieldValues Map of fields and values for negative criteria
146: * @return
147: */
148: public int countMatching(Class clazz, Map positiveFieldValues,
149: Map negativeFieldValues);
150:
151: /**
152: * This method retrieves a collection of business objects populated with data, such that each record in the database populates a
153: * new object instance. This will retrieve business objects by class type and also by criteria passed in as key-value pairs,
154: * specifically attribute name-expected value. Orders the results by the given field.
155: *
156: * @param clazz
157: * @param fieldValues
158: * @return
159: */
160: public Collection findMatchingOrderBy(Class clazz, Map fieldValues,
161: String sortField, boolean sortAscending);
162:
163: /**
164: * Deletes a business object from the database.
165: *
166: * @param bo
167: */
168: public void delete(PersistableBusinessObject bo);
169:
170: /**
171: * Deletes each business object in the given List from the database.
172: *
173: * @param boList
174: */
175: public void delete(List<PersistableBusinessObject> boList);
176:
177: /**
178: * Deletes the business objects matching the given fieldValues
179: *
180: * @param clazz
181: * @param fieldValues
182: */
183: public void deleteMatching(Class clazz, Map fieldValues);
184: }
|