1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.inquiry;
17
18 import java.util.ArrayList;
19 import java.util.Collections;
20 import java.util.List;
21
22 import org.kuali.rice.kim.bo.impl.RoleImpl;
23 import org.kuali.rice.kim.bo.types.impl.KimTypeImpl;
24 import org.kuali.rice.kim.lookup.RoleLookupableHelperServiceImpl;
25 import org.kuali.rice.kim.util.KimConstants;
26 import org.kuali.rice.kns.bo.BusinessObject;
27 import org.kuali.rice.kns.bo.Namespace;
28 import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
29 import org.kuali.rice.kns.lookup.HtmlData;
30 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
31 import org.kuali.rice.kns.util.ObjectUtils;
32
33
34
35
36
37
38
39 public class RoleInquirableImpl extends KualiInquirableImpl {
40
41 protected final String ROLE_NAME = "roleName";
42 protected final String ROLE_ID = "roleId";
43 protected final String NAMESPACE_CODE = "namespaceCode";
44
45
46
47
48
49 @Override
50 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
51 if(ROLE_NAME.equals(attributeName)){
52 List<String> primaryKeys = new ArrayList<String>();
53 primaryKeys.add(ROLE_ID);
54
55 String href = (getInquiryUrlForPrimaryKeys(RoleImpl.class, businessObject, primaryKeys, null)).getHref();
56 AnchorHtmlData htmlData = new AnchorHtmlData();
57 htmlData.setHref(RoleLookupableHelperServiceImpl.getCustomRoleInquiryHref(href));
58 return htmlData;
59 } else if(NAMESPACE_CODE.equals(attributeName)){
60 List<String> primaryKeys = new ArrayList<String>();
61 primaryKeys.add("code");
62 Namespace parameterNamespace = new Namespace();
63 parameterNamespace.setCode((String)ObjectUtils.getPropertyValue(businessObject, attributeName));
64 return getInquiryUrlForPrimaryKeys(Namespace.class, parameterNamespace, primaryKeys, null);
65 } else if("kimRoleType.name".equals(attributeName)){
66 KimTypeImpl kimType = new KimTypeImpl();
67 kimType.setKimTypeId( ((RoleImpl)businessObject).getKimTypeId() );
68 return getInquiryUrlForPrimaryKeys(KimTypeImpl.class, kimType, Collections.singletonList( KimConstants.PrimaryKeyConstants.KIM_TYPE_ID ), null);
69 }
70
71 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
72 }
73
74 }