001/*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.select.document;
017
018import org.kuali.ole.module.purap.document.PurchaseOrderPaymentHoldDocument;
019import org.kuali.ole.module.purap.document.RequisitionDocument;
020import org.kuali.ole.select.document.service.OlePurchaseOrderDocumentHelperService;
021import org.kuali.ole.sys.OLEConstants;
022import org.kuali.ole.sys.context.SpringContext;
023import org.kuali.ole.vnd.businessobject.VendorAlias;
024import org.kuali.rice.krad.rules.rule.event.KualiDocumentEvent;
025
026import java.util.HashMap;
027import java.util.List;
028import java.util.Map;
029
030/**
031 * Purchase Order Payment Hold Document
032 */
033public class OlePurchaseOrderPaymentHoldDocument extends PurchaseOrderPaymentHoldDocument {
034    protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderPaymentHoldDocument.class);
035    private String vendorPoNumber;
036
037    public String getVendorPoNumber() {
038        return vendorPoNumber;
039    }
040
041    public void setVendorPoNumber(String vendorPoNumber) {
042        this.vendorPoNumber = vendorPoNumber;
043    }
044
045    /**
046     * Default constructor.
047     */
048    public OlePurchaseOrderPaymentHoldDocument() {
049        super();
050    }
051
052    /**
053     * This method is overridden to populate newly added ole fields from requisition into Ole Purchase Order Payment Hold Document.
054     *
055     * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#populatePurchaseOrderFromRequisition(org.kuali.ole.module.purap.document.RequisitionDocument)
056     */
057    @Override
058    public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) {
059        LOG.debug("Inside populatePurchaseOrderFromRequisition of OlePurchaseOrderPaymentHoldDocument");
060        SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument);
061        LOG.debug("Leaving populatePurchaseOrderFromRequisition of OlePurchaseOrderPaymentHoldDocument");
062    }
063
064    /**
065     * This method is overriden to populate bib info in Ole Purchase Order  Payment Hold Document.
066     *
067     * @see org.kuali.ole.module.purap.document.PurchaseOrderCloseDocument#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
068     */
069    @Override
070    public void prepareForSave(KualiDocumentEvent event) {
071        LOG.debug("Inside prepareForSave of OlePurchaseOrderPaymentHoldDocument");
072        SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event);
073        super.prepareForSave(event);
074    }
075
076    /**
077     * This method is overriden to populate bib info in Ole Purchase Order  Payment Hold Document.
078     *
079     * @see org.kuali.ole.module.purap.document.PurchaseOrderCloseDocument#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent)
080     */
081    @Override
082    public void processAfterRetrieve() {
083        LOG.debug("Inside processAfterRetrieve of OlePurchaseOrderPaymentHoldDocument");
084        if (this.getVendorAliasName() == null) {
085            populateVendorAliasName();
086        }
087        SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this);
088        LOG.debug("Leaving processAfterRetrieve of OlePurchaseOrderPaymentHoldDocument");
089    }
090
091    @Override
092    public List getItemsActiveOnly() {
093        LOG.debug("Inside getItemsActiveOnly of OlePurchaseOrderPaymentHoldDocument");
094        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnly(this);
095    }
096
097    /**
098     * Gets the active items in this Purchase Order, and sets up the alternate amount for GL entry creation.
099     *
100     * @return the list of all active items in this Purchase Order.
101     */
102    @Override
103    public List getItemsActiveOnlySetupAlternateAmount() {
104        LOG.debug("Inside getItemsActiveOnlySetupAlternateAmount of OlePurchaseOrderPaymentHoldDocument");
105        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnlySetupAlternateAmount(this);
106    }
107
108    @Override
109    public boolean getAdditionalChargesExist() {
110        LOG.debug("Inside getAdditionalChargesExist of OlePurchaseOrderPaymentHoldDocument");
111        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getAdditionalChargesExist(this);
112    }
113
114    /**
115     * This method returns if Purchase Order Document created is in Final Status
116     *
117     * @return
118     */
119    public boolean getIsFinalReqs() {
120        LOG.debug("Inside getIsFinalReqs of OlePurchaseOrderPaymentHoldDocument");
121
122        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsFinalReqs(this);
123    }
124
125    public boolean getIsSplitPO() {
126        LOG.debug("Inside getIsSplitPO of OlePurchaseOrderPaymentHoldDocument");
127        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsSplitPO(this);
128    }
129
130    public boolean getIsReOpenPO() {
131        LOG.debug("Inside getIsReOpenPO of OlePurchaseOrderPaymentHoldDocument");
132        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getIsReOpenPO(this);
133    }
134
135    /**
136     * This method is used to get the bibedtior creat url from propertie file
137     *
138     * @return Bibeditor creat url string
139     */
140    public String getBibeditorCreateURL() {
141        LOG.debug("Inside getBibeditorCreateURL of OlePurchaseOrderPaymentHoldDocument");
142        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorCreateURL();
143    }
144
145    public String getBibSearchURL() {
146        LOG.debug("Inside getBibSearchURL of OlePurchaseOrderPaymentHoldDocument");
147        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibSearchURL();
148    }
149
150    /**
151     * This method is used to get the bibedtior edit url from propertie file
152     *
153     * @return Bibeditor edit url string
154     */
155    public String getBibeditorEditURL() {
156        LOG.debug("Inside getBibeditorEditURL of OlePurchaseOrderPaymentHoldDocument");
157        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorEditURL();
158    }
159
160    /**
161     * This method is used to get the dublinedtior edit url from propertie file
162     *
163     * @return Dublineditor edit url string
164     */
165    public String getDublinEditorEditURL() {
166        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorEditURL();
167    }
168    /**
169     * This method is used to get the Instanceeditor url from propertie file
170     *
171     * @return Instanceeditor url string
172     */
173    public String getInstanceEditorURL() {
174        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getInstanceEditorURL();
175    }
176
177    /**
178     * This method is used to get the bibedtior view url from propertie file
179     *
180     * @return Bibeditor view url string
181     */
182    public String getBibeditorViewURL() {
183        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getBibeditorViewURL();
184    }
185
186    /**
187     * This method is used to get the dublinedtior view url from propertie file
188     *
189     * @return dublineditor view url string
190     */
191    public String getDublinEditorViewURL() {
192        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getDublinEditorViewURL();
193    }
194    /**
195     * This method is used to get the directory path where the marc xml files need to be created
196     *
197     * @return Directory path string
198     */
199    public String getMarcXMLFileDirLocation() throws Exception {
200        LOG.debug("Inside getMarcXMLFileDirLocation of OlePurchaseOrderPaymentHoldDocument");
201        return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getMarcXMLFileDirLocation();
202    }
203
204    /**
205     * This method is used to check the status of the document for displaying view and edit buttons in line item
206     *
207     * @return boolean
208     */
209    public boolean getIsSaved() {
210        if (this.getDocumentHeader().getWorkflowDocument().isSaved() || this.getDocumentHeader().getWorkflowDocument().isInitiated()) {
211            return true;
212        }
213        return false;
214    }
215
216    public boolean getIsATypeOfRCVGDoc() {
217        return false;
218    }
219
220    public boolean getIsATypeOfCORRDoc() {
221        return false;
222    }
223
224    private void populateVendorAliasName() {
225        Map vendorDetailMap = new HashMap();
226        vendorDetailMap.put(OLEConstants.VENDOR_HEADER_IDENTIFIER, this.getVendorHeaderGeneratedIdentifier());
227        vendorDetailMap.put(OLEConstants.VENDOR_DETAIL_IDENTIFIER, this.getVendorDetailAssignedIdentifier());
228        List<VendorAlias> vendorDetailList = (List) getBusinessObjectService().findMatching(VendorAlias.class, vendorDetailMap);
229        if (vendorDetailList != null && vendorDetailList.size() > 0) {
230            this.setVendorAliasName(vendorDetailList.get(0).getVendorAliasName());
231        }
232    }
233}