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