1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.businessobject.options;
17
18 import org.kuali.ole.select.OleSelectConstant;
19 import org.kuali.ole.sys.OLEConstants;
20 import org.kuali.rice.core.api.util.ConcreteKeyValue;
21 import org.kuali.rice.core.api.util.KeyValue;
22 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
23 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
24 import org.kuali.rice.krad.util.GlobalVariables;
25
26 import java.util.ArrayList;
27 import java.util.Collections;
28 import java.util.HashMap;
29 import java.util.List;
30
31 public class DefaultValueForValuesFinder extends KeyValuesBase {
32
33 @Override
34 public List<KeyValue> getKeyValues() {
35 List<KeyValue> keyValues = new ArrayList<KeyValue>();
36 String systemUserRoleId = KimApiServiceLocator.getRoleService().getRoleIdByNamespaceCodeAndName(
37 OLEConstants.CoreModuleNamespaces.OLE, OleSelectConstant.SYSTEM_USER_ROLE_NAME);
38
39 if (KimApiServiceLocator.getRoleService().principalHasRole(
40 GlobalVariables.getUserSession().getPrincipalId(),
41 Collections.singletonList(systemUserRoleId), new HashMap<String, String>())) {
42 keyValues.add(new ConcreteKeyValue(OleSelectConstant.DEFAULT_VALUE_ROLE, OleSelectConstant.DEFAULT_VALUE_ROLE));
43 keyValues.add(new ConcreteKeyValue(OleSelectConstant.DEFAULT_VALUE_SYSTEM, OleSelectConstant.DEFAULT_VALUE_SYSTEM));
44 } else {
45 keyValues.add(new ConcreteKeyValue(OleSelectConstant.DEFAULT_VALUE_USER, OleSelectConstant.DEFAULT_VALUE_USER));
46 }
47 return keyValues;
48 }
49
50 }