01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.document;
17:
18: import org.kuali.rice.KNSServiceLocator;
19:
20: import edu.iu.uis.eden.exception.WorkflowException;
21:
22: /**
23: * This is the base class implementation for all transaction processing eDocs.
24: */
25: public abstract class TransactionalDocumentBase extends DocumentBase
26: implements TransactionalDocument {
27: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
28: .getLogger(TransactionalDocumentBase.class);
29:
30: /**
31: * Default constructor.
32: */
33: public TransactionalDocumentBase() {
34: super ();
35: }
36:
37: /**
38: * @see org.kuali.core.document.TransactionalDocument#getAllowsCopy()
39: * Checks if copy is set to true in data dictionary and the document instance implements
40: * Copyable.
41: */
42: public boolean getAllowsCopy() {
43: return KNSServiceLocator
44: .getTransactionalDocumentDictionaryService()
45: .getAllowsCopy(this ).booleanValue()
46: && this instanceof Copyable;
47: }
48:
49: /**
50: * @see org.kuali.core.document.TransactionalDocument#getAllowsErrorCorrection()
51: * Checks if error correction is set to true in data dictionary and the document instance implements
52: * Correctable. Furthermore, a document cannot be error corrected twice.
53: */
54: public boolean getAllowsErrorCorrection() {
55: boolean allowErrorCorrection = KNSServiceLocator
56: .getTransactionalDocumentDictionaryService()
57: .getAllowsErrorCorrection(this ).booleanValue()
58: && this instanceof Correctable;
59: allowErrorCorrection = allowErrorCorrection
60: && getDocumentHeader().getCorrectedByDocumentId() == null;
61:
62: return allowErrorCorrection;
63: }
64:
65: /**
66: * @see org.kuali.core.document.Correctable#toErrorCorrection()
67: */
68: public void toErrorCorrection() throws WorkflowException,
69: IllegalStateException {
70: if (!this .getAllowsErrorCorrection()) {
71: throw new IllegalStateException(
72: this .getClass().getName()
73: + " does not support document-level error correction");
74: }
75:
76: String sourceDocumentHeaderId = getDocumentNumber();
77: setNewDocumentHeader();
78: getDocumentHeader().setFinancialDocumentInErrorNumber(
79: sourceDocumentHeaderId);
80: addCopyErrorDocumentNote("error-correction for document "
81: + sourceDocumentHeaderId);
82: }
83:
84: }
|