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.RRSF424V1_2Generator.java
private OrganizationDataType getOrganizationDataType() { OrganizationDataType orgType = OrganizationDataType.Factory.newInstance(); RolodexContract rolodex = pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex(); orgType.setAddress(globLibV20Generator.getAddressDataType(rolodex)); OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization();/*w ww . j av a 2 s. c o m*/ 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)); } } return orgType; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_2Generator.java
private void setDivisionName(OrganizationContactPersonDataType PDPI, ProposalPersonContract PI) { String divisionName = PI.getDivision(); if (divisionName != null) { PDPI.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); }/*from w w w . j a va 2 s . c om*/ }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_2Generator.java
private void setDepartmentName(OrganizationContactPersonDataType PDPI, ProposalPersonContract PI) { if (PI.getHomeUnit() != null) { PDPI.setDepartmentName(getDepartmentName(PI.getPerson())); } else {/*from w w w . j a v a2s .c om*/ DevelopmentProposalContract developmentProposal = pdDoc.getDevelopmentProposal(); PDPI.setDepartmentName(StringUtils.substring(developmentProposal.getOwnedByUnit().getUnitName(), 0, DEPARTMENT_NAME_MAX_LENGTH)); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_2Generator.java
private void setDivisionName(AORInfoType aorInfoType) { if (departmentalPerson.getHomeUnit() != null) { aorInfoType.setDivisionName(//from w w w . j av a2s .c o m StringUtils.substring(departmentalPerson.getHomeUnit(), 0, DIVISION_NAME_MAX_LENGTH)); } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java
private OrganizationDataType getOrganizationDataType() { OrganizationDataType orgType = OrganizationDataType.Factory.newInstance(); RolodexContract rolodex = pdDoc.getDevelopmentProposal().getApplicantOrganization().getRolodex(); orgType.setAddress(globLibV20Generator.getAddressDataType(rolodex)); OrganizationContract organization = pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization();//from w w w . j a v a 2 s . c o m if (organization != null) { orgType.setOrganizationName(organization.getOrganizationName()); orgType.setDUNSID(organization.getDunsNumber()); } UnitContract leadUnit = pdDoc.getDevelopmentProposal().getOwnedByUnit(); if (leadUnit != null) { String departmentName = leadUnit.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 = getPIDivision(leadUnit.getUnitNumber()); if (divisionName != null) { orgType.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } } return orgType; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java
private void setDivisionName(OrganizationContactPersonDataType PDPI, ProposalPersonContract PI) { String divisionName = PI.getDivision(); if (divisionName != null) { PDPI.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } else {/*from ww w.ja v a2s . c o m*/ String personId = PI.getPersonId(); KcPersonContract kcPersons = kcPersonRepositoryService.findKcPersonByPersonId(personId); if (kcPersons.getOrganizationIdentifier() != null) { divisionName = getPIDivision(kcPersons.getOrganizationIdentifier()); } if (divisionName != null) { PDPI.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } } }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java
private void setDivisionName(AORInfoType aorInfoType) { if (departmentalPerson.getHomeUnit() != null) { aorInfoType.setDivisionName(StringUtils.substring(getUnitName(departmentalPerson.getHomeUnit()), 0, DIVISION_NAME_MAX_LENGTH)); }/* ww w .j a v a 2 s . c o m*/ }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java
private String getActivityTitle() { return StringUtils.substring(pdDoc.getDevelopmentProposal().getS2sOpportunity().getCfdaDescription(), 0, CFDA_TITLE_MAX_LENGTH); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424_2_0V2_0Generator.java
private String getProjectTitle() { return StringUtils.substring(pdDoc.getDevelopmentProposal().getTitle(), 0, PROJECT_TITLE_MAX_LENGTH); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.SF424V1_0Generator.java
/** * // ww w . ja v a 2 s . co m * Gets the information about the Submitting Organization.This includes * details like CongressionalDistrict * DelinquentFederalDebtIndicator,OrganizationName,DUNSID,DepartmentName,DivisionName,ApplicantID,ApplicantTypeCode * Organization details,OrganizationIdentifyingInformation and Address * * @return submittingOrganization(SubmittingOrganization) organization * details. */ private SubmittingOrganization getSubmittingOrganization() { SubmittingOrganization submittingOrganization = SubmittingOrganization.Factory.newInstance(); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { submittingOrganization.setCongressionalDistrict( pdDoc.getDevelopmentProposal().getApplicantOrganization().getFirstCongressionalDistrictName()); } YesNoType.Enum yesNo = YesNoType.N; for (OrganizationYnqContract orgYnq : pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationYnqs()) { if (PROPOSAL_YNQ_FEDERAL_DEBTS.equals(orgYnq.getQuestionId())) { if (orgYnq.getAnswer() != null) { yesNo = YesNoType.Enum.forString(orgYnq.getAnswer()); } } } submittingOrganization.setDelinquentFederalDebtIndicator(yesNo); Organization organization = Organization.Factory.newInstance(); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { organization.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization() .getOrganization().getOrganizationName()); } if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { organization.setDUNSID( pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getDunsNumber()); } String departmentName = ""; if (pdDoc.getDevelopmentProposal().getOwnedByUnit() != null) { departmentName = pdDoc.getDevelopmentProposal().getOwnedByUnit().getUnitName(); } if (departmentName != null && departmentName.length() > DEPARTMENT_NAME_MAX_LENGTH) { organization.setDepartmentName(departmentName.substring(0, DEPARTMENT_NAME_MAX_LENGTH)); } else { organization.setDepartmentName(departmentName); } String divisionName = getDivisionName(pdDoc); if (divisionName != null) { organization.setDivisionName(StringUtils.substring(divisionName, 0, DIVISION_NAME_MAX_LENGTH)); } if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { organization.setEmployerID(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization() .getFederalEmployerId()); } OrganizationIdentifyingInformation orgIdentifyingInformation = OrganizationIdentifyingInformation.Factory .newInstance(); orgIdentifyingInformation.setApplicantID(pdDoc.getDevelopmentProposal().getProposalNumber()); orgIdentifyingInformation.setApplicantTypeCode(getApplicantType()); orgIdentifyingInformation.setOrganization(organization); submittingOrganization.setOrganizationIdentifyingInformation(orgIdentifyingInformation); Address address = Address.Factory.newInstance(); // Set default values for mandatory fields address.setStreet1(""); address.setCity(""); RolodexContract rolodex = null; if (pdDoc.getDevelopmentProposal().getPerformingOrganization() != null) { rolodex = pdDoc.getDevelopmentProposal().getPerformingOrganization().getRolodex(); if (rolodex != null) { address.setStreet1(rolodex.getAddressLine1() == null ? "" : rolodex.getAddressLine1()); address.setStreet2(rolodex.getAddressLine2()); address.setCity(rolodex.getCity() == null ? "" : rolodex.getCity()); address.setCounty(rolodex.getCounty()); address.setStateCode(rolodex.getState()); address.setZipCode(rolodex.getPostalCode()); if (rolodex.getCountryCode() != null) { CountryCodeType.Enum countryEnum = CountryCodeType.Enum.forString(rolodex.getCountryCode()); address.setCountry(countryEnum); } submittingOrganization.setAddress(address); } } submittingOrganization.setAddress(address); return submittingOrganization; }