| 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 | 0 | public class RoleInquirableImpl extends KualiInquirableImpl { |
| 40 | |
|
| 41 | 0 | protected final String ROLE_NAME = "roleName"; |
| 42 | 0 | protected final String ROLE_ID = "roleId"; |
| 43 | 0 | protected final String NAMESPACE_CODE = "namespaceCode"; |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
@Override |
| 50 | |
public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) { |
| 51 | 0 | if(ROLE_NAME.equals(attributeName)){ |
| 52 | 0 | List<String> primaryKeys = new ArrayList<String>(); |
| 53 | 0 | primaryKeys.add(ROLE_ID); |
| 54 | |
|
| 55 | 0 | String href = (getInquiryUrlForPrimaryKeys(RoleImpl.class, businessObject, primaryKeys, null)).getHref(); |
| 56 | 0 | AnchorHtmlData htmlData = new AnchorHtmlData(); |
| 57 | 0 | htmlData.setHref(RoleLookupableHelperServiceImpl.getCustomRoleInquiryHref(href)); |
| 58 | 0 | return htmlData; |
| 59 | 0 | } else if(NAMESPACE_CODE.equals(attributeName)){ |
| 60 | 0 | List<String> primaryKeys = new ArrayList<String>(); |
| 61 | 0 | primaryKeys.add("code"); |
| 62 | 0 | Namespace parameterNamespace = new Namespace(); |
| 63 | 0 | parameterNamespace.setCode((String)ObjectUtils.getPropertyValue(businessObject, attributeName)); |
| 64 | 0 | return getInquiryUrlForPrimaryKeys(Namespace.class, parameterNamespace, primaryKeys, null); |
| 65 | 0 | } else if("kimRoleType.name".equals(attributeName)){ |
| 66 | 0 | KimTypeImpl kimType = new KimTypeImpl(); |
| 67 | 0 | kimType.setKimTypeId( ((RoleImpl)businessObject).getKimTypeId() ); |
| 68 | 0 | return getInquiryUrlForPrimaryKeys(KimTypeImpl.class, kimType, Collections.singletonList( KimConstants.PrimaryKeyConstants.KIM_TYPE_ID ), null); |
| 69 | |
} |
| 70 | |
|
| 71 | 0 | return super.getInquiryUrl(businessObject, attributeName, forceInquiry); |
| 72 | |
} |
| 73 | |
|
| 74 | |
} |