* @param namesFromUser - names given by user
* @see org.kuali.rice.kew.xml.UserXmlParser
* @see org.kuali.rice.kim.document.IdentityManagementPersonDocument#initializeDocumentForNewPerson
*/
protected void createPrincipal(String principalName, String affiliationCode, String namesFromUser) {
SequenceAccessorService sas = KRADServiceLocator.getSequenceAccessorService();
Long entityId = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_ENTITY_ID_S,
EntityBo.class);
EntityBo entityBo = new EntityBo();
entityBo.setActive(true);
entityBo.setId(String.valueOf(entityId));
Long entityNameId = sas.getNextAvailableSequenceNumber(
"KRIM_ENTITY_NM_ID_S", EntityNameBo.class);
EntityNameBo name = new EntityNameBo();
name.setActive(true);
name.setId(String.valueOf(entityNameId));
name.setEntityId(entityBo.getId());
// must be in krim_ent_nm_typ_t.ent_nm_typ_cd
name.setNameCode("PRFR");
name.setFirstName(getFirstName(namesFromUser));
name.setMiddleName(getMiddleName(namesFromUser));
name.setLastName(getLastName(namesFromUser));
name.setDefaultValue(true);
Long entityAffilId = sas.getNextAvailableSequenceNumber("KRIM_ENTITY_AFLTN_ID_S", EntityAffiliationBo.class);
EntityAffiliationBo affilBo = new EntityAffiliationBo();
affilBo.setActive(true);
affilBo.setDefaultValue(true);
affilBo.setId(String.valueOf(entityAffilId));
affilBo.setAffiliationTypeCode(affiliationCode);
affilBo.setEntityId(entityBo.getId());
List<EntityTypeContactInfoBo> entityTypes = new ArrayList<EntityTypeContactInfoBo>();
EntityTypeContactInfoBo entityType = new EntityTypeContactInfoBo();
entityType.setEntityId(entityBo.getId());
entityType.setEntityTypeCode(KimConstants.EntityTypes.PERSON);
entityType.setActive(true);
entityTypes.add(entityType);
entityBo.setEntityTypeContactInfos(entityTypes);
KimApiServiceLocator.getIdentityService().createEntity(EntityBo.to(entityBo));
getBusinessObjectService().save(affilBo);
getBusinessObjectService().save(name);
// create and populate principal
Long principalId = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_PRNCPL_ID_S,
IdentityManagementPersonDocument.class);
PrincipalBo principalBo = new PrincipalBo();
principalBo.setActive(true);
principalBo.setPrincipalId(String.valueOf(principalId));
principalBo.setPrincipalName(principalName);