Coverage Report - org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementDocumentFormBase
0%
0/37
0%
0/14
2.125
 
 1  
 /*
 2  
  * Copyright 2006-2011 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.web.struts.form;
 17  
 
 18  
 import org.apache.log4j.Logger;
 19  
 import org.kuali.rice.core.api.parameter.Parameter;
 20  
 import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator;
 21  
 import org.kuali.rice.kim.util.KimConstants;
 22  
 import org.kuali.rice.kns.util.PagingBannerUtils;
 23  
 import org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata;
 24  
 import org.kuali.rice.kns.web.struts.form.KualiTransactionalDocumentFormBase;
 25  
 import org.kuali.rice.krad.util.KRADConstants;
 26  
 
 27  
 import javax.servlet.http.HttpServletRequest;
 28  
 import java.util.ArrayList;
 29  
 import java.util.List;
 30  
 
 31  
 /**
 32  
  * This is a description of what this class does - kellerj don't forget to fill this in. 
 33  
  * 
 34  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 35  
  *
 36  
  */
 37  
 @SuppressWarnings("serial")
 38  0
 public abstract class IdentityManagementDocumentFormBase extends KualiTransactionalDocumentFormBase {
 39  0
         protected static final Logger LOG = Logger.getLogger(IdentityManagementDocumentFormBase.class);
 40  
     protected static final String MAX_MEMBERS_PER_PAGE_PARM = "MAX_MEMBERS_PER_PAGE";
 41  
         protected transient KualiTableRenderFormMetadata memberTableMetadata;
 42  0
     protected int recordsPerPage = -1;
 43  0
     protected boolean inquiry = false;
 44  
     
 45  
         protected static final String CHANGE_NAMESPACE_METHOD_TO_CALL = "methodToCall.changeNamespace";
 46  
         protected static final String CHANGE_MEMBER_TYPE_CODE_METHOD_TO_CALL = "methodToCall.changeMemberTypeCode";
 47  
         protected static final String CHANGE_DEL_ROLE_MEMBER_METHOD_TO_CALL = "methodToCall.changeDelegationRoleMember";
 48  
 
 49  
     /**
 50  
      * @see org.kuali.rice.krad.web.struts.form.KualiDocumentFormBase#populate(javax.servlet.http.HttpServletRequest)
 51  
      */
 52  
     @SuppressWarnings("unchecked")
 53  
         @Override
 54  
     public void populate(HttpServletRequest request) {
 55  0
         super.populate(request);
 56  
 
 57  0
         if (memberTableMetadata == null)
 58  0
                 memberTableMetadata = new KualiTableRenderFormMetadata();
 59  
 
 60  0
         if (KRADConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD.equals(getMethodToCall())) {
 61  0
             final String paramPrefix = KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + KRADConstants.TableRenderConstants.SWITCH_TO_PAGE_METHOD + ".";
 62  0
             memberTableMetadata.setSwitchToPageNumber(
 63  
                     PagingBannerUtils.getNumbericalValueAfterPrefix(paramPrefix, request.getParameterNames()));
 64  0
             if (memberTableMetadata.getSwitchToPageNumber() == -1) {
 65  0
                 throw new RuntimeException("Couldn't find page number");
 66  
             }
 67  0
         } else if (KRADConstants.TableRenderConstants.SORT_METHOD.equals(getMethodToCall())) {
 68  0
             final String paramPrefix = KRADConstants.DISPATCH_REQUEST_PARAMETER + "." + KRADConstants.TableRenderConstants.SORT_METHOD + ".";
 69  0
             memberTableMetadata.setColumnToSortIndex(PagingBannerUtils.getNumbericalValueAfterPrefix(paramPrefix, request.getParameterNames()));
 70  0
             if (memberTableMetadata.getColumnToSortIndex() == -1) {
 71  0
                 memberTableMetadata.setColumnToSortName(PagingBannerUtils.getStringValueAfterPrefix(paramPrefix, request.getParameterNames()));
 72  
             }
 73  
         }
 74  0
     }
 75  
 
 76  
         public KualiTableRenderFormMetadata getMemberTableMetadata() {
 77  0
                 return this.memberTableMetadata;
 78  
         }
 79  
 
 80  
         public void setMemberTableMetadata(
 81  
                         KualiTableRenderFormMetadata memberTableMetadata) {
 82  0
                 this.memberTableMetadata = memberTableMetadata;
 83  0
         }
 84  
 
 85  
         public int getRecordsPerPage() {
 86  0
                 if ( recordsPerPage == -1 ) {
 87  0
                         Parameter param = CoreFrameworkServiceLocator.getParameterService().getParameter(KimConstants.NAMESPACE_CODE, KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, MAX_MEMBERS_PER_PAGE_PARM);
 88  0
                         if ( param != null ) {
 89  
                                 try {
 90  0
                                         recordsPerPage = Integer.parseInt( param.getValue() );
 91  0
                                 } catch ( NumberFormatException ex ) {
 92  0
                                         LOG.error( "Unable to parse parameter " + KimConstants.NAMESPACE_CODE+"/"+ KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE+"/"+MAX_MEMBERS_PER_PAGE_PARM + "(+"+param.getValue()+") as an int - defaulting to 1." );
 93  0
                                         recordsPerPage = 1;
 94  0
                                 }
 95  
                         } else {
 96  0
                                 LOG.error( "Unable to find " + KimConstants.NAMESPACE_CODE+"/"+ KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE+"/"+MAX_MEMBERS_PER_PAGE_PARM + " - defaulting to 1." );
 97  0
                                 recordsPerPage = 1;
 98  
                         }
 99  
                 }
 100  0
                 return recordsPerPage;
 101  
         }
 102  
 
 103  
         // support for the inquiryControls tag since using same form
 104  
         public boolean isCanExport() {
 105  0
                 return false;
 106  
         }
 107  
         
 108  
         @SuppressWarnings("unchecked")
 109  
         public List getMemberRows() {
 110  0
                 return new ArrayList();
 111  
         }
 112  
 
 113  
         /**
 114  
          * @return the inquiry
 115  
          */
 116  
         public boolean isInquiry() {
 117  0
                 return this.inquiry;
 118  
         }
 119  
 
 120  
         /**
 121  
          * @param inquiry the inquiry to set
 122  
          */
 123  
         public void setInquiry(boolean inquiry) {
 124  0
                 this.inquiry = inquiry;
 125  0
         }
 126  
 }