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.PurchaseOrderRemoveHoldDocument; 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 * This class is the document class for Ole Purchase Order RemoveHold Document 032 */ 033public class OlePurchaseOrderRemoveHoldDocument extends PurchaseOrderRemoveHoldDocument { 034 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OlePurchaseOrderRemoveHoldDocument.class); 035 /** 036 * This method is overridden to populate newly added ole fields from requisition into Ole Purchase Order RemoveHold Document. 037 * 038 * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#populatePurchaseOrderFromRequisition(org.kuali.ole.module.purap.document.RequisitionDocument) 039 */ 040 private String vendorPoNumber; 041 042 public String getVendorPoNumber() { 043 return vendorPoNumber; 044 } 045 046 public void setVendorPoNumber(String vendorPoNumber) { 047 this.vendorPoNumber = vendorPoNumber; 048 } 049 050 051 @Override 052 public void populatePurchaseOrderFromRequisition(RequisitionDocument requisitionDocument) { 053 054 LOG.debug("Inside populatePurchaseOrderFromRequisition of OlePurchaseOrderRemoveHoldDocument"); 055 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).populatePurchaseOrderFromRequisition(this, requisitionDocument); 056 } 057 058 /** 059 * This method is overriden to populate bib info in Ole Purchase Order RemoveHold Document 060 * 061 * @see org.kuali.ole.module.purap.document.PurchaseOrderDocument#prepareForSave(org.kuali.rice.krad.rule.event.KualiDocumentEvent) 062 */ 063 @Override 064 public void prepareForSave(KualiDocumentEvent event) { 065 066 LOG.debug("Inside prepareForSave of OlePurchaseOrderRemoveHoldDocument"); 067 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).prepareForSave(this, event); 068 super.prepareForSave(event); 069 070 } 071 072 /** 073 * This method is overriden to populate bib info in Ole Purchase Order Retransmit Document 074 * 075 * @see org.kuali.ole.module.purap.document.PurchasingAccountsPayableDocumentBase#processAfterRetrieve() 076 */ 077 @Override 078 public void processAfterRetrieve() { 079 LOG.debug("Inside processAfterRetrieve of OlePurchaseOrderRemoveHoldDocument"); 080 if (this.getVendorAliasName() == null) { 081 populateVendorAliasName(); 082 } 083 SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).processAfterRetrieve(this); 084 } 085 086 @Override 087 public List getItemsActiveOnly() { 088 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnly(this); 089 } 090 091 /** 092 * Gets the active items in this Purchase Order, and sets up the alternate amount for GL entry creation. 093 * 094 * @return the list of all active items in this Purchase Order. 095 */ 096 @Override 097 public List getItemsActiveOnlySetupAlternateAmount() { 098 return SpringContext.getBean(OlePurchaseOrderDocumentHelperService.class).getItemsActiveOnlySetupAlternateAmount(this); 099 } 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}