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