View Javadoc

1   /*
2    * Copyright 2007-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * This is a description of what this class does - bhargavp don't forget to fill this in. 
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   *
38   */
39  public class RoleInquirableImpl extends KualiInquirableImpl {
40  
41  	protected final String ROLE_NAME = "roleName";
42  	protected final String ROLE_ID = "roleId";
43  	protected final String NAMESPACE_CODE = "namespaceCode";
44  	
45      /**
46       * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject,
47       *      java.lang.String, boolean)
48       */
49      @Override
50      public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
51  		if(ROLE_NAME.equals(attributeName)){
52  			List<String> primaryKeys = new ArrayList<String>();
53  			primaryKeys.add(ROLE_ID);
54  		    //((AnchorHtmlData)inqUrl).setHref("../kim/identityManagementRoleDocument.do?methodToCall=inquiry&command=initiate&docTypeName=IdentityManagementRoleDocument"+href.substring(idx1, idx2));
55  		    String href = (getInquiryUrlForPrimaryKeys(RoleImpl.class, businessObject, primaryKeys, null)).getHref();
56  		    AnchorHtmlData htmlData = new AnchorHtmlData();
57  		    htmlData.setHref(RoleLookupableHelperServiceImpl.getCustomRoleInquiryHref(href));
58  			return htmlData;
59  		} else if(NAMESPACE_CODE.equals(attributeName)){
60  			List<String> primaryKeys = new ArrayList<String>();
61  			primaryKeys.add("code");
62  			Namespace parameterNamespace = new Namespace();
63  			parameterNamespace.setCode((String)ObjectUtils.getPropertyValue(businessObject, attributeName));
64  			return getInquiryUrlForPrimaryKeys(Namespace.class, parameterNamespace, primaryKeys, null);
65  		} else if("kimRoleType.name".equals(attributeName)){
66  			KimTypeImpl kimType = new KimTypeImpl();
67  			kimType.setKimTypeId( ((RoleImpl)businessObject).getKimTypeId() );
68  			return getInquiryUrlForPrimaryKeys(KimTypeImpl.class, kimType, Collections.singletonList( KimConstants.PrimaryKeyConstants.KIM_TYPE_ID ), null);
69          }
70  		
71          return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
72      }
73  
74  }