View Javadoc
1   /*
2    * Copyright 2005 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
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.ole.gl.batch.service.impl;
21  
22  import java.util.Date;
23  
24  import org.kuali.ole.gl.GeneralLedgerConstants;
25  import org.kuali.ole.gl.batch.service.AccountingCycleCachingService;
26  import org.kuali.ole.gl.batch.service.PostTransaction;
27  import org.kuali.ole.gl.batch.service.PosterService;
28  import org.kuali.ole.gl.businessobject.Entry;
29  import org.kuali.ole.gl.businessobject.Transaction;
30  import org.kuali.ole.sys.service.ReportWriterService;
31  import org.kuali.rice.krad.service.PersistenceStructureService;
32  import org.springframework.transaction.annotation.Transactional;
33  
34  /**
35   * An implementation of PostTransaction that posts the actual entry
36   */
37  @Transactional
38  public class PostEntry implements PostTransaction {
39      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PostEntry.class);
40  
41      private AccountingCycleCachingService accountingCycleCachingService;
42      private PersistenceStructureService persistenceStructureService;
43  
44      /**
45       * Constructs an instance of PostEntry
46       */
47      public PostEntry() {
48          super();
49      }
50  
51      /**
52       * Saves the transaction as a new GL Entry
53       * 
54       * @param t the transaction which is being posted
55       * @param mode the mode the poster is currently running in
56       * @param postDate the date this transaction should post to
57       * @param posterReportWriterService the writer service where the poster is writing its report
58       * @return the accomplished post type
59       * @see org.kuali.ole.gl.batch.service.PostTransaction#post(org.kuali.ole.gl.businessobject.Transaction, int, java.util.Date)
60       */
61      public String post(Transaction t, int mode, Date postDate, ReportWriterService posterReportWriterService) {
62          LOG.debug("post() started");
63  
64          Entry e = new Entry(t, postDate);
65  
66          if (mode == PosterService.MODE_REVERSAL) {
67              e.setFinancialDocumentReversalDate(null);
68          }
69          
70          accountingCycleCachingService.insertEntry(e);
71  
72          return GeneralLedgerConstants.INSERT_CODE;
73      }
74  
75      /**
76       * @see org.kuali.ole.gl.batch.service.PostTransaction#getDestinationName()
77       */
78      public String getDestinationName() {
79          return persistenceStructureService.getTableName(Entry.class);
80      }
81  
82      public void setAccountingCycleCachingService(AccountingCycleCachingService accountingCycleCachingService) {
83          this.accountingCycleCachingService = accountingCycleCachingService;
84      }
85  
86      public void setPersistenceStructureService(PersistenceStructureService persistenceStructureService) {
87          this.persistenceStructureService = persistenceStructureService;
88      }
89  
90  }