001/**
002 * Copyright 2005-2016 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.hibernate.annotations.GenericGenerator;
019import org.hibernate.annotations.Parameter;
020import org.kuali.rice.core.api.util.KeyValue;
021import org.kuali.rice.kew.api.doctype.RouteNodeConfigurationParameterContract;
022import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
023
024import javax.persistence.AttributeOverride;
025import javax.persistence.AttributeOverrides;
026import javax.persistence.Column;
027import javax.persistence.Entity;
028import javax.persistence.FetchType;
029import javax.persistence.GeneratedValue;
030import javax.persistence.Id;
031import javax.persistence.JoinColumn;
032import javax.persistence.ManyToOne;
033import javax.persistence.Table;
034
035/**
036 * A route node definition configuration parameter.  RouteNodeConfigParameters are
037 * extracted when the route node is parsed, and depend on route node implementation.
038 * (well, they actually depend on the route node parser because the parser is what
039 * will parse them, but the parser is not specialized per-node-type at this point) 
040 * @author Kuali Rice Team (rice.collab@kuali.org)
041 *
042 */
043@Entity
044@Table(name="KREW_RTE_NODE_CFG_PARM_T")
045@AttributeOverrides({@AttributeOverride(name="key", column=@Column(name="KEY_CD")), @AttributeOverride(name="value", column=@Column(name="VAL"))})
046public class RouteNodeConfigParam extends PersistableBusinessObjectBase implements KeyValue, RouteNodeConfigurationParameterContract {
047    private static final long serialVersionUID = 5592421070149273014L;
048
049    /**
050     * Primary key
051     */ 
052    @Id
053        @Column(name="RTE_NODE_CFG_PARM_ID")
054        @GeneratedValue(generator="KREW_RTE_NODE_CFG_PARM_S")
055        @GenericGenerator(name="KREW_RTE_NODE_CFG_PARM_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
056                        @Parameter(name="sequence_name",value="KREW_RTE_NODE_CFG_PARM_S"),
057                        @Parameter(name="value_column",value="id")
058        })
059    //@SequenceGenerator(name="KREW_RTE_NODE_CFG_PARM_SEQ_GEN", sequenceName="KREW_RTE_NODE_CFG_PARM_S")        
060        private String id;
061        private String key;
062    private String value;
063    /**
064     * Foreign key to routenode table
065     */
066    @ManyToOne(fetch=FetchType.EAGER)
067        @JoinColumn(name="RTE_NODE_ID")
068        private RouteNode routeNode;
069
070    public RouteNodeConfigParam() {}
071
072    public RouteNodeConfigParam(RouteNode routeNode, String key, String value) {
073        this.key = key;
074        this.value = value;
075        this.routeNode = routeNode;
076    }
077
078    /**
079     * @return the id
080     */
081    @Override
082    public String getId() {
083                return this.id;
084    }
085    /**
086     * @param id the id to set
087     */
088    public void setId(String id) {
089        this.id = id;
090    }
091    /**
092     * @return the routeNode
093     */
094    public RouteNode getRouteNode() {
095        return this.routeNode;
096    }
097    /**
098     * @param routeNode the routeNode to set
099     */
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}