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.engine.node;
17  
18  import org.kuali.rice.kew.engine.node.dao.impl.RouteNodeDAOJpa;
19  
20  import javax.persistence.AttributeOverride;
21  import javax.persistence.AttributeOverrides;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.FetchType;
25  import javax.persistence.JoinColumn;
26  import javax.persistence.ManyToOne;
27  import javax.persistence.NamedQueries;
28  import javax.persistence.NamedQuery;
29  import javax.persistence.Table;
30  import javax.persistence.Version;
31  import java.util.Map;
32  
33  /**
34   * The state of a {@link RouteNodeInstance} represented as a key-value pair of Strings.
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  @Entity
39  @Table(name="KREW_RTE_NODE_INSTN_ST_T")
40  @AttributeOverrides({
41  @AttributeOverride(name="stateId", column=@Column(name="RTE_NODE_INSTN_ST_ID")) ,
42  @AttributeOverride(name="versionNumber", column=@Column(name="VER_NBR", updatable=false, insertable=false)),
43  //HACK since this super attribute does not exist on the table
44  @AttributeOverride(name="objectId", column=@Column(name="KEY_CD", updatable=false, insertable=false) )
45  })
46  public class NodeState extends State {
47  
48      private static final long serialVersionUID = -4382379569851955918L;
49  
50      @Column(name= "RTE_NODE_INSTN_ID", insertable = false, updatable = false)
51      private String routeNodeInstanceId;
52  
53      @ManyToOne(fetch=FetchType.EAGER)
54  	@JoinColumn(name="RTE_NODE_INSTN_ID")
55  	private RouteNodeInstance nodeInstance;
56  
57      @Version
58  	@Column(name="VER_NBR")
59  	private Integer lockVerNbr;
60  
61      
62      public NodeState() {}
63      
64      public NodeState(String key, String value) {
65      	super(key, value);
66      }
67      
68      
69      public RouteNodeInstance getNodeInstance() {
70          return nodeInstance;
71      }
72      public void setNodeInstance(RouteNodeInstance nodeInstance) {
73          this.nodeInstance = nodeInstance;
74      }
75  
76      public String getNodeStateId() {
77          return getStateId();
78      }
79  
80      public void setNodeStateId(String nodeStateId) {
81          setStateId(nodeStateId);
82      }
83  
84      public Integer getLockVerNbr() {
85          return lockVerNbr;
86      }
87  
88      public void setLockVerNbr(Integer lockVerNbr) {
89          this.lockVerNbr = lockVerNbr;
90      }
91  
92      public NodeState deepCopy(Map<Object, Object> visited) {
93          if (visited.containsKey(this)) {
94              return (NodeState)visited.get(this);
95          }
96          NodeState copy = new NodeState(getKey(), getValue());
97          visited.put(this, copy);
98          copy.stateId = stateId;
99          copy.lockVerNbr = lockVerNbr;
100         if (nodeInstance != null) {
101             copy.nodeInstance = nodeInstance.deepCopy(visited);
102         }
103         return copy;
104     }
105 
106     public String getRouteNodeInstanceId() {
107         return getNodeInstance() != null ? getNodeInstance().getRouteNodeInstanceId() : null;
108     }
109 
110 
111 }