View Javadoc

1   /*
2    * Copyright 2005-2007 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.engine.node;
18  
19  import java.io.Serializable;
20  
21  import javax.persistence.Id;
22  import javax.persistence.MappedSuperclass;
23  import javax.persistence.PrePersist;
24  
25  import org.apache.commons.lang.builder.ToStringBuilder;
26  import org.kuali.rice.core.jpa.annotations.Sequence;
27  import org.kuali.rice.core.util.OrmUtils;
28  import org.kuali.rice.kew.service.KEWServiceLocator;
29  
30  /**
31   * A KeyValuePair that adds an id fields that makes it sufficient for storing in a database.
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  @MappedSuperclass
36  @Sequence(name="KREW_RTE_NODE_S", property="stateId")
37  public abstract class State extends KeyValuePair implements Serializable {
38      @Id
39  	protected Long stateId;
40  
41      public State() {}
42  
43      @PrePersist
44      public void beforeInsert(){
45          OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
46      }
47      
48      public State(String key, String value) {
49          super(key, value);
50      }
51  
52      public Long getStateId() {
53          return stateId;
54      }
55  
56      public void setStateId(Long stateId) {
57          this.stateId = stateId;
58      }
59      
60      public String toString() {
61          return new ToStringBuilder(this)
62              .append("stateId", stateId)
63              .append("key", key)
64              .append("value", value)
65              .toString();
66      }
67  }