1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.rule.bo; |
17 | |
|
18 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
19 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
20 | |
import org.kuali.rice.core.api.util.KeyValue; |
21 | |
import org.kuali.rice.kew.api.rule.RoleName; |
22 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
23 | |
import org.kuali.rice.kew.rule.RuleDelegationBo; |
24 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
25 | |
import org.kuali.rice.kns.util.KNSGlobalVariables; |
26 | |
import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm; |
27 | |
import org.kuali.rice.krad.bo.PersistableBusinessObject; |
28 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
29 | |
|
30 | |
import java.util.ArrayList; |
31 | |
import java.util.List; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 0 | public class RoleNameValuesFinder extends KeyValuesBase { |
43 | |
|
44 | |
@Override |
45 | |
public List<KeyValue> getKeyValues() { |
46 | 0 | List<KeyValue> roleNames = new ArrayList<KeyValue>(); |
47 | 0 | if (KNSGlobalVariables.getKualiForm() != null && KNSGlobalVariables.getKualiForm() instanceof KualiMaintenanceForm) { |
48 | 0 | KualiMaintenanceForm form = (KualiMaintenanceForm)KNSGlobalVariables.getKualiForm(); |
49 | 0 | MaintenanceDocument document = (MaintenanceDocument)form.getDocument(); |
50 | 0 | PersistableBusinessObject businessObject = document.getNewMaintainableObject().getBusinessObject(); |
51 | 0 | RuleBaseValues rule = null; |
52 | 0 | if (businessObject instanceof RuleBaseValues) { |
53 | 0 | rule = (RuleBaseValues)businessObject; |
54 | 0 | } else if (businessObject instanceof RuleDelegationBo) { |
55 | 0 | rule = ((RuleDelegationBo)businessObject).getDelegationRule(); |
56 | |
} else { |
57 | 0 | throw new RiceRuntimeException("Cannot locate RuleBaseValues business object on maintenance document. Business Object was " + businessObject); |
58 | |
} |
59 | 0 | RuleTemplateBo ruleTemplate = rule.getRuleTemplate(); |
60 | 0 | List<RoleName> roles = ruleTemplate.getRoles(); |
61 | 0 | for (RoleName role : roles) { |
62 | 0 | roleNames.add(new ConcreteKeyValue(role.getName(), role.getLabel())); |
63 | |
} |
64 | |
} |
65 | 0 | return roleNames; |
66 | |
} |
67 | |
|
68 | |
} |