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 org.kuali.rice.core.impl.namespace.NamespaceBo; |
19 | |
import org.kuali.rice.kim.impl.role.RoleBo; |
20 | |
import org.kuali.rice.kim.impl.type.KimTypeBo; |
21 | |
import org.kuali.rice.kim.lookup.RoleLookupableHelperServiceImpl; |
22 | |
import org.kuali.rice.kim.util.KimConstants; |
23 | |
import org.kuali.rice.kns.inquiry.KualiInquirableImpl; |
24 | |
import org.kuali.rice.kns.lookup.HtmlData; |
25 | |
import org.kuali.rice.krad.bo.BusinessObject; |
26 | |
import org.kuali.rice.krad.uif.widget.Inquiry; |
27 | |
import org.kuali.rice.krad.util.ObjectUtils; |
28 | |
|
29 | |
import java.util.ArrayList; |
30 | |
import java.util.Collections; |
31 | |
import java.util.HashMap; |
32 | |
import java.util.List; |
33 | |
import java.util.Map; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class RoleInquirableImpl extends KualiInquirableImpl { |
42 | |
|
43 | 0 | protected final String ROLE_NAME = "roleName"; |
44 | 0 | protected final String ROLE_ID = "roleId"; |
45 | 0 | protected final String NAMESPACE_CODE = "namespaceCode"; |
46 | |
|
47 | |
@Override |
48 | |
public void buildInquirableLink(Object dataObject, String propertyName, Inquiry inquiry){ |
49 | 0 | if(ROLE_NAME.equals(propertyName)){ |
50 | 0 | Map<String, String> primaryKeys = new HashMap<String, String>(); |
51 | 0 | primaryKeys.put(ROLE_ID, ROLE_ID); |
52 | 0 | inquiry.buildInquiryLink(dataObject, propertyName, RoleBo.class, primaryKeys); |
53 | 0 | }else if(NAMESPACE_CODE.equals(propertyName)){ |
54 | 0 | Map<String, String> primaryKeys = new HashMap<String, String>(); |
55 | 0 | primaryKeys.put(propertyName, "code"); |
56 | 0 | inquiry.buildInquiryLink(dataObject, propertyName, NamespaceBo.class, primaryKeys); |
57 | 0 | } else if("kimRoleType.name".equals(propertyName)){ |
58 | 0 | Map<String, String> primaryKeys = new HashMap<String, String>(); |
59 | 0 | primaryKeys.put("kimRoleType.id", KimConstants.PrimaryKeyConstants.KIM_TYPE_ID); |
60 | 0 | inquiry.buildInquiryLink(dataObject, propertyName, KimTypeBo.class, primaryKeys); |
61 | 0 | }else{ |
62 | 0 | super.buildInquirableLink(dataObject, propertyName, inquiry); |
63 | |
} |
64 | 0 | } |
65 | |
|
66 | |
@Override |
67 | |
public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { |
68 | 0 | if(ROLE_NAME.equals(attributeName)){ |
69 | 0 | List<String> primaryKeys = new ArrayList<String>(); |
70 | 0 | primaryKeys.add(ROLE_ID); |
71 | |
|
72 | 0 | String href = (getInquiryUrlForPrimaryKeys(RoleBo.class, businessObject, primaryKeys, null)).getHref(); |
73 | 0 | HtmlData.AnchorHtmlData htmlData = new HtmlData.AnchorHtmlData(); |
74 | 0 | htmlData.setHref(RoleLookupableHelperServiceImpl.getCustomRoleInquiryHref(href)); |
75 | 0 | return htmlData; |
76 | 0 | } else if(NAMESPACE_CODE.equals(attributeName)){ |
77 | 0 | List<String> primaryKeys = new ArrayList<String>(); |
78 | 0 | primaryKeys.add("code"); |
79 | 0 | NamespaceBo parameterNamespace = new NamespaceBo(); |
80 | 0 | parameterNamespace.setCode((String)ObjectUtils.getPropertyValue(businessObject, attributeName)); |
81 | 0 | return getInquiryUrlForPrimaryKeys(NamespaceBo.class, parameterNamespace, primaryKeys, null); |
82 | 0 | } else if("kimRoleType.name".equals(attributeName)){ |
83 | 0 | KimTypeBo kimType = new KimTypeBo(); |
84 | 0 | kimType.setId( ((RoleBo)businessObject).getKimTypeId() ); |
85 | 0 | return getInquiryUrlForPrimaryKeys(KimTypeBo.class, kimType, Collections.singletonList( KimConstants.PrimaryKeyConstants.KIM_TYPE_ID ), null); |
86 | |
} |
87 | |
|
88 | 0 | return super.getInquiryUrl(businessObject, attributeName, forceInquiry); |
89 | |
} |
90 | |
|
91 | |
} |