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