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