001/** 002 * Copyright 2005-2015 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.engine.node; 017 018import org.kuali.rice.kew.engine.node.dao.impl.RouteNodeDAOJpa; 019 020import javax.persistence.AttributeOverride; 021import javax.persistence.AttributeOverrides; 022import javax.persistence.Column; 023import javax.persistence.Entity; 024import javax.persistence.FetchType; 025import javax.persistence.JoinColumn; 026import javax.persistence.ManyToOne; 027import javax.persistence.NamedQueries; 028import javax.persistence.NamedQuery; 029import javax.persistence.Table; 030import javax.persistence.Version; 031import java.util.Map; 032 033/** 034 * The state of a {@link RouteNodeInstance} represented as a key-value pair of Strings. 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038@Entity 039@Table(name="KREW_RTE_NODE_INSTN_ST_T") 040@AttributeOverrides({ 041@AttributeOverride(name="stateId", column=@Column(name="RTE_NODE_INSTN_ST_ID")) , 042@AttributeOverride(name="versionNumber", column=@Column(name="VER_NBR", updatable=false, insertable=false)), 043//HACK since this super attribute does not exist on the table 044@AttributeOverride(name="objectId", column=@Column(name="KEY_CD", updatable=false, insertable=false) ) 045}) 046public class NodeState extends State { 047 048 private static final long serialVersionUID = -4382379569851955918L; 049 050 @Column(name= "RTE_NODE_INSTN_ID", insertable = false, updatable = false) 051 private String routeNodeInstanceId; 052 053 @ManyToOne(fetch=FetchType.EAGER) 054 @JoinColumn(name="RTE_NODE_INSTN_ID") 055 private RouteNodeInstance nodeInstance; 056 057 @Version 058 @Column(name="VER_NBR") 059 private Integer lockVerNbr; 060 061 062 public NodeState() {} 063 064 public NodeState(String key, String value) { 065 super(key, value); 066 } 067 068 069 public RouteNodeInstance getNodeInstance() { 070 return nodeInstance; 071 } 072 public void setNodeInstance(RouteNodeInstance nodeInstance) { 073 this.nodeInstance = nodeInstance; 074 } 075 076 public String getNodeStateId() { 077 return getStateId(); 078 } 079 080 public void setNodeStateId(String nodeStateId) { 081 setStateId(nodeStateId); 082 } 083 084 public Integer getLockVerNbr() { 085 return lockVerNbr; 086 } 087 088 public void setLockVerNbr(Integer lockVerNbr) { 089 this.lockVerNbr = lockVerNbr; 090 } 091 092 public NodeState deepCopy(Map<Object, Object> visited) { 093 if (visited.containsKey(this)) { 094 return (NodeState)visited.get(this); 095 } 096 NodeState copy = new NodeState(getKey(), getValue()); 097 visited.put(this, copy); 098 copy.stateId = stateId; 099 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}