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