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