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