1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.core.framework.persistence.jpa.OrmUtils;
22 import org.kuali.rice.kew.service.KEWServiceLocator;
23 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.Id;
27 import javax.persistence.MappedSuperclass;
28 import javax.persistence.PrePersist;
29 import java.util.LinkedHashMap;
30
31
32
33
34
35
36 @MappedSuperclass
37
38 public abstract class State extends PersistableBusinessObjectBase implements KeyValue {
39 @Id
40 @GeneratedValue(generator="KREW_RTE_NODE_S")
41 @GenericGenerator(name="KREW_RTE_NODE_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
42 @Parameter(name="sequence_name",value="KREW_RTE_NODE_S"),
43 @Parameter(name="value_column",value="id")
44 })
45 protected String stateId;
46 private String key;
47 private String value;
48
49 public State() {}
50
51 public State(String key, String value) {
52 this.key = key;
53 this.value = value;
54 }
55
56 @PrePersist
57 public void customPrePersist(){
58 OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
59 }
60
61 public String getStateId() {
62 return stateId;
63 }
64
65 public void setStateId(String stateId) {
66 this.stateId = stateId;
67 }
68
69 @Override
70 public String getKey() {
71 return key;
72 }
73
74 @Override
75 public String getValue() {
76 return value;
77 }
78
79 public void setKey(String key) {
80 this.key = key;
81 }
82
83 public void setValue(String value) {
84 this.value = value;
85 }
86
87 protected LinkedHashMap<String, Object> toStringMapperFields() {
88 final LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
89 map.put("stateId", stateId);
90 map.put("key", key);
91 map.put("value", value);
92 return map;
93 }
94 }