@Override public void setPrincipalInvestigator( ProtocolPersonBase newPrincipalInvestigator, ProtocolBase protocol) { if (protocol != null) { ProtocolPerson currentPrincipalInvestigator = (ProtocolPerson) getPrincipalInvestigator(protocol.getProtocolPersons()); if (newPrincipalInvestigator != null) { newPrincipalInvestigator.setProtocolPersonRoleId(getPrincipalInvestigatorRole()); if (currentPrincipalInvestigator == null) { protocol.getProtocolPersons().add(newPrincipalInvestigator); } else if (!isDuplicatePerson(protocol.getProtocolPersons(), newPrincipalInvestigator)) { protocol.getProtocolPersons().remove(currentPrincipalInvestigator); protocol.getProtocolPersons().add(newPrincipalInvestigator); } // Assign the PI the APPROVER role if PI has a personId (for doc cancel). if (newPrincipalInvestigator.getPersonId() != null) { personEditableService.populateContactFieldsFromPersonId(newPrincipalInvestigator); KcAuthorizationService kraAuthService = KcServiceLocator.getService(KcAuthorizationService.class); kraAuthService.addDocumentLevelRole( newPrincipalInvestigator.getPersonId(), RoleConstants.PROTOCOL_APPROVER, protocol); } else { personEditableService.populateContactFieldsFromRolodexId(newPrincipalInvestigator); } } } }