001/**
002 * Copyright 2005-2018 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.rice.krad.service;
017
018import org.kuali.rice.krad.document.Document;
019import org.kuali.rice.krad.rules.rule.BusinessRule;
020import org.kuali.rice.krad.rules.rule.event.AddAdHocRoutePersonEvent;
021import org.kuali.rice.krad.rules.rule.event.AddAdHocRouteWorkgroupEvent;
022import org.kuali.rice.krad.rules.rule.event.DocumentEvent;
023
024import java.util.List;
025
026/**
027 * Defines the interface to the business-rule evaluation service, used to evauluate document-type-specific business
028 * rules using document-related events to drive the process.
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public interface KualiRuleService {
033
034    /**
035     * Retrieves and instantiates the businessRulesClass associated with the event's document type (if any), and calls
036     * the appropriate process* method of that businessRule for handling the given event type.
037     *
038     * <p>This is a helper method that takes in the generic DocumentEvent class and determines which event call to
039     * make.</p>
040     *
041     * @param event
042     * @return true if no rule is applied, or all rules are applied successfully, false otherwise
043     */
044    boolean applyRules(DocumentEvent event);
045
046    /**
047     * Builds a list containing ad hoc route person events appropriate for the context.
048     *
049     * @param document
050     * @return List
051     */
052    List<AddAdHocRoutePersonEvent> generateAdHocRoutePersonEvents(Document document);
053
054    /**
055     * Builds a list containing ad hoc route workgroup events appropriate for the context.
056     *
057     * @param document
058     * @return List
059     */
060    List<AddAdHocRouteWorkgroupEvent> generateAdHocRouteWorkgroupEvents(Document document);
061
062    /**
063     * Allows code in actions or business objects to directly access rule methods in the class.
064     *
065     * @param document
066     * @param ruleInterface
067     * @return BusinessRule
068     */
069    BusinessRule getBusinessRulesInstance(Document document, Class<? extends BusinessRule> ruleInterface);
070}