1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.actionrequest.bo; |
17 | |
|
18 | |
import org.kuali.rice.core.util.ConcreteKeyValue; |
19 | |
import org.kuali.rice.core.util.KeyValue; |
20 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
21 | |
import org.kuali.rice.kew.rule.RuleTemplateOption; |
22 | |
import org.kuali.rice.kew.rule.bo.RuleTemplate; |
23 | |
import org.kuali.rice.kew.util.KEWConstants; |
24 | |
import org.kuali.rice.kns.util.KNSGlobalVariables; |
25 | |
import org.kuali.rice.kns.web.struts.form.KualiForm; |
26 | |
import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm; |
27 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
28 | |
import org.kuali.rice.krad.util.GlobalVariables; |
29 | |
|
30 | |
import java.util.ArrayList; |
31 | |
import java.util.List; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | 0 | public class RuleMaintenanceActionRequestCodeValuesFinder extends ActionRequestCodeValuesFinder { |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
@Override |
45 | |
public List<KeyValue> getKeyValues() { |
46 | 0 | final List<KeyValue> actionRequestCodes = new ArrayList<KeyValue>(); |
47 | |
|
48 | 0 | final KualiForm kForm = KNSGlobalVariables.getKualiForm(); |
49 | 0 | if (!(kForm instanceof KualiMaintenanceForm)) { |
50 | 0 | return super.getKeyValues(); |
51 | |
} |
52 | |
|
53 | 0 | final MaintenanceDocument maintDoc = (MaintenanceDocument) ((KualiMaintenanceForm) kForm).getDocument(); |
54 | 0 | final RuleTemplate ruleTemplate = ((RuleBaseValues) maintDoc.getNewMaintainableObject().getBusinessObject()).getRuleTemplate(); |
55 | |
|
56 | 0 | if (ruleTemplate == null) { |
57 | 0 | throw new RuntimeException("Rule template cannot be null for document ID " + maintDoc.getDocumentNumber()); |
58 | |
} |
59 | |
|
60 | 0 | final RuleTemplateOption[] ruleOpts = {ruleTemplate.getAcknowledge(), ruleTemplate.getComplete(), |
61 | |
ruleTemplate.getApprove(), ruleTemplate.getFyi()}; |
62 | 0 | final String[] ruleConsts = {KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KEWConstants.ACTION_REQUEST_COMPLETE_REQ, |
63 | |
KEWConstants.ACTION_REQUEST_APPROVE_REQ, KEWConstants.ACTION_REQUEST_FYI_REQ}; |
64 | |
|
65 | 0 | for (int i = 0; i < ruleOpts.length; i++) { |
66 | 0 | if (ruleOpts[i] == null || ruleOpts[i].getValue() == null || "true".equals(ruleOpts[i].getValue())) { |
67 | 0 | actionRequestCodes.add(new ConcreteKeyValue(ruleConsts[i], KEWConstants.ACTION_REQUEST_CODES.get(ruleConsts[i]))); |
68 | |
} |
69 | |
} |
70 | 0 | return actionRequestCodes; |
71 | |
} |
72 | |
|
73 | |
} |