List of usage examples for org.apache.commons.lang3 StringUtils substring
public static String substring(final String str, int start, int end)
Gets a substring from the specified String avoiding exceptions.
A negative start position can be used to start/end n characters from the end of the String.
The returned substring starts with the character in the start position and ends before the end position.
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_0Generator.java
private PersonProfileDataType getPersonProfilePI() { PersonProfileDataType profileDataType = PersonProfileDataType.Factory.newInstance(); Profile profile = Profile.Factory.newInstance(); ProposalPersonContract PI = s2SProposalPersonService.getPrincipalInvestigator(pdDoc); if (PI != null) { if (PI.getPersonId() != null) { pIPersonOrRolodexId = PI.getPersonId(); } else if (PI.getRolodexId() != null) { pIPersonOrRolodexId = PI.getRolodexId().toString(); }/* w w w . j av a 2 s . com*/ profile.setName(globLibV10Generator.getHumanNameDataType(PI)); if (PI.getDirectoryTitle() != null) { if (PI.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) { profile.setTitle(PI.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH)); } else { profile.setTitle(PI.getDirectoryTitle()); } } profile.setAddress(globLibV10Generator.getAddressRequireCountryDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } profile.setEmail(PI.getEmailAddress()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { profile.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (PI.getHomeUnit() != null) { KcPersonContract kcPerson = PI.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profile.setDepartmentName(StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profile.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } profile.setProjectRole(ProjectRoleDataType.PD_PI); PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profile.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profile.setSupportsAttached(supportsAttached); } profileDataType.setProfile(profile); } return profileDataType; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_0Generator.java
private PersonProfileDataType[] getpersonProfileKeyPerson() { List<PersonProfileDataType> personProfileDataTypeList = new ArrayList<>(); List<? extends ProposalPersonContract> keyPersons = pdDoc.getDevelopmentProposal().getProposalPersons(); Collections.sort(keyPersons, new ProposalPersonComparator()); List<ProposalPersonContract> nKeyPersons = s2SProposalPersonService.getNKeyPersons(keyPersons, MAX_KEY_PERSON_COUNT);//from w w w. j a v a 2 s .c o m extraPersons = keyPersons.stream().filter(kp -> !nKeyPersons.contains(kp)).collect(Collectors.toList()); if (nKeyPersons.size() > 0) { for (ProposalPersonContract keyPerson : nKeyPersons) { if (pIPersonOrRolodexId != null) { // Don't add PI to keyperson list if (keyPerson.getPersonId() != null && keyPerson.getPersonId().equals(pIPersonOrRolodexId)) { continue; } else if ((keyPerson.getRolodexId() != null) && pIPersonOrRolodexId.equals(keyPerson.getRolodexId().toString())) { continue; } } Profile profileKeyPerson = Profile.Factory.newInstance(); profileKeyPerson.setName(globLibV10Generator.getHumanNameDataType(keyPerson)); if (keyPerson.getDirectoryTitle() != null) { if (keyPerson.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) { profileKeyPerson .setTitle(keyPerson.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH)); } else { profileKeyPerson.setTitle(keyPerson.getDirectoryTitle()); } } profileKeyPerson.setAddress(globLibV10Generator.getAddressRequireCountryDataType(keyPerson)); profileKeyPerson.setPhone(keyPerson.getOfficePhone()); if (StringUtils.isNotEmpty(keyPerson.getFaxNumber())) { profileKeyPerson.setFax(keyPerson.getFaxNumber()); } profileKeyPerson.setEmail(keyPerson.getEmailAddress()); profileKeyPerson.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); if (keyPerson.getHomeUnit() != null) { KcPersonContract kcPerson = keyPerson.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profileKeyPerson.setDepartmentName( StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profileKeyPerson.setDepartmentName(StringUtils.substring( developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = keyPerson.getDivision(); if (divisionName != null) { profileKeyPerson .setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (keyPerson.getEraCommonsUserName() != null) { profileKeyPerson.setCredential(keyPerson.getEraCommonsUserName()); } if (keyPerson.isMultiplePi() || keyPerson.isCoInvestigator()) { if (sponsorHierarchyService .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { profileKeyPerson.setProjectRole(ProjectRoleDataType.PD_PI); } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.OTHER_SPECIFY); OtherProjectRoleCategory otherProjectRole = OtherProjectRoleCategory.Factory.newInstance(); String otherRole; if (keyPerson.getProjectRole() != null) { if (keyPerson.getProjectRole().length() > ROLE_DESCRIPTION_MAX_LENGTH) { otherRole = keyPerson.getProjectRole().substring(0, ROLE_DESCRIPTION_MAX_LENGTH); } else { otherRole = keyPerson.getProjectRole(); } } else { otherRole = FieldValueConstants.VALUE_UNKNOWN; } otherProjectRole.setStringValue(otherRole); profileKeyPerson.setOtherProjectRoleCategory(otherProjectRole); } PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profileKeyPerson.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profileKeyPerson.setSupportsAttached(supportsAttached); } PersonProfileDataType personProfileDataTypeKeyPerson = PersonProfileDataType.Factory.newInstance(); personProfileDataTypeKeyPerson.setProfile(profileKeyPerson); personProfileDataTypeList.add(personProfileDataTypeKeyPerson); } } PersonProfileDataType[] personProfileDataArray = new PersonProfileDataType[0]; personProfileDataArray = personProfileDataTypeList.toArray(personProfileDataArray); return personProfileDataArray; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_1Generator.java
private PersonProfileDataType getPersonProfilePI() { PersonProfileDataType profileDataType = PersonProfileDataType.Factory.newInstance(); Profile profile = Profile.Factory.newInstance(); ProposalPersonContract PI = s2SProposalPersonService.getPrincipalInvestigator(pdDoc); if (PI != null) { if (PI.getPersonId() != null) { pIPersonOrRolodexId = PI.getPersonId(); } else if (PI.getRolodexId() != null) { pIPersonOrRolodexId = PI.getRolodexId().toString(); }/* www .ja v a 2 s .c om*/ profile.setName(globLibV20Generator.getHumanNameDataType(PI)); if (PI.getDirectoryTitle() != null) { if (PI.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) { profile.setTitle(PI.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH)); } else { profile.setTitle(PI.getDirectoryTitle()); } } profile.setAddress(globLibV20Generator.getAddressDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } profile.setEmail(PI.getEmailAddress()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { profile.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (PI.getHomeUnit() != null) { KcPersonContract kcPerson = PI.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profile.setDepartmentName(StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profile.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + PI.getFullName(), AuditError.GG_LINK)); } } profile.setProjectRole(ProjectRoleDataType.PD_PI); PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profile.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profile.setSupportsAttached(supportsAttached); } profileDataType.setProfile(profile); } return profileDataType; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_1Generator.java
private PersonProfileDataType[] getpersonProfileKeyPerson() { List<PersonProfileDataType> personProfileDataTypeList = new ArrayList<>(); List<? extends ProposalPersonContract> keyPersons = pdDoc.getDevelopmentProposal().getProposalPersons(); Collections.sort(keyPersons, new ProposalPersonComparator()); List<ProposalPersonContract> nKeyPersons = s2SProposalPersonService.getNKeyPersons(keyPersons, MAX_KEY_PERSON_COUNT);//from w w w . java 2 s . co m extraPersons = keyPersons.stream().filter(kp -> !nKeyPersons.contains(kp)).collect(Collectors.toList()); if (nKeyPersons.size() > 0) { for (ProposalPersonContract keyPerson : nKeyPersons) { if (pIPersonOrRolodexId != null) { // Don't add PI to keyperson list if (keyPerson.getPersonId() != null && keyPerson.getPersonId().equals(pIPersonOrRolodexId)) { continue; } else if ((keyPerson.getRolodexId() != null) && pIPersonOrRolodexId.equals(keyPerson.getRolodexId().toString())) { continue; } } Profile profileKeyPerson = Profile.Factory.newInstance(); profileKeyPerson.setName(globLibV20Generator.getHumanNameDataType(keyPerson)); if (keyPerson.getDirectoryTitle() != null) { if (keyPerson.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) { profileKeyPerson .setTitle(keyPerson.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH)); } else { profileKeyPerson.setTitle(keyPerson.getDirectoryTitle()); } } profileKeyPerson.setAddress(globLibV20Generator.getAddressDataType(keyPerson)); profileKeyPerson.setPhone(keyPerson.getOfficePhone()); if (StringUtils.isNotEmpty(keyPerson.getFaxNumber())) { profileKeyPerson.setFax(keyPerson.getFaxNumber()); } profileKeyPerson.setEmail(keyPerson.getEmailAddress()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { profileKeyPerson.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (keyPerson.getHomeUnit() != null) { KcPersonContract kcPerson = keyPerson.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profileKeyPerson.setDepartmentName( StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profileKeyPerson.setDepartmentName(StringUtils.substring( developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = keyPerson.getDivision(); if (divisionName != null) { profileKeyPerson .setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (keyPerson.getEraCommonsUserName() != null) { profileKeyPerson.setCredential(keyPerson.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + keyPerson.getFullName(), AuditError.GG_LINK)); } } } if (keyPerson.isMultiplePi() || keyPerson.isCoInvestigator()) { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { profileKeyPerson.setProjectRole(ProjectRoleDataType.PD_PI); } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.OTHER_SPECIFY); OtherProjectRoleCategory otherProjectRole = OtherProjectRoleCategory.Factory.newInstance(); String otherRole; if (keyPerson.getProjectRole() != null) { if (keyPerson.getProjectRole().length() > ROLE_DESCRIPTION_MAX_LENGTH) { otherRole = keyPerson.getProjectRole().substring(0, ROLE_DESCRIPTION_MAX_LENGTH); } else { otherRole = keyPerson.getProjectRole(); } } else { otherRole = FieldValueConstants.VALUE_UNKNOWN; } otherProjectRole.setStringValue(otherRole); profileKeyPerson.setOtherProjectRoleCategory(otherProjectRole); } PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profileKeyPerson.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profileKeyPerson.setSupportsAttached(supportsAttached); } PersonProfileDataType personProfileDataTypeKeyPerson = PersonProfileDataType.Factory.newInstance(); personProfileDataTypeKeyPerson.setProfile(profileKeyPerson); personProfileDataTypeList.add(personProfileDataTypeKeyPerson); } } PersonProfileDataType[] personProfileDataArray = new PersonProfileDataType[0]; personProfileDataArray = personProfileDataTypeList.toArray(personProfileDataArray); return personProfileDataArray; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_2Generator.java
private void setPersonalProfileDetailsToProfile(PersonProfileDataType profileDataType, Profile profile, ProposalPersonContract PI) {/*from ww w . ja v a 2s .c o m*/ assignRolodexId(PI); profile.setName(globLibV20Generator.getHumanNameDataType(PI)); setDirectoryTitleToProfile(profile, PI); profile.setAddress(globLibV20Generator.getAddressDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } if (PI.getDegree() != null) { profile.setDegreeType(PI.getDegree()); } if (PI.getYearGraduated() != null) { profile.setDegreeYear(PI.getYearGraduated()); } if (PI.getDegree() == null && PI.getYearGraduated() == null) { if (PI.getProposalPersonDegrees() != null && PI.getProposalPersonDegrees().size() > 0) { ProposalPersonDegreeContract proposalPersonDegree = PI.getProposalPersonDegrees().get(0); if (proposalPersonDegree != null) { if (proposalPersonDegree.getDegreeType() != null && proposalPersonDegree.getDegreeType().getDescription() != null) profile.setDegreeType(proposalPersonDegree.getDegreeType().getDescription()); if (proposalPersonDegree.getGraduationYear() != null) profile.setDegreeYear(proposalPersonDegree.getGraduationYear()); } } } profile.setEmail(PI.getEmailAddress()); DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); setOrganizationName(profile, developmentProposal); setDepartmentNameToProfile(profile, PI); String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + PI.getFullName(), AuditError.GG_LINK)); } } profile.setProjectRole(ProjectRoleDataType.PD_PI); setAttachments(profile, PI); profileDataType.setProfile(profile); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_2Generator.java
private void setDepartmentNameToProfile(Profile profile, ProposalPersonContract PI) { if (PI.getHomeUnit() != null && PI.getPerson() != null) { final String departmentName = PI.getPerson().getOrganizationIdentifier(); profile.setDepartmentName(StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else {// w w w.jav a2 s .com DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profile.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV1_2Generator.java
private void setAllkeyPersonDetailsToKeyPerson(ProposalPersonContract keyPerson, Profile profileKeyPerson) { assignRolodexId(keyPerson);//from w w w. j av a 2 s.c o m profileKeyPerson.setName(globLibV20Generator.getHumanNameDataType(keyPerson)); setDirectoryTitleToProfile(profileKeyPerson, keyPerson); profileKeyPerson.setAddress(globLibV20Generator.getAddressDataType(keyPerson)); profileKeyPerson.setPhone(keyPerson.getOfficePhone()); if (StringUtils.isNotEmpty(keyPerson.getFaxNumber())) { profileKeyPerson.setFax(keyPerson.getFaxNumber()); } if (keyPerson.getDegree() != null) { profileKeyPerson.setDegreeType(keyPerson.getDegree()); } if (keyPerson.getYearGraduated() != null) { profileKeyPerson.setDegreeYear(keyPerson.getYearGraduated()); } if (keyPerson.getDegree() == null && keyPerson.getYearGraduated() == null) { if (keyPerson.getProposalPersonDegrees() != null && keyPerson.getProposalPersonDegrees().size() > 0) { ProposalPersonDegreeContract proposalPersonDegree = keyPerson.getProposalPersonDegrees().get(0); if (proposalPersonDegree != null) { if (proposalPersonDegree.getDegreeType() != null && proposalPersonDegree.getDegreeType().getDescription() != null) profileKeyPerson.setDegreeType(proposalPersonDegree.getDegreeType().getDescription()); if (proposalPersonDegree.getGraduationYear() != null) profileKeyPerson.setDegreeYear(proposalPersonDegree.getGraduationYear()); } } } profileKeyPerson.setEmail(keyPerson.getEmailAddress()); DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); setOrganizationName(profileKeyPerson, developmentProposal); setDepartmentNameToProfile(profileKeyPerson, keyPerson); String divisionName = keyPerson.getDivision(); if (divisionName != null) { profileKeyPerson.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (keyPerson.getEraCommonsUserName() != null) { profileKeyPerson.setCredential(keyPerson.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + keyPerson.getFullName(), AuditError.GG_LINK)); } } } if (keyPerson.isMultiplePi() || keyPerson.isCoInvestigator()) { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { profileKeyPerson.setProjectRole(ProjectRoleDataType.PD_PI); } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_INVESTIGATOR); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { setProjectRoleCategoryToProfile(keyPerson, profileKeyPerson); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonExpandedV2_0Generator.java
private void setPersonalProfileDetailsToProfile(PersonProfileDataType profileDataType, Profile profile, ProposalPersonContract PI) {/* w ww . j a v a 2s . c om*/ assignRolodexId(PI); profile.setName(globLibV20Generator.getHumanNameDataType(PI)); setDirectoryTitleToProfile(profile, PI); profile.setAddress(globLibV20Generator.getAddressDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } if (PI.getDegree() != null) { profile.setDegreeType(PI.getDegree()); } if (PI.getYearGraduated() != null) { profile.setDegreeYear(PI.getYearGraduated()); } if (PI.getDegree() == null && PI.getYearGraduated() == null) { if (PI.getProposalPersonDegrees() != null && PI.getProposalPersonDegrees().size() > 0) { ProposalPersonDegreeContract proposalPersonDegree = PI.getProposalPersonDegrees().get(0); if (proposalPersonDegree != null) { if (proposalPersonDegree.getDegreeType() != null && proposalPersonDegree.getDegreeType().getDescription() != null) profile.setDegreeType(proposalPersonDegree.getDegreeType().getDescription()); if (proposalPersonDegree.getGraduationYear() != null) profile.setDegreeYear(proposalPersonDegree.getGraduationYear()); } } } profile.setEmail(PI.getEmailAddress()); DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); setOrganizationName(profile, developmentProposal); setDepartmentNameToProfile(profile, PI); String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } else { String personId = PI.getPersonId(); KcPersonContract kcPersonContact = kcPersonRepositoryService.findKcPersonByPersonId(personId); if (!kcPersonContact.getOrganizationIdentifier().isEmpty()) { divisionName = getPIDivision(kcPersonContact.getOrganizationIdentifier()); } if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } else { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { getAuditErrors().add(new AuditError(AuditError.NO_FIELD_ERROR_KEY, ERROR_ERA_COMMON_USER_NAME + PI.getFullName(), AuditError.GG_LINK)); } } profile.setProjectRole(ProjectRoleDataType.PD_PI); setAttachments(profile, PI); profileDataType.setProfile(profile); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonV1_0Generator.java
private PersonProfileDataType getPersonProfilePI() { PersonProfileDataType profileDataType = PersonProfileDataType.Factory.newInstance(); PersonProfileDataType.Profile profile = PersonProfileDataType.Profile.Factory.newInstance(); ProposalPersonContract PI = s2SProposalPersonService.getPrincipalInvestigator(pdDoc); if (PI != null) { if (PI.getPersonId() != null) { pIPersonOrRolodexId = PI.getPersonId(); } else if (PI.getRolodexId() != null) { pIPersonOrRolodexId = PI.getRolodexId().toString(); }//from w ww. j a v a 2 s.c o m profile.setName(globLibV10Generator.getHumanNameDataType(PI)); if (PI.getDirectoryTitle() != null) { if (PI.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) { profile.setTitle(PI.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH)); } else { profile.setTitle(PI.getDirectoryTitle()); } } profile.setAddress(globLibV10Generator.getAddressRequireCountryDataType(PI)); profile.setPhone(PI.getOfficePhone()); if (StringUtils.isNotEmpty(PI.getFaxNumber())) { profile.setFax(PI.getFaxNumber()); } profile.setEmail(PI.getEmailAddress()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { profile.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (PI.getHomeUnit() != null) { KcPersonContract kcPerson = PI.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profile.setDepartmentName(StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profile.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = PI.getDivision(); if (divisionName != null) { profile.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (PI.getEraCommonsUserName() != null) { profile.setCredential(PI.getEraCommonsUserName()); } profile.setProjectRole(ProjectRoleDataType.PD_PI); PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profile.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, PI.getPersonId(), PI.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profile.setSupportsAttached(supportsAttached); } profileDataType.setProfile(profile); } return profileDataType; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonV1_0Generator.java
private PersonProfileDataType[] getPersonProfileKeyPerson() { List<PersonProfileDataType> personProfileDataTypeList = new ArrayList<>(); List<? extends ProposalPersonContract> keyPersons = pdDoc.getDevelopmentProposal().getProposalPersons(); Collections.sort(keyPersons, new ProposalPersonComparator()); List<ProposalPersonContract> nKeyPersons = s2SProposalPersonService.getNKeyPersons(keyPersons, MAX_KEY_PERSON_COUNT);// www. jav a 2 s . c o m extraPersons = keyPersons.stream().filter(kp -> !nKeyPersons.contains(kp)).collect(Collectors.toList()); if (nKeyPersons.size() > 0) { for (ProposalPersonContract keyPerson : nKeyPersons) { if (pIPersonOrRolodexId != null) { // Don't add PI to keyperson list if (keyPerson.getPersonId() != null && keyPerson.getPersonId().equals(pIPersonOrRolodexId)) { continue; } else if ((keyPerson.getRolodexId() != null) && pIPersonOrRolodexId.equals(keyPerson.getRolodexId().toString())) { continue; } } Profile profileKeyPerson = Profile.Factory.newInstance(); profileKeyPerson.setName(globLibV10Generator.getHumanNameDataType(keyPerson)); if (keyPerson.getDirectoryTitle() != null) { profileKeyPerson.setTitle(keyPerson.getDirectoryTitle()); } profileKeyPerson.setAddress(globLibV10Generator.getAddressRequireCountryDataType(keyPerson)); profileKeyPerson.setPhone(keyPerson.getOfficePhone()); if (StringUtils.isNotEmpty(keyPerson.getFaxNumber())) { profileKeyPerson.setFax(keyPerson.getFaxNumber()); } profileKeyPerson.setEmail(keyPerson.getEmailAddress()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { profileKeyPerson.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (keyPerson.getHomeUnit() != null) { KcPersonContract kcPerson = keyPerson.getPerson(); String departmentName = kcPerson.getOrganizationIdentifier(); profileKeyPerson.setDepartmentName( StringUtils.substring(departmentName, 0, DEPARTMENT_NAME_MAX_LENGTH)); } else { DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); profileKeyPerson.setDepartmentName(StringUtils.substring( developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } String divisionName = keyPerson.getDivision(); if (divisionName != null) { profileKeyPerson .setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (keyPerson.getEraCommonsUserName() != null) { profileKeyPerson.setCredential(keyPerson.getEraCommonsUserName()); } if (keyPerson.isMultiplePi() || keyPerson.isCoInvestigator()) { if (getSponsorHierarchyService() .isSponsorNihMultiplePi(pdDoc.getDevelopmentProposal().getSponsor().getSponsorCode())) { if (keyPerson.isMultiplePi()) { profileKeyPerson.setProjectRole(ProjectRoleDataType.PD_PI); } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.CO_PD_PI); } } else { profileKeyPerson.setProjectRole(ProjectRoleDataType.OTHER_SPECIFY); OtherProjectRoleCategory otherProjectRole = OtherProjectRoleCategory.Factory.newInstance(); String otherRole; if (keyPerson.getProjectRole() != null) { if (keyPerson.getProjectRole().length() > ROLE_DESCRIPTION_MAX_LENGTH) { otherRole = keyPerson.getProjectRole().substring(0, ROLE_DESCRIPTION_MAX_LENGTH); } else { otherRole = keyPerson.getProjectRole(); } } else { otherRole = FieldValueConstants.VALUE_UNKNOWN; } otherProjectRole.setStringValue(otherRole); profileKeyPerson.setOtherProjectRoleCategory(otherProjectRole); } PersonProfileDataType.Profile.BioSketchsAttached personBioSketch = PersonProfileDataType.Profile.BioSketchsAttached.Factory .newInstance(); AttachedFileDataType bioSketchAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), BIOSKETCH_TYPE); personBioSketch.setBioSketchAttached(bioSketchAttachment); profileKeyPerson.setBioSketchsAttached(personBioSketch); AttachedFileDataType supportAttachment = getPernonnelAttachments(pdDoc, keyPerson.getPersonId(), keyPerson.getRolodexId(), CURRENT_PENDING_TYPE); if (supportAttachment != null) { PersonProfileDataType.Profile.SupportsAttached supportsAttached = PersonProfileDataType.Profile.SupportsAttached.Factory .newInstance(); supportsAttached.setSupportAttached(supportAttachment); profileKeyPerson.setSupportsAttached(supportsAttached); } PersonProfileDataType personProfileDataTypeKeyperson = PersonProfileDataType.Factory.newInstance(); personProfileDataTypeKeyperson.setProfile(profileKeyPerson); personProfileDataTypeList.add(personProfileDataTypeKeyperson); } } PersonProfileDataType[] personProfileDataTypeArray = new PersonProfileDataType[0]; personProfileDataTypeArray = personProfileDataTypeList.toArray(personProfileDataTypeArray); return personProfileDataTypeArray; }