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