1 /** 2 * Copyright 2005-2014 The Kuali Foundation 3 * 4 * Licensed under the Educational Community License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.opensource.org/licenses/ecl2.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.kuali.rice.krms.api.engine; 17 18 import java.util.Map; 19 import java.util.Set; 20 21 /** 22 * The ExecutionEnvironment manages contextual information which is made available to 23 * different components of the rules engine during execution. Facts can be retrieved 24 * from and published to the environment. It also provides a reference to the 25 * {@link EngineResults} or tracking engine activity and returning values back to 26 * the client of the rules engine. 27 * 28 * @author Kuali Rice Team (rice.collab@kuali.org) 29 * 30 */ 31 public interface ExecutionEnvironment { 32 33 /** 34 * Returns the selection criteria that was used to initialize the environment. 35 * 36 * @return the selection criteria for this environment 37 */ 38 public SelectionCriteria getSelectionCriteria(); 39 40 /** 41 * Returns an immutable Map of facts available within this environment. 42 * 43 * @return the facts in this environment 44 */ 45 public Map<Term, Object> getFacts(); 46 47 /** 48 * Publishes a new fact 49 * 50 * @param factName name of the fact to publish 51 * @param factValue value of the fact to publish 52 * // TODO: we don't support updating facts, refactor this method 53 * @return true if an existing fact was updated, false if this was a new fact 54 */ 55 public boolean publishFact(Term factName, Object factValue); 56 57 /** 58 * Add a {@link TermResolver} 59 * @param termResolver 60 */ 61 public void addTermResolver(TermResolver<?> termResolver); 62 63 /** 64 * Resolve 65 * @param term {@link Term} 66 * @param caller 67 * @return <T> T 68 * @throws {@link TermResolutionException} 69 */ 70 public <T> T resolveTerm(Term term, Object caller) throws TermResolutionException; 71 72 /** 73 * Return a set of Term for the given value 74 * @param caller 75 * @return Set<Term> 76 */ 77 public Set<Term> getTermsForCaller(Object caller); 78 79 /** 80 * Return the {@link ExecutionOptions} 81 * @return {@link ExecutionOptions} 82 */ 83 public ExecutionOptions getExecutionOptions(); 84 85 /** 86 * Return the {@link EngineResults} 87 * @return {@link EngineResults} 88 */ 89 public EngineResults getEngineResults(); 90 91 }