View Javadoc

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