001 /*
002 * Copyright 2005-2008 The Kuali Foundation
003 *
004 *
005 * Licensed under the Educational Community License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.opensource.org/licenses/ecl2.php
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.kuali.rice.kew.validation;
018
019 import org.kuali.rice.kew.rule.RuleBaseValues;
020 import org.kuali.rice.kew.rule.RuleDelegation;
021 import org.kuali.rice.kns.UserSession;
022
023
024 /**
025 * The RuleValidationContext represents the context under which to validate a Rule which is being entered
026 * into the system, be it through the web-based Rule GUI or via an XML import.
027 *
028 * The ruleAuthor is the UserSession of the individual who is entering or editing the rule. This may
029 * be <code>null</code> if the rule is being run through validation from the context of an XML rule
030 * import.
031 *
032 * The RuleDelegation represents the pointer to the rule from it's parent rule's RuleResponsibility.
033 * This will be <code>null</code> if the rule being entered is not a delegation rule.
034 *
035 * @author Kuali Rice Team (rice.collab@kuali.org)
036 */
037 public class RuleValidationContext {
038
039 private final RuleBaseValues rule;
040 private final RuleDelegation ruleDelegation;
041 private final UserSession ruleAuthor;
042
043 /**
044 * Construct a RuleValidationContext under which to validate a rule. The rule must be non-null, the delegation
045 * and author can be <code>null</code> given the circumstances defined in the description of this class.
046 */
047 public RuleValidationContext(RuleBaseValues rule, RuleDelegation ruleDelegation, UserSession ruleAuthor) {
048 this.ruleAuthor = ruleAuthor;
049 this.rule = rule;
050 this.ruleDelegation = ruleDelegation;
051 }
052
053 /**
054 * Retrieve the rule which is being validated.
055 */
056 public RuleBaseValues getRule() {
057 return rule;
058 }
059
060 /**
061 * Retrieve the UserSession of the individual entering the rule into the system. May be null in the
062 * case of an XML rule import.
063 */
064 public UserSession getRuleAuthor() {
065 return ruleAuthor;
066 }
067
068 /**
069 * Retrieve the RuleDelegation representing the parent of the rule being validated. If the rule is
070 * not a delegation rule, then this will return null;
071 */
072 public RuleDelegation getRuleDelegation() {
073 return ruleDelegation;
074 }
075
076 }