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