View Javadoc

1   /**
2    * Copyright 2005-2013 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.kew.rule;
17  
18  import org.apache.commons.lang.ObjectUtils;
19  import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
20  import org.kuali.rice.kew.service.KEWServiceLocator;
21  
22  import javax.persistence.CascadeType;
23  import javax.persistence.Column;
24  import javax.persistence.Entity;
25  import javax.persistence.FetchType;
26  import javax.persistence.GeneratedValue;
27  import javax.persistence.Id;
28  import javax.persistence.JoinColumn;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.Table;
31  import javax.persistence.Version;
32  import java.io.Serializable;
33  
34  
35  /**
36   * The value of an extension to a rule.  Essentially contains a
37   * key-value pair containing the key of the extension data and
38   * it's value.
39   * 
40   * @see RuleBaseValues
41   * @see RuleExtensionBo
42   *
43   * @author Kuali Rice Team (rice.collab@kuali.org)
44   */
45  @Entity
46  @Table(name="KREW_RULE_EXT_VAL_T")
47  //@Sequence(name="KREW_RTE_TMPL_S", property="ruleExtensionValueId")
48  public class RuleExtensionValue implements Serializable {
49  
50  	private static final long serialVersionUID = 8909789087052290261L;
51  	@Id
52  	@GeneratedValue(generator="KREW_RTE_TMPL_S")
53  	@Column(name="RULE_EXT_VAL_ID")
54  	private String ruleExtensionValueId;
55      @Column(name="RULE_EXT_ID", insertable=false, updatable=false)
56  	private String ruleExtensionId;
57      @Column(name="VAL")
58  	private String value;
59      @Column(name="KEY_CD")
60  	private String key;
61      @Version
62  	@Column(name="VER_NBR")
63  	private Integer lockVerNbr;
64      
65      @ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
66  	@JoinColumn(name="RULE_EXT_ID")
67  	private RuleExtensionBo extension;
68      
69      public RuleExtensionValue() {
70      }
71      
72      public RuleExtensionValue(String key, String value) {
73          this.key = key;
74          this.value = value;
75      }
76      
77      //@PrePersist
78      public void beforeInsert(){
79          OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
80      }
81      
82      public RuleExtensionBo getExtension() {
83          return extension;
84      }
85      public void setExtension(RuleExtensionBo extension) {
86          this.extension = extension;
87      }
88      public Integer getLockVerNbr() {
89          return lockVerNbr;
90      }
91      public void setLockVerNbr(Integer lockVerNbr) {
92          this.lockVerNbr = lockVerNbr;
93      }
94      public String getKey() {
95          return key;
96      }
97      public void setKey(String key) {
98          this.key = key;
99      }
100     public String getRuleExtensionId() {
101         return ruleExtensionId;
102     }
103     public void setRuleExtensionId(String ruleExtensionId) {
104         this.ruleExtensionId = ruleExtensionId;
105     }
106     public String getRuleExtensionValueId() {
107         return ruleExtensionValueId;
108     }
109     public void setRuleExtensionValueId(String ruleExtensionValueId) {
110         this.ruleExtensionValueId = ruleExtensionValueId;
111     }
112     public String getValue() {
113         return value;
114     }
115     public void setValue(String value) {
116         this.value = value;
117     }
118 
119     public boolean equals(Object o) {
120         if (o == null) return false;
121         if (!(o instanceof RuleExtensionValue)) return false;
122         RuleExtensionValue pred = (RuleExtensionValue) o;
123         return ObjectUtils.equals(key, pred.key) && ObjectUtils.equals(value, pred.value);
124     }
125 
126     public String toString() {
127         return "[RuleExtensionValue:"
128                +  " ruleExtensionValueId=" + ruleExtensionValueId
129                + ", ruleExtensionId=" + ruleExtensionId
130                + ", value=" + value
131                + ", key=" + key
132                + ", lockVerNbr=" + lockVerNbr
133                + "]";
134             
135     }
136 }