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