1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.rule;
18
19 import java.util.LinkedHashMap;
20
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.FetchType;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30 import javax.persistence.Transient;
31
32 import org.kuali.rice.core.jpa.annotations.Sequence;
33 import org.kuali.rice.kew.bo.KewPersistableBusinessObjectBase;
34 import org.kuali.rice.kew.doctype.bo.DocumentType;
35 import org.kuali.rice.kew.service.KEWServiceLocator;
36 import org.kuali.rice.kew.util.KEWConstants;
37
38
39
40
41
42
43
44
45
46 @Entity
47 @Table(name="KREW_DLGN_RSP_T")
48 @Sequence(name="KREW_RTE_TMPL_S", property="ruleDelegationId")
49 public class RuleDelegation extends KewPersistableBusinessObjectBase {
50
51 private static final long serialVersionUID = 7989203310473741293L;
52 @Id
53 @Column(name="DLGN_RULE_ID")
54 private Long ruleDelegationId;
55 @Column(name="RSP_ID", insertable=false, updatable=false)
56 private Long responsibilityId;
57 @Column(name="DLGN_RULE_BASE_VAL_ID", insertable=false, updatable=false)
58 private Long delegateRuleId;
59 @Column(name="DLGN_TYP")
60 private String delegationType = KEWConstants.DELEGATION_PRIMARY;
61
62 @OneToOne(fetch=FetchType.EAGER, cascade={CascadeType.PERSIST})
63 @JoinColumn(name="DLGN_RULE_BASE_VAL_ID")
64 private RuleBaseValues delegationRuleBaseValues;
65
66
67
68
69 public RuleDelegation() {
70 }
71
72 public Object copy(boolean preserveKeys) {
73 RuleDelegation clone = new RuleDelegation();
74 if (ruleDelegationId != null && preserveKeys) {
75 clone.setRuleDelegationId(new Long(ruleDelegationId.longValue()));
76 }
77 clone.setDelegationRuleBaseValues(delegationRuleBaseValues);
78 clone.setDelegateRuleId(delegationRuleBaseValues.getRuleBaseValuesId());
79 if (delegationType != null) {
80 clone.setDelegationType(new String(delegationType));
81 }
82 return clone;
83 }
84
85 public Long getDelegateRuleId() {
86 return delegateRuleId;
87 }
88 public void setDelegateRuleId(Long delegateRuleId) {
89 this.delegateRuleId = delegateRuleId;
90 }
91 public RuleBaseValues getDelegationRuleBaseValues() {
92 return delegationRuleBaseValues;
93 }
94 public void setDelegationRuleBaseValues(RuleBaseValues delegationRuleBaseValues) {
95 this.delegationRuleBaseValues = delegationRuleBaseValues;
96 }
97 public String getDelegationType() {
98 return delegationType;
99 }
100 public void setDelegationType(String delegationType) {
101 this.delegationType = delegationType;
102 }
103 public Long getRuleDelegationId() {
104 return ruleDelegationId;
105 }
106 public void setRuleDelegationId(Long ruleDelegationId) {
107 this.ruleDelegationId = ruleDelegationId;
108 }
109
110
111
112
113
114 public RuleResponsibility getRuleResponsibility() {
115 if ( getResponsibilityId() == null ) {
116 return null;
117 }
118 return KEWServiceLocator.getRuleService().findRuleResponsibility(getResponsibilityId());
119 }
120
121 public DocumentType getDocumentType() {
122 return this.getDelegationRuleBaseValues().getDocumentType();
123 }
124
125 public Long getResponsibilityId() {
126 return responsibilityId;
127 }
128 public void setResponsibilityId(Long ruleResponsibilityId) {
129 this.responsibilityId = ruleResponsibilityId;
130 }
131
132 @Override
133 protected LinkedHashMap toStringMapper() {
134 LinkedHashMap map = new LinkedHashMap();
135 map.put("ruleDelegationId", ruleDelegationId);
136 map.put("responsibilityId", responsibilityId);
137 map.put("delegateRuleId", delegateRuleId);
138 map.put("delegationType", delegationType);
139 return map;
140 }
141
142
143
144
145
146
147
148
149
150
151
152 @Override
153 public void refresh() {
154 RuleBaseValues oldRuleBaseValues = this.getDelegationRuleBaseValues();
155 super.refresh();
156 if (this.getDelegationRuleBaseValues() == null) {
157 this.refreshReferenceObject("delegationRuleBaseValues");
158 if (this.getDelegationRuleBaseValues() == null) {
159 this.setDelegationRuleBaseValues(oldRuleBaseValues);
160 }
161 }
162 }
163 }
164