Java tutorial
/* * Kuali Coeus, a comprehensive research administration system for higher education. * * Copyright 2005-2016 Kuali, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.kuali.coeus.s2sgen.impl.generate.support; import gov.grants.apply.forms.rrBudgetV10.*; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.*; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.Equipment.AdditionalEquipmentsAttachment; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.Equipment.EquipmentList; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.Equipment.TotalFundForAttachedEquipment; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.KeyPersons.AttachedKeyPersons; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.KeyPersons.TotalFundForAttachedKeyPersons; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.OtherDirectCosts.Others; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.OtherPersonnel.GraduateStudents; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.OtherPersonnel.PostDocAssociates; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.OtherPersonnel.SecretarialClerical; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.OtherPersonnel.UndergraduateStudents; import gov.grants.apply.forms.rrBudgetV10.BudgetYearDataType.ParticipantTraineeSupportCosts.Other; import gov.grants.apply.forms.rrBudgetV10.RRBudgetDocument.RRBudget.BudgetSummary; import gov.grants.apply.forms.rrBudgetV10.RRBudgetDocument.RRBudget.BudgetSummary.CumulativeEquipments; import gov.grants.apply.forms.rrBudgetV10.RRBudgetDocument.RRBudget.BudgetSummary.CumulativeOtherDirect; import gov.grants.apply.forms.rrBudgetV10.RRBudgetDocument.RRBudget.BudgetSummary.CumulativeTrainee; import gov.grants.apply.forms.rrBudgetV10.RRBudgetDocument.RRBudget.BudgetSummary.CumulativeTravels; import gov.grants.apply.system.attachmentsV10.AttachedFileDataType; import gov.grants.apply.system.attachmentsV10.AttachedFileDataType.FileLocation; import gov.grants.apply.system.globalLibraryV10.YesNoDataType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.xmlbeans.XmlObject; import org.kuali.coeus.s2sgen.api.core.InfastructureConstants; import org.kuali.coeus.s2sgen.api.generate.AttachmentData; import org.kuali.coeus.s2sgen.impl.budget.*; import org.kuali.coeus.propdev.api.core.ProposalDevelopmentDocumentContract; import org.kuali.coeus.s2sgen.impl.generate.FormVersion; import org.kuali.coeus.sys.api.model.ScaleTwoDecimal; import org.kuali.coeus.s2sgen.api.core.S2SException; import org.kuali.coeus.propdev.api.attachment.NarrativeContract; import org.kuali.coeus.s2sgen.impl.generate.FormGenerator; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; /** * * This class is used to generate XML Document object for grants.gov * RRBudgetV1.0. This form is generated using XMLBean API's generated by * compiling RRBudgetV1.0 schema. * * @author Kuali Research Administration Team (kualidev@oncourse.iu.edu) */ @FormGenerator("RRBudgetV1_0Generator") public class RRBudgetV1_0Generator extends RRBudgetBaseGenerator { private static final Logger LOG = LoggerFactory.getLogger(RRBudgetV1_0Generator.class); @Value("http://apply.grants.gov/forms/RR_Budget-V1.0") private String namespace; @Value("RR_Budget-V1.0") private String formName; @Value("classpath:org/kuali/coeus/s2sgen/impl/generate/support/stylesheet/RR_Budget-V1.0.fo.xsl") private Resource stylesheet; @Value("gov.grants.apply.forms.rrBudgetV10") private String packageName; @Value("165") private int sortIndex; /** * This method returns RRBudgetDocument object based on proposal development * document which contains the informations such as * DUNSID,OrganizationName,BudgetType,BudgetYear and BudgetSummary. * * @return rrBudgetDocument {@link XmlObject} of type RRBudgetDocument. */ private RRBudgetDocument getRRBudget() { deleteAutoGenNarratives(); RRBudgetDocument rrBudgetDocument = RRBudgetDocument.Factory.newInstance(); RRBudgetDocument.RRBudget rrBudget = RRBudgetDocument.RRBudget.Factory.newInstance(); rrBudget.setFormVersion(FormVersion.v1_0.getVersion()); if (pdDoc.getDevelopmentProposal().getApplicantOrganization() != null) { rrBudget.setDUNSID( pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization().getDunsNumber()); rrBudget.setOrganizationName(pdDoc.getDevelopmentProposal().getApplicantOrganization().getOrganization() .getOrganizationName()); } rrBudget.setBudgetType(BudgetTypeDataType.PROJECT); // Set default values for mandatory fields rrBudget.setBudgetYear1(BudgetYear1DataType.Factory.newInstance()); List<BudgetPeriodDto> budgetperiodList; BudgetSummaryDto budgetSummary = null; try { budgetperiodList = s2sBudgetCalculatorService.getBudgetPeriods(pdDoc); budgetSummary = s2sBudgetCalculatorService.getBudgetInfo(pdDoc, budgetperiodList); } catch (S2SException e) { LOG.error(e.getMessage(), e); return rrBudgetDocument; } for (BudgetPeriodDto budgetPeriodData : budgetperiodList) { if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P1.getNum()) { rrBudget.setBudgetYear1(getBudgetYear1DataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P2.getNum()) { rrBudget.setBudgetYear2(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P3.getNum()) { rrBudget.setBudgetYear3(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P4.getNum()) { rrBudget.setBudgetYear4(getBudgetYearDataType(budgetPeriodData)); } else if (budgetPeriodData.getBudgetPeriod() == BudgetPeriodNum.P5.getNum()) { rrBudget.setBudgetYear5(getBudgetYearDataType(budgetPeriodData)); } } rrBudget.setBudgetSummary(getBudgetSummary(budgetSummary)); rrBudgetDocument.setRRBudget(rrBudget); return rrBudgetDocument; } /** * This method gets BudgetYear1DataType details like * BudgetPeriodStartDate,BudgetPeriodEndDate,BudgetPeriod * KeyPersons,OtherPersonnel,TotalCompensation,Equipment,ParticipantTraineeSupportCosts,Travel,OtherDirectCosts * DirectCosts,IndirectCosts,CognizantFederalAgency,TotalCosts and * BudgetJustificationAttachment based on BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return BudgetYear1DataType corresponding to the BudgetPeriodInfo entry. */ private BudgetYear1DataType getBudgetYear1DataType(BudgetPeriodDto periodInfo) { BudgetYear1DataType budgetYear = BudgetYear1DataType.Factory.newInstance(); budgetYear.setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate())); budgetYear.setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getEndDate())); BudgetPeriod.Enum budgetPeriod = BudgetPeriod.Enum.forInt(periodInfo.getBudgetPeriod()); budgetYear.setBudgetPeriod(budgetPeriod); budgetYear.setKeyPersons(getKeyPersons(periodInfo)); budgetYear.setOtherPersonnel(getOtherPersonnel(periodInfo)); if (periodInfo.getTotalCompensation() != null) { budgetYear.setTotalCompensation(periodInfo.getTotalCompensation().bigDecimalValue()); } budgetYear.setEquipment(getEquipment(periodInfo)); budgetYear.setTravel(getTravel(periodInfo)); budgetYear.setParticipantTraineeSupportCosts(getParticipantTraineeSupportCosts(periodInfo)); budgetYear.setOtherDirectCosts(getOtherDirectCosts(periodInfo)); budgetYear.setDirectCosts(periodInfo.getDirectCostsTotal().bigDecimalValue()); IndirectCosts indirectCosts = getIndirectCosts(periodInfo); if (indirectCosts != null) { budgetYear.setIndirectCosts(indirectCosts); budgetYear.setTotalCosts( periodInfo.getDirectCostsTotal().bigDecimalValue().add(indirectCosts.getTotalIndirectCosts())); } else { budgetYear.setTotalCosts(periodInfo.getDirectCostsTotal().bigDecimalValue()); } budgetYear.setCognizantFederalAgency(periodInfo.getCognizantFedAgency()); AttachedFileDataType attachedFileDataType = null; for (NarrativeContract narrative : pdDoc.getDevelopmentProposal().getNarratives()) { if (narrative.getNarrativeType().getCode() != null && Integer .parseInt(narrative.getNarrativeType().getCode()) == BUDGET_JUSTIFICATION_ATTACHMENT) { attachedFileDataType = getAttachedFileType(narrative); if (attachedFileDataType != null) { budgetYear.setBudgetJustificationAttachment(attachedFileDataType); break; } } } return budgetYear; } /** * This method gets BudgetYearDataType details like * BudgetPeriodStartDate,BudgetPeriodEndDate,BudgetPeriod * KeyPersons,OtherPersonnel,TotalCompensation,Equipment,ParticipantTraineeSupportCosts,Travel,OtherDirectCosts * DirectCosts,IndirectCosts,CognizantFederalAgency,TotalCosts based on * BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return BudgetYearDataType corresponding to the BudgetPeriodInfo entry. */ private BudgetYearDataType getBudgetYearDataType(BudgetPeriodDto periodInfo) { BudgetYearDataType budgetYear = BudgetYearDataType.Factory.newInstance(); if (periodInfo != null) { if (periodInfo.getStartDate() != null) { budgetYear.setBudgetPeriodStartDate( s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate())); } if (periodInfo.getEndDate() != null) { budgetYear .setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getEndDate())); } BudgetPeriod.Enum budgetPeriod = BudgetPeriod.Enum.forInt(periodInfo.getBudgetPeriod()); budgetYear.setBudgetPeriod(budgetPeriod); budgetYear.setKeyPersons(getKeyPersons(periodInfo)); budgetYear.setOtherPersonnel(getOtherPersonnel(periodInfo)); if (periodInfo.getTotalCompensation() != null) { budgetYear.setTotalCompensation(periodInfo.getTotalCompensation().bigDecimalValue()); } budgetYear.setEquipment(getEquipment(periodInfo)); budgetYear.setTravel(getTravel(periodInfo)); budgetYear.setParticipantTraineeSupportCosts(getParticipantTraineeSupportCosts(periodInfo)); budgetYear.setOtherDirectCosts(getOtherDirectCosts(periodInfo)); BigDecimal directCosts = null; if (periodInfo.getDirectCostsTotal() != null) { directCosts = periodInfo.getDirectCostsTotal().bigDecimalValue(); budgetYear.setDirectCosts(directCosts); } IndirectCosts indirectCosts = getIndirectCosts(periodInfo); budgetYear.setIndirectCosts(indirectCosts); budgetYear.setCognizantFederalAgency(periodInfo.getCognizantFedAgency()); if (indirectCosts != null && directCosts != null) { budgetYear.setTotalCosts(directCosts.add(indirectCosts.getTotalIndirectCosts())); } else { budgetYear.setTotalCosts(periodInfo.getTotalCosts().bigDecimalValue()); } } return budgetYear; } /** * This method gets BudgetSummary details such as * CumulativeTotalFundsRequestedSeniorKeyPerson,CumulativeTotalFundsRequestedOtherPersonnel * CumulativeTotalNoOtherPersonnel,CumulativeTotalFundsRequestedPersonnel,CumulativeEquipments,CumulativeTravels * CumulativeTrainee,CumulativeOtherDirect,CumulativeTotalFundsRequestedDirectCosts,CumulativeTotalFundsRequestedIndirectCost * CumulativeTotalFundsRequestedDirectIndirectCosts and CumulativeFee based * on BudgetSummaryInfo for the RRBudget. * * @param budgetSummaryData * (BudgetSummaryInfo) budget summary info entry. * @return BudgetSummary details corresponding to the BudgetSummaryInfo * object. */ private BudgetSummary getBudgetSummary(BudgetSummaryDto budgetSummaryData) { BudgetSummary budgetSummary = BudgetSummary.Factory.newInstance(); // Set default values for mandatory fields budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson(BigDecimal.ZERO); budgetSummary.setCumulativeTotalFundsRequestedPersonnel(BigDecimal.ZERO); budgetSummary.setCumulativeTotalFundsRequestedDirectCosts(BigDecimal.ZERO); if (budgetSummaryData != null) { if (budgetSummaryData.getCumTotalFundsForSrPersonnel() != null) { budgetSummary.setCumulativeTotalFundsRequestedSeniorKeyPerson( budgetSummaryData.getCumTotalFundsForSrPersonnel().bigDecimalValue()); } if (budgetSummaryData.getCumTotalFundsForOtherPersonnel() != null) { budgetSummary.setCumulativeTotalFundsRequestedOtherPersonnel( budgetSummaryData.getCumTotalFundsForOtherPersonnel().bigDecimalValue()); } if (budgetSummaryData.getCumNumOtherPersonnel() != null) { budgetSummary .setCumulativeTotalNoOtherPersonnel(budgetSummaryData.getCumNumOtherPersonnel().intValue()); } if (budgetSummaryData.getCumTotalFundsForPersonnel() != null) { budgetSummary.setCumulativeTotalFundsRequestedPersonnel( budgetSummaryData.getCumTotalFundsForPersonnel().bigDecimalValue()); } budgetSummary.setCumulativeEquipments(getCumulativeEquipments(budgetSummaryData)); budgetSummary.setCumulativeTravels(getCumulativeTravels(budgetSummaryData)); budgetSummary.setCumulativeTrainee(getCumulativeTrainee(budgetSummaryData)); budgetSummary.setCumulativeOtherDirect(getCumulativeOtherDirect(budgetSummaryData)); if (budgetSummaryData.getCumTotalDirectCosts() != null) { budgetSummary.setCumulativeTotalFundsRequestedDirectCosts( budgetSummaryData.getCumTotalDirectCosts().bigDecimalValue()); } if (budgetSummaryData.getCumTotalIndirectCosts() != null) { budgetSummary.setCumulativeTotalFundsRequestedIndirectCost( budgetSummaryData.getCumTotalIndirectCosts().bigDecimalValue()); } if (budgetSummaryData.getCumTotalCosts() != null) { budgetSummary.setCumulativeTotalFundsRequestedDirectIndirectCosts( budgetSummaryData.getCumTotalCosts().bigDecimalValue()); } if (budgetSummaryData.getCumFee() != null) { budgetSummary.setCumulativeFee(budgetSummaryData.getCumFee().bigDecimalValue()); } } return budgetSummary; } /** * This method gets CumulativeEquipments information * CumulativeTotalFundsRequestedEquipment based on BudgetSummaryInfo for the * form RRBudget. * * @param budgetSummaryData * (BudgetSummaryInfo) budget summary info entry. * @return CumulativeEquipments details corresponding to the * BudgetSummaryInfo object. */ private CumulativeEquipments getCumulativeEquipments(BudgetSummaryDto budgetSummaryData) { CumulativeEquipments cumulativeEquipments = CumulativeEquipments.Factory.newInstance(); if (budgetSummaryData.getCumEquipmentFunds() != null) { cumulativeEquipments.setCumulativeTotalFundsRequestedEquipment( budgetSummaryData.getCumEquipmentFunds().bigDecimalValue()); } return cumulativeEquipments; } /** * This method gets CumulativeTravels * details,CumulativeTotalFundsRequestedTravel,CumulativeDomesticTravelCosts * and CumulativeForeignTravelCosts based on BudgetSummaryInfo for the * RRBudget. * * @param budgetSummaryData * (BudgetSummaryInfo) budget summary info entry. * @return CumulativeTravels details corresponding to the BudgetSummaryInfo * object. */ private CumulativeTravels getCumulativeTravels(BudgetSummaryDto budgetSummaryData) { CumulativeTravels cumulativeTravels = CumulativeTravels.Factory.newInstance(); if (budgetSummaryData.getCumDomesticTravel() != null) { cumulativeTravels .setCumulativeDomesticTravelCosts(budgetSummaryData.getCumDomesticTravel().bigDecimalValue()); } if (budgetSummaryData.getCumForeignTravel() != null) { cumulativeTravels .setCumulativeForeignTravelCosts(budgetSummaryData.getCumForeignTravel().bigDecimalValue()); } if (budgetSummaryData.getCumTravel() != null) { cumulativeTravels .setCumulativeTotalFundsRequestedTravel(budgetSummaryData.getCumTravel().bigDecimalValue()); } return cumulativeTravels; } /** * This method gets CumulativeTrainee details, * CumulativeTotalFundsRequestedTraineeCosts,CumulativeTraineeTuitionFeesHealthInsurance * CumulativeTraineeStipends,CumulativeTraineeTravel,CumulativeTraineeSubsistence,CumulativeOtherTraineeCost * and CumulativeNoofTrainees based on BudgetSummaryInfo for the RRBudget. * * @param budgetSummaryData * (BudgetSummaryInfo) budget summary info entry. * @return CumulativeTrainee details corresponding to the BudgetSummaryInfo * object. */ private CumulativeTrainee getCumulativeTrainee(BudgetSummaryDto budgetSummaryData) { CumulativeTrainee cumulativeTrainee = CumulativeTrainee.Factory.newInstance(); cumulativeTrainee.setCumulativeTotalFundsRequestedTraineeCosts(BigDecimal.ZERO); if (budgetSummaryData != null) { if (budgetSummaryData.getpartOtherCost() != null && budgetSummaryData.getpartStipendCost() != null && budgetSummaryData.getpartTravelCost() != null && budgetSummaryData.getPartTuition() != null) { cumulativeTrainee.setCumulativeTotalFundsRequestedTraineeCosts(budgetSummaryData.getpartOtherCost() .add(budgetSummaryData.getpartStipendCost().add(budgetSummaryData.getpartTravelCost().add( budgetSummaryData.getPartTuition().add(budgetSummaryData.getPartSubsistence())))) .bigDecimalValue()); } if (budgetSummaryData.getPartTuition() != null) { cumulativeTrainee.setCumulativeTraineeTuitionFeesHealthInsurance( budgetSummaryData.getPartTuition().bigDecimalValue()); } if (budgetSummaryData.getpartStipendCost() != null) { cumulativeTrainee .setCumulativeTraineeStipends(budgetSummaryData.getpartStipendCost().bigDecimalValue()); } if (budgetSummaryData.getpartTravelCost() != null) { cumulativeTrainee .setCumulativeTraineeTravel(budgetSummaryData.getpartTravelCost().bigDecimalValue()); } if (budgetSummaryData.getPartSubsistence() != null) { cumulativeTrainee .setCumulativeTraineeSubsistence(budgetSummaryData.getPartSubsistence().bigDecimalValue()); } if (budgetSummaryData.getpartOtherCost() != null) { cumulativeTrainee .setCumulativeOtherTraineeCost(budgetSummaryData.getpartOtherCost().bigDecimalValue()); } cumulativeTrainee.setCumulativeNoofTrainees(budgetSummaryData.getparticipantCount()); } return cumulativeTrainee; } /** * This method gets CumulativeOtherDirectCost * details,CumulativeMaterialAndSupplies,CumulativePublicationCosts, * CumulativeConsultantServices,CumulativeADPComputerServices,CumulativeSubawardConsortiumContractualCosts * CumulativeEquipmentFacilityRentalFees,CumulativeAlterationsAndRenovations * and CumulativeOther1DirectCost based on BudgetSummaryInfo for the * RRBudget. * * @param budgetSummaryData * (BudgetSummaryInfo) budget summary info entry. * @return CumulativeOtherDirect details corresponding to the * BudgetSummaryInfo object. */ private CumulativeOtherDirect getCumulativeOtherDirect(BudgetSummaryDto budgetSummaryData) { CumulativeOtherDirect cumulativeOtherDirect = CumulativeOtherDirect.Factory.newInstance(); cumulativeOtherDirect.setCumulativeTotalFundsRequestedOtherDirectCosts(BigDecimal.ZERO); if (budgetSummaryData != null) { for (OtherDirectCostInfoDto cumOtherDirect : budgetSummaryData.getOtherDirectCosts()) { if (cumOtherDirect.gettotalOtherDirect() != null) { cumulativeOtherDirect.setCumulativeTotalFundsRequestedOtherDirectCosts( cumOtherDirect.gettotalOtherDirect().bigDecimalValue()); } if (cumOtherDirect.getmaterials() != null) { cumulativeOtherDirect .setCumulativeMaterialAndSupplies(cumOtherDirect.getmaterials().bigDecimalValue()); } if (cumOtherDirect.getpublications() != null) { cumulativeOtherDirect .setCumulativePublicationCosts(cumOtherDirect.getpublications().bigDecimalValue()); } if (cumOtherDirect.getConsultants() != null) { cumulativeOtherDirect .setCumulativeConsultantServices(cumOtherDirect.getConsultants().bigDecimalValue()); } if (cumOtherDirect.getcomputer() != null) { cumulativeOtherDirect .setCumulativeADPComputerServices(cumOtherDirect.getcomputer().bigDecimalValue()); } if (cumOtherDirect.getsubAwards() != null) { cumulativeOtherDirect.setCumulativeSubawardConsortiumContractualCosts( cumOtherDirect.getsubAwards().bigDecimalValue()); } if (cumOtherDirect.getEquipRental() != null) { cumulativeOtherDirect.setCumulativeEquipmentFacilityRentalFees( cumOtherDirect.getEquipRental().bigDecimalValue()); } if (cumOtherDirect.getAlterations() != null) { cumulativeOtherDirect.setCumulativeAlterationsAndRenovations( cumOtherDirect.getAlterations().bigDecimalValue()); } if (cumOtherDirect.getOtherCosts() != null && cumOtherDirect.getOtherCosts().size() > 0) { cumulativeOtherDirect.setCumulativeOther1DirectCost( new BigDecimal(cumOtherDirect.getOtherCosts().get(0).get(CostConstants.KEY_COST))); } } } return cumulativeOtherDirect; } /** * This method gets KeyPersons details such as * Name,ProjectRole,Compensation,TotalFundForAttachedKeyPersons * TotalFundForKeyPersons and AttachedKeyPersons based on BudgetPeriodInfo * for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return KeyPersons details corresponding to the BudgetPeriodInfo object. */ private KeyPersons getKeyPersons(BudgetPeriodDto periodInfo) { KeyPersons keyPersons = KeyPersons.Factory.newInstance(); ScaleTwoDecimal extraFunds = ScaleTwoDecimal.ZERO; if (periodInfo != null) { KeyPersonDataType[] keyPersonDataTypeArray = null; if (periodInfo.getKeyPersons() != null) { keyPersonDataTypeArray = new KeyPersonDataType[periodInfo.getKeyPersons().size()]; } if (keyPersonDataTypeArray != null) { int keyPersonCount = 0; for (KeyPersonDto keyPerson : periodInfo.getKeyPersons()) { KeyPersonDataType keyPersonDataType = KeyPersonDataType.Factory.newInstance(); keyPersonDataType.setName(globLibV10Generator.getHumanNameDataType(keyPerson)); if (isSponsorNIH(pdDoc) && KEYPERSON_CO_PD_PI.equals(keyPerson.getRole())) { keyPersonDataType.setProjectRole(NID_PD_PI); } else { keyPersonDataType.setProjectRole(keyPerson.getRole()); } keyPersonDataType.setCompensation(getCompensation(keyPerson, periodInfo.getBudgetPeriod())); keyPersonDataTypeArray[keyPersonCount] = keyPersonDataType; keyPersonCount++; LOG.info("keyPersonCount:" + keyPersonCount); } keyPersons.setKeyPersonArray(keyPersonDataTypeArray); } if (periodInfo.getTotalFundsKeyPersons() != null) { keyPersons.setTotalFundForKeyPersons(periodInfo.getTotalFundsKeyPersons().bigDecimalValue()); } for (KeyPersonDto keyPerson : periodInfo.getExtraKeyPersons()) { extraFunds = extraFunds.add(keyPerson.getFundsRequested()); } TotalFundForAttachedKeyPersons totalFundForAttachedKeyPersons = TotalFundForAttachedKeyPersons.Factory .newInstance(); totalFundForAttachedKeyPersons.setTotalFundForAttachedKeyPersonsExist(YesNoDataType.YES); totalFundForAttachedKeyPersons.setBigDecimalValue(extraFunds.bigDecimalValue()); keyPersons.setTotalFundForAttachedKeyPersons(totalFundForAttachedKeyPersons); NarrativeContract narrative = saveExtraKeyPersons(periodInfo); if (narrative != null) { AttachedKeyPersons attachedKeyPersons = AttachedKeyPersons.Factory.newInstance(); FileLocation fileLocation = FileLocation.Factory.newInstance(); attachedKeyPersons.setFileLocation(fileLocation); String contentId = createContentId(narrative); fileLocation.setHref(contentId); attachedKeyPersons.setFileLocation(fileLocation); attachedKeyPersons.setFileName(narrative.getNarrativeAttachment().getName()); attachedKeyPersons.setMimeType(InfastructureConstants.CONTENT_TYPE_OCTET_STREAM); if (narrative.getNarrativeAttachment() != null) { attachedKeyPersons.setHashValue(getHashValue(narrative.getNarrativeAttachment().getData())); } AttachmentData attachmentData = new AttachmentData(); if (narrative.getNarrativeAttachment() != null) { attachmentData.setContent(narrative.getNarrativeAttachment().getData()); } attachmentData.setContentId(contentId); attachmentData.setContentType(InfastructureConstants.CONTENT_TYPE_OCTET_STREAM); attachmentData.setFileName(narrative.getNarrativeAttachment().getName()); addAttachment(attachmentData); attachedKeyPersons.setTotalFundForAttachedKeyPersonsExist(YesNoDataType.YES); keyPersons.setAttachedKeyPersons(attachedKeyPersons); } } return keyPersons; } /** * This method gets KeyPersonCompensationDataType informations such as * AcademicMonths,CalendarMonths,FringeBenefits * SummerMonths,RequestedSalary,FundsRequested and BaseSalary based on * KeyPersonInfo for the keyPerson. * * @param keyPerson * (KeyPersonInfo) key person entry. * @return KeyPersonCompensationDataType details corresponding to the * KeyPersonInfo object. */ private KeyPersonCompensationDataType getCompensation(KeyPersonDto keyPerson, int budgetPeriod) { KeyPersonCompensationDataType keyPersonCompensation = KeyPersonCompensationDataType.Factory.newInstance(); ScaleTwoDecimal baseSalaryByPeriod; if (keyPerson != null) { if (keyPerson.getAcademicMonths() != null) { keyPersonCompensation.setAcademicMonths(keyPerson.getAcademicMonths().bigDecimalValue()); } if (keyPerson.getCalendarMonths() != null) { keyPersonCompensation.setCalendarMonths(keyPerson.getCalendarMonths().bigDecimalValue()); } if (keyPerson.getFringe() != null) { keyPersonCompensation.setFringeBenefits(keyPerson.getFringe().bigDecimalValue()); } if (keyPerson.getSummerMonths() != null) { keyPersonCompensation.setSummerMonths(keyPerson.getSummerMonths().bigDecimalValue()); } if (keyPerson.getRequestedSalary() != null) { keyPersonCompensation.setRequestedSalary(keyPerson.getRequestedSalary().bigDecimalValue()); } if (keyPerson.getFundsRequested() != null) { keyPersonCompensation.setFundsRequested(keyPerson.getFundsRequested().bigDecimalValue()); } if (pdDoc.getDevelopmentProposal().getBudgets() != null) { baseSalaryByPeriod = s2sBudgetCalculatorService.getBaseSalaryByPeriod( pdDoc.getDevelopmentProposal().getBudgets().get(0).getBudgetId(), budgetPeriod, keyPerson); if (baseSalaryByPeriod != null && baseSalaryByPeriod.isGreaterThan(ScaleTwoDecimal.ZERO)) { keyPersonCompensation.setBaseSalary(baseSalaryByPeriod.bigDecimalValue()); } else { if (keyPerson.getBaseSalary() != null) { keyPersonCompensation.setBaseSalary(keyPerson.getBaseSalary().bigDecimalValue()); } } } else { if (keyPerson.getBaseSalary() != null) { keyPersonCompensation.setBaseSalary(keyPerson.getBaseSalary().bigDecimalValue()); } } } return keyPersonCompensation; } /** * This method gets SectBCompensationDataType details * AcademicMonths,CalendarMonths,FringeBenefits * FundsRequested,SummerMonths,and RequestedSalary based on KeyPersonInfo * for the OtherPersonnel. * * @param compensation * (CompensationInfo) compensation entry. * @return SectBCompensationDataType details corresponding to the * CompensationInfo object. */ private SectBCompensationDataType getSectBCompensationDataType(CompensationDto compensation) { SectBCompensationDataType sectBCompensation = SectBCompensationDataType.Factory.newInstance(); if (compensation != null) { if (compensation.getAcademicMonths() != null) { sectBCompensation.setAcademicMonths(compensation.getAcademicMonths().bigDecimalValue()); } if (compensation.getCalendarMonths() != null) { sectBCompensation.setCalendarMonths(compensation.getCalendarMonths().bigDecimalValue()); } if (compensation.getFringe() != null) { sectBCompensation.setFringeBenefits(compensation.getFringe().bigDecimalValue()); } if (compensation.getFundsRequested() != null) { sectBCompensation.setFundsRequested(compensation.getFundsRequested().bigDecimalValue()); } if (compensation.getSummerMonths() != null) { sectBCompensation.setSummerMonths(compensation.getSummerMonths().bigDecimalValue()); } if (compensation.getRequestedSalary() != null) { sectBCompensation.setRequestedSalary(compensation.getRequestedSalary().bigDecimalValue()); } } return sectBCompensation; } /** * This method gets OtherPersonnel informations like * PostDocAssociates,GraduateStudents,UndergraduateStudents * SecretarialClerical based on PersonnelType and also gets * NumberOfPersonnel, ProjectRole,Compensation OtherPersonnelTotalNumber and * TotalOtherPersonnelFund based on BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return OtherPersonnel details corresponding to the BudgetPeriodInfo * object. */ private OtherPersonnel getOtherPersonnel(BudgetPeriodDto periodInfo) { OtherPersonnel otherPersonnel = OtherPersonnel.Factory.newInstance(); int OtherpersonalCount = 0; List<OtherPersonnelDataType> otherPersonnelList = new ArrayList<>(); OtherPersonnelDataType otherPersonnelDataTypeArray[] = new OtherPersonnelDataType[1]; if (periodInfo != null) { for (OtherPersonnelDto otherPersonnelInfo : periodInfo.getOtherPersonnel()) { if (OTHERPERSONNEL_POSTDOC.equals(otherPersonnelInfo.getPersonnelType())) { otherPersonnel.setPostDocAssociates(getPostDocAssociates(otherPersonnelInfo)); } else if (OTHERPERSONNEL_GRADUATE.equals(otherPersonnelInfo.getPersonnelType())) { otherPersonnel.setGraduateStudents(getGraduateStudents(otherPersonnelInfo)); } else if (OTHERPERSONNEL_UNDERGRADUATE.equals(otherPersonnelInfo.getPersonnelType())) { otherPersonnel.setUndergraduateStudents(getUndergraduateStudents(otherPersonnelInfo)); } else if (OTHERPERSONNEL_SECRETARIAL.equals(otherPersonnelInfo.getPersonnelType())) { otherPersonnel.setSecretarialClerical(getSecretarialClerical(otherPersonnelInfo)); } else if (OtherpersonalCount < OTHERPERSONNEL_MAX_ALLOWED) {// Max // allowed // is 6 OtherPersonnelDataType otherPersonnelDataType = OtherPersonnelDataType.Factory.newInstance(); otherPersonnelDataType.setNumberOfPersonnel(otherPersonnelInfo.getNumberPersonnel()); otherPersonnelDataType.setProjectRole(otherPersonnelInfo.getRole()); otherPersonnelDataType .setCompensation(getSectBCompensationDataType(otherPersonnelInfo.getCompensation())); otherPersonnelList.add(otherPersonnelDataType); OtherpersonalCount++; } } otherPersonnelDataTypeArray = otherPersonnelList.toArray(otherPersonnelDataTypeArray); otherPersonnel.setOtherArray(otherPersonnelDataTypeArray); if (periodInfo.getOtherPersonnelTotalNumber() != null) { otherPersonnel.setOtherPersonnelTotalNumber(periodInfo.getOtherPersonnelTotalNumber().intValue()); } if (periodInfo.getTotalOtherPersonnelFunds() != null) { otherPersonnel .setTotalOtherPersonnelFund(periodInfo.getTotalOtherPersonnelFunds().bigDecimalValue()); } } return otherPersonnel; } /** * This method gets the PostDocAssociates details,ProjectRole, * NumberOfPersonnel,Compensation based on OtherPersonnelInfo for the * RRBudget,if it is a PostDocAssociates type. * * @param otherPersonnel * (OtherPersonnelInfo) other personnel entry. * @return PostDocAssociates details corresponding to the OtherPersonnelInfo * object. */ private PostDocAssociates getPostDocAssociates(OtherPersonnelDto otherPersonnel) { PostDocAssociates postDocAssociates = PostDocAssociates.Factory.newInstance(); if (otherPersonnel != null) { postDocAssociates.setNumberOfPersonnel(otherPersonnel.getNumberPersonnel()); postDocAssociates.setProjectRole(otherPersonnel.getRole()); postDocAssociates.setCompensation(getSectBCompensationDataType(otherPersonnel.getCompensation())); } return postDocAssociates; } /** * This method gets the GraduateStudents details,ProjectRole, * NumberOfPersonnel,Compensation based on OtherPersonnelInfo for the * RRBudget, if it is a GraduateStudents type. * * @param otherPersonnel * (OtherPersonnelInfo) other personnel entry. * @return GraduateStudents details corresponding to the OtherPersonnelInfo * object. */ private GraduateStudents getGraduateStudents(OtherPersonnelDto otherPersonnel) { GraduateStudents graduate = GraduateStudents.Factory.newInstance(); if (otherPersonnel != null) { graduate.setNumberOfPersonnel(otherPersonnel.getNumberPersonnel()); graduate.setProjectRole(otherPersonnel.getRole()); graduate.setCompensation(getSectBCompensationDataType(otherPersonnel.getCompensation())); } return graduate; } /** * This method is to get the UndergraduateStudents details,ProjectRole, * NumberOfPersonnel,Compensation based on OtherPersonnelInfo for the * RRBudget,if it is a UndergraduateStudents type. * * @param otherPersonnel * (OtherPersonnelInfo) other personnel entry. * @return UndergraduateStudents details corresponding to the * OtherPersonnelInfo object. */ private UndergraduateStudents getUndergraduateStudents(OtherPersonnelDto otherPersonnel) { UndergraduateStudents undergraduate = UndergraduateStudents.Factory.newInstance(); if (otherPersonnel != null) { undergraduate.setNumberOfPersonnel(otherPersonnel.getNumberPersonnel()); undergraduate.setProjectRole(otherPersonnel.getRole()); undergraduate.setCompensation(getSectBCompensationDataType(otherPersonnel.getCompensation())); } return undergraduate; } /** * This method is to get the SecretarialClerical details,ProjectRole, * NumberOfPersonnel,Compensation based on OtherPersonnelInfo for the * RRBudget,if it is a SecretarialClerical type. * * @param otherPersonnel * (OtherPersonnelInfo) other personnel entry. * @return SecretarialClerical corresponding to the OtherPersonnelInfo * object. */ private SecretarialClerical getSecretarialClerical(OtherPersonnelDto otherPersonnel) { SecretarialClerical secretarialClerical = SecretarialClerical.Factory.newInstance(); if (otherPersonnel != null) { secretarialClerical.setNumberOfPersonnel(otherPersonnel.getNumberPersonnel()); secretarialClerical.setProjectRole(otherPersonnel.getRole()); secretarialClerical.setCompensation(getSectBCompensationDataType(otherPersonnel.getCompensation())); } return secretarialClerical; } /** * This method gets Equipment details such as * EquipmentItem,FundsRequested,TotalFundForAttachedEquipment, TotalFund and * AdditionalEquipmentsAttachment based on BudgetPeriodInfo for the * RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return Equipment costs corresponding to the BudgetPeriodInfo object. */ private Equipment getEquipment(BudgetPeriodDto periodInfo) { Equipment equipment = Equipment.Factory.newInstance(); NarrativeContract extraEquipmentNarr = null; if (periodInfo != null && periodInfo.getEquipment() != null && periodInfo.getEquipment().size() > 0) { // Evaluating Equipments. List<EquipmentList> equipmentArrayList = new ArrayList<>(); ScaleTwoDecimal totalFund = ScaleTwoDecimal.ZERO; for (CostDto costInfo : periodInfo.getEquipment().get(0).getEquipmentList()) { EquipmentList equipmentList = EquipmentList.Factory.newInstance(); equipmentList.setEquipmentItem(costInfo.getDescription()); if (costInfo.getCost() != null) { equipmentList.setFundsRequested(costInfo.getCost().bigDecimalValue()); } totalFund = totalFund.add(costInfo.getCost()); equipmentArrayList.add(equipmentList); } // Evaluating Extra Equipments. List<CostDto> extraEquipmentArrayList = new ArrayList<>(); ScaleTwoDecimal totalExtraEquipFund = ScaleTwoDecimal.ZERO; for (CostDto costInfo : periodInfo.getEquipment().get(0).getExtraEquipmentList()) { extraEquipmentArrayList.add(costInfo); totalExtraEquipFund = totalExtraEquipFund.add(costInfo.getCost()); } EquipmentList[] equipmentArray = new EquipmentList[0]; equipmentArray = equipmentArrayList.toArray(equipmentArray); equipment.setEquipmentListArray(equipmentArray); TotalFundForAttachedEquipment totalFundForAttachedEquipment = TotalFundForAttachedEquipment.Factory .newInstance(); totalFundForAttachedEquipment.setTotalFundForAttachedEquipmentExist(YesNoDataType.YES); totalFundForAttachedEquipment .setBigDecimalValue(periodInfo.getEquipment().get(0).getTotalExtraFund().bigDecimalValue()); totalFund = totalFund.add(totalExtraEquipFund); equipment.setTotalFundForAttachedEquipment(totalFundForAttachedEquipment); equipment.setTotalFund(totalFund.bigDecimalValue()); extraEquipmentNarr = saveAdditionalEquipments(periodInfo, extraEquipmentArrayList); } if (extraEquipmentNarr != null) { AdditionalEquipmentsAttachment equipmentAttachment = AdditionalEquipmentsAttachment.Factory .newInstance(); FileLocation fileLocation = FileLocation.Factory.newInstance(); equipmentAttachment.setFileLocation(fileLocation); String contentId = createContentId(extraEquipmentNarr); fileLocation.setHref(contentId); equipmentAttachment.setFileLocation(fileLocation); equipmentAttachment.setFileName(extraEquipmentNarr.getNarrativeAttachment().getName()); equipmentAttachment.setMimeType(InfastructureConstants.CONTENT_TYPE_OCTET_STREAM); equipmentAttachment.setHashValue(getHashValue(extraEquipmentNarr.getNarrativeAttachment().getData())); AttachmentData attachmentData = new AttachmentData(); attachmentData.setContent(extraEquipmentNarr.getNarrativeAttachment().getData()); attachmentData.setContentId(contentId); attachmentData.setContentType(InfastructureConstants.CONTENT_TYPE_OCTET_STREAM); attachmentData.setFileName(extraEquipmentNarr.getNarrativeAttachment().getName()); addAttachment(attachmentData); equipmentAttachment.setTotalFundForAttachedEquipmentExist(YesNoDataType.YES); equipment.setAdditionalEquipmentsAttachment(equipmentAttachment); } return equipment; } /** * This method gets Travel cost information including * DomesticTravelCost,ForeignTravelCost and TotalTravelCost in the * BudgetYearDataType based on BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return Travel travel cost corresponding to the BudgetPeriodInfo object. */ private Travel getTravel(BudgetPeriodDto periodInfo) { Travel travel = Travel.Factory.newInstance(); if (periodInfo != null) { if (periodInfo.getDomesticTravelCost() != null) { travel.setDomesticTravelCost(periodInfo.getDomesticTravelCost().bigDecimalValue()); } if (periodInfo.getForeignTravelCost() != null) { travel.setForeignTravelCost(periodInfo.getForeignTravelCost().bigDecimalValue()); } if (periodInfo.getTotalTravelCost() != null) { travel.setTotalTravelCost(periodInfo.getTotalTravelCost().bigDecimalValue()); } } return travel; } /** * This method gets ParticipantTraineeSupportCosts details in * BudgetYearDataType such as TuitionFeeHealthInsurance * Stipends,Subsistence,Travel,Other,ParticipantTraineeNumber and TotalCost * based on the BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return ParticipantTraineeSupportCosts corresponding to the * BudgetPeriodInfo object. */ private ParticipantTraineeSupportCosts getParticipantTraineeSupportCosts(BudgetPeriodDto periodInfo) { ParticipantTraineeSupportCosts traineeSupportCosts = ParticipantTraineeSupportCosts.Factory.newInstance(); if (periodInfo != null) { traineeSupportCosts.setTuitionFeeHealthInsurance(periodInfo.getPartTuition().bigDecimalValue()); traineeSupportCosts.setStipends(periodInfo.getpartStipendCost().bigDecimalValue()); traineeSupportCosts.setTravel(periodInfo.getpartTravelCost().bigDecimalValue()); traineeSupportCosts.setSubsistence(periodInfo.getPartSubsistence().bigDecimalValue()); traineeSupportCosts.setOther(getOtherPTSupportCosts(periodInfo)); traineeSupportCosts.setParticipantTraineeNumber(periodInfo.getparticipantCount()); traineeSupportCosts.setTotalCost(traineeSupportCosts.getTuitionFeeHealthInsurance() .add(traineeSupportCosts.getStipends().add(traineeSupportCosts.getTravel().add( traineeSupportCosts.getSubsistence().add(traineeSupportCosts.getOther().getCost()))))); } return traineeSupportCosts; } /** * This method gets Other type description and total cost for * ParticipantTraineeSupportCosts based on BudgetPeriodInfo. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return Other other participant trainee support costs corresponding to * the BudgetPeriodInfo object. */ private Other getOtherPTSupportCosts(BudgetPeriodDto periodInfo) { Other other = Other.Factory.newInstance(); other.setDescription(OTHERCOST_DESCRIPTION); ScaleTwoDecimal otherCost = ScaleTwoDecimal.ZERO; if (periodInfo != null && periodInfo.getpartOtherCost() != null) { otherCost = periodInfo.getpartOtherCost(); } other.setCost(otherCost.bigDecimalValue()); return other; } /** * This method gets OtherDirectCosts details such as * PublicationCosts,MaterialsSupplies,ConsultantServices, * ADPComputerServices,SubawardConsortiumContractualCosts,EquipmentRentalFee,AlterationsRenovations * and TotalOtherDirectCost in BudgetYearDataType based on BudgetPeriodInfo * for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return OtherDirectCosts corresponding to the BudgetPeriodInfo object. */ private OtherDirectCosts getOtherDirectCosts(BudgetPeriodDto periodInfo) { OtherDirectCosts otherDirectCosts = OtherDirectCosts.Factory.newInstance(); if (periodInfo != null && periodInfo.getOtherDirectCosts() != null && periodInfo.getOtherDirectCosts().size() > 0) { if (periodInfo.getOtherDirectCosts().get(0).getpublications() != null) { otherDirectCosts.setPublicationCosts( periodInfo.getOtherDirectCosts().get(0).getpublications().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getmaterials() != null) { otherDirectCosts.setMaterialsSupplies( periodInfo.getOtherDirectCosts().get(0).getmaterials().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getConsultants() != null) { otherDirectCosts.setConsultantServices( periodInfo.getOtherDirectCosts().get(0).getConsultants().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getcomputer() != null) { otherDirectCosts.setADPComputerServices( periodInfo.getOtherDirectCosts().get(0).getcomputer().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getsubAwards() != null) { otherDirectCosts.setSubawardConsortiumContractualCosts( periodInfo.getOtherDirectCosts().get(0).getsubAwards().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getEquipRental() != null) { otherDirectCosts.setEquipmentRentalFee( periodInfo.getOtherDirectCosts().get(0).getEquipRental().bigDecimalValue()); } if (periodInfo.getOtherDirectCosts().get(0).getAlterations() != null) { otherDirectCosts.setAlterationsRenovations( periodInfo.getOtherDirectCosts().get(0).getAlterations().bigDecimalValue()); } otherDirectCosts.setOthers(getOthersForOtherDirectCosts(periodInfo)); if (periodInfo.getOtherDirectCosts().get(0).gettotalOtherDirect() != null) { otherDirectCosts.setTotalOtherDirectCost( periodInfo.getOtherDirectCosts().get(0).gettotalOtherDirect().bigDecimalValue()); } } return otherDirectCosts; } /** * This method is to get Other type description and total cost * OtherDirectCosts details in BudgetYearDataType based on BudgetPeriodInfo * for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return Other others for other direct costs corresponding to the * BudgetPeriodInfo object. */ private Others getOthersForOtherDirectCosts(BudgetPeriodDto periodInfo) { Others others = Others.Factory.newInstance(); if (periodInfo != null) { Others.Other otherArray[] = new Others.Other[periodInfo.getOtherDirectCosts().size()]; int Otherscount = 0; for (OtherDirectCostInfoDto otherDirectCostInfo : periodInfo.getOtherDirectCosts()) { Others.Other other = Others.Other.Factory.newInstance(); if (otherDirectCostInfo.getOtherCosts() != null && otherDirectCostInfo.getOtherCosts().size() > 0) { other.setCost( new BigDecimal(otherDirectCostInfo.getOtherCosts().get(0).get(CostConstants.KEY_COST))); } other.setDescription(OTHERCOST_DESCRIPTION); otherArray[Otherscount] = other; Otherscount++; } others.setOtherArray(otherArray); } return others; } /** * This method returns IndirectCosts details such as * Base,CostType,FundRequested,Rate and TotalIndirectCosts in * BudgetYearDataType based on BudgetPeriodInfo for the RRBudget. * * @param periodInfo * (BudgetPeriodInfo) budget period entry. * @return IndirectCosts corresponding to the BudgetPeriodInfo object. */ private IndirectCosts getIndirectCosts(BudgetPeriodDto periodInfo) { IndirectCosts indirectCosts = null; if (periodInfo != null) { List<IndirectCosts.IndirectCost> indirectCostList = new ArrayList<>(); int IndirectCostCount = 0; for (IndirectCostDetailsDto indirectCostDetails : periodInfo.getIndirectCosts() .getIndirectCostDetails()) { IndirectCosts.IndirectCost indirectCost = IndirectCosts.IndirectCost.Factory.newInstance(); indirectCost.setBase(indirectCostDetails.getBase().bigDecimalValue()); indirectCost.setCostType(indirectCostDetails.getCostType()); indirectCost.setFundRequested(indirectCostDetails.getFunds().bigDecimalValue()); indirectCost.setRate(indirectCostDetails.getRate().bigDecimalValue()); indirectCostList.add(indirectCost); IndirectCostCount++; if (IndirectCostCount == ARRAY_LIMIT_IN_SCHEMA) { LOG.warn( "Stopping iteration over indirect cost details because array limit in schema is only 4"); break; } } if (IndirectCostCount > 0) { indirectCosts = IndirectCosts.Factory.newInstance(); IndirectCosts.IndirectCost indirectCostArray[] = new IndirectCosts.IndirectCost[0]; indirectCosts.setIndirectCostArray(indirectCostList.toArray(indirectCostArray)); indirectCosts.setTotalIndirectCosts( periodInfo.getIndirectCosts().getTotalIndirectCosts().bigDecimalValue()); } } return indirectCosts; } /** * This method creates {@link XmlObject} of type {@link RRBudgetDocument} by * populating data from the given {@link ProposalDevelopmentDocumentContract} * * @param proposalDevelopmentDocument * for which the {@link XmlObject} needs to be created * @return {@link XmlObject} which is generated using the given * {@link ProposalDevelopmentDocumentContract} */ @Override public RRBudgetDocument getFormObject(ProposalDevelopmentDocumentContract proposalDevelopmentDocument) { this.pdDoc = proposalDevelopmentDocument; return getRRBudget(); } @Override public String getNamespace() { return namespace; } public void setNamespace(String namespace) { this.namespace = namespace; } @Override public String getFormName() { return formName; } public void setFormName(String formName) { this.formName = formName; } @Override public Resource getStylesheet() { return stylesheet; } public void setStylesheet(Resource stylesheet) { this.stylesheet = stylesheet; } @Override public String getPackageName() { return packageName; } public void setPackageName(String packageName) { this.packageName = packageName; } @Override public int getSortIndex() { return sortIndex; } public void setSortIndex(int sortIndex) { this.sortIndex = sortIndex; } }