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.module.labor.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.module.labor.document.LaborLedgerPostingDocument;
025: import org.kuali.module.labor.rule.GenerateLaborLedgerPendingEntriesRule;
026:
027: /**
028: * Event used to re/generate general ledger pending entries for a transactional document.
029: */
030: public final class GenerateLaborLedgerPendingEntriesEvent 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 GenerateLaborLedgerPendingEntriesEvent(
044: String errorPathPrefix,
045: LaborLedgerPostingDocument accountingDocument,
046: AccountingLine accountingLine,
047: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
048: super ("creating generatePendingEntries event for document "
049: + getDocumentId(accountingDocument), errorPathPrefix,
050: accountingDocument);
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 = accountingDocument;
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 GenerateLaborLedgerPendingEntriesEvent(
067: LaborLedgerPostingDocument accountingDocument,
068: AccountingLine accountingLine,
069: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
070: this ("", accountingDocument, accountingLine, sequenceHelper);
071: }
072:
073: /**
074: * Gets the transactionalDocument attribute.
075: *
076: * @return TransactionalDocument associated with this event
077: */
078: public TransactionalDocument getTransactionalDocument() {
079: return (TransactionalDocument) getDocument();
080: }
081:
082: /**
083: * Gets the accountingLine attribute.
084: *
085: * @return accountingLine associated with this event
086: */
087: public AccountingLine getAccountingLine() {
088: return accountingLine;
089: }
090:
091: /**
092: * Gets the sequenceHelper.
093: *
094: * @return sequenceHelper associated with this event
095: */
096: public GeneralLedgerPendingEntrySequenceHelper getSequenceHelper() {
097: return sequenceHelper;
098: }
099:
100: /**
101: * Sets the value of the sequenceHelper.
102: *
103: * @param sequenceHelper
104: */
105: public void setSequenceHelper(
106: GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
107: this .sequenceHelper = sequenceHelper;
108: }
109:
110: public void validate() {
111: super .validate();
112: if (getAccountingLine() == null) {
113: throw new IllegalArgumentException(
114: "invalid (null) accounting line");
115: }
116: }
117:
118: /**
119: * Gets the GenerateLaborLedgerPendingEntriesRule.
120: *
121: * @return GenerateLaborLedgerPendingEntriesRule class
122: */
123: public Class getRuleInterfaceClass() {
124: return GenerateLaborLedgerPendingEntriesRule.class;
125: }
126:
127: /**
128: * @see org.kuali.core.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.core.rule.BusinessRule)
129: */
130: public boolean invokeRuleMethod(BusinessRule rule) {
131: return ((GenerateLaborLedgerPendingEntriesRule) rule)
132: .processGenerateLaborLedgerPendingEntries(
133: (LaborLedgerPostingDocument) getDocument(),
134: getAccountingLine(), getSequenceHelper());
135: }
136: }
|