Coverage Report - org.kuali.rice.kim.inquiry.GroupInquirableImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
GroupInquirableImpl
0%
0/35
0%
0/12
4
 
 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 org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kim.bo.impl.GroupImpl;
 20  
 import org.kuali.rice.kim.bo.types.impl.KimTypeImpl;
 21  
 import org.kuali.rice.kim.util.KimCommonUtils;
 22  
 import org.kuali.rice.kim.util.KimConstants;
 23  
 import org.kuali.rice.kns.bo.BusinessObject;
 24  
 import org.kuali.rice.kns.bo.Namespace;
 25  
 import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
 26  
 import org.kuali.rice.kns.lookup.HtmlData;
 27  
 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
 28  
 import org.kuali.rice.kns.util.KNSConstants;
 29  
 import org.kuali.rice.kns.util.ObjectUtils;
 30  
 import org.kuali.rice.kns.util.UrlFactory;
 31  
 
 32  
 import java.util.*;
 33  
 
 34  
 /**
 35  
  * This is a description of what this class does - kellerj don't forget to fill this in.
 36  
  *
 37  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 38  
  *
 39  
  */
 40  0
 public class GroupInquirableImpl extends KualiInquirableImpl {
 41  
 
 42  
 
 43  0
         protected final String GROUP_NAME = "groupName";
 44  0
         protected final String GROUP_ID = "groupId";
 45  0
         protected final String NAMESPACE_CODE = "namespaceCode";
 46  
         
 47  
     /**
 48  
      * @see org.kuali.kfs.sys.businessobject.inquiry.KfsInquirableImpl#getInquiryUrl(org.kuali.rice.kns.bo.BusinessObject,
 49  
      *      java.lang.String, boolean)
 50  
      */
 51  
     @Override
 52  
     public HtmlData getInquiryUrl(BusinessObject businessObject, String attributeName, boolean forceInquiry) {
 53  0
                 if(GROUP_NAME.equals(attributeName)){
 54  0
                         List<String> primaryKeys = new ArrayList<String>();
 55  0
                         primaryKeys.add(GROUP_ID);
 56  0
                     String href = (getInquiryUrlForPrimaryKeys(GroupImpl.class, businessObject, primaryKeys, null)).getHref();
 57  0
                     AnchorHtmlData htmlData = new AnchorHtmlData();
 58  0
                     htmlData.setHref(getCustomGroupInquiryHref(href));
 59  0
                         return htmlData;
 60  0
                 } else if(NAMESPACE_CODE.equals(attributeName)){
 61  0
                         List<String> primaryKeys = new ArrayList<String>();
 62  0
                         primaryKeys.add("code");
 63  0
                         Namespace parameterNamespace = new Namespace();
 64  0
                         parameterNamespace.setCode((String)ObjectUtils.getPropertyValue(businessObject, attributeName));
 65  0
                         return getInquiryUrlForPrimaryKeys(Namespace.class, parameterNamespace, primaryKeys, null);
 66  0
                 } else if("kimTypeInfo.name".equals(attributeName)){
 67  0
                         KimTypeImpl kimType = new KimTypeImpl();
 68  0
                         kimType.setKimTypeId( ((GroupImpl)businessObject).getKimTypeId() );
 69  0
                         return getInquiryUrlForPrimaryKeys(KimTypeImpl.class, kimType, Collections.singletonList( KimConstants.PrimaryKeyConstants.KIM_TYPE_ID ), null);
 70  
         }
 71  
                 
 72  0
         return super.getInquiryUrl(businessObject, attributeName, forceInquiry);
 73  
     }
 74  
 
 75  
         public String getCustomGroupInquiryHref(String href){
 76  0
         Properties parameters = new Properties();
 77  0
         String hrefPart = "";
 78  0
                 if (StringUtils.isNotBlank(href) && href.contains("&" + KimConstants.PrimaryKeyConstants.GROUP_ID + "=")) {
 79  0
                         int idx1 = href.indexOf("&"+KimConstants.PrimaryKeyConstants.GROUP_ID+"=");
 80  0
                     int idx2 = href.indexOf("&", idx1+1);
 81  0
                     if (idx2 < 0) {
 82  0
                             idx2 = href.length();
 83  
                     }
 84  0
                 parameters.put(KNSConstants.DISPATCH_REQUEST_PARAMETER, KNSConstants.PARAM_MAINTENANCE_VIEW_MODE_INQUIRY);
 85  0
                 hrefPart = href.substring(idx1, idx2);
 86  
             }
 87  0
                 return UrlFactory.parameterizeUrl(KimCommonUtils.getKimBasePath()+
 88  
                                 KimConstants.KimUIConstants.KIM_GROUP_INQUIRY_ACTION, parameters)+hrefPart;
 89  
         }
 90  
 
 91  
         /**
 92  
          * This overridden method ...
 93  
          *
 94  
          * @see org.kuali.rice.kns.inquiry.KualiInquirableImpl#getBusinessObject(java.util.Map)
 95  
          */
 96  
         @SuppressWarnings("unchecked")
 97  
         @Override
 98  
         public BusinessObject getBusinessObject(Map fieldValues) {
 99  0
             BusinessObject bo = super.getBusinessObject(fieldValues);
 100  0
             ((GroupImpl)bo).setMemberPersonsAndGroups();
 101  0
             return bo;
 102  
         }
 103  
 
 104  
 }