View Javadoc
1   /*
2    * Copyright 2011 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.select.document;
17  
18  import org.kuali.ole.module.purap.document.PurchaseOrderSplitDocument;
19  import org.kuali.ole.module.purap.document.RequisitionDocument;
20  import org.kuali.ole.select.businessobject.OlePurchaseOrderItem;
21  import org.kuali.ole.select.document.service.OlePurchaseOrderDocumentHelperService;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.ole.vnd.businessobject.VendorAlias;
25  import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
26  
27  import java.util.HashMap;
28  import java.util.List;
29  import java.util.Map;
30  
31  
32  /**
33   * This class is the document class for Ole Purchase Order Split Document
34   */
35  public class OlePurchaseOrderSplitDocument extends PurchaseOrderSplitDocument {
36  
37      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderSplitDocument.class);
38  
39      private String vendorPoNumber;
40  
41      public String getVendorPoNumber() {
42          return vendorPoNumber;
43      }
44  
45      public void setVendorPoNumber(String vendorPoNumber) {
46          this.vendorPoNumber = vendorPoNumber;
47      }
48  
49      /**
50       * This method is overridden to populate newly added ole fields from requisition into Ole Purchase Order Split Document.
51       *
52       * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#populatePurchaseOrderFromRequisition(org.kuali.ole.module.purap.document.RequisitionDocument)
53       */
54      @Override
55      public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
56  
57          if (LOG.isDebugEnabled()) {
58              LOG.debug("Inside populatePurchaseOrderFromRequisition of OlePurchaseOrderSplitDocument");
59          }
60          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument);
61      }
62  
63      /**
64       * This method is overriden to populate bib info in Ole Purchase Order Split Document
65       *
66       * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
67       */
68      @Override
69      public void prepareForSave(KualiDocumentEvent event) {
70  
71          if (LOG.isDebugEnabled()) {
72              LOG.debug("Inside prepareForSave of OlePurchaseOrderSplitDocument");
73          }
74          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event);
75          super.prepareForSave(event);
76  
77      }
78  
79      /**
80       * This method is overriden to populate bib info in Ole Purchase Order Retransmit Document
81       *
82       * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#processAfterRetrieve()
83       */
84      @Override
85      public void processAfterRetrieve() {
86          if (LOG.isDebugEnabled()) {
87              LOG.debug("Inside processAfterRetrieve of OlePurchaseOrderSplitDocument");
88          }
89          if (this.getVendorAliasName() == null) {
90              populateVendorAliasName();
91          }
92          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this);
93      }
94  
95      @Override
96      public List getItemsActiveOnly() {
97          if (LOG.isDebugEnabled()) {
98              LOG.debug("Inside getItemsActiveOnly of OlePurchaseOrderSplitDocument");
99          }
100         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnly(this);
101     }
102 
103     /**
104      * Gets the active items in this Purchase Order, and sets up the alternate amount for GL entry creation.
105      *
106      * @return the list of all active items in this Purchase Order.
107      */
108     @Override
109     public List getItemsActiveOnlySetupAlternateAmount() {
110         if (LOG.isDebugEnabled()) {
111             LOG.debug("Inside getItemsActiveOnlySetupAlternateAmount of OlePurchaseOrderSplitDocument");
112         }
113         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnlySetupAlternateAmount(this);
114     }
115 
116     @Override
117     public boolean getAdditionalChargesExist() {
118         if (LOG.isDebugEnabled()) {
119             LOG.debug("Inside getAdditionalChargesExist of OlePurchaseOrderSplitDocument");
120         }
121         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getAdditionalChargesExist(this);
122     }
123 
124     /**
125      * This method returns if Purchase Order Document created is in Final Status
126      *
127      * @return
128      */
129     public boolean getIsFinalReqs() {
130         if (LOG.isDebugEnabled()) {
131             LOG.debug("Inside getIsFinalReqs of OlePurchaseOrderSplitDocument");
132         }
133 
134         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsFinalReqs(this);
135     }
136 
137     public boolean getIsSplitPO() {
138         if (LOG.isDebugEnabled()) {
139             LOG.debug("Inside getIsSplitPO of OlePurchaseOrderSplitDocument");
140         }
141         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsSplitPO(this);
142     }
143 
144     public boolean getIsReOpenPO() {
145         if (LOG.isDebugEnabled()) {
146             LOG.debug("Inside getIsReOpenPO of OlePurchaseOrderSplitDocument");
147         }
148         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsReOpenPO(this);
149     }
150 
151     /**
152      * This method is used to get the bibedtior creat url from propertie file
153      *
154      * @return Bibeditor creat url string
155      */
156     public String getBibeditorCreateURL() {
157         if (LOG.isDebugEnabled()) {
158             LOG.debug("Inside getBibeditorCreateURL of OlePurchaseOrderSplitDocument");
159         }
160         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorCreateURL();
161     }
162 
163     public String getBibSearchURL() {
164         LOG.debug("Inside getBibSearchURL of OlePurchaseOrderSplitDocument");
165         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibSearchURL();
166     }
167 
168     /**
169      * This method is used to get the bibedtior edit url from propertie file
170      *
171      * @return Bibeditor edit url string
172      */
173     public String getBibeditorEditURL() {
174         if (LOG.isDebugEnabled()) {
175             LOG.debug("Inside getBibeditorEditURL of OlePurchaseOrderSplitDocument");
176         }
177         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorEditURL();
178     }
179 
180     /**
181      * This method is used to get the Instanceeditor url from propertie file
182      *
183      * @return Instanceeditor url string
184      */
185     public String getInstanceEditorURL() {
186         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getInstanceEditorURL();
187     }
188 
189     /**
190      * This method is used to get the bibedtior view url from propertie file
191      *
192      * @return Bibeditor view url string
193      */
194     public String getBibeditorViewURL() {
195         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorViewURL();
196     }
197 
198     /**
199      * This method is used to get the dublin editor edit url from property file
200      *
201      * @return Dublineditor edit url string
202      */
203     public String getDublinEditorEditURL() {
204         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
205     }
206 
207     /**
208      * This method is used to get the dublin editor view url from property file
209      *
210      * @return dublineditor view url string
211      */
212     public String getDublinEditorViewURL() {
213         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
214     }
215 
216     /**
217      * This method is used to get the directory path where the marc xml files need to be created
218      *
219      * @return Directory path string
220      */
221     public String getMarcXMLFileDirLocation() throws Exception {
222         if (LOG.isDebugEnabled()) {
223             LOG.debug("Inside getMarcXMLFileDirLocation of OlePurchaseOrderSplitDocument");
224         }
225         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getMarcXMLFileDirLocation();
226     }
227 
228     @Override
229     public Class getItemClass() {
230         return OlePurchaseOrderItem.class;
231     }
232 
233     /**
234      * This method is used to check the status of the document for displaying view and edit buttons in line item
235      *
236      * @return boolean
237      */
238     public boolean getIsSaved() {
239         if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
240             return true;
241         }
242         return false;
243     }
244 
245     public boolean getIsATypeOfRCVGDoc() {
246         return false;
247     }
248 
249     public boolean getIsATypeOfCORRDoc() {
250         return false;
251     }
252 
253     private void populateVendorAliasName() {
254         Map vendorDetailMap = new HashMap();
255         vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
256         vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
257         List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
258         if (vendorDetailList != null && vendorDetailList.size() > 0) {
259             this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
260         }
261     }
262 }