View Javadoc

1   /**
2    * Copyright 2005-2011 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.engine.node;
17  
18  import org.hibernate.annotations.GenericGenerator;
19  import org.hibernate.annotations.Parameter;
20  import org.kuali.rice.core.api.util.KeyValue;
21  import org.kuali.rice.kew.api.doctype.RouteNodeConfigurationParameterContract;
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  
24  import javax.persistence.AttributeOverride;
25  import javax.persistence.AttributeOverrides;
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  
35  /**
36   * A route node definition configuration parameter.  RouteNodeConfigParameters are
37   * extracted when the route node is parsed, and depend on route node implementation.
38   * (well, they actually depend on the route node parser because the parser is what
39   * will parse them, but the parser is not specialized per-node-type at this point) 
40   * @author Kuali Rice Team (rice.collab@kuali.org)
41   *
42   */
43  @Entity
44  @Table(name="KREW_RTE_NODE_CFG_PARM_T")
45  @AttributeOverrides({@AttributeOverride(name="key", column=@Column(name="KEY_CD")), @AttributeOverride(name="value", column=@Column(name="VAL"))})
46  public class RouteNodeConfigParam extends PersistableBusinessObjectBase implements KeyValue, RouteNodeConfigurationParameterContract {
47      private static final long serialVersionUID = 5592421070149273014L;
48  
49      /**
50       * Primary key
51       */ 
52      @Id
53  	@Column(name="RTE_NODE_CFG_PARM_ID")
54  	@GeneratedValue(generator="KREW_RTE_NODE_CFG_PARM_S")
55  	@GenericGenerator(name="KREW_RTE_NODE_CFG_PARM_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
56  			@Parameter(name="sequence_name",value="KREW_RTE_NODE_CFG_PARM_S"),
57  			@Parameter(name="value_column",value="id")
58  	})
59      //@SequenceGenerator(name="KREW_RTE_NODE_CFG_PARM_SEQ_GEN", sequenceName="KREW_RTE_NODE_CFG_PARM_S")	
60  	private String id;
61  	private String key;
62      private String value;
63      /**
64       * Foreign key to routenode table
65       */
66      @ManyToOne(fetch=FetchType.EAGER)
67  	@JoinColumn(name="RTE_NODE_ID")
68  	private RouteNode routeNode;
69  
70      public RouteNodeConfigParam() {}
71  
72      public RouteNodeConfigParam(RouteNode routeNode, String key, String value) {
73      	this.key = key;
74      	this.value = value;
75          this.routeNode = routeNode;
76      }
77  
78      /**
79       * @return the id
80       */
81      @Override
82      public String getId() {
83  		return this.id;
84      }
85      /**
86       * @param id the id to set
87       */
88      public void setId(String id) {
89          this.id = id;
90      }
91      /**
92       * @return the routeNode
93       */
94      public RouteNode getRouteNode() {
95          return this.routeNode;
96      }
97      /**
98       * @param routeNode the routeNode to set
99       */
100     public void setRouteNode(RouteNode routeNode) {
101         this.routeNode = routeNode;
102     }
103     
104     @Override
105     public String getKey() {
106     	return key;
107     }
108     
109     @Override
110     public String getValue() {
111     	return value;
112     }
113     
114     public void setKey(String key) {
115 		this.key = key;
116 	}
117 
118 	public void setValue(String value) {
119 		this.value = value;
120 	}
121 
122     @Override
123     public String getRouteNodeId() {
124         if (routeNode == null || routeNode.getRouteNodeId() == null) {
125             return null;
126         }
127         return routeNode.getRouteNodeId().toString();
128     }
129 	
130 	
131 }