View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.validation;
18  
19  import org.kuali.rice.kew.rule.RuleBaseValues;
20  import org.kuali.rice.kew.rule.RuleDelegation;
21  import org.kuali.rice.krad.UserSession;
22  
23  
24  /**
25   * The RuleValidationContext represents the context under which to validate a Rule which is being entered
26   * into the system, be it through the web-based Rule GUI or via an XML import.
27   * 
28   * The ruleAuthor is the UserSession of the individual who is entering or editing the rule.  This may
29   * be <code>null</code> if the rule is being run through validation from the context of an XML rule
30   * import.
31   * 
32   * The RuleDelegation represents the pointer to the rule from it's parent rule's RuleResponsibility.
33   * This will be <code>null</code> if the rule being entered is not a delegation rule.
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public class RuleValidationContext {
38  
39  	private final RuleBaseValues rule;
40  	private final RuleDelegation ruleDelegation;
41  	private final UserSession ruleAuthor;
42  
43  	/**
44  	 * Construct a RuleValidationContext under which to validate a rule.  The rule must be non-null, the delegation
45  	 * and author can be <code>null</code> given the circumstances defined in the description of this class.
46  	 */
47  	public RuleValidationContext(RuleBaseValues rule, RuleDelegation ruleDelegation, UserSession ruleAuthor) {
48  		this.ruleAuthor = ruleAuthor;
49  		this.rule = rule;
50  		this.ruleDelegation = ruleDelegation;
51  	}
52  
53  	/**
54  	 * Retrieve the rule which is being validated.
55  	 */
56  	public RuleBaseValues getRule() {
57  		return rule;
58  	}
59  
60  	/**
61  	 * Retrieve the UserSession of the individual entering the rule into the system.  May be null in the
62  	 * case of an XML rule import. 
63  	 */
64  	public UserSession getRuleAuthor() {
65  		return ruleAuthor;
66  	}
67  
68  	/**
69  	 * Retrieve the RuleDelegation representing the parent of the rule being validated.  If the rule is
70  	 * not a delegation rule, then this will return null;
71  	 */
72  	public RuleDelegation getRuleDelegation() {
73  		return ruleDelegation;
74  	}
75  	
76  }