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     */
016    
017    package org.kuali.kfs.module.purap.document;
018    
019    import java.util.List;
020    
021    import org.kuali.kfs.module.purap.PurapConstants;
022    import org.kuali.kfs.module.purap.document.service.PurapService;
023    import org.kuali.kfs.module.purap.document.service.PurchaseOrderService;
024    import org.kuali.kfs.sys.context.SpringContext;
025    import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
026    import org.kuali.rice.kns.rule.event.KualiDocumentEvent;
027    
028    /**
029     * Purchase Order Remove Payment Hold Document
030     */
031    public class PurchaseOrderRemoveHoldDocument extends PurchaseOrderDocument {
032        protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurchaseOrderRemoveHoldDocument.class);
033    
034        /**
035         * Default constructor.
036         */
037        public PurchaseOrderRemoveHoldDocument() {
038            super();
039        }
040    
041        /**
042         * General Ledger pending entries are not created for this document. Overriding this method so that entries are not created.
043         * 
044         * @see org.kuali.kfs.module.purap.document.PurchaseOrderDocument#customPrepareForSave(org.kuali.rice.kns.rule.event.KualiDocumentEvent)
045         */
046        @Override
047        public void customPrepareForSave(KualiDocumentEvent event) {
048            // do not set the accounts in sourceAccountingLines; this document should not create GL entries
049        }
050    
051        @Override
052        public List<Long> getWorkflowEngineDocumentIdsToLock() {
053            return super.getWorkflowEngineDocumentIdsToLock();
054        }
055    
056        /**
057         * When Purchase Order Remove Payment Hold document has been Processed through Workflow, the PO status changes to "OPEN".
058         * 
059         * @see org.kuali.kfs.module.purap.document.PurchaseOrderDocument#doRouteStatusChange()
060         */
061        @Override
062        public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) {
063            super.doRouteStatusChange(statusChangeEvent);
064    
065            // DOCUMENT PROCESSED
066            if (getDocumentHeader().getWorkflowDocument().stateIsProcessed()) {
067                SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForApprovedPODocuments(this);
068    
069                // set purap status
070                SpringContext.getBean(PurapService.class).updateStatus(this, PurapConstants.PurchaseOrderStatuses.OPEN);
071            }
072            // DOCUMENT DISAPPROVED
073            else if (getDocumentHeader().getWorkflowDocument().stateIsDisapproved()) {
074                SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForDisapprovedRemoveHoldPODocuments(this);
075            }
076            // DOCUMENT CANCELED
077            else if (getDocumentHeader().getWorkflowDocument().stateIsCanceled()) {
078                SpringContext.getBean(PurchaseOrderService.class).setCurrentAndPendingIndicatorsForCancelledRemoveHoldPODocuments(this);
079            }
080        }
081    
082    }