001: /*
002: * Copyright 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.kfs.rule.event;
017:
018: import org.kuali.core.document.TransactionalDocument;
019: import org.kuali.core.rule.BusinessRule;
020: import org.kuali.core.rule.event.KualiDocumentEventBase;
021: import org.kuali.core.util.GeneralLedgerPendingEntrySequenceHelper;
022: import org.kuali.core.util.ObjectUtils;
023: import org.kuali.kfs.bo.AccountingLine;
024: import org.kuali.kfs.document.GeneralLedgerPostingDocument;
025: import org.kuali.kfs.rule.GenerateGeneralLedgerPendingEntriesRule;
026:
027: /**
028: * Event used to re/generate general ledger pending entries for a transactional document.
029: */
030: public final class GenerateGeneralLedgerPendingEntriesEvent extends
031: KualiDocumentEventBase {
032: private final AccountingLine accountingLine;
033: private GeneralLedgerPendingEntrySequenceHelper sequenceHelper;
034:
035: /**
036: * Constructs a GenerateGeneralLedgerPendingEntriesEvent with the given errorPathPrefix, document, accountingLine, and counter
037: *
038: * @param errorPathPrefix
039: * @param generalLedgerPostingDocument
040: * @param accountingLine
041: * @param sequenceHelper
042: */
043: public GenerateGeneralLedgerPendingEntriesEvent(
044: String errorPathPrefix,
045: GeneralLedgerPostingDocument generalLedgerPostingDocument,
046: AccountingLine accountingLine,
047: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
048: super ("creating generatePendingEntries event for document "
049: + getDocumentId(generalLedgerPostingDocument),
050: errorPathPrefix, generalLedgerPostingDocument);
051: // note that we want to override the parent b/c we do want this by reference here
052: // the parent does a deepCopy and we don't want that b/c we need to set the GLPEs into the document
053: super .document = generalLedgerPostingDocument;
054: this .accountingLine = (AccountingLine) ObjectUtils
055: .deepCopy(accountingLine);
056: this .sequenceHelper = sequenceHelper;
057: }
058:
059: /**
060: * Constructs a GenerateGeneralLedgerPendingEntriesEvent with the given document and accountingLine
061: *
062: * @param generalLedgerPostingDocument
063: * @param accountingLine
064: * @param sequenceHelper
065: */
066: public GenerateGeneralLedgerPendingEntriesEvent(
067: GeneralLedgerPostingDocument generalLedgerPostingDocument,
068: AccountingLine accountingLine,
069: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
070: this ("", generalLedgerPostingDocument, accountingLine,
071: sequenceHelper);
072: }
073:
074: /**
075: * @return TransactionalDocument associated with this event
076: */
077: public TransactionalDocument getTransactionalDocument() {
078: return (TransactionalDocument) getDocument();
079: }
080:
081: /**
082: * @return accountingLine associated with this event
083: */
084: public AccountingLine getAccountingLine() {
085: return accountingLine;
086: }
087:
088: /**
089: * @return sequenceHelper associated with this event
090: */
091: public GeneralLedgerPendingEntrySequenceHelper getSequenceHelper() {
092: return sequenceHelper;
093: }
094:
095: /**
096: * This method sets the value of the sequenceHelper.
097: *
098: * @param sequenceHelper
099: */
100: public void setSequenceHelper(
101: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
102: this .sequenceHelper = sequenceHelper;
103: }
104:
105: public void validate() {
106: super .validate();
107: if (getAccountingLine() == null) {
108: throw new IllegalArgumentException(
109: "invalid (null) accounting line");
110: }
111: }
112:
113: /**
114: * @see org.kuali.core.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
115: */
116: public Class getRuleInterfaceClass() {
117: return GenerateGeneralLedgerPendingEntriesRule.class;
118: }
119:
120: /**
121: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
122: */
123: public boolean invokeRuleMethod(BusinessRule rule) {
124: return ((GenerateGeneralLedgerPendingEntriesRule) rule)
125: .processGenerateGeneralLedgerPendingEntries(
126: (GeneralLedgerPostingDocument) getDocument(),
127: getAccountingLine(), getSequenceHelper());
128: }
129: }
|