Coverage Report - org.kuali.rice.kim.web.struts.form.IdentityManagementGroupDocumentForm
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementGroupDocumentForm
0%
0/45
0%
0/18
2.059
 
 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.web.struts.form;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.web.format.DateDisplayTimestampObjectFormatter;
 20  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 21  
 import org.kuali.rice.kim.api.type.KimType;
 22  
 import org.kuali.rice.kim.bo.impl.PersonImpl;
 23  
 import org.kuali.rice.kim.bo.impl.RoleImpl;
 24  
 import org.kuali.rice.kim.bo.ui.GroupDocumentMember;
 25  
 import org.kuali.rice.kim.document.IdentityManagementGroupDocument;
 26  
 import org.kuali.rice.kim.impl.group.GroupBo;
 27  
 import org.kuali.rice.kim.impl.type.KimTypeBo;
 28  
 import org.kuali.rice.kim.util.KimConstants;
 29  
 
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * This is a description of what this class does - shyu don't forget to fill this in. 
 34  
  * 
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  *
 37  
  */
 38  
 public class IdentityManagementGroupDocumentForm extends IdentityManagementDocumentFormBase {
 39  
         protected static final long serialVersionUID = -107836689162363400L;
 40  
         
 41  
         {
 42  0
                 requiredNonEditableProperties.add("methodToCall");
 43  
         }
 44  
         
 45  0
         protected boolean canAssignGroup = true;
 46  
         
 47  
         protected KimType kimType;
 48  0
         protected GroupDocumentMember member = new GroupDocumentMember();
 49  
         protected String groupId;
 50  
     
 51  
         public IdentityManagementGroupDocumentForm() {
 52  0
         super();
 53  0
         setFormatterType("document.members.activeFromDate", DateDisplayTimestampObjectFormatter.class);
 54  0
         setFormatterType("document.members.activeToDate", DateDisplayTimestampObjectFormatter.class);
 55  0
     }
 56  
 
 57  
         @Override
 58  
         public String getDefaultDocumentTypeName(){
 59  0
                 return "IdentityManagementGroupDocument";
 60  
         }
 61  
         
 62  
         public IdentityManagementGroupDocument getGroupDocument() {
 63  0
         return (IdentityManagementGroupDocument) this.getDocument();
 64  
     }
 65  
 
 66  
         public String getMemberFieldConversions(){
 67  0
                 if(member==null) {
 68  0
                         return "";
 69  
                 }
 70  0
                 return getMemberFieldConversions(member.getMemberTypeCode());
 71  
         }
 72  
 
 73  
         public String getMemberBusinessObjectName(){
 74  0
                 if(member==null) {
 75  0
                         return "";
 76  
                 }
 77  0
                 return getMemberBusinessObjectName(member.getMemberTypeCode());
 78  
         }
 79  
 
 80  
         protected String getMemberFieldConversions(String memberTypeCode){
 81  0
                 if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode))
 82  0
                         return "principalId:member.memberId,principalName:member.memberName";
 83  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode))
 84  0
                         return "roleId:member.memberId,roleName:member.memberName";
 85  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode))
 86  0
                         return "id:member.memberId,name:member.memberName,namespaceCode:member.memberNamespaceCode";
 87  0
                 return "";
 88  
         }
 89  
 
 90  
         protected String getMemberBusinessObjectName(String memberTypeCode){
 91  0
                 if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode))
 92  0
                         return PersonImpl.class.getName();
 93  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode))
 94  0
                         return RoleImpl.class.getName();
 95  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode))
 96  0
                         return GroupBo.class.getName();
 97  0
                 return "";
 98  
         }
 99  
 
 100  
         /**
 101  
          * @return the kimType
 102  
          */
 103  
         public KimType getKimType() {
 104  0
                 if(StringUtils.isNotBlank(getGroupDocument().getGroupTypeId()))
 105  0
                         return KimApiServiceLocator.getKimTypeInfoService().getKimType(getGroupDocument().getGroupTypeId());
 106  0
                 else return kimType;
 107  
         }
 108  
 
 109  
         public String getKimTypeClass(){
 110  0
                 return KimTypeBo.class.getName();
 111  
         }
 112  
         /**
 113  
          * @return the canAssignGroup
 114  
          */
 115  
         public boolean isCanAssignGroup() {
 116  0
                 return this.canAssignGroup;
 117  
         }
 118  
 
 119  
         /**
 120  
          * @param canAssignGroup the canAssignGroup to set
 121  
          */
 122  
         public void setCanAssignGroup(boolean canAssignGroup) {
 123  0
                 this.canAssignGroup = canAssignGroup;
 124  0
         }
 125  
 
 126  
         /**
 127  
          * @return the member
 128  
          */
 129  
         public GroupDocumentMember getMember() {
 130  0
                 return this.member;
 131  
         }
 132  
 
 133  
         /**
 134  
          * @param member the member to set
 135  
          */
 136  
         public void setMember(GroupDocumentMember member) {
 137  0
                 this.member = member;
 138  0
         }
 139  
         
 140  
         /**
 141  
          * This overridden method ...
 142  
          * 
 143  
          * @see org.kuali.rice.kim.web.struts.form.IdentityManagementDocumentFormBase#getMemberRows()
 144  
          */
 145  
         @SuppressWarnings("unchecked")
 146  
         @Override
 147  
         public List getMemberRows() {
 148  0
                 return getGroupDocument().getMembers();
 149  
         }
 150  
 
 151  
         /**
 152  
          * @return the groupId
 153  
          */
 154  
         public String getGroupId() {
 155  0
                 return this.groupId;
 156  
         }
 157  
 
 158  
         /**
 159  
          * @param groupId the groupId to set
 160  
          */
 161  
         public void setGroupId(String groupId) {
 162  0
                 this.groupId = groupId;
 163  0
         }
 164  
 
 165  
         /**
 166  
          * @param kimType the kimType to set
 167  
          */
 168  
         public void setKimType(KimType kimType) {
 169  0
                 this.kimType = kimType;
 170  0
         }
 171  
 
 172  
 }