View Javadoc

1   /*
2    * Copyright 2005-2008 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.rule.bo;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import javax.persistence.Basic;
23  import javax.persistence.CascadeType;
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.Lob;
30  import javax.persistence.NamedQueries;
31  import javax.persistence.NamedQuery;
32  import javax.persistence.OneToMany;
33  import javax.persistence.Table;
34  import javax.persistence.Transient;
35  
36  import org.hibernate.annotations.Fetch;
37  import org.hibernate.annotations.FetchMode;
38  import org.hibernate.annotations.GenericGenerator;
39  import org.hibernate.annotations.Parameter;
40  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
41  
42  
43  /**
44   * Model bean defining a rule attribute.  Includes the classname of the attribute
45   * class, as well as it's name and other information.
46   *
47   * @author Kuali Rice Team (rice.collab@kuali.org)
48   */
49  @Entity
50  @Table(name="KREW_RULE_ATTR_T")
51  //@Sequence(name="KREW_RTE_TMPL_S", property="ruleAttributeId")
52  @NamedQueries({
53    @NamedQuery(name="RuleAttribute.FindById",  query="select ra from RuleAttribute ra where ra.ruleAttributeId = :ruleAttributeId"),
54    @NamedQuery(name="RuleAttribute.FindByName",  query="select ra from RuleAttribute ra where ra.name = :name"),
55    @NamedQuery(name="RuleAttribute.FindByClassName",  query="select ra from RuleAttribute ra where ra.className = :className"),
56    @NamedQuery(name="RuleAttribute.GetAllRuleAttributes",  query="select ra from RuleAttribute ra")
57  })
58  public class RuleAttribute extends PersistableBusinessObjectBase  {
59  
60  	private static final long serialVersionUID = 1027673603158346349L;
61  	@Id
62  	@GeneratedValue(generator="KREW_RTE_TMPL_S")
63  	@GenericGenerator(name="KREW_RTE_TMPL_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
64  			@Parameter(name="sequence_name",value="KREW_RTE_TMPL_S"),
65  			@Parameter(name="value_column",value="id")
66  	})
67  	@Column(name="RULE_ATTR_ID")
68  	private String ruleAttributeId;
69      @Column(name="NM")
70  	private String name;
71      @Column(name="LBL")
72  	private String label;
73      @Column(name="RULE_ATTR_TYP_CD")
74  	private String type;
75      @Column(name="CLS_NM")
76  	private String className;
77      @Column(name="DESC_TXT")
78  	private String description;
79      @Lob
80  	@Basic(fetch=FetchType.LAZY)
81  	@Column(name="XML")
82  	private String xmlConfigData;
83  
84      @Column(name="APPL_ID")
85  	private String applicationId;
86      
87      @OneToMany(fetch=FetchType.EAGER,cascade={CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE},
88             targetEntity=org.kuali.rice.kew.rule.bo.RuleTemplateAttribute.class, mappedBy="ruleAttribute")
89      @Fetch(value=FetchMode.SELECT)
90  	private List ruleTemplateAttributes;
91      @Transient
92      private List validValues;
93      
94      // required to be lookupable
95      @Transient
96      private String returnUrl;
97  
98      public RuleAttribute() {
99          ruleTemplateAttributes = new ArrayList();
100         validValues = new ArrayList();
101     }
102 
103     public List getValidValues() {
104         return validValues;
105     }
106     public void setValidValues(List ruleAttributeValidValues) {
107         this.validValues = ruleAttributeValidValues;
108     }
109     public List getRuleTemplateAttributes() {
110         return ruleTemplateAttributes;
111     }
112     public void setRuleTemplateAttributes(List ruleTemplateAttributes) {
113         this.ruleTemplateAttributes = ruleTemplateAttributes;
114     }
115     public String getDescription() {
116         return description;
117     }
118     public void setDescription(String description) {
119         this.description = description;
120     }
121     public String getLabel() {
122         return label;
123     }
124     public void setLabel(String label) {
125         this.label = label;
126     }
127 
128     public String getName() {
129         return name;
130     }
131     public void setName(String name) {
132         this.name = name;
133     }
134     public String getRuleAttributeId() {
135         return ruleAttributeId;
136     }
137     public void setRuleAttributeId(String ruleAttributeId) {
138         this.ruleAttributeId = ruleAttributeId;
139     }
140     public String getType() {
141         return type;
142     }
143     public void setType(String type) {
144         this.type = type;
145     }
146 
147     /**
148      * @return Returns the className.
149      */
150     public String getClassName() {
151       return className;
152     }
153     /**
154      * @param className The className to set.
155      */
156     public void setClassName(String className) {
157       this.className = className;
158     }
159     
160     public String getRuleAttributeActionsUrl() {
161         return "<a href=\"RuleAttributeReport.do?ruleAttributeId="+ruleAttributeId+"\" >report</a>";
162     }
163     
164     public String getReturnUrl() {
165         return returnUrl;
166     }
167     public void setReturnUrl(String returnUrl) {
168         this.returnUrl = returnUrl;
169     }
170 
171 	public String getXmlConfigData() {
172 		return xmlConfigData;
173 	}
174 
175 	public void setXmlConfigData(String xmlConfigData) {
176 		this.xmlConfigData = xmlConfigData;
177 	}
178 
179 	public String getApplicationId() {
180 		return applicationId;
181 	}
182 
183 	public void setApplicationId(String applicationId) {
184 		this.applicationId = applicationId;
185 	}
186 }