| 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.hibernate.annotations.GenericGenerator; |
| 20 | |
import org.hibernate.annotations.Parameter; |
| 21 | |
import org.kuali.rice.kew.api.rule.*; |
| 22 | |
import org.kuali.rice.kew.api.rule.RuleExpression; |
| 23 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
| 24 | |
|
| 25 | |
import javax.persistence.*; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
@Entity |
| 32 | |
@Table(name="KREW_RULE_EXPR_T") |
| 33 | |
|
| 34 | 0 | public class RuleExpressionDef extends PersistableBusinessObjectBase implements RuleExpressionContract { |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
@Id |
| 40 | |
@GeneratedValue(generator="KREW_RULE_EXPR_S") |
| 41 | |
@GenericGenerator(name="KREW_RULE_EXPR_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
| 42 | |
@Parameter(name="sequence_name",value="KREW_RULE_EXPR_S"), |
| 43 | |
@Parameter(name="value_column",value="id") |
| 44 | |
}) |
| 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 | 0 | return this.id; |
| 62 | |
} |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
public void setId(String id) { |
| 67 | 0 | this.id = id; |
| 68 | 0 | } |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
public String getType() { |
| 73 | 0 | return this.type; |
| 74 | |
} |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
public void setType(String type) { |
| 79 | 0 | this.type = type; |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
public String getExpression() { |
| 85 | 0 | return this.expression; |
| 86 | |
} |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public void setExpression(String expression) { |
| 91 | 0 | this.expression = expression; |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
|
| 100 | |
@Override |
| 101 | |
public boolean equals(Object obj) { |
| 102 | 0 | if (obj == null) return false; |
| 103 | 0 | if (!(obj instanceof RuleExpressionDef)) return false; |
| 104 | 0 | RuleExpressionDef arg = (RuleExpressionDef) obj; |
| 105 | 0 | 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 | 0 | if (bo == null) { |
| 115 | 0 | return null; |
| 116 | |
} |
| 117 | |
|
| 118 | 0 | return RuleExpression.Builder.create(bo).build(); |
| 119 | |
} |
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
public static RuleExpressionDef from(RuleExpression im) { |
| 127 | 0 | if (im == null) { |
| 128 | 0 | return null; |
| 129 | |
} |
| 130 | |
|
| 131 | 0 | RuleExpressionDef bo = new RuleExpressionDef(); |
| 132 | 0 | bo.setId(im.getId()); |
| 133 | 0 | bo.setType(im.getType()); |
| 134 | 0 | bo.setExpression(im.getExpression()); |
| 135 | 0 | bo.setVersionNumber(im.getVersionNumber()); |
| 136 | 0 | bo.setObjectId(im.getObjectId()); |
| 137 | |
|
| 138 | 0 | return bo; |
| 139 | |
} |
| 140 | |
} |