Example usage for org.apache.commons.lang3 StringUtils substring

List of usage examples for org.apache.commons.lang3 StringUtils substring

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substring.

Prototype

public static String substring(final String str, int start, int end) 

Source Link

Document

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.

Usage

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonV1_1Generator.java

private PersonProfileDataType getPersonProfilePI() {

    PersonProfileDataType personProfileDataType = PersonProfileDataType.Factory.newInstance();
    Profile profile = Profile.Factory.newInstance();
    ProposalPersonContract PI = s2SProposalPersonService.getPrincipalInvestigator(pdDoc);
    if (PI != null) {
        if (PI.getPersonId() != null) {
            pIPersonOrRolodexId = PI.getPersonId();
            rolodex = null;// w w  w . jav a2 s .c  o  m
        } else if (PI.getRolodexId() != null) {
            pIPersonOrRolodexId = PI.getRolodexId().toString();
            rolodex = rolodexService.getRolodex(Integer.valueOf(pIPersonOrRolodexId));
        }
        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) {
            if (rolodex != null)
                profile.setOrganizationName(rolodex.getOrganization());
            else
                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);
        }
        personProfileDataType.setProfile(profile);
    }
    return personProfileDataType;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRKeyPersonV1_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  ww  . j ava 2s.  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;
                }
            }
            if (keyPerson.getPersonId() != null) {
                pIPersonOrRolodexId = keyPerson.getPersonId();
                rolodex = null;
            } else if (keyPerson.getRolodexId() != null) {
                pIPersonOrRolodexId = keyPerson.getRolodexId().toString();
                rolodex = rolodexService.getRolodex(Integer.valueOf(pIPersonOrRolodexId));
            }
            Profile profileKeyPerson = Profile.Factory.newInstance();
            profileKeyPerson.setName(globLibV20Generator.getHumanNameDataType(keyPerson));
            if (keyPerson.getDirectoryTitle() != null) {
                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) {
                if (rolodex != null)
                    profileKeyPerson.setOrganizationName(rolodex.getOrganization());
                else
                    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[] personProfileDataTypeArray = new PersonProfileDataType[0];
    personProfileDataTypeArray = personProfileDataTypeList.toArray(personProfileDataTypeArray);
    return personProfileDataTypeArray;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424BaseGenerator.java

protected String getFederalId() {
    final String federalId = pdDoc.getDevelopmentProposal().getSponsorProposalNumber();

    return StringUtils.substring(federalId, 0, FEDERAL_ID_MAX_LENGTH);
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424BaseGenerator.java

protected String getDepartmentName(KcPersonContract kcPerson) {
    final UnitContract unit = kcPerson.getUnit();
    return unit != null ? StringUtils.substring(unit.getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH) : "";
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_0Generator.java

/**
 *
 * This method gives the information for an application which consists of
 * personal details/*from   ww  w . j a v  a 2s  .  c om*/
 *
 * @return ApplicantInfo applicant details.
 */
private ApplicantInfo getApplicationInfo() {
    ApplicantInfo appInfo = ApplicantInfo.Factory.newInstance();
    String contactType = getContactType();
    if (CONTACT_TYPE_I.equals(contactType)) {
        // use organization rolodex contact
        if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) {
            appInfo.setContactPersonInfo(
                    getContactInfo(pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex()));
        }
    } else {
        // contact will come from unit or unit_administrators
        DepartmentalPersonDto depPerson = getContactPerson(pdDoc);
        ContactPersonInfo contactInfo = ContactPersonInfo.Factory.newInstance();
        if (depPerson != null) {
            contactInfo.setName(globLibV10Generator.getHumanNameDataType(depPerson));
            contactInfo.setPhone(depPerson.getOfficePhone());
            if (StringUtils.isNotEmpty(depPerson.getFaxNumber())) {
                contactInfo.setFax(depPerson.getFaxNumber());
            }
            if (depPerson.getEmailAddress() != null) {
                contactInfo.setEmail(depPerson.getEmailAddress());
            }
        }
        appInfo.setContactPersonInfo(contactInfo);
    }
    OrganizationDataTypeV2 orgType = OrganizationDataTypeV2.Factory.newInstance();
    RolodexContract rolodex = pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex();
    orgType.setAddress(globLibV10Generator.getAddressRequireCountryDataType(rolodex));

    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    if (organization != null) {
        orgType.setOrganizationName(organization.getOrganizationName());
        orgType.setDUNSID(organization.getDunsNumber());
    }
    if (pdDoc.getDevelopmentProposal().getOwnedByUnit() != null) {
        String departmentName = pdDoc.getDevelopmentProposal().getOwnedByUnit().getUnitName();
        if (departmentName != null && departmentName.length() > DEPARTMENT_NAME_MAX_LENGTH) {
            departmentName = departmentName.substring(0, DEPARTMENT_NAME_MAX_LENGTH - 1);
        }
        if (departmentName != null) {
            orgType.setDepartmentName(departmentName);
        }
        // divisionName
        String divisionName = getDivisionName(pdDoc);
        if (divisionName != null) {
            orgType.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH));
        }
    }
    appInfo.setOrganizationInfo(orgType);
    return appInfo;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_0Generator.java

/**
 *
 * This method is used to get details of Principal Investigator for
 * Organization Contact/*from   w  w w .  j  a  v a  2 s  .co  m*/
 *
 * @return OrganizationContactPersonDataType Principal investigator details.
 */
private OrganizationContactPersonDataType getPDPI() {

    OrganizationContactPersonDataType PDPI = OrganizationContactPersonDataType.Factory.newInstance();
    ProposalPersonContract PI;
    for (ProposalPersonContract proposalPerson : pdDoc.getDevelopmentProposal().getProposalPersons()) {
        if (PRINCIPAL_INVESTIGATOR.equals(proposalPerson.getProposalPersonRoleId())) {
            PI = proposalPerson;
            OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
                    .getOrganization();
            PDPI.setName(globLibV10Generator.getHumanNameDataType(PI));
            PDPI.setPhone(PI.getOfficePhone());
            PDPI.setEmail(PI.getEmailAddress());
            if (StringUtils.isNotEmpty(PI.getFaxNumber())) {
                PDPI.setFax(PI.getFaxNumber());
            }
            PDPI.setAddress(globLibV10Generator.getAddressRequireCountryDataType(PI));

            if (PI.getDirectoryTitle() != null) {
                if (PI.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) {
                    PDPI.setTitle(PI.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH));
                } else {
                    PDPI.setTitle(PI.getDirectoryTitle());
                }
            }

            if (PI.getHomeUnit() != null) {
                PDPI.setDepartmentName(getDepartmentName(PI.getPerson()));
            } else {
                DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal();
                PDPI.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(),
                        0, DEPARTMENT_NAME_MAX_LENGTH));
            }

            // divisionName
            String divisionName = proposalPerson.getDivision();
            if (divisionName != null) {
                PDPI.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH));
            }
            if (organization != null) {
                PDPI.setOrganizationName(organization.getOrganizationName());
            }
        }
    }
    return PDPI;

}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_0Generator.java

/**
 *
 * This method is used to get AOR Information for RRSf424
 *
 * @return aorInfoType(AORInfoType) Authorized representative information.
 *//*w ww .j  a v  a  2s  . co  m*/
private AORInfoType getAORInfoType() {
    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    AORInfoType aorInfoType = AORInfoType.Factory.newInstance();
    if (departmentalPerson != null) {
        aorInfoType.setName(globLibV10Generator.getHumanNameDataType(departmentalPerson));

        if (departmentalPerson.getPrimaryTitle() != null) {
            if (departmentalPerson.getPrimaryTitle().length() > PRIMARY_TITLE_MAX_LENGTH) {
                aorInfoType
                        .setTitle(departmentalPerson.getPrimaryTitle().substring(0, PRIMARY_TITLE_MAX_LENGTH));
            } else {
                aorInfoType.setTitle(departmentalPerson.getPrimaryTitle());
            }
        }
        aorInfoType.setAddress(globLibV10Generator.getAddressRequireCountryDataType(departmentalPerson));
        aorInfoType.setPhone(departmentalPerson.getOfficePhone());
        if (StringUtils.isNotEmpty(departmentalPerson.getFaxNumber())) {
            aorInfoType.setFax(departmentalPerson.getFaxNumber());
        }
        aorInfoType.setDepartmentName(departmentalPerson.getDirDept().substring(0, DEPARTMENT_NAME_MAX_LENGTH));
        aorInfoType.setEmail(departmentalPerson.getEmailAddress());
        if (departmentalPerson.getHomeUnit() != null) {
            aorInfoType.setDivisionName(
                    StringUtils.substring(departmentalPerson.getHomeUnit(), 0, DIVISION_NAME_MAX_LENGTH));
        }

    }
    if (organization != null) {
        aorInfoType.setOrganizationName(organization.getOrganizationName());
    }

    return aorInfoType;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_1Generator.java

/**
 * //  w ww  .  j  a  va 2s  .  c  o  m
 * This method gives the information for an application which consists of
 * personal details
 * 
 * @return appInfo(ApplicantInfo) applicant details.
 */
private ApplicantInfo getApplicationInfo() {
    ApplicantInfo appInfo = ApplicantInfo.Factory.newInstance();
    String contactType = getContactType();
    if (contactType.equals(CONTACT_TYPE_I)) {
        // use organization rolodex contact
        if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) {
            appInfo.setContactPersonInfo(
                    getContactInfo(pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex()));
        }
    } else {
        // contact will come from unit or unit_administrators
        DepartmentalPersonDto depPerson = getContactPerson(pdDoc);
        ContactPersonInfo contactInfo = ContactPersonInfo.Factory.newInstance();
        if (depPerson != null) {
            contactInfo.setName(globLibV20Generator.getHumanNameDataType(depPerson));
            contactInfo.setPhone(depPerson.getOfficePhone());
            if (StringUtils.isNotEmpty(depPerson.getFaxNumber())) {
                contactInfo.setFax(depPerson.getFaxNumber());
            }
            if (depPerson.getEmailAddress() != null) {
                contactInfo.setEmail(depPerson.getEmailAddress());
            }
        }
        appInfo.setContactPersonInfo(contactInfo);
    }
    OrganizationDataType orgType = OrganizationDataType.Factory.newInstance();
    RolodexContract rolodex = pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex();
    orgType.setAddress(globLibV20Generator.getAddressDataType(rolodex));
    OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization()
            .getOrganization();
    if (organization != null) {
        orgType.setOrganizationName(organization.getOrganizationName());
        orgType.setDUNSID(organization.getDunsNumber());
    }
    if (pdDoc.getDevelopmentProposal().getOwnedByUnit() != null) {
        String departmentName = pdDoc.getDevelopmentProposal().getOwnedByUnit().getUnitName();
        if (departmentName != null && departmentName.length() > DEPARTMENT_NAME_MAX_LENGTH) {
            departmentName = departmentName.substring(0, DEPARTMENT_NAME_MAX_LENGTH - 1);
        }
        orgType.setDepartmentName(departmentName);
        // divisionName
        String divisionName = getDivisionName(pdDoc);
        if (divisionName != null) {
            orgType.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH));
        }
    }
    appInfo.setOrganizationInfo(orgType);
    return appInfo;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_1Generator.java

/**
 * /*from w  w  w  .  j  a v  a2 s.  c o  m*/
 * This method is used to get details of Principal Investigator for
 * Organization Contact
 * 
 * @return OrganizationContactPersonDataType Principal investigator details.
 */
private OrganizationContactPersonDataType getPDPI() {
    OrganizationContactPersonDataType PDPI = OrganizationContactPersonDataType.Factory.newInstance();
    ProposalPersonContract PI;
    for (ProposalPersonContract proposalPerson : pdDoc.getDevelopmentProposal().getProposalPersons()) {
        if (PRINCIPAL_INVESTIGATOR.equals(proposalPerson.getProposalPersonRoleId())) {
            PI = proposalPerson;
            ProposalSiteContract applicantOrganization = pdDoc.getDevelopmentProposal()
                    .getApplicantOrganization();
            PDPI.setName(globLibV20Generator.getHumanNameDataType(PI));
            PDPI.setPhone(PI.getOfficePhone());
            PDPI.setEmail(PI.getEmailAddress());
            if (StringUtils.isNotEmpty(PI.getFaxNumber())) {
                PDPI.setFax(PI.getFaxNumber());
            }
            PDPI.setAddress(globLibV20Generator.getAddressDataType(PI));
            if (PI.getDirectoryTitle() != null) {
                if (PI.getDirectoryTitle().length() > DIRECTORY_TITLE_MAX_LENGTH) {
                    PDPI.setTitle(PI.getDirectoryTitle().substring(0, DIRECTORY_TITLE_MAX_LENGTH));
                } else {
                    PDPI.setTitle(PI.getDirectoryTitle());
                }
            }
            if (PI.getHomeUnit() != null) {
                PDPI.setDepartmentName(getDepartmentName(PI.getPerson()));
            } else {
                DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal();
                PDPI.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(),
                        0, DEPARTMENT_NAME_MAX_LENGTH));
            }
            // divisionName
            String divisionName = proposalPerson.getDivision();
            if (divisionName != null) {
                PDPI.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH));
            }
            if (applicantOrganization != null) {
                PDPI.setOrganizationName(applicantOrganization.getLocationName());
            }
        }
    }
    return PDPI;
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_1Generator.java

/**
 * //from w ww.j a va  2s .  c om
 * This method is used to get AOR Information for RRSf424
 * 
 * @return aorInfoType(AORInfoType) Authorized representative information.
 */
private AORInfoType getAORInfoType() {
    ProposalSiteContract applicantOrganization = pdDoc.getDevelopmentProposal().getApplicantOrganization();
    AORInfoType aorInfoType = AORInfoType.Factory.newInstance();
    if (departmentalPerson != null) {
        aorInfoType.setName(globLibV20Generator.getHumanNameDataType(departmentalPerson));
        if (departmentalPerson.getPrimaryTitle() != null) {
            if (departmentalPerson.getPrimaryTitle().length() > PRIMARY_TITLE_MAX_LENGTH) {
                aorInfoType
                        .setTitle(departmentalPerson.getPrimaryTitle().substring(0, PRIMARY_TITLE_MAX_LENGTH));
            } else {
                aorInfoType.setTitle(departmentalPerson.getPrimaryTitle());
            }
        } else {
            aorInfoType.setTitle("");
        }
        AddressDataType address = AddressDataType.Factory.newInstance();
        address.setStreet1(departmentalPerson.getAddress1());
        address.setStreet2(departmentalPerson.getAddress2());
        address.setCity(departmentalPerson.getCity());
        if (departmentalPerson.getState() != null) {
            address.setState(globLibV20Generator.getStateCodeDataType(departmentalPerson.getCountryCode(),
                    departmentalPerson.getState()));
        }
        address.setZipPostalCode(departmentalPerson.getPostalCode());
        if (departmentalPerson.getCountryCode() != null) {
            address.setCountry(globLibV20Generator.getCountryCodeDataType(departmentalPerson.getCountryCode()));
        }
        aorInfoType.setAddress(address);
        aorInfoType.setPhone(departmentalPerson.getOfficePhone());
        if (StringUtils.isNotEmpty(departmentalPerson.getFaxNumber())) {
            aorInfoType.setFax(departmentalPerson.getFaxNumber());
        }
        aorInfoType.setDepartmentName(departmentalPerson.getDirDept().substring(0, DEPARTMENT_NAME_MAX_LENGTH));
        aorInfoType.setEmail(departmentalPerson.getEmailAddress());
        if (departmentalPerson.getHomeUnit() != null) {
            aorInfoType.setDivisionName(
                    StringUtils.substring(departmentalPerson.getHomeUnit(), 0, DIVISION_NAME_MAX_LENGTH));
        }
    }
    if (applicantOrganization != null) {
        aorInfoType.setOrganizationName(applicantOrganization.getLocationName());
    }
    return aorInfoType;
}