Coverage Report - org.kuali.rice.kim.document.IdentityManagementRoleDocument
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementRoleDocument
0%
0/216
0%
0/104
2.32
IdentityManagementRoleDocument$RoleMemberMetaDataType
0%
0/19
0%
0/12
2.32
 
 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.document;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
 20  
 import org.kuali.rice.kim.bo.types.dto.KimTypeInfo;
 21  
 import org.kuali.rice.kim.bo.ui.*;
 22  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 23  
 import org.kuali.rice.kim.service.KIMServiceLocatorInternal;
 24  
 import org.kuali.rice.kim.service.KIMServiceLocatorWeb;
 25  
 import org.kuali.rice.kim.service.ResponsibilityService;
 26  
 import org.kuali.rice.kim.util.KimConstants;
 27  
 import org.kuali.rice.kim.web.struts.form.IdentityManagementRoleDocumentForm;
 28  
 import org.kuali.rice.kns.datadictionary.AttributeDefinition;
 29  
 import org.kuali.rice.kns.datadictionary.KimDataDictionaryAttributeDefinition;
 30  
 import org.kuali.rice.kns.datadictionary.KimNonDataDictionaryAttributeDefinition;
 31  
 import org.kuali.rice.kns.service.SequenceAccessorService;
 32  
 import org.springframework.util.AutoPopulatingList;
 33  
 
 34  
 import java.util.ArrayList;
 35  
 import java.util.Comparator;
 36  
 import java.util.List;
 37  
 
 38  
 
 39  
 /**
 40  
  * This is a description of what this class does - bhargavp don't forget to fill this in. 
 41  
  * 
 42  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 43  
  *
 44  
  */
 45  
 public class IdentityManagementRoleDocument extends IdentityManagementTypeAttributeTransactionalDocument {
 46  
 
 47  
         private static final long serialVersionUID = 1L;
 48  
         // principal data
 49  
         protected String roleId;
 50  
         protected String roleTypeId;
 51  
         protected String roleTypeName;
 52  0
         protected String roleNamespace = "";
 53  0
         protected String roleName = "";
 54  0
         protected String roleDescription = "";
 55  
 
 56  0
         protected boolean active = true;
 57  
 
 58  
         protected boolean editing;
 59  
         
 60  0
         protected List<KimDocumentRolePermission> permissions = new AutoPopulatingList(KimDocumentRolePermission.class);
 61  0
         protected List<KimDocumentRoleResponsibility> responsibilities = new AutoPopulatingList(KimDocumentRoleResponsibility.class);
 62  0
         protected List<KimDocumentRoleMember> members = new AutoPopulatingList(KimDocumentRoleMember.class);
 63  0
         private List<RoleDocumentDelegationMember> delegationMembers = new AutoPopulatingList(RoleDocumentDelegationMember.class);
 64  0
         private List<RoleDocumentDelegation> delegations = new AutoPopulatingList(RoleDocumentDelegation.class);
 65  
         
 66  
         transient private ResponsibilityService responsibilityService;
 67  
         
 68  0
         public IdentityManagementRoleDocument() {
 69  0
         }
 70  
 
 71  
         /**
 72  
          * @return the active
 73  
          */
 74  
         public boolean isActive() {
 75  0
                 return this.active;
 76  
         }
 77  
 
 78  
         /**
 79  
          * @param active the active to set
 80  
          */
 81  
         public void setActive(boolean active) {
 82  0
                 this.active = active;
 83  0
         }
 84  
 
 85  
         /**
 86  
          * @param roleId the roleId to set
 87  
          */
 88  
         public void setRoleId(String roleId) {
 89  0
                 this.roleId = roleId;
 90  0
         }
 91  
 
 92  
         /**
 93  
          * @return the roleName
 94  
          */
 95  
         public String getRoleName() {
 96  0
                 return this.roleName;
 97  
         }
 98  
 
 99  
         /**
 100  
          * @param roleName the roleName to set
 101  
          */
 102  
         public void setRoleName(String roleName) {
 103  0
                 this.roleName = roleName;
 104  0
         }
 105  
 
 106  
         /**
 107  
          * @return the roleDescription
 108  
          */
 109  
         public String getRoleDescription() {
 110  0
                 return this.roleDescription;
 111  
         }
 112  
 
 113  
         /**
 114  
          * @param roleDescription the roleDescription to set
 115  
          */
 116  
         public void setRoleDescription(String roleDescription) {
 117  0
                 this.roleDescription = roleDescription;
 118  0
         }
 119  
 
 120  
         /**
 121  
          * @return the roleNamespace
 122  
          */
 123  
         public String getRoleNamespace() {
 124  0
                 return this.roleNamespace;
 125  
         }
 126  
 
 127  
         /**
 128  
          * @param roleNamespace the roleNamespace to set
 129  
          */
 130  
         public void setRoleNamespace(String roleNamespace) {
 131  0
                 this.roleNamespace = roleNamespace;
 132  0
         }
 133  
 
 134  
         /**
 135  
          * @return the roleTypeId
 136  
          */
 137  
         public String getRoleTypeId() {
 138  0
                 return this.roleTypeId;
 139  
         }
 140  
 
 141  
         /**
 142  
          * @param roleTypeId the roleTypeId to set
 143  
          */
 144  
         public void setRoleTypeId(String roleTypeId) {
 145  0
                 this.roleTypeId = roleTypeId;
 146  0
         }
 147  
 
 148  
         /**
 149  
          * @return the roleTypeName
 150  
          */
 151  
         public String getRoleTypeName() {
 152  0
                 if ( roleTypeName == null ) {
 153  0
                         if ( kimType != null ) {
 154  0
                                 roleTypeName = kimType.getName();
 155  0
                         } else if ( roleTypeId != null ) {
 156  0
                                 setKimType( KIMServiceLocatorWeb.getTypeInfoService().getKimType(roleTypeId) );
 157  0
                         if ( kimType != null ) {
 158  0
                                 roleTypeName = kimType.getName();
 159  
                         }
 160  
                         }
 161  
                 }
 162  0
                 return this.roleTypeName;
 163  
         }
 164  
 
 165  
         /**
 166  
          * @param roleTypeName the roleTypeName to set
 167  
          */
 168  
         public void setRoleTypeName(String roleTypeName) {
 169  0
                 this.roleTypeName = roleTypeName;
 170  0
         }
 171  
 
 172  
         /**
 173  
          * @return the delegationMembers
 174  
          */
 175  
         public List<RoleDocumentDelegationMember> getDelegationMembers() {
 176  0
                 return this.delegationMembers;
 177  
         }
 178  
 
 179  
         /**
 180  
          * @param delegationMembers the delegationMembers to set
 181  
          */
 182  
         public void setDelegationMembers(
 183  
                         List<RoleDocumentDelegationMember> delegationMembers) {
 184  0
                 this.delegationMembers = delegationMembers;
 185  0
         }
 186  
 
 187  
         /**
 188  
          * @return the permissions
 189  
          */
 190  
         public List<KimDocumentRolePermission> getPermissions() {
 191  0
                 return this.permissions;
 192  
         }
 193  
 
 194  
         /**
 195  
          * @param permissions the permissions to set
 196  
          */
 197  
         public void setPermissions(List<KimDocumentRolePermission> permissions) {
 198  0
                 this.permissions = permissions;
 199  0
         }
 200  
 
 201  
         /**
 202  
          * @return the responsibilities
 203  
          */
 204  
         public List<KimDocumentRoleResponsibility> getResponsibilities() {
 205  0
                 return this.responsibilities;
 206  
         }
 207  
 
 208  
         /**
 209  
          * @param responsibilities the responsibilities to set
 210  
          */
 211  
         public void setResponsibilities(
 212  
                         List<KimDocumentRoleResponsibility> responsibilities) {
 213  0
                 this.responsibilities = responsibilities;
 214  0
         }
 215  
 
 216  
         /**
 217  
          * @return the members
 218  
          */
 219  
         public List<KimDocumentRoleMember> getMembers() {
 220  0
                 return this.members;
 221  
         }
 222  
 
 223  0
     public enum RoleMemberMetaDataType implements Comparator<KimDocumentRoleMember>{
 224  0
         MEMBER_ID("memberId"),
 225  0
         MEMBER_NAME("memberName"),
 226  0
         FULL_MEMBER_NAME("memberFullName");
 227  
 
 228  
         private final String attributeName;
 229  
 
 230  0
         RoleMemberMetaDataType(String anAttributeName) {
 231  0
             this.attributeName = anAttributeName;
 232  0
         }
 233  
 
 234  
         public String getAttributeName() {
 235  0
             return attributeName;
 236  
         }
 237  
 
 238  
         @Override
 239  
         public int compare(KimDocumentRoleMember m1, KimDocumentRoleMember m2) {
 240  0
             if (m1 == null && m2 == null) {
 241  0
                 return 0;
 242  0
             } else if (m1 == null) {
 243  0
                 return -1;
 244  0
             } else if (m2 == null) {
 245  0
                 return 1;
 246  
             }
 247  0
             if (this.getAttributeName().equals(MEMBER_ID.getAttributeName()))
 248  0
                 return m1.getMemberId().compareToIgnoreCase(m2.getMemberId());
 249  0
             else if (this.getAttributeName().equals(FULL_MEMBER_NAME.getAttributeName()))
 250  0
                 return m1.getMemberFullName().compareToIgnoreCase(m2.getMemberFullName());
 251  0
             return m1.getMemberName().compareToIgnoreCase(m2.getMemberName());
 252  
         }
 253  
     }
 254  
 
 255  
     public void setMemberMetaDataTypeToSort(Integer columnNumber)
 256  
         {
 257  0
            switch( columnNumber )
 258  
            {
 259  
                case 1:
 260  0
                    this.memberMetaDataType = RoleMemberMetaDataType.MEMBER_ID;
 261  0
                    break;
 262  
                case 2:
 263  0
                    this.memberMetaDataType = RoleMemberMetaDataType.MEMBER_NAME;
 264  0
                    break;
 265  
                case 3:
 266  0
                    this.memberMetaDataType = RoleMemberMetaDataType.FULL_MEMBER_NAME;
 267  0
                    break;
 268  
                default:
 269  0
                    this.memberMetaDataType = RoleMemberMetaDataType.MEMBER_NAME;
 270  
                    break;
 271  
            }
 272  0
         }
 273  
 
 274  0
     protected RoleMemberMetaDataType memberMetaDataType = RoleMemberMetaDataType.MEMBER_NAME;
 275  
 
 276  
     public RoleMemberMetaDataType getMemberMetaDataType() {
 277  0
         return memberMetaDataType;
 278  
     }
 279  
 
 280  
     public void setMemberMetaDataType(RoleMemberMetaDataType memberMetaDataType) {
 281  0
         this.memberMetaDataType = memberMetaDataType;
 282  0
     }
 283  
 
 284  
         /**
 285  
          * @return the members
 286  
          */
 287  
         public KimDocumentRoleMember getMember(String roleMemberId) {
 288  0
                 if(StringUtils.isEmpty(roleMemberId)) return null;
 289  0
                 for(KimDocumentRoleMember roleMember: getMembers()){
 290  0
                         if(roleMemberId.equals(roleMember.getRoleMemberId()))
 291  0
                                 return roleMember;
 292  
                 }
 293  0
                 return null;
 294  
         }
 295  
 
 296  
         /**
 297  
          * @param members the members to set
 298  
          */
 299  
         public void setMembers(List<KimDocumentRoleMember> members) {
 300  0
                 this.members = members;
 301  0
         }
 302  
 
 303  
         public void addResponsibility(KimDocumentRoleResponsibility roleResponsibility){
 304  0
                 if(!getResponsibilityService().areActionsAtAssignmentLevelById(roleResponsibility.getResponsibilityId())) {
 305  0
                         roleResponsibility.getRoleRspActions().add(getNewRespAction(roleResponsibility));
 306  
                 }
 307  0
                getResponsibilities().add(roleResponsibility);
 308  0
         }
 309  
 
 310  
         protected KimDocumentRoleResponsibilityAction getNewRespAction(KimDocumentRoleResponsibility roleResponsibility){
 311  0
                 KimDocumentRoleResponsibilityAction roleRspAction = new KimDocumentRoleResponsibilityAction();
 312  0
                 roleRspAction.setKimResponsibility(roleResponsibility.getKimResponsibility());
 313  0
                 roleRspAction.setRoleResponsibilityId(roleResponsibility.getRoleResponsibilityId());                        
 314  0
                 return roleRspAction;
 315  
         }
 316  
         
 317  
         public void addDelegationMember(RoleDocumentDelegationMember newDelegationMember){
 318  0
                 getDelegationMembers().add(newDelegationMember);
 319  0
         }
 320  
 
 321  
         /**
 322  
          * @param member the members to set
 323  
          */
 324  
         public void addMember(KimDocumentRoleMember member) {
 325  0
                 SequenceAccessorService sas = getSequenceAccessorService();
 326  0
                 Long nextSeq = sas.getNextAvailableSequenceNumber(
 327  
                                 KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S, 
 328  
                                 KimDocumentRoleMember.class);
 329  0
                 String roleMemberId = nextSeq.toString();
 330  0
                 member.setRoleMemberId(roleMemberId);
 331  0
                 setupMemberRspActions(member);
 332  0
                getMembers().add(member);
 333  0
         }
 334  
 
 335  
         public KimDocumentRoleMember getBlankMember() {
 336  0
                 KimDocumentRoleMember member = new KimDocumentRoleMember();
 337  
                 KimDocumentRoleQualifier qualifier;
 338  0
                 if(getDefinitions()!=null){
 339  0
                         for(String key : getDefinitions().keySet()) {
 340  0
                         qualifier = new KimDocumentRoleQualifier();
 341  0
                         qualifier.setKimAttrDefnId(getKimAttributeDefnId(getDefinitions().get(key)));
 342  0
                         member.getQualifiers().add(qualifier);
 343  
                 }
 344  
                 }
 345  0
                setupMemberRspActions(member);
 346  0
                return member;
 347  
         }
 348  
 
 349  
         public RoleDocumentDelegationMember getBlankDelegationMember() {
 350  0
                 RoleDocumentDelegationMember member = new RoleDocumentDelegationMember();
 351  
                 RoleDocumentDelegationMemberQualifier qualifier;
 352  0
                 if(getDefinitions()!=null){
 353  0
                         for(String key : getDefinitions().keySet()) {
 354  0
                                 qualifier = new RoleDocumentDelegationMemberQualifier();
 355  0
                                 setAttrDefnIdForDelMemberQualifier(qualifier, getDefinitions().get(key));
 356  0
                         member.getQualifiers().add(qualifier);
 357  
                 }
 358  
                 }
 359  0
                return member;
 360  
         }
 361  
 
 362  
     public void setupMemberRspActions(KimDocumentRoleMember member) {
 363  0
             member.getRoleRspActions().clear();
 364  0
         for (KimDocumentRoleResponsibility roleResp: getResponsibilities()) {
 365  0
                 if (getResponsibilityService().areActionsAtAssignmentLevelById(roleResp.getResponsibilityId())) {
 366  0
                         KimDocumentRoleResponsibilityAction action = new KimDocumentRoleResponsibilityAction();
 367  0
                         action.setRoleResponsibilityId("*");
 368  0
                         action.setRoleMemberId(member.getRoleMemberId());
 369  0
                         member.getRoleRspActions().add(action);
 370  0
                         break;
 371  
                 }                
 372  
         }
 373  0
     }
 374  
 
 375  
     public void updateMembers(IdentityManagementRoleDocumentForm roleDocumentForm){
 376  0
             for(KimDocumentRoleMember member: roleDocumentForm.getRoleDocument().getMembers()){
 377  0
                     roleDocumentForm.getRoleDocument().setupMemberRspActions(member);
 378  
             }
 379  0
     }
 380  
     
 381  
     public void updateMembers(KimDocumentRoleResponsibility newResponsibility){
 382  0
             for(KimDocumentRoleMember member: getMembers()){
 383  0
                     setupMemberRspActions(newResponsibility, member);
 384  
             }
 385  0
     }
 386  
     
 387  
     public void setupMemberRspActions(KimDocumentRoleResponsibility roleResp, KimDocumentRoleMember member) {
 388  0
             if ((member.getRoleRspActions()==null || member.getRoleRspActions().size()<1) && getResponsibilityService().areActionsAtAssignmentLevelById(roleResp.getResponsibilityId())) {
 389  0
                     KimDocumentRoleResponsibilityAction action = new KimDocumentRoleResponsibilityAction();
 390  0
                     action.setRoleResponsibilityId("*");
 391  0
                     action.setRoleMemberId(member.getRoleMemberId());
 392  0
                     if(member.getRoleRspActions()==null)
 393  0
                             member.setRoleRspActions(new ArrayList<KimDocumentRoleResponsibilityAction>());
 394  0
                     member.getRoleRspActions().add(action);
 395  
             }                
 396  0
     }
 397  
     
 398  
     protected void setAttrDefnIdForDelMemberQualifier(RoleDocumentDelegationMemberQualifier qualifier,AttributeDefinition definition) {
 399  0
             if (definition instanceof KimDataDictionaryAttributeDefinition) {
 400  0
                     qualifier.setKimAttrDefnId(((KimDataDictionaryAttributeDefinition)definition).getKimAttrDefnId());
 401  
                     //qualifier.refreshReferenceObject("kimAttribute");
 402  
             } else {
 403  0
                     qualifier.setKimAttrDefnId(((KimNonDataDictionaryAttributeDefinition)definition).getKimAttrDefnId());
 404  
                     //qualifier.refreshReferenceObject("kimAttribute");
 405  
 
 406  
             }
 407  0
     }
 408  
     
 409  
     /**
 410  
      * @see org.kuali.rice.kns.document.DocumentBase#doRouteStatusChange(org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO)
 411  
      */
 412  
     @Override
 413  
         public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) {
 414  0
                 super.doRouteStatusChange(statusChangeEvent);
 415  0
                 if (getDocumentHeader().getWorkflowDocument().stateIsProcessed()) {
 416  0
                         KIMServiceLocatorInternal.getUiDocumentService().saveRole(this);
 417  
                 }
 418  0
         }
 419  
 
 420  
         public void initializeDocumentForNewRole() {
 421  0
                 if(StringUtils.isBlank(this.roleId)){
 422  0
                         SequenceAccessorService sas = getSequenceAccessorService();
 423  0
                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 424  
                                         KimConstants.SequenceNames.KRIM_ROLE_ID_S, this.getClass());
 425  0
                         this.roleId = nextSeq.toString();
 426  
                 }
 427  0
                 if(StringUtils.isBlank(this.roleTypeId)) {
 428  0
                         this.roleTypeId = "1";
 429  
                 }
 430  0
         }
 431  
         
 432  
         public String getRoleId(){
 433  0
                 if(StringUtils.isBlank(this.roleId)){
 434  0
                         initializeDocumentForNewRole();
 435  
                 }
 436  0
                 return roleId;
 437  
         }
 438  
         
 439  
         @Override
 440  
         public void prepareForSave(){
 441  0
                 SequenceAccessorService sas = getSequenceAccessorService();
 442  
                 
 443  
                 String roleId;
 444  0
                 if(StringUtils.isBlank(getRoleId())){
 445  0
                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 446  
                                         KimConstants.SequenceNames.KRIM_ROLE_ID_S, this.getClass()); 
 447  0
                         roleId = nextSeq.toString();
 448  0
                         setRoleId(roleId);
 449  0
                 } else
 450  0
                         roleId = getRoleId();
 451  
 
 452  0
                 if(getPermissions()!=null){
 453  
                         String rolePermissionId;
 454  0
                         for(KimDocumentRolePermission permission: getPermissions()){
 455  0
                                 permission.setRoleId(roleId);
 456  0
                                 if(StringUtils.isBlank(permission.getRolePermissionId())){
 457  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 458  
                                                         KimConstants.SequenceNames.KRIM_ROLE_PERM_ID_S, 
 459  
                                                         KimDocumentRolePermission.class);
 460  0
                                         rolePermissionId = nextSeq.toString();
 461  0
                                         permission.setRolePermissionId(rolePermissionId);
 462  0
                                 }
 463  
                         }
 464  
                 }
 465  0
                 if(getResponsibilities()!=null){
 466  
                         String roleResponsibilityId;
 467  0
                         for(KimDocumentRoleResponsibility responsibility: getResponsibilities()){
 468  0
                                 if(StringUtils.isBlank(responsibility.getRoleResponsibilityId())){
 469  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 470  
                                                         KimConstants.SequenceNames.KRIM_ROLE_RSP_ID_S, 
 471  
                                                         KimDocumentRoleResponsibility.class);
 472  0
                                         roleResponsibilityId = nextSeq.toString();
 473  0
                                         responsibility.setRoleResponsibilityId(roleResponsibilityId);
 474  
                                 }
 475  0
                                 responsibility.setRoleId(roleId);
 476  0
                                 if(!getResponsibilityService().areActionsAtAssignmentLevelById(responsibility.getResponsibilityId())){
 477  0
                                         if(StringUtils.isBlank(responsibility.getRoleRspActions().get(0).getRoleResponsibilityActionId())){
 478  0
                                                 Long nextSeq = sas.getNextAvailableSequenceNumber(
 479  
                                                                 KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S,
 480  
                                                                 KimDocumentRoleResponsibilityAction.class);
 481  0
                                                 String roleResponsibilityActionId = nextSeq.toString();
 482  0
                                                 responsibility.getRoleRspActions().get(0).setRoleResponsibilityActionId(roleResponsibilityActionId);
 483  
                                         }
 484  0
                                         responsibility.getRoleRspActions().get(0).setRoleMemberId("*");
 485  0
                                         responsibility.getRoleRspActions().get(0).setDocumentNumber(getDocumentNumber());
 486  
                                 }
 487  
                         }
 488  
                 }
 489  0
                 if(getMembers()!=null){
 490  
                         String roleMemberId;
 491  
                         String roleResponsibilityActionId;
 492  0
                         for(KimDocumentRoleMember member: getMembers()){
 493  0
                                 member.setRoleId(roleId);
 494  0
                                 if(StringUtils.isBlank(member.getRoleMemberId())){
 495  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 496  
                                                         KimConstants.SequenceNames.KRIM_ROLE_MBR_ID_S,
 497  
                                                         KimDocumentRoleMember.class);
 498  0
                                         roleMemberId = nextSeq.toString();
 499  0
                                         member.setRoleMemberId(roleMemberId);
 500  
                                 }
 501  0
                                 for(KimDocumentRoleQualifier qualifier: member.getQualifiers()){
 502  0
                                         qualifier.setKimTypId(getKimType().getKimTypeId());
 503  
                                 }
 504  0
                                 for(KimDocumentRoleResponsibilityAction roleRespAction: member.getRoleRspActions()){
 505  0
                                         if(StringUtils.isBlank(roleRespAction.getRoleResponsibilityActionId())){
 506  0
                                                 Long nextSeq = sas.getNextAvailableSequenceNumber(
 507  
                                                                 KimConstants.SequenceNames.KRIM_ROLE_RSP_ACTN_ID_S,
 508  
                                                                 KimDocumentRoleResponsibilityAction.class);
 509  0
                                                 roleResponsibilityActionId = nextSeq.toString();
 510  0
                                                 roleRespAction.setRoleResponsibilityActionId(roleResponsibilityActionId);
 511  
                                         }
 512  0
                                         roleRespAction.setRoleMemberId(member.getRoleMemberId());
 513  0
                                         roleRespAction.setDocumentNumber(getDocumentNumber());
 514  0
                                         if ( !StringUtils.equals( roleRespAction.getRoleResponsibilityId(), "*" ) ) {
 515  0
                                                 for(KimDocumentRoleResponsibility responsibility: getResponsibilities()){
 516  0
                                                         if( StringUtils.equals( roleRespAction.getKimResponsibility().getResponsibilityId(), responsibility.getResponsibilityId() ) ) {
 517  0
                                                                 roleRespAction.setRoleResponsibilityId(responsibility.getRoleResponsibilityId());
 518  
                                                         }
 519  
                                                 }
 520  
                                         }
 521  
                                 }
 522  
                         }
 523  
                 }
 524  0
                 if(getDelegationMembers()!=null){
 525  0
                         for(RoleDocumentDelegationMember delegationMember: getDelegationMembers()){
 526  0
                                 delegationMember.setDocumentNumber(getDocumentNumber());
 527  0
                                 addDelegationMemberToDelegation(delegationMember);
 528  
                         }
 529  0
                         for(RoleDocumentDelegation delegation: getDelegations()){
 530  0
                                 delegation.setDocumentNumber(getDocumentNumber());
 531  0
                                 delegation.setKimTypeId(getKimType().getKimTypeId());
 532  0
                                 for(RoleDocumentDelegationMember member: delegation.getMembers()){
 533  0
                                         for(RoleDocumentDelegationMemberQualifier qualifier: member.getQualifiers()){
 534  0
                                                 qualifier.setKimTypId(getKimType().getKimTypeId());
 535  
                                         }
 536  
                                 }
 537  0
                                 delegation.setRoleId(roleId);
 538  
                         }
 539  
                 }
 540  0
         }
 541  
         
 542  
     public ResponsibilityService getResponsibilityService() {
 543  0
             if ( responsibilityService == null ) {
 544  0
                     responsibilityService = KIMServiceLocator.getResponsibilityService();
 545  
             }
 546  0
                 return responsibilityService;
 547  
         }
 548  
 
 549  
         /**
 550  
          * @return the editing
 551  
          */
 552  
         public boolean isEditing() {
 553  0
                 return this.editing;
 554  
         }
 555  
 
 556  
         /**
 557  
          * @param editing the editing to set
 558  
          */
 559  
         public void setEditing(boolean editing) {
 560  0
                 this.editing = editing;
 561  0
         }
 562  
 
 563  
         /**
 564  
          * @return the delegations
 565  
          */
 566  
         public List<RoleDocumentDelegation> getDelegations() {
 567  0
                 return this.delegations;
 568  
         }
 569  
 
 570  
         /**
 571  
          * @param delegations the delegations to set
 572  
          */
 573  
         public void setDelegations(List<RoleDocumentDelegation> delegations) {
 574  0
                 this.delegations = delegations;
 575  0
         }
 576  
         
 577  
         public void setKimType(KimTypeInfo kimType) {
 578  0
                 super.setKimType(kimType);
 579  0
                 if (kimType != null){
 580  0
                         setRoleTypeId(kimType.getKimTypeId());
 581  0
                         setRoleTypeName(kimType.getName());
 582  
                 }
 583  0
         }
 584  
 }