001/*
002 * Copyright 2008-2009 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.module.purap.document.validation.impl;
017
018import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
019import org.kuali.ole.module.purap.document.service.PurapService;
020import org.kuali.ole.module.purap.document.service.PurchaseOrderService;
021import org.kuali.ole.sys.OLEConstants;
022import org.kuali.ole.sys.context.SpringContext;
023import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
024
025public class PurchaseOrderAmendmentRequiresAccountValidationBranchingValidation extends PurchaseOrderRequiresAccountValidationBranchingValidation {
026
027    protected PurchaseOrderService purchaseOrderService;
028    protected PurapService purapService;
029
030    @Override
031    protected String determineBranch(AttributedDocumentEvent event) {
032        PurchaseOrderDocument document = (PurchaseOrderDocument) event.getDocument();
033        // If a new unordered item has been added to the purchase order, this is due to Receiving Line document,
034        // and items should not have account validation performed initially, until new unordered items review.
035        if (SpringContext.getBean(PurchaseOrderService.class).hasNewUnorderedItem(document) &&
036                !SpringContext.getBean(PurapService.class).isDocumentStoppedInRouteNode(document, "New Unordered Items")) {
037            return OLEConstants.EMPTY_STRING;
038        } else {
039            return super.determineBranch(event);
040        }
041    }
042
043    public PurchaseOrderService getPurchaseOrderService() {
044        return purchaseOrderService;
045    }
046
047    public void setPurchaseOrderService(PurchaseOrderService purchaseOrderService) {
048        this.purchaseOrderService = purchaseOrderService;
049    }
050
051    public PurapService getPurapService() {
052        return purapService;
053    }
054
055    public void setPurapService(PurapService purapService) {
056        this.purapService = purapService;
057    }
058
059
060}