Coverage Report - org.kuali.rice.kim.web.struts.form.IdentityManagementRoleDocumentForm
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementRoleDocumentForm
0%
0/100
0%
0/40
2.062
 
 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 java.util.List;
 19  
 
 20  
 import org.apache.commons.lang.StringUtils;
 21  
 import org.kuali.rice.kim.bo.impl.GroupImpl;
 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.types.dto.KimTypeInfo;
 25  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember;
 26  
 import org.kuali.rice.kim.bo.ui.KimDocumentRolePermission;
 27  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier;
 28  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleResponsibility;
 29  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember;
 30  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier;
 31  
 import org.kuali.rice.kim.document.IdentityManagementRoleDocument;
 32  
 import org.kuali.rice.kim.util.KimConstants;
 33  
 import org.kuali.rice.kns.util.TableRenderUtil;
 34  
 import org.kuali.rice.kns.web.format.DateDisplayTimestampObjectFormatter;
 35  
 
 36  
 /**
 37  
  * This is a description of what this class does - shyu don't forget to fill this in. 
 38  
  * 
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  *
 41  
  */
 42  
 public class IdentityManagementRoleDocumentForm extends IdentityManagementDocumentFormBase {
 43  
         protected static final long serialVersionUID = 7099079353241080483L;
 44  
         {
 45  0
                 requiredNonEditableProperties.add("methodToCall");
 46  0
                 requiredNonEditableProperties.add("roleCommand");
 47  
         }
 48  
         
 49  
         protected String delegationMemberRoleMemberId;
 50  
         protected String dmrmi;
 51  0
         protected boolean canAssignRole = true;
 52  0
         protected boolean canModifyAssignees = true;
 53  
         protected KimTypeInfo kimType;
 54  
         protected KimDocumentRoleMember member;
 55  
         {
 56  0
                 member = new KimDocumentRoleMember();
 57  0
                 member.getQualifiers().add(new KimDocumentRoleQualifier());
 58  
         }
 59  
         protected KimDocumentRolePermission permission;
 60  
         protected KimDocumentRoleResponsibility responsibility;
 61  
         protected RoleDocumentDelegationMember delegationMember;
 62  
         {
 63  0
                 delegationMember = new RoleDocumentDelegationMember();
 64  0
                 delegationMember.getQualifiers().add(new RoleDocumentDelegationMemberQualifier());
 65  
         }
 66  
         protected String roleId;
 67  
 
 68  
 
 69  
         public IdentityManagementRoleDocumentForm() {
 70  0
         super();
 71  0
         setFormatterType("document.members.activeFromDate", DateDisplayTimestampObjectFormatter.class);
 72  0
         setFormatterType("document.delegationMembers.activeFromDate", DateDisplayTimestampObjectFormatter.class);
 73  0
         setFormatterType("document.members.activeToDate", DateDisplayTimestampObjectFormatter.class);
 74  0
         setFormatterType("document.delegationMembers.activeToDate", DateDisplayTimestampObjectFormatter.class);
 75  0
     }
 76  
         
 77  
     /**
 78  
          * @return the delegationMember
 79  
          */
 80  
         public RoleDocumentDelegationMember getDelegationMember() {
 81  0
                 return this.delegationMember;
 82  
         }
 83  
 
 84  
         /**
 85  
          * @param delegationMember the delegationMember to set
 86  
          */
 87  
         public void setDelegationMember(RoleDocumentDelegationMember delegationMember) {
 88  0
                 this.delegationMember = delegationMember;
 89  0
         }
 90  
 
 91  
         @Override
 92  
         public String getDefaultDocumentTypeName(){
 93  0
                 return "IdentityManagementRoleDocument";
 94  
         }
 95  
         
 96  
         public IdentityManagementRoleDocument getRoleDocument() {
 97  0
         return (IdentityManagementRoleDocument) this.getDocument();
 98  
     }
 99  
 
 100  
         /**
 101  
          * @return the member
 102  
          */
 103  
         public KimDocumentRoleMember getMember() {
 104  0
                 return this.member;
 105  
         }
 106  
 
 107  
         /**
 108  
          * @param member the member to set
 109  
          */
 110  
         public void setMember(KimDocumentRoleMember member) {
 111  0
                 this.member = member;
 112  0
         }
 113  
 
 114  
         /**
 115  
          * @return the permission
 116  
          */
 117  
         public KimDocumentRolePermission getPermission() {
 118  0
                 return this.permission;
 119  
         }
 120  
 
 121  
         /**
 122  
          * @param permission the permission to set
 123  
          */
 124  
         public void setPermission(KimDocumentRolePermission permission) {
 125  0
                 this.permission = permission;
 126  0
         }
 127  
 
 128  
         /**
 129  
          * @return the responsibility
 130  
          */
 131  
         public KimDocumentRoleResponsibility getResponsibility() {
 132  0
                 return this.responsibility;
 133  
         }
 134  
 
 135  
         /**
 136  
          * @param responsibility the responsibility to set
 137  
          */
 138  
         public void setResponsibility(KimDocumentRoleResponsibility responsibility) {
 139  0
                 this.responsibility = responsibility;
 140  0
         }
 141  
 
 142  
         public String getMemberFieldConversions(){
 143  0
                 if(member==null)
 144  0
                         return "";
 145  0
                 return getMemberFieldConversions(member.getMemberTypeCode());
 146  
         }
 147  
 
 148  
         public String getMemberBusinessObjectName(){
 149  0
                 if(member==null)
 150  0
                         return "";
 151  0
                 return getMemberBusinessObjectName(member.getMemberTypeCode());
 152  
         }
 153  
 
 154  
         public String getDelegationMemberFieldConversions(){
 155  0
                 if(getDelegationMember()==null)
 156  0
                         return "";
 157  0
                 String memberTypeCode = getDelegationMember().getMemberTypeCode();
 158  0
                 if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode))
 159  0
                         return "principalId:delegationMember.memberId,principalName:delegationMember.memberName";
 160  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode))
 161  0
                         return "roleId:delegationMember.memberId,roleName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode";
 162  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode))
 163  0
                         return "groupId:delegationMember.memberId,groupName:delegationMember.memberName,namespaceCode:delegationMember.memberNamespaceCode";
 164  0
                 return "";
 165  
         }
 166  
 
 167  
         public String getDelegationMemberBusinessObjectName(){
 168  0
                 if(getDelegationMember()==null)
 169  0
                         return "";
 170  0
                 return getMemberBusinessObjectName(getDelegationMember().getMemberTypeCode());
 171  
         }
 172  
 
 173  
         protected String getMemberFieldConversions(String memberTypeCode){
 174  0
                 if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode))
 175  0
                         return "principalId:member.memberId,principalName:member.memberName";
 176  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode))
 177  0
                         return "roleId:member.memberId,roleName:member.memberName,namespaceCode:member.memberNamespaceCode";
 178  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode))
 179  0
                         return "groupId:member.memberId,groupName:member.memberName,namespaceCode:member.memberNamespaceCode";
 180  0
                 return "";
 181  
         }
 182  
 
 183  
         protected String getMemberBusinessObjectName(String memberTypeCode){
 184  0
                 if(KimConstants.KimUIConstants.MEMBER_TYPE_PRINCIPAL_CODE.equals(memberTypeCode))
 185  0
                         return PersonImpl.class.getName();
 186  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_ROLE_CODE.equals(memberTypeCode))
 187  0
                         return RoleImpl.class.getName();
 188  0
                 else if(KimConstants.KimUIConstants.MEMBER_TYPE_GROUP_CODE.equals(memberTypeCode))
 189  0
                         return GroupImpl.class.getName();
 190  0
                 return "";
 191  
         }
 192  
 
 193  
         /**
 194  
          * @return the kimType
 195  
          */
 196  
         public KimTypeInfo getKimType() {
 197  0
                 return this.kimType;
 198  
         }
 199  
 
 200  
         /**
 201  
          * @param kimType the kimType to set
 202  
          */
 203  
         public void setKimType(KimTypeInfo kimType) {
 204  0
                 this.kimType = kimType;
 205  0
                 if ( kimType != null && getRoleDocument() != null ) {
 206  0
                         getRoleDocument().setKimType(kimType);
 207  
                 }
 208  0
         }
 209  
 
 210  
         /**
 211  
          * @return the canAssignRole
 212  
          */
 213  
         public boolean isCanAssignRole() {
 214  0
                 return this.canAssignRole;
 215  
         }
 216  
 
 217  
         /**
 218  
          * @param canAssignRole the canAssignRole to set
 219  
          */
 220  
         public void setCanAssignRole(boolean canAssignRole) {
 221  0
                 this.canAssignRole = canAssignRole;
 222  0
         }
 223  
 
 224  
         /**
 225  
          * @return the canModifyAssignees
 226  
          */
 227  
         public boolean isCanModifyAssignees() {
 228  0
                 return this.canModifyAssignees;
 229  
         }
 230  
 
 231  
         /**
 232  
          * @param canModifyAssignees the canModifyAssignees to set
 233  
          */
 234  
         public void setCanModifyAssignees(boolean canModifyAssignees) {
 235  0
                 this.canModifyAssignees = canModifyAssignees;
 236  0
         }
 237  
         
 238  
         public List<KimDocumentRoleMember> getMemberRows() {
 239  0
                 return getRoleDocument().getMembers();
 240  
         }
 241  
 
 242  
         public int getIndexOfRoleMemberFromMemberRows(String roleMemberId){
 243  0
                 int index = 0;
 244  0
                 for(KimDocumentRoleMember roleMember: getMemberRows()){
 245  0
                         if(StringUtils.equals(roleMember.getRoleMemberId(), roleMemberId)){
 246  0
                                 break;
 247  
                         }
 248  0
                         index++;
 249  
                 }
 250  0
                 return index;
 251  
         }
 252  
 
 253  
         public int getPageNumberOfRoleMemberId(String roleMemberId){
 254  0
                 if(StringUtils.isEmpty(roleMemberId)) return 1;
 255  0
                 int index = getIndexOfRoleMemberFromMemberRows(roleMemberId);
 256  0
                 return TableRenderUtil.computeTotalNumberOfPages(index+1, getRecordsPerPage())-1;
 257  
         }
 258  
         
 259  
         /**
 260  
          * @return the roleId
 261  
          */
 262  
         public String getRoleId() {
 263  0
                 return this.roleId;
 264  
         }
 265  
 
 266  
         /**
 267  
          * @param roleId the roleId to set
 268  
          */
 269  
         public void setRoleId(String roleId) {
 270  0
                 this.roleId = roleId;
 271  0
         }
 272  
 
 273  
         /**
 274  
          * @return the delegationMemberRoleMemberId
 275  
          */
 276  
         public String getDelegationMemberRoleMemberId() {
 277  0
                 return this.delegationMemberRoleMemberId;
 278  
         }
 279  
 
 280  
         /**
 281  
          * @param delegationMemberRoleMemberId the delegationMemberRoleMemberId to set
 282  
          */
 283  
         public void setDelegationMemberRoleMemberId(String delegationMemberRoleMemberId) {
 284  0
                 this.delegationMemberRoleMemberId = delegationMemberRoleMemberId;
 285  0
                 getDelegationMember().setRoleMemberId(delegationMemberRoleMemberId);
 286  0
                 KimDocumentRoleMember roleMember = getRoleDocument().getMember(delegationMemberRoleMemberId);
 287  0
                 if(roleMember!=null){
 288  0
                         delegationMember.setRoleMemberId(roleMember.getRoleMemberId());
 289  0
                         delegationMember.setRoleMemberName(roleMember.getMemberName());
 290  0
                         delegationMember.setRoleMemberNamespaceCode(roleMember.getMemberNamespaceCode());
 291  
                         RoleDocumentDelegationMemberQualifier delegationMemberQualifier;
 292  0
                         for(KimDocumentRoleQualifier roleQualifier: roleMember.getQualifiers()){
 293  0
                                 delegationMemberQualifier = getDelegationMember().getQualifier(roleQualifier.getKimAttrDefnId());
 294  0
                                 delegationMemberQualifier.setAttrVal(roleQualifier.getAttrVal());
 295  
                         }
 296  
                 }
 297  0
         }
 298  
 
 299  
         /**
 300  
          * @return the dmrmi
 301  
          */
 302  
         public String getDmrmi() {
 303  0
                 return this.dmrmi;
 304  
         }
 305  
 
 306  
         /**
 307  
          * @param dmrmi the dmrmi to set
 308  
          */
 309  
         public void setDmrmi(String dmrmi) {
 310  0
                 this.dmrmi = dmrmi;
 311  0
         }
 312  
 
 313  
 }