| 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.bo.PersistableBusinessObject; |
| 28 |
|
import org.kuali.rice.kns.document.MaintenanceDocument; |
| 29 |
|
import org.kuali.rice.kns.lookup.keyvalues.KeyValuesBase; |
| 30 |
|
import org.kuali.rice.kns.util.GlobalVariables; |
| 31 |
|
import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@author |
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 42 |
|
public class RoleNameValuesFinder extends KeyValuesBase { |
| 43 |
|
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 5 |
Complexity Density: 0.31 |
|
| 44 |
0
|
@Override... |
| 45 |
|
public List<KeyValue> getKeyValues() { |
| 46 |
0
|
List<KeyValue> roleNames = new ArrayList<KeyValue>(); |
| 47 |
0
|
if (GlobalVariables.getKualiForm() != null && GlobalVariables.getKualiForm() instanceof KualiMaintenanceForm) { |
| 48 |
0
|
KualiMaintenanceForm form = (KualiMaintenanceForm)GlobalVariables.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 RuleDelegation) { |
| 55 |
0
|
rule = ((RuleDelegation)businessObject).getDelegationRuleBaseValues(); |
| 56 |
|
} else { |
| 57 |
0
|
throw new RiceRuntimeException("Cannot locate RuleBaseValues business object on maintenance document. Business Object was " + businessObject); |
| 58 |
|
} |
| 59 |
0
|
RuleTemplate ruleTemplate = rule.getRuleTemplate(); |
| 60 |
0
|
List<Role> roles = ruleTemplate.getRoles(); |
| 61 |
0
|
for (Role role : roles) { |
| 62 |
0
|
roleNames.add(new ConcreteKeyValue(role.getName(), role.getLabel())); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
0
|
return roleNames; |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
} |