1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.doctype; |
18 | |
|
19 | |
import java.util.LinkedHashMap; |
20 | |
|
21 | |
import javax.persistence.Column; |
22 | |
import javax.persistence.Entity; |
23 | |
import javax.persistence.FetchType; |
24 | |
import javax.persistence.Id; |
25 | |
import javax.persistence.IdClass; |
26 | |
import javax.persistence.JoinColumn; |
27 | |
import javax.persistence.ManyToOne; |
28 | |
import javax.persistence.Table; |
29 | |
import javax.persistence.Transient; |
30 | |
|
31 | |
import org.kuali.rice.kew.bo.KewPersistableBusinessObjectBase; |
32 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
33 | |
import org.kuali.rice.kew.util.KEWConstants; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
@IdClass(org.kuali.rice.kew.doctype.DocumentTypePolicyId.class) |
42 | |
@Entity |
43 | |
@Table(name="KREW_DOC_TYP_PLCY_RELN_T") |
44 | |
public class DocumentTypePolicy extends KewPersistableBusinessObjectBase { |
45 | |
private static final long serialVersionUID = -4612246888683336474L; |
46 | |
|
47 | |
@Id |
48 | |
@Column(name="DOC_TYP_ID") |
49 | |
private Long documentTypeId; |
50 | |
@Id |
51 | |
@Column(name="DOC_PLCY_NM") |
52 | |
private String policyName; |
53 | |
@Column(name="PLCY_NM") |
54 | |
private Boolean policyValue; |
55 | |
@Column(name="PLCY_VAL") |
56 | |
private String policyStringValue; |
57 | |
@Transient |
58 | |
private Boolean inheritedFlag; |
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | 0 | public DocumentTypePolicy() { |
65 | 0 | } |
66 | |
|
67 | 0 | public DocumentTypePolicy(String policyName, Boolean policyValue) { |
68 | 0 | this.policyName = policyName; |
69 | 0 | this.policyValue = policyValue; |
70 | 0 | } |
71 | |
|
72 | |
public String getPolicyDisplayValue() { |
73 | 0 | if(policyValue != null){ |
74 | 0 | if(policyValue.booleanValue()){ |
75 | 0 | return "Active"; |
76 | |
} else { |
77 | 0 | return "Inactive"; |
78 | |
} |
79 | |
} |
80 | 0 | return "Inherited"; |
81 | |
} |
82 | |
|
83 | |
public Boolean getInheritedFlag() { |
84 | 0 | return inheritedFlag; |
85 | |
} |
86 | |
|
87 | |
public void setInheritedFlag(Boolean inheritedFlag) { |
88 | 0 | this.inheritedFlag = inheritedFlag; |
89 | 0 | } |
90 | |
|
91 | |
public boolean isAllowUnrequestedAction() { |
92 | 0 | return KEWConstants.ALLOW_UNREQUESTED_ACTION_POLICY.equals(policyName); |
93 | |
} |
94 | |
|
95 | |
public boolean isDefaultApprove() { |
96 | 0 | return KEWConstants.DEFAULT_APPROVE_POLICY.equals(policyName); |
97 | |
} |
98 | |
|
99 | |
public boolean isDisApprove() { |
100 | 0 | return KEWConstants.DISAPPROVE_POLICY.equals(policyName); |
101 | |
} |
102 | |
|
103 | |
public Long getDocumentTypeId() { |
104 | 0 | return documentTypeId; |
105 | |
} |
106 | |
|
107 | |
public void setDocumentTypeId(Long documentTypeId) { |
108 | 0 | this.documentTypeId = documentTypeId; |
109 | 0 | } |
110 | |
|
111 | |
public String getPolicyName() { |
112 | 0 | return policyName; |
113 | |
} |
114 | |
|
115 | |
public void setPolicyName(String policyName) { |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | 0 | DocumentTypePolicyEnum policy = DocumentTypePolicyEnum.lookup(policyName); |
125 | 0 | this.policyName = policy.getName(); |
126 | 0 | } |
127 | |
|
128 | |
public Boolean getPolicyValue() { |
129 | 0 | return policyValue; |
130 | |
} |
131 | |
|
132 | |
public void setPolicyValue(Boolean policyValue) { |
133 | 0 | this.policyValue = policyValue; |
134 | 0 | } |
135 | |
|
136 | |
public String getPolicyStringValue() { |
137 | 0 | return policyStringValue; |
138 | |
} |
139 | |
|
140 | |
public void setPolicyStringValue(String policyStringValue) { |
141 | 0 | this.policyStringValue = policyStringValue; |
142 | 0 | } |
143 | |
|
144 | |
public Object copy(boolean preserveKeys) { |
145 | 0 | DocumentTypePolicy clone = new DocumentTypePolicy(); |
146 | |
|
147 | 0 | if(preserveKeys && documentTypeId != null){ |
148 | 0 | clone.setDocumentTypeId(new Long(documentTypeId.longValue())); |
149 | |
} |
150 | 0 | if(policyName != null){ |
151 | 0 | clone.setPolicyName(new String(policyName)); |
152 | |
} |
153 | |
|
154 | 0 | if(policyValue != null){ |
155 | 0 | clone.setPolicyValue(new Boolean(policyValue.booleanValue())); |
156 | |
} |
157 | |
|
158 | 0 | if(policyStringValue != null){ |
159 | 0 | clone.setPolicyStringValue(new String(policyStringValue)); |
160 | |
} |
161 | |
|
162 | 0 | return clone; |
163 | |
} |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
@Override |
177 | |
protected LinkedHashMap toStringMapper() { |
178 | 0 | LinkedHashMap m = new LinkedHashMap(); |
179 | 0 | m.put("documentTypeId", this.documentTypeId); |
180 | 0 | m.put("policyName", this.policyName); |
181 | 0 | m.put("policyValue", this.policyValue); |
182 | 0 | m.put("policyStringValue", this.policyStringValue); |
183 | 0 | return m; |
184 | |
} |
185 | |
} |