001    /**
002     * Copyright 2005-2012 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    package org.kuali.rice.kns.rules;
017    
018    import org.kuali.rice.krad.document.Document;
019    import org.kuali.rice.kns.document.MaintenanceDocument;
020    import org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent;
021    
022    /**
023     * Rule event interface for implementing business rules against a <code>MaintenanceDocument</code>
024     *
025     * @author Kuali Rice Team (rice.collab@kuali.org)
026     */
027    public interface MaintenanceDocumentRule {
028    
029        /**
030         * Runs all business rules needed prior to saving. This includes both common rules for all maintenance documents,
031         * plus class-specific business rules.
032         *
033         * Will only return false if it fails the isValidForSave() test. Otherwise, it will always return positive
034         * regardless of the outcome of the business rules. However, any error messages resulting from the business rules
035         * will still be populated, for display to the consumer of this service.
036         *
037         * @see org.kuali.rice.krad.rules.rule.SaveDocumentRule#processSaveDocument(org.kuali.rice.krad.document.Document)
038         */
039        public abstract boolean processSaveDocument(Document document);
040    
041        /**
042         * Runs all business rules needed prior to routing. This includes both common rules for all maintenance documents,
043         * plus class-specific business rules.
044         *
045         * Will return false if any business rule fails, or if the document is in an invalid state, and not routable (see
046         * isDocumentValidForRouting()).
047         *
048         * @see org.kuali.rice.krad.rules.rule.RouteDocumentRule#processRouteDocument(org.kuali.rice.krad.document.Document)
049         */
050        public abstract boolean processRouteDocument(Document document);
051    
052        /**
053         * Runs all business rules needed prior to approving. This includes both common rules for all maintenance documents,
054         * plus class-specific business rules.
055         *
056         * Will return false if any business rule fails, or if the document is in an invalid state, and not approvable (see
057         * isDocumentValidForApproving()).
058         *
059         * @see org.kuali.rice.krad.rules.rule.ApproveDocumentRule#processApproveDocument(org.kuali.rice.krad.rules.rule.event.ApproveDocumentEvent)
060         */
061        public abstract boolean processApproveDocument(ApproveDocumentEvent approveEvent);
062    
063        /**
064         * Sets the convenience objects like newAccount and oldAccount, so you have short and easy handles to the new and
065         * old objects contained in the maintenance document.
066         *
067         * It also calls the BusinessObjectBase.refresh(), which will attempt to load all sub-objects from the DB by their
068         * primary keys, if available.
069         *
070         * @param document - the maintenanceDocument being evaluated
071         */
072        public void setupBaseConvenienceObjects(MaintenanceDocument document);
073    
074        /**
075         * Should always be overriden if a subclass is created.
076         *
077         * The goal for this is to cast the oldBo and newBo into the correct types of the subclass.
078         */
079        public void setupConvenienceObjects();
080    }