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