1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.businessobject.inquiry;
17
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.ole.select.businessobject.OlePersonRequestor;
21 import org.kuali.ole.sys.businessobject.inquiry.KfsInquirableImpl;
22 import org.kuali.rice.kns.lookup.HtmlData;
23 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
24 import org.kuali.rice.krad.bo.BusinessObject;
25 import org.kuali.rice.krad.util.KRADConstants;
26 import org.kuali.rice.krad.util.ObjectUtils;
27 import org.kuali.rice.krad.util.UrlFactory;
28
29 import java.util.*;
30
31
32
33
34
35 public class OlePersonRequestorInquirableImpl extends KfsInquirableImpl {
36
37
38
39
40
41
42
43
44
45 @Override
46 public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
47 if (businessObject instanceof OlePersonRequestor && attributeName.equalsIgnoreCase("id")) {
48 List<String> primaryKeys = new ArrayList<String>();
49 primaryKeys.add("id");
50 String href = (getInquiryUrlForPrimaryKeys(OlePersonRequestor.class, businessObject, primaryKeys, null)).getHref();
51 href = "kr/" + href;
52 AnchorHtmlData htmlData = new AnchorHtmlData();
53 htmlData.setHref(href);
54 return htmlData;
55 }
56
57 return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
58 }
59
60 @Override
61 public AnchorHtmlData getInquiryUrlForPrimaryKeys(
62 Class clazz, Object businessObject, List<String> primaryKeys, String displayText) {
63 Map<String, String> fieldList = new HashMap<String, String>();
64 if (businessObject == null) {
65 return new AnchorHtmlData(KRADConstants.EMPTY_STRING, KRADConstants.EMPTY_STRING);
66 }
67
68 Properties parameters = new Properties();
69 parameters.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.START_METHOD);
70 OlePersonRequestor olePersonRequestor = (OlePersonRequestor) businessObject;
71 if (olePersonRequestor.getInternalRequestorId() != null) {
72 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, "org.kuali.rice.kim.api.identity.Person");
73 parameters.put("principalId", olePersonRequestor.getInternalRequestorId());
74 fieldList.put("principalId", olePersonRequestor.getInternalRequestorId());
75 } else if (olePersonRequestor.getExternalRequestorId() != null) {
76 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, "org.kuali.ole.select.businessobject.OleRequestor");
77 parameters.put("requestorId", olePersonRequestor.getExternalRequestorId());
78 fieldList.put("requestorId", olePersonRequestor.getExternalRequestorId());
79 } else {
80 parameters.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, clazz.getClass());
81 String titleAttributeValue;
82 for (String primaryKey : primaryKeys) {
83 titleAttributeValue = ObjectUtils.getPropertyValue(businessObject, primaryKey).toString();
84 parameters.put(primaryKey, titleAttributeValue);
85 fieldList.put(primaryKey, titleAttributeValue);
86 }
87 }
88 if (StringUtils.isEmpty(displayText)) {
89 return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters));
90 } else {
91 return getHyperLink(clazz, fieldList, UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, parameters), displayText);
92 }
93 }
94
95 }