001 /**
002 * Copyright 2005-2014 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.kew.rule;
017
018 import org.apache.commons.lang.ObjectUtils;
019 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
020
021 import javax.persistence.Column;
022 import javax.persistence.Entity;
023 import javax.persistence.FetchType;
024 import javax.persistence.GeneratedValue;
025 import javax.persistence.Id;
026 import javax.persistence.JoinColumn;
027 import javax.persistence.ManyToOne;
028 import javax.persistence.Table;
029 import javax.persistence.Version;
030 import java.io.Serializable;
031
032
033 /**
034 * The value of an extension to a rule. Essentially contains a
035 * key-value pair containing the key of the extension data and
036 * it's value.
037 *
038 * @see RuleBaseValues
039 * @see RuleExtensionBo
040 *
041 * @author Kuali Rice Team (rice.collab@kuali.org)
042 */
043 @Entity
044 @Table(name="KREW_RULE_EXT_VAL_T")
045 public class RuleExtensionValue implements Serializable {
046
047 private static final long serialVersionUID = 8909789087052290261L;
048 @Id
049 @PortableSequenceGenerator(name="KREW_RTE_TMPL_S")
050 @GeneratedValue(generator="KREW_RTE_TMPL_S")
051 @Column(name="RULE_EXT_VAL_ID")
052 private String ruleExtensionValueId;
053
054 @Column(name="VAL")
055 private String value;
056 @Column(name="KEY_CD")
057 private String key;
058 @Version
059 @Column(name="VER_NBR")
060 private Integer lockVerNbr;
061
062 @ManyToOne(fetch=FetchType.EAGER)
063 @JoinColumn(name="RULE_EXT_ID", nullable = false)
064 private RuleExtensionBo extension;
065
066 public RuleExtensionValue() {
067 }
068
069 public RuleExtensionValue(String key, String value) {
070 this.key = key;
071 this.value = value;
072 }
073
074 public RuleExtensionBo getExtension() {
075 return extension;
076 }
077 public void setExtension(RuleExtensionBo extension) {
078 this.extension = extension;
079 }
080 public Integer getLockVerNbr() {
081 return lockVerNbr;
082 }
083 public void setLockVerNbr(Integer lockVerNbr) {
084 this.lockVerNbr = lockVerNbr;
085 }
086 public String getKey() {
087 return key;
088 }
089 public void setKey(String key) {
090 this.key = key;
091 }
092 public String getRuleExtensionValueId() {
093 return ruleExtensionValueId;
094 }
095 public void setRuleExtensionValueId(String ruleExtensionValueId) {
096 this.ruleExtensionValueId = ruleExtensionValueId;
097 }
098 public String getValue() {
099 return value;
100 }
101 public void setValue(String value) {
102 this.value = value;
103 }
104
105 public boolean equals(Object o) {
106 if (o == null) return false;
107 if (!(o instanceof RuleExtensionValue)) return false;
108 RuleExtensionValue pred = (RuleExtensionValue) o;
109 return ObjectUtils.equals(key, pred.key) && ObjectUtils.equals(value, pred.value);
110 }
111
112 public String toString() {
113 return "[RuleExtensionValue:"
114 + " ruleExtensionValueId=" + ruleExtensionValueId
115 + ", value=" + value
116 + ", key=" + key
117 + ", lockVerNbr=" + lockVerNbr
118 + "]";
119
120 }
121 }