View Javadoc
1   /*
2    * Copyright 2006 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  package org.kuali.ole.fp.document.web.struts;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  import org.kuali.ole.fp.businessobject.AdvanceDepositDetail;
24  import org.kuali.ole.fp.businessobject.CapitalAssetInformation;
25  import org.kuali.ole.fp.document.AdvanceDepositDocument;
26  import org.kuali.ole.fp.document.CapitalAssetEditable;
27  import org.kuali.ole.sys.context.SpringContext;
28  import org.kuali.rice.kns.service.BusinessObjectDictionaryService;
29  
30  /**
31   * This class is the struts form for Advance Deposit document.
32   */
33  public class AdvanceDepositForm extends CapitalAccountingLinesFormBase implements CapitalAssetEditable {
34      protected AdvanceDepositDetail newAdvanceDeposit;
35      protected List<CapitalAssetInformation> capitalAssetInformation;
36  
37      /**
38       * Constructs a AdvanceDepositForm.java.
39       */
40      public AdvanceDepositForm() {
41          super();
42  
43          AdvanceDepositDetail advanceDepositDetail = new AdvanceDepositDetail();
44          advanceDepositDetail.setDefaultBankCode();
45          setNewAdvanceDeposit(advanceDepositDetail);
46  
47          capitalAssetInformation = new ArrayList<CapitalAssetInformation>();
48          this.capitalAccountingLine.setCanCreateAsset(false); //This document can only edit asset information
49      }
50  
51      @Override
52      protected String getDefaultDocumentTypeName() {
53          return "OLE_AD";
54      }
55      
56      /**
57       * @return AdvanceDepositDocument
58       */
59      public AdvanceDepositDocument getAdvanceDepositDocument() {
60          return (AdvanceDepositDocument) getDocument();
61      }
62  
63      /**
64       * @return AdvanceDepositDetail
65       */
66      public AdvanceDepositDetail getNewAdvanceDeposit() {
67          return newAdvanceDeposit;
68      }
69  
70      /**
71       * @param newAdvanceDeposit
72       */
73      public void setNewAdvanceDeposit(AdvanceDepositDetail newAdvanceDeposit) {
74          this.newAdvanceDeposit = newAdvanceDeposit;
75      }
76  
77      /**
78       * Overrides the parent to call super.populate and then tells each line to check the associated data dictionary and modify the
79       * values entered to follow all the attributes set for the values of the accounting line.
80       * 
81       * @see org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
82       */
83      @Override
84      public void populate(HttpServletRequest request) {
85          super.populate(request);
86  
87          // now run through all of the accounting lines and make sure they've been uppercased and populated appropriately
88          SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(getNewAdvanceDeposit());
89  
90          List<AdvanceDepositDetail> advancedDeposits = getAdvanceDepositDocument().getAdvanceDeposits();
91          for (AdvanceDepositDetail detail : advancedDeposits) {
92              SpringContext.getBean(BusinessObjectDictionaryService.class).performForceUppercase(detail);
93          }
94      }
95  
96      /**
97       * @see org.kuali.ole.fp.document.CapitalAssetEditable#getCapitalAssetInformation()
98       */
99      public List<CapitalAssetInformation> getCapitalAssetInformation() {
100         return capitalAssetInformation;
101     }
102 
103     /**
104      * @see org.kuali.ole.fp.document.CapitalAssetEditable#setCapitalAssetInformation(org.kuali.ole.fp.businessobject.CapitalAssetInformation)
105      */
106     public void setCapitalAssetInformation(List<CapitalAssetInformation> capitalAssetInformation) {
107         this.capitalAssetInformation = capitalAssetInformation;
108     }
109 }