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  
17  package org.kuali.ole.select.document;
18  
19  import org.kuali.ole.module.purap.document.PurchaseOrderReopenDocument;
20  import org.kuali.ole.module.purap.document.RequisitionDocument;
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   * Purchase Order Reopen Document
33   */
34  public class OlePurchaseOrderReopenDocument extends PurchaseOrderReopenDocument {
35      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderReopenDocument.class);
36  
37      private String vendorPoNumber;
38  
39      /**
40       * Default constructor.
41       */
42      public OlePurchaseOrderReopenDocument() {
43          super();
44      }
45  
46      /**
47       * This method is overridden to populate newly added ole fields from requisition into Ole Purchase Order Reopen Document.
48       *
49       * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#populatePurchaseOrderFromRequisition(org.kuali.ole.module.purap.document.RequisitionDocument)
50       */
51      @Override
52      public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
53  
54          if (LOG.isDebugEnabled()) {
55              LOG.debug("Inside populatePurchaseOrderFromRequisition of OlePurchaseOrderReopenDocument");
56          }
57          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument);
58  
59  
60      }
61  
62      /**
63       * This method is overriden to populate bib info in Ole Purchase Order Reopen Document
64       *
65       * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
66       */
67      @Override
68      public void prepareForSave(KualiDocumentEvent event) {
69  
70          if (LOG.isDebugEnabled()) {
71              LOG.debug("Inside prepareForSave of OlePurchaseOrderReopenDocument");
72          }
73          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event);
74          super.prepareForSave(event);
75      }
76  
77  
78      /**
79       * This method is overriden to populate bib info in Ole Purchase Order Reopen Document
80       *
81       * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#processAfterRetrieve()
82       */
83      @Override
84      public void processAfterRetrieve() {
85          if (LOG.isDebugEnabled()) {
86              LOG.debug("Inside processAfterRetrieve of OlePurchaseOrderReopenDocument");
87          }
88          if (this.getVendorAliasName() == null) {
89              populateVendorAliasName();
90          }
91          SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this);
92  
93      }
94  
95      @Override
96      public List getItemsActiveOnly() {
97          if (LOG.isDebugEnabled()) {
98              LOG.debug("Inside getItemsActiveOnly of OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
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 OlePurchaseOrderReopenDocument");
159         }
160         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorCreateURL();
161     }
162 
163     public String getBibSearchURL() {
164         LOG.debug("Inside getBibSearchURL of OlePurchaseOrderReopenDocument");
165         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibSearchURL();
166     }
167 
168 
169     /**
170      * This method is used to get the Instanceeditor url from propertie file
171      *
172      * @return Instanceeditor url string
173      */
174     public String getInstanceEditorURL() {
175         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getInstanceEditorURL();
176     }
177 
178     /**
179      * This method is used to get the bibedtior edit url from propertie file
180      *
181      * @return Bibeditor edit url string
182      */
183     public String getBibeditorEditURL() {
184         if (LOG.isDebugEnabled()) {
185             LOG.debug("Inside getBibeditorEditURL of OlePurchaseOrderReopenDocument");
186         }
187         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorEditURL();
188     }
189 
190     /**
191      * This method is used to get the bibedtior view url from propertie file
192      *
193      * @return Bibeditor view url string
194      */
195     public String getBibeditorViewURL() {
196         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorViewURL();
197     }
198 
199     /**
200      * This method is used to get the directory path where the marc xml files need to be created
201      *
202      * @return Directory path string
203      */
204     public String getMarcXMLFileDirLocation() throws Exception {
205         if (LOG.isDebugEnabled()) {
206             LOG.debug("Inside getMarcXMLFileDirLocation of OlePurchaseOrderReopenDocument");
207         }
208         return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getMarcXMLFileDirLocation();
209     }
210 
211 
212     public String getVendorPoNumber() {
213         return vendorPoNumber;
214     }
215 
216     public void setVendorPoNumber(String vendorPoNumber) {
217         this.vendorPoNumber = vendorPoNumber;
218     }
219 
220     /**
221      * This method is used to check the status of the document for displaying view and edit buttons in line item
222      *
223      * @return boolean
224      */
225     public boolean getIsSaved() {
226         if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
227             return true;
228         }
229         return false;
230     }
231 
232     public boolean getIsATypeOfRCVGDoc() {
233         return false;
234     }
235 
236     public boolean getIsATypeOfCORRDoc() {
237         return false;
238     }
239 
240     private void populateVendorAliasName() {
241         Map vendorDetailMap = new HashMap();
242         vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
243         vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
244         List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
245         if (vendorDetailList != null && vendorDetailList.size() > 0) {
246             this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
247         }
248     }
249 }