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: /*
17: * Created on Oct 12, 2005
18: *
19: */
20: package org.kuali.module.gl.batch.poster.impl;
21:
22: import java.util.Date;
23:
24: import org.apache.ojb.broker.metadata.MetadataManager;
25: import org.kuali.module.gl.GLConstants;
26: import org.kuali.module.gl.batch.poster.PostTransaction;
27: import org.kuali.module.gl.bo.Entry;
28: import org.kuali.module.gl.bo.Transaction;
29: import org.kuali.module.gl.dao.EntryDao;
30: import org.kuali.module.gl.service.PosterService;
31: import org.springframework.transaction.annotation.Transactional;
32:
33: /**
34: * An implementation of PostTransaction that posts the actual entry
35: */
36: @Transactional
37: public class PostGlEntry implements PostTransaction {
38: private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
39: .getLogger(PostGlEntry.class);
40:
41: private EntryDao entryDao;
42:
43: /**
44: * Constructs an instance of PostGlEntry
45: */
46: public PostGlEntry() {
47: super ();
48: }
49:
50: /**
51: * Saves the transaction as a new GL Entry
52: *
53: * @param t the transaction which is being posted
54: * @param mode the mode the poster is currently running in
55: * @param postDate the date this transaction should post to
56: * @return the accomplished post type
57: * @see org.kuali.module.gl.batch.poster.PostTransaction#post(org.kuali.module.gl.bo.Transaction, int, java.util.Date)
58: */
59: public String post(Transaction t, int mode, Date postDate) {
60: LOG.debug("post() started");
61:
62: Entry e = new Entry(t, postDate);
63:
64: if (mode == PosterService.MODE_REVERSAL) {
65: e.setFinancialDocumentReversalDate(null);
66: }
67:
68: // Make sure the row will be unique when adding to the entries table by
69: // adjusting the transaction sequence id
70: int maxSequenceId = entryDao.getMaxSequenceNumber(t);
71: e.setTransactionLedgerEntrySequenceNumber(new Integer(
72: maxSequenceId + 1));
73:
74: entryDao.addEntry(e, postDate);
75:
76: return GLConstants.INSERT_CODE;
77: }
78:
79: /**
80: * @see org.kuali.module.gl.batch.poster.PostTransaction#getDestinationName()
81: */
82: public String getDestinationName() {
83: return MetadataManager.getInstance().getGlobalRepository()
84: .getDescriptorFor(Entry.class).getFullTableName();
85: }
86:
87: public void setEntryDao(EntryDao ed) {
88: entryDao = ed;
89: }
90: }
|