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.core.service.mock;
017:
018: import org.kuali.core.document.Document;
019: import org.kuali.core.rule.ApproveDocumentRule;
020: import org.kuali.core.rule.RouteDocumentRule;
021: import org.kuali.core.rule.SaveDocumentRule;
022: import org.kuali.core.rule.event.ApproveDocumentEvent;
023: import org.kuali.core.util.GeneralLedgerPendingEntrySequenceHelper;
024: import org.kuali.kfs.bo.AccountingLine;
025: import org.kuali.kfs.document.AccountingDocument;
026: import org.kuali.kfs.document.GeneralLedgerPostingDocument;
027: import org.kuali.kfs.rule.AddAccountingLineRule;
028: import org.kuali.kfs.rule.DeleteAccountingLineRule;
029: import org.kuali.kfs.rule.GenerateGeneralLedgerPendingEntriesRule;
030: import org.kuali.kfs.rule.ReviewAccountingLineRule;
031: import org.kuali.kfs.rule.UpdateAccountingLineRule;
032:
033: /**
034: *
035: *
036: */
037: public class MockRule implements RouteDocumentRule, SaveDocumentRule,
038: AddAccountingLineRule, DeleteAccountingLineRule,
039: UpdateAccountingLineRule, ReviewAccountingLineRule,
040: GenerateGeneralLedgerPendingEntriesRule, ApproveDocumentRule {
041:
042: private static final String NONE = "none";
043: private static final String ROUTE_DOCUMENT = "routeDoc";
044: private static final String APPROVE_DOCUMENT = "approveDoc";
045: private static final String SAVE_DOCUMENT = "saveDoc";
046: private static final String ADD_LINE = "addLine";
047: private static final String DELETE_LINE = "deleteLine";
048: private static final String UPDATE_LINE = "updateLine";
049: private static final String REVIEW_LINE = "reviewLine";
050: private static final String GENERATE_PENDING = "generatePending";
051: private static final String ADD_DOC_NOTE = "addDocNote";
052:
053: /**
054: * @see org.kuali.core.rule.AccountingLineRule#isAmountValid(org.kuali.core.document.TransactionalDocument,
055: * org.kuali.core.bo.AccountingLine)
056: */
057: public boolean isAmountValid(AccountingDocument document,
058: AccountingLine accountingLine) {
059: return true;
060: }
061:
062: /**
063: * @see org.kuali.core.rule.AccountingLineRule#isFundGroupAllowed(org.kuali.core.bo.AccountingLine)
064: */
065: public boolean isFundGroupAllowed(Class documentClass,
066: AccountingLine accountingLine) {
067: return true;
068: }
069:
070: /**
071: * @see org.kuali.core.rule.AccountingLineRule#isObjectCodeAllowed(org.kuali.core.bo.AccountingLine)
072: */
073: public boolean isObjectCodeAllowed(Class documentClass,
074: AccountingLine accountingLine) {
075: return true;
076: }
077:
078: /**
079: * @see org.kuali.core.rule.AccountingLineRule#isObjectConsolidationAllowed(org.kuali.core.bo.AccountingLine)
080: */
081: public boolean isObjectConsolidationAllowed(Class documentClass,
082: AccountingLine accountingLine) {
083: return true;
084: }
085:
086: /**
087: * @see org.kuali.core.rule.AccountingLineRule#isObjectLevelAllowed(org.kuali.core.bo.AccountingLine)
088: */
089: public boolean isObjectLevelAllowed(Class documentClass,
090: AccountingLine accountingLine) {
091: return true;
092: }
093:
094: /**
095: * @see org.kuali.core.rule.AccountingLineRule#isObjectSubTypeAllowed(org.kuali.core.bo.AccountingLine)
096: */
097: public boolean isObjectSubTypeAllowed(Class documentClass,
098: AccountingLine accountingLine) {
099: return true;
100: }
101:
102: /**
103: * @see org.kuali.core.rule.AccountingLineRule#isObjectTypeAllowed(org.kuali.core.bo.AccountingLine)
104: */
105: public boolean isObjectTypeAllowed(Class documentClass,
106: AccountingLine accountingLine) {
107: return true;
108: }
109:
110: /**
111: * @see org.kuali.core.rule.AccountingLineRule#isSubFundGroupAllowed(org.kuali.core.bo.AccountingLine)
112: */
113: public boolean isSubFundGroupAllowed(Class documentClass,
114: AccountingLine accountingLine) {
115: return true;
116: }
117:
118: /**
119: * @see org.kuali.core.rule.AccountingLineRule#isDebit(TransactionalDocument, org.kuali.core.bo.AccountingLine)
120: */
121: public boolean isDebit(AccountingDocument transactionalDocument,
122: AccountingLine accountingLine) {
123: return true;
124: }
125:
126: /**
127: * @see org.kuali.core.rule.AccountingLineRule#isCredit(org.kuali.core.bo.AccountingLine, TransactionalDocument)
128: */
129: public boolean isCredit(AccountingLine accountingLine,
130: AccountingDocument transactionalDocument) {
131: return true;
132: }
133:
134: /**
135: * @see org.kuali.core.rule.AddAccountingLineRule#processAddAccountingLineBusinessRules(org.kuali.core.document.TransactionalDocument,
136: * org.kuali.core.bo.AccountingLine)
137: */
138: public boolean processAddAccountingLineBusinessRules(
139: AccountingDocument transactionalDocument,
140: AccountingLine accountingLine) {
141: MockDocumentInterface m = (MockDocumentInterface) transactionalDocument;
142: m.setProcessed(true);
143: m.setEventType(ADD_LINE);
144: return true;
145: }
146:
147: /**
148: * @see org.kuali.core.rule.DeleteAccountingLineRule#processDeleteAccountingLineBusinessRules(org.kuali.core.document.TransactionalDocument,
149: * org.kuali.core.bo.AccountingLine, boolean)
150: */
151: public boolean processDeleteAccountingLineBusinessRules(
152: AccountingDocument transactionalDocument,
153: AccountingLine accountingLine,
154: boolean lineWasAlreadyDeletedFromDocument) {
155: MockDocumentInterface m = (MockDocumentInterface) transactionalDocument;
156: m.setProcessed(true);
157: m.setEventType(DELETE_LINE);
158: return true;
159: }
160:
161: /**
162: * @see org.kuali.core.rule.UpdateAccountingLineRule#processUpdateAccountingLineBusinessRules(org.kuali.core.document.TransactionalDocument,
163: * org.kuali.core.bo.AccountingLine, org.kuali.core.bo.AccountingLine)
164: */
165: public boolean processUpdateAccountingLineBusinessRules(
166: AccountingDocument transactionalDocument,
167: AccountingLine originalAccountingLine,
168: AccountingLine updatedAccountingLine) {
169: MockDocumentInterface m = (MockDocumentInterface) transactionalDocument;
170: m.setProcessed(true);
171: m.setEventType(UPDATE_LINE);
172: return true;
173: }
174:
175: /**
176: * @see org.kuali.core.rule.ReviewAccountingLineRule#processReviewAccountingLineBusinessRules(org.kuali.core.document.TransactionalDocument,
177: * org.kuali.core.bo.AccountingLine)
178: */
179: public boolean processReviewAccountingLineBusinessRules(
180: AccountingDocument transactionalDocument,
181: AccountingLine accountingLine) {
182: MockDocumentInterface m = (MockDocumentInterface) transactionalDocument;
183: m.setProcessed(true);
184: m.setEventType(REVIEW_LINE);
185: return true;
186: }
187:
188: /**
189: * @see org.kuali.core.rule.RouteDocumentRule#processRouteDocument(org.kuali.core.document.Document)
190: */
191: public boolean processRouteDocument(Document document) {
192: MockDocumentInterface m = (MockDocumentInterface) document;
193: m.setProcessed(true);
194: m.setEventType(ROUTE_DOCUMENT);
195:
196: return true;
197: }
198:
199: /**
200: * @see org.kuali.core.rule.ApproveDocumentRule#processApproveDocument(org.kuali.core.rule.event.ApproveDocumentEvent)
201: */
202: public boolean processApproveDocument(
203: ApproveDocumentEvent approveEvent) {
204: MockDocumentInterface m = (MockDocumentInterface) approveEvent
205: .getDocument();
206: m.setProcessed(true);
207: m.setEventType(APPROVE_DOCUMENT);
208:
209: return true;
210: }
211:
212: // TODO: revisit is this still needed
213: // /**
214: // * @see org.kuali.core.rule.AddDocumentNoteRule#processAddDocumentNote(org.kuali.core.document.Document,
215: // * org.kuali.core.document.DocumentNote)
216: // */
217: // public boolean processAddDocumentNote(Document document, DocumentNote note) {
218: // MockDocumentInterface m = (MockDocumentInterface) document;
219: // m.setProcessed(true);
220: // m.setEventType(ADD_DOC_NOTE);
221: //
222: // return true;
223: // }
224:
225: /**
226: * @see org.kuali.core.rule.SaveDocumentRule#processSaveDocument(org.kuali.core.document.Document)
227: */
228: public boolean processSaveDocument(Document document) {
229: MockDocumentInterface m = (MockDocumentInterface) document;
230: m.setProcessed(true);
231: m.setEventType(SAVE_DOCUMENT);
232:
233: return true;
234: }
235:
236: /**
237: * @see org.kuali.core.rule.GenerateGeneralLedgerPendingEntriesRule#processGenerateGeneralLedgerPendingEntries(org.kuali.core.document.TransactionalDocument,
238: * org.kuali.core.bo.AccountingLine, org.kuali.core.util.GeneralLedgerPendingEntrySequenceHelper)
239: */
240: public boolean processGenerateGeneralLedgerPendingEntries(
241: GeneralLedgerPostingDocument document,
242: AccountingLine accountingLine,
243: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
244: MockDocumentInterface m = (MockDocumentInterface) document;
245: m.setProcessed(true);
246: m.setEventType(GENERATE_PENDING);
247:
248: return true;
249: }
250: }
|