1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sec.businessobject.inquiry;
17
18 import java.util.HashMap;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sec.SecPropertyConstants;
24 import org.kuali.ole.sec.businessobject.SecurityModelDefinition;
25 import org.kuali.ole.sys.OLEConstants;
26 import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl;
27 import org.kuali.rice.core.api.membership.MemberType;
28 import org.kuali.rice.kim.api.KimConstants;
29 import org.kuali.rice.kim.api.identity.Person;
30 import org.kuali.rice.kim.framework.group.GroupEbo;
31 import org.kuali.rice.kim.framework.role.RoleEbo;
32 import org.kuali.rice.kns.lookup.HtmlData;
33 import org.kuali.rice.krad.bo.BusinessObject;
34 import org.kuali.rice.krad.util.KRADConstants;
35 import org.kuali.rice.krad.util.ObjectUtils;
36 import org.kuali.rice.krad.util.UrlFactory;
37
38
39
40
41
42 public class SecurityModelMemberInquirable extends KfsInquirableImpl {
43
44
45
46
47 @Override
48 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
49 if (SecPropertyConstants.MEMBER_ID.equals(attributeName)) {
50 Properties parameters = new Properties();
51 parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD);
52
53 Map<String, String> fieldList = new HashMap<String, String>();
54
55 String memberId = (String) ObjectUtils.getPropertyValue(businessObject, SecPropertyConstants.MEMBER_ID);
56 String memberTypeCode = (String) ObjectUtils.getPropertyValue(businessObject, SecPropertyConstants.MEMBER_TYPE_CODE);
57
58 if (StringUtils.isNotBlank(memberId) && StringUtils.isNotBlank(memberTypeCode)) {
59 if (MemberType.ROLE.getCode().equals(memberTypeCode)) {
60 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, RoleEbo.class.getName());
61 parameters.put(KimConstants.PrimaryKeyConstants.ROLE_ID, memberId);
62 fieldList.put(KimConstants.PrimaryKeyConstants.ROLE_ID, memberId.toString());
63 }
64 else if (MemberType.GROUP.getCode().equals(memberTypeCode)) {
65 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, GroupEbo.class.getName());
66 parameters.put(KimConstants.PrimaryKeyConstants.GROUP_ID, memberId);
67 fieldList.put(KimConstants.PrimaryKeyConstants.GROUP_ID, memberId.toString());
68 }
69 else {
70 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, Person.class.getName());
71 parameters.put(KimConstants.PrimaryKeyConstants.PRINCIPAL_ID, memberId);
72 fieldList.put(KimConstants.PrimaryKeyConstants.PRINCIPAL_ID, memberId.toString());
73 }
74
75 return getHyperLink(SecurityModelDefinition.class, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters));
76 }
77 }
78
79 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
80 }
81
82
83 }