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