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.kuali.rice.core.framework.persistence.jpa.OrmUtils;
19  import org.kuali.rice.kew.api.rule.RuleTemplateOptionContract;
20  import org.kuali.rice.kew.rule.bo.RuleTemplateBo;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  import org.kuali.rice.krad.bo.BusinessObjectBase;
23  import org.kuali.rice.krad.service.KRADServiceLocator;
24  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
25  
26  import javax.persistence.Column;
27  import javax.persistence.Entity;
28  import javax.persistence.FetchType;
29  import javax.persistence.GeneratedValue;
30  import javax.persistence.Id;
31  import javax.persistence.JoinColumn;
32  import javax.persistence.ManyToOne;
33  import javax.persistence.Table;
34  import javax.persistence.Version;
35  
36  /**
37   * Defines default values and other preset information for a {@link RuleBaseValues} 
38   * which is based off of the associated {@link org.kuali.rice.kew.rule.bo.RuleTemplateBo}.
39   * 
40   * @see RuleBaseValues
41   * @see org.kuali.rice.kew.rule.bo.RuleTemplateBo
42   *
43   * @author Kuali Rice Team (rice.collab@kuali.org)
44   */
45  @Entity
46  @Table(name="KREW_RULE_TMPL_OPTN_T")
47  //@Sequence(name="KREW_RULE_TMPL_OPTN_S", property="id")
48  public class RuleTemplateOptionBo extends BusinessObjectBase implements RuleTemplateOptionContract {
49  
50  	private static final long serialVersionUID = 8913119135197149224L;
51  	@Id
52  	@GeneratedValue(generator="KREW_RULE_TMPL_OPTN_S")
53  	@Column(name="RULE_TMPL_OPTN_ID")
54  	private String id;
55      @Column(name="RULE_TMPL_ID", insertable=false, updatable=false)
56  	private String ruleTemplateId;
57      @Column(name="KEY_CD")
58  	private String code;
59      @Column(name="VAL")
60  	private String value;
61      @Version
62  	@Column(name="VER_NBR")
63  	private Long versionNumber;
64  
65      @ManyToOne(fetch=FetchType.EAGER)
66  	@JoinColumn(name="RULE_TMPL_ID")
67  	private RuleTemplateBo ruleTemplate;
68      
69      public RuleTemplateOptionBo(){}
70      
71      public RuleTemplateOptionBo(String key, String value){
72          this.code = key;
73          this.value = value;
74      }
75  
76      //@PrePersist
77      public void beforeInsert(){
78          OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
79      }
80      @Override
81      public String getCode() {
82          return code;
83      }
84  
85      public void setCode(String code) {
86          this.code = code;
87      }
88      @Override
89      public Long getVersionNumber() {
90          return versionNumber;
91      }
92  
93      public void setVersionNumber(Long versionNumber) {
94          this.versionNumber = versionNumber;
95      }
96  
97      public RuleTemplateBo getRuleTemplate() {
98          return ruleTemplate;
99      }
100 
101     public void setRuleTemplate(RuleTemplateBo ruleTemplate) {
102         this.ruleTemplate = ruleTemplate;
103     }
104     @Override
105     public String getRuleTemplateId() {
106         return ruleTemplateId;
107     }
108 
109     public void setRuleTemplateId(String ruleTemplateId) {
110         this.ruleTemplateId = ruleTemplateId;
111     }
112     @Override
113     public String getId() {
114         return id;
115     }
116 
117     public void setId(String id) {
118         this.id = id;
119     }
120 
121     @Override
122     public String getValue() {
123         return value;
124     }
125 
126     public void setValue(String value) {
127         this.value = value;
128     }
129 
130     @Override
131     public void refresh() {
132         KRADServiceLocatorWeb.getLegacyDataAdapter().retrieveNonKeyFields(this);
133     }
134 }
135