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