001: /*
002: * Copyright 2006-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.module.gl.service;
017:
018: import java.io.IOException;
019: import java.io.OutputStream;
020: import java.sql.Date;
021: import java.util.Collection;
022: import java.util.Iterator;
023: import java.util.List;
024:
025: import org.kuali.core.web.ui.Column;
026: import org.kuali.module.gl.bo.CorrectionChangeGroup;
027: import org.kuali.module.gl.bo.OriginEntryFull;
028: import org.kuali.module.gl.document.CorrectionDocument;
029: import org.kuali.module.gl.util.CorrectionDocumentEntryMetadata;
030: import org.kuali.module.gl.util.CorrectionDocumentUtils;
031:
032: /**
033: * An interface declaring methods needed by the GLCP to function
034: */
035: public interface CorrectionDocumentService {
036: public final static String CORRECTION_TYPE_MANUAL = "M";
037: public final static String CORRECTION_TYPE_CRITERIA = "C";
038: public final static String CORRECTION_TYPE_REMOVE_GROUP_FROM_PROCESSING = "R";
039:
040: public final static String SYSTEM_DATABASE = "D";
041: public final static String SYSTEM_UPLOAD = "U";
042:
043: /**
044: * When passed into {@link #retrievePersistedInputOriginEntries(CorrectionDocument, int)} and
045: * {@link #retrievePersistedOutputOriginEntries(CorrectionDocument, int)} as the int parameter, this will signify that there is
046: * no abort threshold (i.e. the methods should return all of the persisted rows, regardless of number of rows.
047: */
048: public final static int UNLIMITED_ABORT_THRESHOLD = CorrectionDocumentUtils.RECORD_COUNT_FUNCTIONALITY_LIMIT_IS_UNLIMITED;
049:
050: /**
051: * Returns a specific correction change group for a GLCP document
052: *
053: * @param docId the document id of a GLCP document
054: * @param i the number of the correction group within the document
055: * @return a CorrectionChangeGroup
056: */
057: public CorrectionChangeGroup findByDocumentNumberAndCorrectionChangeGroupNumber(
058: String docId, int i);
059:
060: /**
061: * Finds CollectionChange records associated with a given document id and correction change group
062: *
063: * @param docId the document id of a GLCP document
064: * @param i the number of the correction group within the document
065: * @return a List of qualifying CorrectionChange records
066: */
067: public List findByDocumentHeaderIdAndCorrectionGroupNumber(
068: String docId, int i);
069:
070: /**
071: * Finds Collection Criteria associated with the given GLCP document and group
072: *
073: * @param docId the document id of a GLCP document
074: * @param i the number of the correction group within the document
075: * @return a List of qualifying CorrectionCriteria
076: */
077: public List findByDocumentNumberAndCorrectionGroupNumber(
078: String docId, int i);
079:
080: /**
081: * Retrieves a correction document by the document id
082: *
083: * @param docId the document id of the GLCP to find
084: * @return a CorrectionDocument if found
085: */
086: public CorrectionDocument findByCorrectionDocumentHeaderId(
087: String docId);
088:
089: /**
090: * Returns metadata to help render columns in the GLCP. Do not modify this list or the contents in this list.
091: *
092: * @param docId the document id of a GLCP document
093: * @return a List of Columns to render
094: */
095: public List<Column> getTableRenderColumnMetadata(String docId);
096:
097: /**
098: * This method persists an Iterator of input origin entries for a document that is in the initiated or saved state
099: *
100: * @param document an initiated or saved document
101: * @param entries an Iterator of origin entries
102: */
103: public void persistInputOriginEntriesForInitiatedOrSavedDocument(
104: CorrectionDocument document,
105: Iterator<OriginEntryFull> entries);
106:
107: /**
108: * Removes input origin entries that were saved to the database associated with the given document
109: *
110: * @param document a GLCP document
111: */
112: public void removePersistedInputOriginEntries(
113: CorrectionDocument document);
114:
115: /**
116: * Removes input origin entries that were saved to the database associated with the given document
117: *
118: * @param docId the document id of a GLCP document
119: */
120: public void removePersistedInputOriginEntries(String docId);
121:
122: /**
123: * Retrieves input origin entries that have been persisted for this document
124: *
125: * @param document the document
126: * @param abortThreshold if the file exceeds this number of rows, then null is returned. {@link UNLIMITED_ABORT_THRESHOLD}
127: * signifies that there is no limit
128: * @return the list, or null if there are too many origin entries
129: * @throws RuntimeException several reasons, primarily relating to underlying persistence layer problems
130: */
131: public List<OriginEntryFull> retrievePersistedInputOriginEntries(
132: CorrectionDocument document, int abortThreshold);
133:
134: /**
135: * Returns true if the system is storing input origin entries for this class. Note that this does not mean that there's at least
136: * one input origin entry record persisted for this document, but merely returns true if and only if the underlying persistence
137: * mechanism has a record of this document's origin entries. See the docs for the implementations of this method for more
138: * implementation specific details.
139: *
140: * @param document a GLCP document
141: * @return Returns true if system should store origin entries, false otherwise
142: */
143: public boolean areInputOriginEntriesPersisted(
144: CorrectionDocument document);
145:
146: /**
147: * Writes out the persisted input origin entries in an {@link OutputStream} in a flat file format
148: *
149: * @param document a GLCP document
150: * @param out an open and ready output stream
151: * @throws IOException thrown if errors were encountered writing to the Stream
152: * @throws RuntimeException several reasons, including if the entries are not persisted
153: */
154: public void writePersistedInputOriginEntriesToStream(
155: CorrectionDocument document, OutputStream out)
156: throws IOException;
157:
158: /**
159: * This method persists an Iterator of input origin entries for a document that is in the initiated or saved state
160: *
161: * @param document an initiated or saved document
162: * @param entries an Iterator of OriginEntries to persist
163: */
164: public void persistOutputOriginEntriesForInitiatedOrSavedDocument(
165: CorrectionDocument document,
166: Iterator<OriginEntryFull> entries);
167:
168: /**
169: * Removes all output origin entries persisted in the database created by the given document
170: *
171: * @param document a GLCP document
172: */
173: public void removePersistedOutputOriginEntries(
174: CorrectionDocument document);
175:
176: /**
177: * Removes all output origin entries persisted in the database created by the given document
178: *
179: * @param docId the document id of a GLCP document
180: */
181: public void removePersistedOutputOriginEntries(String docId);
182:
183: /**
184: * Retrieves output origin entries that have been persisted for this document
185: *
186: * @param document the document
187: * @param abortThreshold if the file exceeds this number of rows, then null is returned. {@link UNLIMITED_ABORT_THRESHOLD}
188: * signifies that there is no limit
189: * @return the list, or null if there are too many origin entries
190: * @throws RuntimeException several reasons, primarily relating to underlying persistence layer problems
191: */
192: public List<OriginEntryFull> retrievePersistedOutputOriginEntries(
193: CorrectionDocument document, int abortThreshold);
194:
195: /**
196: * Retrieves input origin entries that have been persisted for this document in an iterator. Implementations of this method may
197: * choose to implement this method in a way that consumes very little memory.
198: *
199: * @param document the document
200: * @return the iterator
201: * @throws RuntimeException several reasons, primarily relating to underlying persistence layer problems
202: */
203: public Iterator<OriginEntryFull> retrievePersistedInputOriginEntriesAsIterator(
204: CorrectionDocument document);
205:
206: /**
207: * Retrieves output origin entries that have been persisted for this document in an iterator. Implementations of this method may
208: * choose to implement this method in a way that consumes very little memory.
209: *
210: * @param document the document
211: * @return the iterator
212: * @throws RuntimeException several reasons, primarily relating to underlying persistence layer problems
213: */
214: public Iterator<OriginEntryFull> retrievePersistedOutputOriginEntriesAsIterator(
215: CorrectionDocument document);
216:
217: /**
218: * Returns true if the system is storing output origin entries for this class. Note that this does not mean that there's at
219: * least one output origin entry record persisted for this document, but merely returns true if and only if the underlying
220: * persistence mechanism has a record of this document's origin entries. See the docs for the implementations of this method for
221: * more implementation specific details.
222: *
223: * @param document a GLCP document to query
224: * @return true if origin entries are stored to the system, false otherwise
225: */
226: public boolean areOutputOriginEntriesPersisted(
227: CorrectionDocument document);
228:
229: /**
230: * Writes out the persisted output origin entries in an {@link OutputStream} in a flat file format\
231: *
232: * @param document a GLCP document
233: * @param out axn open and ready output stream
234: * @throws IOException thrown if IOExceptions occurred in writing the persisted origin entries
235: * @throws RuntimeException several reasons, including if the entries are not persisted
236: */
237: public void writePersistedOutputOriginEntriesToStream(
238: CorrectionDocument document, OutputStream out)
239: throws IOException;
240:
241: /**
242: * Saves the input and output origin entry groups for a document prior to saving the document
243: *
244: * @param document a GLCP document
245: * @param correctionDocumentEntryMetadata metadata about this GLCP document
246: */
247: public void persistOriginEntryGroupsForDocumentSave(
248: CorrectionDocument document,
249: CorrectionDocumentEntryMetadata correctionDocumentEntryMetadata);
250:
251: /**
252: * Retrieves all of the documents that were finalized on a certain date
253: *
254: * @param date the date to find GLCP documents finalized on
255: * @return a collection of documents
256: */
257: public Collection<CorrectionDocument> getCorrectionDocumentsFinalizedOn(
258: Date date);
259: }
|