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