1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.rule;
17
18 import org.apache.commons.lang.ObjectUtils;
19 import org.kuali.rice.kew.api.rule.RuleExpression;
20 import org.kuali.rice.kew.api.rule.RuleExpressionContract;
21 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
22 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
23
24 import javax.persistence.Column;
25 import javax.persistence.Entity;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.Id;
28 import javax.persistence.Table;
29
30
31
32
33
34 @Entity
35 @Table(name="KREW_RULE_EXPR_T")
36
37 public class RuleExpressionDef extends PersistableBusinessObjectBase implements RuleExpressionContract {
38
39
40
41
42 @Id
43 @PortableSequenceGenerator(name="KREW_RULE_EXPR_S")
44 @GeneratedValue(generator="KREW_RULE_EXPR_S")
45 @Column(name="RULE_EXPR_ID")
46 private String id;
47
48
49
50 @Column(name="TYP")
51 private String type;
52
53
54
55 @Column(name="RULE_EXPR", nullable=true)
56 private String expression;
57
58
59
60 public String getId() {
61 return this.id;
62 }
63
64
65
66 public void setId(String id) {
67 this.id = id;
68 }
69
70
71
72 public String getType() {
73 return this.type;
74 }
75
76
77
78 public void setType(String type) {
79 this.type = type;
80 }
81
82
83
84 public String getExpression() {
85 return this.expression;
86 }
87
88
89
90 public void setExpression(String expression) {
91 this.expression = expression;
92 }
93
94
95
96
97
98
99
100 @Override
101 public boolean equals(Object obj) {
102 if (obj == null) return false;
103 if (!(obj instanceof RuleExpressionDef)) return false;
104 RuleExpressionDef arg = (RuleExpressionDef) obj;
105 return ObjectUtils.equals(type, arg.getType()) && ObjectUtils.equals(expression, arg.getExpression());
106 }
107
108
109
110
111
112
113 public static org.kuali.rice.kew.api.rule.RuleExpression to(RuleExpressionDef bo) {
114 if (bo == null) {
115 return null;
116 }
117
118 return RuleExpression.Builder.create(bo).build();
119 }
120
121
122
123
124
125
126 public static RuleExpressionDef from(RuleExpression im) {
127 if (im == null) {
128 return null;
129 }
130
131 RuleExpressionDef bo = new RuleExpressionDef();
132 bo.setId(im.getId());
133 bo.setType(im.getType());
134 bo.setExpression(im.getExpression());
135 bo.setVersionNumber(im.getVersionNumber());
136 bo.setObjectId(im.getObjectId());
137
138 return bo;
139 }
140 }