Coverage Report - org.kuali.rice.kim.document.IdentityManagementPersonDocument
 
Classes in this File Line Coverage Branch Coverage Complexity
IdentityManagementPersonDocument
0%
0/202
0%
0/86
1.956
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.collections.CollectionUtils;
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.hibernate.annotations.Fetch;
 21  
 import org.hibernate.annotations.FetchMode;
 22  
 import org.hibernate.annotations.GenericGenerator;
 23  
 import org.hibernate.annotations.Parameter;
 24  
 import org.hibernate.annotations.Type;
 25  
 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
 26  
 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
 27  
 import org.kuali.rice.kim.api.type.KimType;
 28  
 import org.kuali.rice.kim.bo.entity.dto.KimEntityEmploymentInformationInfo;
 29  
 import org.kuali.rice.kim.bo.role.dto.KimRoleInfo;
 30  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleMember;
 31  
 import org.kuali.rice.kim.bo.ui.KimDocumentRoleQualifier;
 32  
 import org.kuali.rice.kim.bo.ui.PersonDocumentAddress;
 33  
 import org.kuali.rice.kim.bo.ui.PersonDocumentAffiliation;
 34  
 import org.kuali.rice.kim.bo.ui.PersonDocumentCitizenship;
 35  
 import org.kuali.rice.kim.bo.ui.PersonDocumentEmail;
 36  
 import org.kuali.rice.kim.bo.ui.PersonDocumentEmploymentInfo;
 37  
 import org.kuali.rice.kim.bo.ui.PersonDocumentGroup;
 38  
 import org.kuali.rice.kim.bo.ui.PersonDocumentName;
 39  
 import org.kuali.rice.kim.bo.ui.PersonDocumentPhone;
 40  
 import org.kuali.rice.kim.bo.ui.PersonDocumentPrivacy;
 41  
 import org.kuali.rice.kim.bo.ui.PersonDocumentRole;
 42  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMember;
 43  
 import org.kuali.rice.kim.bo.ui.RoleDocumentDelegationMemberQualifier;
 44  
 import org.kuali.rice.kim.service.KIMServiceLocatorInternal;
 45  
 import org.kuali.rice.kim.service.UiDocumentService;
 46  
 import org.kuali.rice.kim.util.KimConstants;
 47  
 import org.kuali.rice.kns.service.DocumentHelperService;
 48  
 import org.kuali.rice.kns.service.KNSServiceLocatorWeb;
 49  
 import org.kuali.rice.kns.service.SequenceAccessorService;
 50  
 import org.kuali.rice.kns.util.GlobalVariables;
 51  
 
 52  
 import javax.persistence.AssociationOverride;
 53  
 import javax.persistence.AssociationOverrides;
 54  
 import javax.persistence.AttributeOverride;
 55  
 import javax.persistence.AttributeOverrides;
 56  
 import javax.persistence.CascadeType;
 57  
 import javax.persistence.Column;
 58  
 import javax.persistence.Entity;
 59  
 import javax.persistence.FetchType;
 60  
 import javax.persistence.GeneratedValue;
 61  
 import javax.persistence.JoinColumn;
 62  
 import javax.persistence.OneToMany;
 63  
 import javax.persistence.OneToOne;
 64  
 import javax.persistence.Table;
 65  
 import javax.persistence.Transient;
 66  
 import java.util.ArrayList;
 67  
 import java.util.HashMap;
 68  
 import java.util.List;
 69  
 import java.util.Map;
 70  
 
 71  
 /**
 72  
  * This is a description of what this class does - shyu don't forget to fill
 73  
  * this in.
 74  
  *
 75  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 76  
  *
 77  
  */
 78  
 @Entity
 79  
 @AttributeOverrides({
 80  
         @AttributeOverride(name="documentNumber",column=@Column(name="FDOC_NBR"))
 81  
 })
 82  
 @AssociationOverrides({
 83  
         @AssociationOverride(name="documentHeader",joinColumns=@JoinColumn(name="FDOC_NBR",referencedColumnName="DOC_HDR_ID",insertable=false,updatable=false))
 84  
 })
 85  
 @Table(name="KRIM_PERSON_DOCUMENT_T")
 86  
 public class IdentityManagementPersonDocument extends IdentityManagementKimDocument {
 87  
 
 88  
     protected static final long serialVersionUID = -534993712085516925L;
 89  
     // principal data
 90  
     
 91  
     @GeneratedValue(generator="KRIM_PRNCPL_ID_S")
 92  
         @GenericGenerator(name="KRIM_PRNCPL_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
 93  
                         @Parameter(name="sequence_name",value="KRIM_PRNCPL_ID_S"),
 94  
                         @Parameter(name="value_column",value="id")
 95  
                 })
 96  
         @Column(name="PRNCPL_ID")
 97  
     protected String principalId;
 98  
     @Column(name="PRNCPL_NM")
 99  
     protected String principalName;
 100  
     @GeneratedValue(generator="KRIM_ENTITY_ID_S")
 101  
         @GenericGenerator(name="KRIM_ENTITY_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
 102  
                         @Parameter(name="sequence_name",value="KRIM_ENTITY_ID_S"),
 103  
                         @Parameter(name="value_column",value="id")
 104  
                 })
 105  
         @Column(name="ENTITY_ID")
 106  
     protected String entityId;
 107  
     @Type(type="org.kuali.rice.kns.util.HibernateKualiHashType")
 108  
     @Column(name="PRNCPL_PSWD")
 109  
     protected String password;
 110  
 
 111  0
     protected String univId = "";
 112  
     // affiliation data
 113  
     @OneToMany(targetEntity=PersonDocumentAffiliation.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 114  
     @Fetch(value = FetchMode.SELECT)
 115  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 116  
     protected List<PersonDocumentAffiliation> affiliations;
 117  
 
 118  0
     @Transient
 119  
     protected String campusCode = "";
 120  
     // external identifier data
 121  0
     @Transient
 122  
     protected Map<String, String> externalIdentifiers = null;
 123  
 
 124  
     @Column(name="ACTV_IND")
 125  
         @Type(type="yes_no")
 126  
     protected boolean active;
 127  
 
 128  
     // citizenship
 129  
     @Transient
 130  
     protected List<PersonDocumentCitizenship> citizenships;
 131  
     // protected List<DocEmploymentInfo> employmentInformations;
 132  
     @OneToMany(targetEntity=PersonDocumentName.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 133  
     @Fetch(value = FetchMode.SELECT)
 134  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 135  
     protected List<PersonDocumentName> names;
 136  
     @OneToMany(targetEntity=PersonDocumentAddress.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 137  
     @Fetch(value = FetchMode.SELECT)
 138  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 139  
     protected List<PersonDocumentAddress> addrs;
 140  
     @OneToMany(targetEntity=PersonDocumentPhone.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 141  
     @Fetch(value = FetchMode.SELECT)
 142  
     @JoinColumn(name="FDOC_NBR")
 143  
     protected List<PersonDocumentPhone> phones;
 144  
     @OneToMany(targetEntity=PersonDocumentEmail.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 145  
     @Fetch(value = FetchMode.SELECT)
 146  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 147  
     protected List<PersonDocumentEmail> emails;
 148  
     @OneToMany(targetEntity=PersonDocumentGroup.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 149  
     @Fetch(value = FetchMode.SELECT)
 150  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 151  
     protected List<PersonDocumentGroup> groups;
 152  
     @OneToMany(targetEntity=PersonDocumentRole.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 153  
     @Fetch(value = FetchMode.SELECT)
 154  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 155  
     protected List<PersonDocumentRole> roles;
 156  
 
 157  
     @OneToOne(targetEntity=PersonDocumentPrivacy.class, fetch=FetchType.EAGER, cascade={CascadeType.ALL})
 158  
     @JoinColumn(name="FDOC_NBR",insertable=false,updatable=false)
 159  
     protected PersonDocumentPrivacy privacy;
 160  
 
 161  0
     public IdentityManagementPersonDocument() {
 162  0
         affiliations = new ArrayList<PersonDocumentAffiliation>();
 163  0
         citizenships = new ArrayList<PersonDocumentCitizenship>();
 164  
         // employmentInformations = new ArrayList<DocEmploymentInfo>();
 165  0
         names = new ArrayList<PersonDocumentName>();
 166  0
         addrs = new ArrayList<PersonDocumentAddress>();
 167  0
         phones = new ArrayList<PersonDocumentPhone>();
 168  0
         emails = new ArrayList<PersonDocumentEmail>();
 169  0
         groups = new ArrayList<PersonDocumentGroup>();
 170  0
         roles = new ArrayList<PersonDocumentRole>();
 171  0
         privacy = new PersonDocumentPrivacy();
 172  0
         this.active = true;
 173  
         // privacy.setDocumentNumber(documentNumber);
 174  0
     }
 175  
 
 176  
     public String getPrincipalId() {
 177  0
         return this.principalId;
 178  
     }
 179  
 
 180  
     public void setPrincipalId(String principalId) {
 181  0
         this.principalId = principalId;
 182  0
     }
 183  
 
 184  
     public String getPrincipalName() {
 185  0
         return this.principalName;
 186  
     }
 187  
 
 188  
     /*
 189  
      * sets the principal name.  
 190  
      * Principal names are converted to lower case.
 191  
      */
 192  
     public void setPrincipalName(String principalName) {
 193  0
         this.principalName = principalName; // != null ? principalName.toLowerCase() : principalName ;
 194  0
     }
 195  
 
 196  
     public String getEntityId() {
 197  0
         return this.entityId;
 198  
     }
 199  
 
 200  
     public void setEntityId(String entityId) {
 201  0
         this.entityId = entityId;
 202  0
     }
 203  
 
 204  
     public List<PersonDocumentAffiliation> getAffiliations() {
 205  0
         return this.affiliations;
 206  
     }
 207  
 
 208  
     public void setAffiliations(List<PersonDocumentAffiliation> affiliations) {
 209  0
         this.affiliations = affiliations;
 210  0
     }
 211  
 
 212  
     public String getCampusCode() {
 213  0
         return this.campusCode;
 214  
     }
 215  
 
 216  
     public void setCampusCode(String campusCode) {
 217  0
         this.campusCode = campusCode;
 218  0
     }
 219  
 
 220  
     public Map<String, String> getExternalIdentifiers() {
 221  0
         return this.externalIdentifiers;
 222  
     }
 223  
 
 224  
     public void setExternalIdentifiers(Map<String, String> externalIdentifiers) {
 225  0
         this.externalIdentifiers = externalIdentifiers;
 226  0
     }
 227  
 
 228  
     public String getPassword() {
 229  0
         return this.password;
 230  
     }
 231  
 
 232  
     public void setPassword(String password) {
 233  0
         this.password = password;
 234  0
     }
 235  
 
 236  
     public boolean isActive() {
 237  0
         return this.active;
 238  
     }
 239  
 
 240  
     public void setActive(boolean active) {
 241  0
         this.active = active;
 242  0
     }
 243  
 
 244  
     public List<PersonDocumentCitizenship> getCitizenships() {
 245  0
         return this.citizenships;
 246  
     }
 247  
 
 248  
     public void setCitizenships(List<PersonDocumentCitizenship> citizenships) {
 249  0
         this.citizenships = citizenships;
 250  0
     }
 251  
 
 252  
     public List<PersonDocumentName> getNames() {
 253  0
         return this.names;
 254  
     }
 255  
 
 256  
     public void setNames(List<PersonDocumentName> names) {
 257  0
         this.names = names;
 258  0
     }
 259  
 
 260  
     public List<PersonDocumentAddress> getAddrs() {
 261  0
         return this.addrs;
 262  
     }
 263  
 
 264  
     public void setAddrs(List<PersonDocumentAddress> addrs) {
 265  0
         this.addrs = addrs;
 266  0
     }
 267  
 
 268  
     public List<PersonDocumentPhone> getPhones() {
 269  0
         return this.phones;
 270  
     }
 271  
 
 272  
     public void setPhones(List<PersonDocumentPhone> phones) {
 273  0
         this.phones = phones;
 274  0
     }
 275  
 
 276  
     public List<PersonDocumentEmail> getEmails() {
 277  0
         return this.emails;
 278  
     }
 279  
 
 280  
     public void setEmails(List<PersonDocumentEmail> emails) {
 281  0
         this.emails = emails;
 282  0
     }
 283  
 
 284  
     public void setGroups(List<PersonDocumentGroup> groups) {
 285  0
         this.groups = groups;
 286  0
     }
 287  
 
 288  
     public List<PersonDocumentRole> getRoles() {
 289  0
         return this.roles;
 290  
     }
 291  
 
 292  
     public void setRoles(List<PersonDocumentRole> roles) {
 293  0
         this.roles = roles;
 294  0
     }
 295  
 
 296  
     public List<PersonDocumentGroup> getGroups() {
 297  0
         return this.groups;
 298  
     }
 299  
 
 300  
     public String getUnivId() {
 301  0
         return this.univId;
 302  
     }
 303  
 
 304  
     public void setUnivId(String univId) {
 305  0
         this.univId = univId;
 306  0
     }
 307  
 
 308  
     public PersonDocumentPrivacy getPrivacy() {
 309  0
         return this.privacy;
 310  
     }
 311  
 
 312  
     public void setPrivacy(PersonDocumentPrivacy privacy) {
 313  0
         this.privacy = privacy;
 314  0
     }
 315  
 
 316  
     public void initializeDocumentForNewPerson() {
 317  0
         if(StringUtils.isBlank(this.principalId)){
 318  0
             this.principalId = getSequenceAccessorService().getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_PRNCPL_ID_S).toString();
 319  
         }
 320  0
         if(StringUtils.isBlank(this.entityId)){
 321  0
             this.entityId = getSequenceAccessorService().getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ENTITY_ID_S).toString();
 322  
         }
 323  0
     }
 324  
 
 325  
     @SuppressWarnings("unchecked")
 326  
     @Override
 327  
     public List buildListOfDeletionAwareLists() {
 328  0
         List managedLists = super.buildListOfDeletionAwareLists();
 329  0
         List<PersonDocumentEmploymentInfo> empInfos = new ArrayList<PersonDocumentEmploymentInfo>();
 330  0
         for (PersonDocumentAffiliation affiliation : getAffiliations()) {
 331  0
             empInfos.addAll(affiliation.getEmpInfos());
 332  
         }
 333  
 
 334  0
         managedLists.add(empInfos);
 335  0
         managedLists.add(getAffiliations());
 336  0
         managedLists.add(getCitizenships());
 337  0
         managedLists.add(getPhones());
 338  0
         managedLists.add(getAddrs());
 339  0
         managedLists.add(getEmails());
 340  0
         managedLists.add(getNames());
 341  0
         managedLists.add(getGroups());
 342  0
         managedLists.add(getRoles());
 343  0
         return managedLists;
 344  
     }
 345  
 
 346  
     /**
 347  
      * @see org.kuali.rice.kns.document.DocumentBase#doRouteStatusChange(org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO)
 348  
      */
 349  
     @Override
 350  
     public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent) {
 351  0
         super.doRouteStatusChange(statusChangeEvent);
 352  0
         if (getDocumentHeader().getWorkflowDocument().stateIsProcessed()) {
 353  0
                 setIfRolesEditable();
 354  0
             KIMServiceLocatorInternal.getUiDocumentService().saveEntityPerson(this);
 355  
         }
 356  0
     }
 357  
 
 358  
 
 359  
     @Override
 360  
     public void prepareForSave(){
 361  0
         if (StringUtils.isBlank(getPrivacy().getDocumentNumber())) {
 362  0
             getPrivacy().setDocumentNumber(
 363  
                     getDocumentNumber());
 364  
         }
 365  0
         setEmployeeRecordIds();
 366  0
         for (PersonDocumentRole role : getRoles()) {
 367  0
                 role.setDocumentNumber(getDocumentNumber());
 368  
                 //if (StringUtils.isEmpty(role.getRoleId())) {
 369  
                     //        SequenceAccessorService sas = getSequenceAccessorService();
 370  
                         //        Long nextSeq = sas.getNextAvailableSequenceNumber(
 371  
                         //                        "KRIM_ROLE_ID_S", this.getClass());
 372  
                         //        String roleId = nextSeq.toString();
 373  
                         //        role.setRoleId(roleId);
 374  
                     //}
 375  0
             for (KimDocumentRoleMember rolePrncpl : role.getRolePrncpls()) {
 376  0
                 rolePrncpl.setDocumentNumber(getDocumentNumber());
 377  0
                 rolePrncpl.setRoleId(role.getRoleId());
 378  0
                 if (StringUtils.isEmpty(rolePrncpl.getRoleMemberId())) {
 379  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 380  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 381  
                                                         "KRIM_ROLE_MBR_ID_S", this.getClass());
 382  0
                                         String roleMemberId = nextSeq.toString();
 383  0
                                         rolePrncpl.setRoleMemberId(roleMemberId);
 384  
                         }
 385  0
                 for (KimDocumentRoleQualifier qualifier : rolePrncpl.getQualifiers()) {
 386  0
                     qualifier.setDocumentNumber(getDocumentNumber());
 387  0
                     qualifier.setKimTypId(role.getKimTypeId());
 388  
                 }
 389  
             }
 390  
         }
 391  0
         if(getDelegationMembers()!=null){
 392  0
             for(RoleDocumentDelegationMember delegationMember: getDelegationMembers()){
 393  0
                 delegationMember.setDocumentNumber(getDocumentNumber());
 394  0
                 for (RoleDocumentDelegationMemberQualifier qualifier: delegationMember.getQualifiers()) {
 395  0
                     qualifier.setDocumentNumber(getDocumentNumber());
 396  0
                     qualifier.setKimTypId(delegationMember.getRoleImpl().getKimTypeId());
 397  
                 }
 398  0
                 addDelegationMemberToDelegation(delegationMember);
 399  
             }
 400  
         }
 401  0
         if (getAddrs() != null) {
 402  
                 String entityAddressId;
 403  0
                 for(PersonDocumentAddress address : getAddrs()) {
 404  0
                         address.setDocumentNumber(getDocumentNumber());
 405  0
                         if (StringUtils.isEmpty(address.getEntityAddressId())) {
 406  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 407  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 408  
                                                         "KRIM_ENTITY_ADDR_ID_S", this.getClass());
 409  0
                                         entityAddressId = nextSeq.toString();
 410  0
                                         address.setEntityAddressId(entityAddressId);
 411  0
                         }
 412  
                 }
 413  
         }
 414  0
         if (getAffiliations() != null) {
 415  
                 String affiliationId;
 416  0
                 for(PersonDocumentAffiliation affiliation : getAffiliations()) {
 417  0
                         affiliation.setDocumentNumber(getDocumentNumber());
 418  0
                         if (StringUtils.isEmpty(affiliation.getEntityAffiliationId())) {
 419  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 420  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 421  
                                                         "KRIM_ENTITY_AFLTN_ID_S", this.getClass());
 422  0
                                         affiliationId = nextSeq.toString();
 423  0
                                         affiliation.setEntityAffiliationId(affiliationId);
 424  0
                         }
 425  
                 }
 426  
         }
 427  0
         if (getEmails() != null) {
 428  
                 String entityEmailId;
 429  0
                 for(PersonDocumentEmail email : getEmails()) {
 430  0
                         email.setDocumentNumber(getDocumentNumber());
 431  0
                         if (StringUtils.isEmpty(email.getEntityEmailId())) {
 432  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 433  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 434  
                                                         "KRIM_ENTITY_EMAIL_ID_S", this.getClass());
 435  0
                                         entityEmailId = nextSeq.toString();
 436  0
                                         email.setEntityEmailId(entityEmailId);
 437  0
                         }
 438  
                 }
 439  
         }
 440  0
         if (getGroups() != null) {
 441  
                 String groupMemberId;
 442  0
                 for(PersonDocumentGroup group : getGroups()) {
 443  0
                         group.setDocumentNumber(getDocumentNumber());
 444  0
                         if (StringUtils.isEmpty(group.getGroupMemberId())) {
 445  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 446  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 447  
                                                         "KRIM_GRP_MBR_ID_S", this.getClass());
 448  0
                                         groupMemberId = nextSeq.toString();
 449  0
                                         group.setGroupMemberId(groupMemberId);
 450  0
                         }
 451  
                 }
 452  
         }
 453  0
         if (getNames() != null) {
 454  
                 String entityNameId;
 455  0
                 for(PersonDocumentName name : getNames()) {
 456  0
                         name.setDocumentNumber(getDocumentNumber());
 457  0
                         if (StringUtils.isEmpty(name.getEntityNameId())) {
 458  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 459  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 460  
                                                         "KRIM_ENTITY_NM_ID_S", this.getClass());
 461  0
                                         entityNameId = nextSeq.toString();
 462  0
                                         name.setEntityNameId(entityNameId);
 463  0
                         }
 464  
                 }
 465  
         }
 466  0
         if (getPhones() != null) {
 467  
                 String entityPhoneId;
 468  0
                 for(PersonDocumentPhone phone : getPhones()) {
 469  0
                         phone.setDocumentNumber(getDocumentNumber());
 470  0
                         if (StringUtils.isEmpty(phone.getEntityPhoneId())) {
 471  0
                                 SequenceAccessorService sas = getSequenceAccessorService();
 472  0
                                         Long nextSeq = sas.getNextAvailableSequenceNumber(
 473  
                                                         "KRIM_ENTITY_PHONE_ID_S", this.getClass());
 474  0
                                         entityPhoneId = nextSeq.toString();
 475  0
                                         phone.setEntityPhoneId(entityPhoneId);
 476  0
                         }
 477  
                 }
 478  
         }
 479  
         
 480  0
     }
 481  
 
 482  
     protected void setEmployeeRecordIds(){
 483  0
             List<KimEntityEmploymentInformationInfo> empInfos = getUiDocumentService().getEntityEmploymentInformationInfo(getEntityId());
 484  0
         for(PersonDocumentAffiliation affiliation: getAffiliations()) {
 485  0
             int employeeRecordCounter = CollectionUtils.isEmpty(empInfos) ? 0 : empInfos.size();
 486  0
             for(PersonDocumentEmploymentInfo empInfo: affiliation.getEmpInfos()){
 487  0
                 if(CollectionUtils.isNotEmpty(empInfos)){
 488  0
                     for(KimEntityEmploymentInformationInfo origEmpInfo: empInfos){
 489  0
                         if (origEmpInfo.getEntityEmploymentId().equals(empInfo.getEntityEmploymentId())) {
 490  0
                             empInfo.setEmploymentRecordId(origEmpInfo.getEmploymentRecordId());
 491  
                         }
 492  
                     }
 493  
                 }
 494  0
                 if(StringUtils.isEmpty(empInfo.getEmploymentRecordId())){
 495  0
                     employeeRecordCounter++;
 496  0
                     empInfo.setEmploymentRecordId(employeeRecordCounter+"");
 497  
                 }
 498  
             }
 499  0
         }
 500  0
     }
 501  
 
 502  
     public KimTypeAttributesHelper getKimTypeAttributesHelper(String roleId) {
 503  0
         KimRoleInfo roleInfo = KimApiServiceLocator.getRoleService().getRole(roleId);
 504  0
         KimType kimTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(roleInfo.getKimTypeId());
 505  0
         return new KimTypeAttributesHelper(kimTypeInfo);
 506  
         //addDelegationRoleKimTypeAttributeHelper(roleId, helper);
 507  
     }
 508  
 
 509  
         public void setIfRolesEditable(){
 510  0
                 if(CollectionUtils.isNotEmpty(getRoles())){
 511  0
                         for(PersonDocumentRole role: getRoles()){
 512  0
                                 role.setEditable(validAssignRole(role));
 513  
                         }
 514  
                 }
 515  0
         }
 516  
 
 517  
         public boolean validAssignRole(PersonDocumentRole role){
 518  0
         boolean rulePassed = true;
 519  0
         if(StringUtils.isNotEmpty(role.getNamespaceCode())){
 520  0
                 Map<String,String> additionalPermissionDetails = new HashMap<String,String>();
 521  0
                 additionalPermissionDetails.put(KimConstants.AttributeConstants.NAMESPACE_CODE, role.getNamespaceCode());
 522  0
                 additionalPermissionDetails.put(KimConstants.AttributeConstants.ROLE_NAME, role.getRoleName());
 523  0
                         if (!getDocumentHelperService().getDocumentAuthorizer(this).isAuthorizedByTemplate(
 524  
                                         this,
 525  
                                         KimConstants.NAMESPACE_CODE,
 526  
                                         KimConstants.PermissionTemplateNames.ASSIGN_ROLE,
 527  
                                         GlobalVariables.getUserSession().getPrincipalId(),
 528  
                                         additionalPermissionDetails, null)){
 529  0
                     rulePassed = false;
 530  
                         }
 531  
         }
 532  0
         return rulePassed;
 533  
         }
 534  
 
 535  
         @Transient
 536  
         protected transient DocumentHelperService documentHelperService;
 537  
         @Transient
 538  
         protected transient UiDocumentService uiDocumentService;
 539  
 
 540  
         protected DocumentHelperService getDocumentHelperService() {
 541  0
             if ( documentHelperService == null ) {
 542  0
                 documentHelperService = KNSServiceLocatorWeb.getDocumentHelperService();
 543  
                 }
 544  0
             return this.documentHelperService;
 545  
         }
 546  
 
 547  
         protected UiDocumentService getUiDocumentService() {
 548  0
             if (uiDocumentService == null ) {
 549  0
                     uiDocumentService = KIMServiceLocatorInternal.getUiDocumentService();
 550  
                 }
 551  0
             return this.uiDocumentService;
 552  
         }
 553  
 
 554  
 }