001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.gl.dataaccess;
017    
018    import java.util.Collection;
019    import java.util.Iterator;
020    import java.util.Map;
021    
022    import org.kuali.kfs.gl.businessobject.OriginEntryInformation;
023    import org.kuali.kfs.gl.businessobject.OriginEntryFull;
024    import org.kuali.kfs.gl.businessobject.OriginEntryGroup;
025    import org.kuali.rice.kns.util.KualiDecimal;
026    
027    /**
028     * 
029     */
030    public interface OriginEntryDao {
031        /**
032         * Sort origin entries by document id
033         */
034        public static final int SORT_DOCUMENT = 1;
035        /**
036         * Sort origin entries by account number
037         */
038        public static final int SORT_ACCOUNT = 2;
039        /**
040         * Sort origin entries by standard report order (by document type code and system origination code)
041         */
042        public static final int SORT_REPORT = 3;
043        /**
044         * 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)
045         */
046        public static final int SORT_LISTING_REPORT = 4;
047    
048        /**
049         * Get the total amount of transactions in a group
050         * @param the id of the origin entry group to total
051         * @param isCredit whether the total should be of credits or not
052         * @return the sum of all queried origin entries
053         */
054        public KualiDecimal getGroupTotal(Integer groupId, boolean isCredit);
055    
056        /**
057         * Counts the number of entries in a group
058         * @param the id of an origin entry group
059         * @return the count of the entries in that group
060         */
061        public Integer getGroupCount(Integer groupId);
062    
063        /**
064         * Counts of rows of all the origin entry groups
065         * 
066         * @return iterator of Object[] {[BigDecimal id,BigDecimal count]}
067         */
068        public Iterator getGroupCounts();
069    
070        /**
071         * Delete an entry
072         * 
073         * @param oe Entry to delete
074         */
075        public void deleteEntry(OriginEntryInformation oe);
076    
077        /**
078         * Return an iterator to all document keys reference by origin entries in a given group
079         * 
080         * @param oeg Group the origin entry group to find entries in, by origin entry
081         * @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
082         */
083        public Iterator getDocumentsByGroup(OriginEntryGroup oeg);
084    
085        /**
086         * Return an iterator to all the entries in a group
087         * 
088         * @param oeg the origin entry group to get entries in
089         * @param sort the Sort Order (one of the Sort Orders defined by the SORT_ constants defined in this class)
090         * @return Iterator of entries in the specified group
091         */
092        public <T> Iterator<T> getEntriesByGroup(OriginEntryGroup oeg, int sort);
093    
094        /**
095         * 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
096         * 
097         * @param groups a Collection of groups to remove bad entries in
098         * @return an Iterator of no good, won't use, bad balance entries
099         */
100        public Iterator<OriginEntryFull> getBadBalanceEntries(Collection groups);
101    
102        /**
103         * Collection of entries that match criteria
104         * 
105         * @param searchCriteria Map of field, value pairs
106         * @return collection of entries
107         */
108        public Collection<OriginEntryFull> getMatchingEntriesByCollection(Map searchCriteria);
109    
110        /**
111         * Iterator of entries that match criteria
112         * 
113         * @param searchCriteria Map of field, value pairs
114         * @return collection of entries
115         */
116        public Iterator getMatchingEntries(Map searchCriteria);
117    
118        /**
119         * Delete entries that match criteria
120         * 
121         * @param searchCriteria Map of field, value pairs
122         */
123        public void deleteMatchingEntries(Map searchCriteria);
124    
125        /**
126         * Delete all the groups in the list. This will delete the entries. The OriginEntryGroupDao has a method to delete the groups
127         * 
128         * @param groups a Collection of Origin Entry Groups to delete entries in
129         */
130        public void deleteGroups(Collection<OriginEntryGroup> groups);
131    
132        /**
133         * Save origin entry
134         * 
135         * @param entry entry to save
136         */
137        public void saveOriginEntry(OriginEntryInformation entry);
138    
139    
140        /**
141         * Finds an entry for the given entryId, or returns a newly created on
142         * 
143         * @param entryId an entry id to find an entry for
144         * @return the entry for the given entry id, or a newly created entry
145         */
146        public OriginEntryFull getExactMatchingEntry(Integer entryId);
147    
148        /**
149         * get the summarized information of the entries that belong to the entry groups with the given group ids
150         * 
151         * @param groupIdList the ids of origin entry groups
152         * @return a set of summarized information of the entries within the specified groups
153         */
154        public Iterator getSummaryByGroupId(Collection groupIdList);
155    
156        /**
157         * This method should only be used in unit tests. It loads all the gl_origin_entry_t rows in memory into a collection. This
158         * won't scale for production.
159         * 
160         * @return a Collection with every single origin entry in the database
161         */
162        public Collection testingGetAllEntries();
163    
164        /**
165         * get the summarized information of poster input entries that belong to the entry groups with the given group id list
166         * 
167         * @param groups the origin entry groups
168         * @return a set of summarized information of poster input entries within the specified groups
169         */
170        public Iterator getPosterOutputSummaryByGroupId(Collection groups);
171    
172    }