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