1 /*
2 * The Kuali Financial System, a comprehensive financial management system for higher education.
3 *
4 * Copyright 2005-2014 The Kuali Foundation
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 package org.kuali.kfs.gl.dataaccess;
20
21 import java.util.Collection;
22 import java.util.Iterator;
23 import java.util.Map;
24
25 import org.kuali.kfs.gl.businessobject.OriginEntryFull;
26 import org.kuali.kfs.gl.businessobject.OriginEntryGroup;
27 import org.kuali.kfs.gl.businessobject.OriginEntryInformation;
28 import org.kuali.rice.core.api.util.type.KualiDecimal;
29
30 /**
31 *
32 */
33 public interface OriginEntryDao {
34 /**
35 * Sort origin entries by document id
36 */
37 public static final int SORT_DOCUMENT = 1;
38 /**
39 * Sort origin entries by account number
40 */
41 public static final int SORT_ACCOUNT = 2;
42 /**
43 * Sort origin entries by standard report order (by document type code and system origination code)
44 */
45 public static final int SORT_REPORT = 3;
46 /**
47 * Sort origin entries by listing report order (by fiscal year, chart code, account number, etc.: the order you see them in in generated text files)
48 */
49 public static final int SORT_LISTING_REPORT = 4;
50
51 /**
52 * Get the total amount of transactions in a group
53 * @param the id of the origin entry group to total
54 * @param isCredit whether the total should be of credits or not
55 * @return the sum of all queried origin entries
56 */
57 public KualiDecimal getGroupTotal(Integer groupId, boolean isCredit);
58
59 /**
60 * Counts the number of entries in a group
61 * @param the id of an origin entry group
62 * @return the count of the entries in that group
63 */
64 public Integer getGroupCount(Integer groupId);
65
66 /**
67 * Counts of rows of all the origin entry groups
68 *
69 * @return iterator of Object[] {[BigDecimal id,BigDecimal count]}
70 */
71 public Iterator getGroupCounts();
72
73 /**
74 * Delete an entry
75 *
76 * @param oe Entry to delete
77 */
78 public void deleteEntry(OriginEntryInformation oe);
79
80 /**
81 * Return an iterator to all document keys reference by origin entries in a given group
82 *
83 * @param oeg Group the origin entry group to find entries in, by origin entry
84 * @return Iterator of java.lang.Object[] with report data about all of the distinct document numbers/type code/origination code combinations of origin entries in the group
85 */
86 public Iterator getDocumentsByGroup(OriginEntryGroup oeg);
87
88 /**
89 * Return an iterator to all the entries in a group
90 *
91 * @param oeg the origin entry group to get entries in
92 * @param sort the Sort Order (one of the Sort Orders defined by the SORT_ constants defined in this class)
93 * @return Iterator of entries in the specified group
94 */
95 public <T> Iterator<T> getEntriesByGroup(OriginEntryGroup oeg, int sort);
96
97 /**
98 * Get bad balance entries; bad because a) they have invalid balance types, and b) because they revert the balances back to their stone age selves
99 *
100 * @param groups a Collection of groups to remove bad entries in
101 * @return an Iterator of no good, won't use, bad balance entries
102 */
103 public Iterator<OriginEntryFull> getBadBalanceEntries(Collection groups);
104
105 /**
106 * Collection of entries that match criteria
107 *
108 * @param searchCriteria Map of field, value pairs
109 * @return collection of entries
110 */
111 public Collection<OriginEntryFull> getMatchingEntriesByCollection(Map searchCriteria);
112
113 /**
114 * Iterator of entries that match criteria
115 *
116 * @param searchCriteria Map of field, value pairs
117 * @return collection of entries
118 */
119 public Iterator getMatchingEntries(Map searchCriteria);
120
121 /**
122 * Delete entries that match criteria
123 *
124 * @param searchCriteria Map of field, value pairs
125 */
126 public void deleteMatchingEntries(Map searchCriteria);
127
128 /**
129 * Delete all the groups in the list. This will delete the entries. The OriginEntryGroupDao has a method to delete the groups
130 *
131 * @param groups a Collection of Origin Entry Groups to delete entries in
132 */
133 public void deleteGroups(Collection<OriginEntryGroup> groups);
134
135 /**
136 * Finds an entry for the given entryId, or returns a newly created on
137 *
138 * @param entryId an entry id to find an entry for
139 * @return the entry for the given entry id, or a newly created entry
140 */
141 public OriginEntryFull getExactMatchingEntry(Integer entryId);
142
143 /**
144 * get the summarized information of the entries that belong to the entry groups with the given group ids
145 *
146 * @param groupIdList the ids of origin entry groups
147 * @return a set of summarized information of the entries within the specified groups
148 */
149 public Iterator getSummaryByGroupId(Collection groupIdList);
150
151 /**
152 * This method should only be used in unit tests. It loads all the gl_origin_entry_t rows in memory into a collection. This
153 * won't scale for production.
154 *
155 * @return a Collection with every single origin entry in the database
156 */
157 public Collection testingGetAllEntries();
158
159 /**
160 * get the summarized information of poster input entries that belong to the entry groups with the given group id list
161 *
162 * @param groups the origin entry groups
163 * @return a set of summarized information of poster input entries within the specified groups
164 */
165 public Iterator getPosterOutputSummaryByGroupId(Collection groups);
166
167 }