Example usage for org.apache.commons.lang3.time DateUtils toCalendar

List of usage examples for org.apache.commons.lang3.time DateUtils toCalendar

Introduction

In this page you can find the example usage for org.apache.commons.lang3.time DateUtils toCalendar.

Prototype

public static Calendar toCalendar(final Date date) 

Source Link

Document

Converts a Date into a Calendar .

Usage

From source file:gov.nih.nci.firebird.service.periodic.DailyJobServiceBean.java

@Inject
void setInitialExpiration(@Named("daily.job.runtime") String startTimeExpression) throws ParseException {
    Calendar startTime = DateUtils.toCalendar(DateUtils.parseDate(startTimeExpression, "H:mm"));
    initialExpiration = new Date();
    initialExpiration = DateUtils.setHours(initialExpiration, startTime.get(Calendar.HOUR_OF_DAY));
    initialExpiration = DateUtils.setMinutes(initialExpiration, startTime.get(Calendar.MINUTE));
    initialExpiration = DateUtils.setSeconds(initialExpiration, 0);
    initialExpiration = DateUtils.setMilliseconds(initialExpiration, 0);
    if (initialExpiration.before(new Date())) {
        initialExpiration = DateUtils.addDays(initialExpiration, 1);
    }/*from   www.  ja v  a 2s .  c  o  m*/
}

From source file:cn.mypandora.util.MyDateUtils.java

/**
 * ???X//from w w w . j  a v a 2 s.  co  m
 *
 * @param specifiedTime ,?yyyy-MM-dd HH:mm:ss
 * @param offset        ??
 * @return
 * @throws ParseException
 */
public static String getSpecifiedOffsetTime(String specifiedTime, int offset) throws ParseException {
    Date date = DateUtils.parseDate(specifiedTime, TIME_FORMAT);
    Calendar cal = DateUtils.toCalendar(date);
    cal.add(Calendar.DAY_OF_MONTH, offset);
    String returnDate = DateFormatUtils.format(cal, TIME_FORMAT);
    return returnDate;
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.chartfactory.impl.PartyChartDataManagerImpl.java

@Override
public void createPartyAgeChart(final AbstractOrderedLayout content) {
    createPartyBallotChart(content,//from   w w  w .  j a  v  a 2s.  co  m
            viewRiksdagenVoteDataBallotPartySummaryDaily -> (DateUtils
                    .toCalendar(viewRiksdagenVoteDataBallotPartySummaryDaily.getEmbeddedId().getVoteDate())
                    .get(Calendar.YEAR))
                    - viewRiksdagenVoteDataBallotPartySummaryDaily.getPartyAvgBornYear().intValue());
}

From source file:com.inkubator.hrm.service.impl.LogWtAttendanceRealizationServiceImpl.java

@Override
@Transactional(readOnly = false, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void afterMonthEndProcess() throws Exception {

    /** update payrollType status di periode yg lama menjadi VOID */
    WtPeriode wtPeriode = wtPeriodeDao.getEntityByAbsentTypeActive();
    wtPeriode.setAbsen(HRMConstant.PERIODE_ABSEN_VOID);
    wtPeriode.setUpdatedOn(new Date());
    wtPeriode.setUpdatedBy(HRMConstant.SYSTEM_ADMIN);
    wtPeriodeDao.update(wtPeriode);// w w w.  j a  v  a 2s. c  om

    /** dapatkan range (untilPeriode dan fromPeriode) untuk periode yg baru */
    Date untilPeriode = wtPeriode.getUntilPeriode();
    Date fromPeriode = DateUtils.addDays(untilPeriode, 1);
    int lastDateOfMonth = DateUtils.toCalendar(untilPeriode).getActualMaximum(Calendar.DAY_OF_MONTH);
    if (lastDateOfMonth == DateUtils.toCalendar(untilPeriode).get(Calendar.DATE)) {
        untilPeriode = DateUtils.addMonths(untilPeriode, 1);
        lastDateOfMonth = DateUtils.toCalendar(untilPeriode).getActualMaximum(Calendar.DAY_OF_MONTH);
        untilPeriode = DateUtils.setDays(untilPeriode, lastDateOfMonth);
    } else {
        untilPeriode = DateUtils.addMonths(untilPeriode, 1);
    }

    /** adding process or update the entity if already exist */
    WtPeriode wtp = wtPeriodeDao.getEntityByFromPeriodeAndUntilPeriode(fromPeriode, untilPeriode);
    if (wtp == null) {
        wtp = new WtPeriode();
        wtp.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(9)));
        wtp.setTahun(String.valueOf(DateUtils.toCalendar(fromPeriode).get(Calendar.YEAR)));
        wtp.setBulan(DateUtils.toCalendar(fromPeriode).get(Calendar.MONTH) + 1);
        wtp.setFromPeriode(fromPeriode);
        wtp.setUntilPeriode(untilPeriode);
        wtp.setAbsen(HRMConstant.PERIODE_ABSEN_ACTIVE);
        wtp.setPayrollType(HRMConstant.PERIODE_PAYROLL_NOT_ACTIVE);
        long totalHoliday = wtHolidayDao.getTotalBetweenDate(fromPeriode, untilPeriode);
        int workingDays = DateTimeUtil.getTotalWorkingDay(fromPeriode, untilPeriode, (int) totalHoliday, 0);
        wtp.setWorkingDays(workingDays);
        wtp.setCreatedOn(new Date());
        wtp.setCreatedBy(HRMConstant.SYSTEM_ADMIN);
        wtPeriodeDao.save(wtp);
    } else {
        wtp.setAbsen(HRMConstant.PERIODE_ABSEN_ACTIVE);
        wtp.setUpdatedOn(new Date());
        wtp.setUpdatedBy(HRMConstant.SYSTEM_ADMIN);
        wtPeriodeDao.update(wtp);
    }

    /** delete all the record in the temporary table **/
    tempProcessReadFingerDao.deleteAllData();
    tempAttendanceRealizationDao.deleteAllData();
}

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

private PHS398TrainingBudget getPHS398TrainingBudget(
        ProposalDevelopmentDocumentContract proposalDevelopmentDocument) throws S2SException {
    DevelopmentProposalContract developmentProposal = proposalDevelopmentDocument.getDevelopmentProposal();
    ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService.getBudget(developmentProposal);

    PHS398TrainingBudget trainingBudgetType = PHS398TrainingBudget.Factory.newInstance();
    if (budget != null) {
        trainingBudgetType.setFormVersion(FormVersion.v1_0.getVersion());
        trainingBudgetType.setBudgetType(BudgetType.PROJECT);
        setOrganizationData(trainingBudgetType, developmentProposal);
    } else {//  ww  w . j ava 2s .c  om
        return trainingBudgetType;
    }

    int numPeople = 0;

    BigDecimal stipendAmountOtherFull = new BigDecimal("0"), stipendAmountOtherShort = new BigDecimal("0");
    BigDecimal stipendAmountF = new BigDecimal("0"), stipendAmountJ = new BigDecimal("0");
    BigDecimal stipendAmountPreSingFull = new BigDecimal("0"), stipendAmountPreDualFull = new BigDecimal("0");
    BigDecimal stipendAmountPreSingShort = new BigDecimal("0"), stipendAmountPreDualShort = new BigDecimal("0");
    BigDecimal stipendAmount0 = new BigDecimal("0"), stipendAmount1 = new BigDecimal("0"),
            stipendAmount2 = new BigDecimal("0"), stipendAmount3 = new BigDecimal("0"),
            stipendAmount4 = new BigDecimal("0");
    BigDecimal stipendAmount5 = new BigDecimal("0"), stipendAmount6 = new BigDecimal("0"),
            stipendAmount7 = new BigDecimal("0");
    BigDecimal stipendAmountDeg0 = new BigDecimal("0"), stipendAmountDeg1 = new BigDecimal("0"),
            stipendAmountDeg2 = new BigDecimal("0"), stipendAmountDeg3 = new BigDecimal("0"),
            stipendAmountDeg4 = new BigDecimal("0");
    BigDecimal stipendAmountDeg5 = new BigDecimal("0"), stipendAmountDeg6 = new BigDecimal("0"),
            stipendAmountDeg7 = new BigDecimal("0");
    BigDecimal stipendAmountNonDeg0 = new BigDecimal("0"), stipendAmountNonDeg1 = new BigDecimal("0"),
            stipendAmountNonDeg2 = new BigDecimal("0"), stipendAmountNonDeg3 = new BigDecimal("0"),
            stipendAmountNonDeg4 = new BigDecimal("0");
    BigDecimal stipendAmountNonDeg5 = new BigDecimal("0"), stipendAmountNonDeg6 = new BigDecimal("0"),
            stipendAmountNonDeg7 = new BigDecimal("0");

    /***** cumulative stipends **/
    BigDecimal cumUndergradStipends = new BigDecimal("0"), cumPreDocSingleStipends = new BigDecimal("0"),
            cumPreDocDualStipends = new BigDecimal("0"), cumPreDocTotalStipends = new BigDecimal("0");
    BigDecimal cumPostDocNonDegStipends = new BigDecimal("0"), cumPostDocDegStipends = new BigDecimal("0"),
            cumPostDocTotalStipends = new BigDecimal("0");
    BigDecimal cumOtherStipends = new BigDecimal("0");

    /***** cumulative tuition **/
    BigDecimal cumUndergradTuition = new BigDecimal("0"), cumPreDocSingleTuition = new BigDecimal("0"),
            cumPreDocDualTuition = new BigDecimal("0"), cumPreDocTotalTuition = new BigDecimal("0");
    BigDecimal cumPostDocNonDegTuition = new BigDecimal("0"), cumPostDocDegTuition = new BigDecimal("0"),
            cumPostDocTotalTuition = new BigDecimal("0");
    BigDecimal cumOtherTuition = new BigDecimal("0");

    /********** cumulative costs **/
    BigDecimal cumTrainingCosts = new BigDecimal("0"), cumTravelCosts = new BigDecimal("0"),
            cumConsCosts = new BigDecimal("0");
    BigDecimal cumResearchTotalDirectCosts = new BigDecimal("0"),
            cumTotalOtherDirectCosts = new BigDecimal("0"), cumTotalDirectCosts = new BigDecimal("0");
    BigDecimal cumTotalIndCosts1 = new BigDecimal("0"), cumTotalIndCosts2 = new BigDecimal("0"),
            cumTotalIndCosts = new BigDecimal("0");
    BigDecimal cumTotalDirectAndIndCosts = new BigDecimal("0");

    BigDecimal researchDirectCosts = new BigDecimal("0");
    BigDecimal totalOtherDirectCostsRequested = new BigDecimal("0");
    /********************************
     * get budget periods
     *********************************/
    List<? extends BudgetPeriodContract> budgetPeriods = budget.getBudgetPeriods();
    for (BudgetPeriodContract budgetPeriod : budgetPeriods) {
        PHS398TrainingBudgetYearDataType phs398TrainingBudgetYearDataType = trainingBudgetType
                .addNewBudgetYear();
        ScaleTwoDecimal trainingTraveCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.TRAINEE_TRAVEL_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType.setTraineeTravelRequested(trainingTraveCost.bigDecimalValue());
        ScaleTwoDecimal trainingCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.TRAINING_REL_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType.setTrainingRelatedExpensesRequested(trainingCost.bigDecimalValue());
        ScaleTwoDecimal consTrainingCost = getBudgetPeriodCost(budgetPeriod,
                ConfigurationConstants.SUBCONTRACT_COST_ELEMENTS);
        phs398TrainingBudgetYearDataType
                .setConsortiumTrainingCostsRequested(consTrainingCost.bigDecimalValue());

        phs398TrainingBudgetYearDataType.setPostdocNonDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_POSTDOC_NONDEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setPostdocDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_POSTDOC_DEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setUndergraduateTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_UNDERGRAD_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType.setPredocDualDegreeTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_PREDOC_DUAL_DEG_COST_ELEMENTS)
                        .bigDecimalValue());
        phs398TrainingBudgetYearDataType
                .setPredocSingleDegreeTuitionAndFeesRequested(getBudgetPeriodCost(budgetPeriod,
                        ConfigurationConstants.TUITION_PREDOC_SINGLE_DEG_COST_ELEMENTS).bigDecimalValue());
        phs398TrainingBudgetYearDataType.setOtherTuitionAndFeesRequested(
                getBudgetPeriodCost(budgetPeriod, ConfigurationConstants.TUITION_OTHER_COST_ELEMENTS)
                        .bigDecimalValue());

        phs398TrainingBudgetYearDataType.setPeriodEndDate(DateUtils.toCalendar(budgetPeriod.getEndDate()));
        phs398TrainingBudgetYearDataType.setPeriodStartDate(DateUtils.toCalendar(budgetPeriod.getStartDate()));

        /******************************
         * add to cumulative amounts for tuition and costs
         ******************************/
        cumUndergradTuition = cumUndergradTuition
                .add(phs398TrainingBudgetYearDataType.getUndergraduateTuitionAndFeesRequested());
        cumPreDocSingleTuition = cumPreDocSingleTuition
                .add(phs398TrainingBudgetYearDataType.getPredocSingleDegreeTuitionAndFeesRequested());
        cumPreDocDualTuition = cumPreDocDualTuition
                .add(phs398TrainingBudgetYearDataType.getPredocDualDegreeTuitionAndFeesRequested());

        cumPostDocNonDegTuition = cumPostDocNonDegTuition
                .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeTuitionAndFeesRequested());
        cumPostDocDegTuition = cumPostDocDegTuition
                .add(phs398TrainingBudgetYearDataType.getPostdocDegreeTuitionAndFeesRequested());
        cumPostDocTotalTuition = cumPostDocNonDegTuition.add(cumPostDocDegTuition);
        cumOtherTuition = cumOtherTuition
                .add(phs398TrainingBudgetYearDataType.getOtherTuitionAndFeesRequested());
        cumTrainingCosts = cumTrainingCosts
                .add(phs398TrainingBudgetYearDataType.getTrainingRelatedExpensesRequested());
        cumTravelCosts = cumTravelCosts.add(phs398TrainingBudgetYearDataType.getTraineeTravelRequested());
        cumConsCosts = cumConsCosts.add(phs398TrainingBudgetYearDataType.getConsortiumTrainingCostsRequested());

        /************************
         * getting first two indirect cost type
         ************************/

        IndirectCostDto indirectCostInfo = s2sBudgetCalculatorService.getIndirectCosts(budget, budgetPeriod);
        List<IndirectCostDetailsDto> cvIndirectCost = indirectCostInfo.getIndirectCostDetails();
        BigDecimal totIndCosts = new BigDecimal("0");
        for (int i = 0; i < cvIndirectCost.size() & i < CV_INDIRECT_COST_LIMIT; i++) {
            IndirectCostDetailsDto indireCost = cvIndirectCost.get(i);
            totIndCosts = totIndCosts.add(indireCost.getFunds().bigDecimalValue());
            switch (i) {
            case (0):
                phs398TrainingBudgetYearDataType.setIndirectCostType1(indireCost.getCostType());
                phs398TrainingBudgetYearDataType.setIndirectCostBase1(indireCost.getBase().bigDecimalValue());
                phs398TrainingBudgetYearDataType
                        .setIndirectCostFundsRequested1(indireCost.getFunds().bigDecimalValue());
                phs398TrainingBudgetYearDataType.setIndirectCostRate1(indireCost.getRate().bigDecimalValue());
                cumTotalIndCosts1 = cumTotalIndCosts1
                        .add(phs398TrainingBudgetYearDataType.getIndirectCostFundsRequested1());
                break;
            case (1):
                phs398TrainingBudgetYearDataType.setIndirectCostType1(indireCost.getCostType());
                phs398TrainingBudgetYearDataType.setIndirectCostBase2(indireCost.getBase().bigDecimalValue());
                phs398TrainingBudgetYearDataType
                        .setIndirectCostFundsRequested2(indireCost.getFunds().bigDecimalValue());
                phs398TrainingBudgetYearDataType.setIndirectCostRate2(indireCost.getRate().bigDecimalValue());
                cumTotalIndCosts2 = cumTotalIndCosts2
                        .add(phs398TrainingBudgetYearDataType.getIndirectCostFundsRequested2());
                break;
            default:
                break;
            }

        }
        phs398TrainingBudgetYearDataType.setTotalIndirectCostsRequested(totIndCosts);

        int numPostDocLevel0, numPostDocLevel1, numPostDocLevel2, numPostDocLevel3, numPostDocLevel4 = 0;
        int numPostDocLevel5, numPostDocLevel6, numPostDocLevel7 = 0;

        Map<String, String> hmNonDegree = new HashMap<>();
        Map<String, String> hmDegree = new HashMap<>();

        hmNonDegree.put("fulllevel0", "0");
        hmNonDegree.put("fulllevel1", "0");
        hmNonDegree.put("fulllevel2", "0");
        hmNonDegree.put("fulllevel3", "0");
        hmNonDegree.put("fulllevel4", "0");
        hmNonDegree.put("fulllevel5", "0");
        hmNonDegree.put("fulllevel6", "0");
        hmNonDegree.put("fulllevel7", "0");
        hmNonDegree.put("shortlevel0", "0");
        hmNonDegree.put("shortlevel1", "0");
        hmNonDegree.put("shortlevel2", "0");
        hmNonDegree.put("shortlevel3", "0");
        hmNonDegree.put("shortlevel4", "0");
        hmNonDegree.put("shortlevel5", "0");
        hmNonDegree.put("shortlevel6", "0");
        hmNonDegree.put("shortlevel7", "0");

        /********************************************************
         * get questionnaire answers for undergrads and predocs and others
         ********************************************************/

        String answer = null;
        int preDocCountFull = 0, preDocCountShort = 0;
        int undergradFirstYearNum = 0, undergradJrNum = 0;
        BigDecimal otherShortStipends = new BigDecimal("0"), otherFullStipends = new BigDecimal("0");
        List<? extends AnswerHeaderContract> answerHeaders = findQuestionnaireWithAnswers(developmentProposal);
        if (answerHeaders != null) {
            for (AnswerHeaderContract answerHeader : answerHeaders) {
                QuestionnaireContract questionnaire = getQuestionAnswerService()
                        .findQuestionnaireById(answerHeader.getQuestionnaireId());
                List<? extends QuestionnaireQuestionContract> questionnaireQuestions = questionnaire
                        .getQuestionnaireQuestions();
                for (QuestionnaireQuestionContract questionnaireQuestion : questionnaireQuestions) {
                    AnswerContract answerBO = getAnswer(questionnaireQuestion, answerHeader);
                    answer = answerBO.getAnswer();
                    QuestionContract question = questionnaireQuestion.getQuestion();
                    if (answer != null) {
                        int answerIntVal = 0;
                        try {
                            answerIntVal = Integer.parseInt(answer);
                        } catch (NumberFormatException ex) {
                        }
                        if (isPreDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod)) {
                            switch (question.getQuestionSeqId()) {
                            case 72:
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setUndergraduateNumFullTime(answerIntVal);
                                break;
                            case 73:
                                // short term undergrad
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setUndergraduateNumShortTerm(answerIntVal);
                                break;
                            case 74:
                                // stipends first year
                                if (answer != null)
                                    undergradFirstYearNum = undergradFirstYearNum + answerIntVal;

                                break;
                            case 75:
                                // stipends junior
                                if (answer != null)
                                    undergradJrNum = undergradJrNum + answerIntVal;

                                break;
                            case 77:
                                // full time single degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocSingleDegreeNumFullTime(answerIntVal);
                                    preDocCountFull = preDocCountFull + phs398TrainingBudgetYearDataType
                                            .getPredocSingleDegreeNumFullTime();
                                }
                                break;
                            case 78:
                                // short term single degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocSingleDegreeNumShortTerm(answerIntVal);
                                    preDocCountShort = preDocCountShort + phs398TrainingBudgetYearDataType
                                            .getPredocSingleDegreeNumShortTerm();
                                }
                                break;
                            case 79:
                                // full term dual degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocDualDegreeNumFullTime(answerIntVal);
                                    preDocCountFull = preDocCountFull
                                            + phs398TrainingBudgetYearDataType.getPredocDualDegreeNumFullTime();
                                }
                                break;
                            case 80:
                                // short term dual degree predoc
                                if (answer != null) {
                                    phs398TrainingBudgetYearDataType
                                            .setPredocDualDegreeNumShortTerm(answerIntVal);
                                    preDocCountShort = preDocCountShort + phs398TrainingBudgetYearDataType
                                            .getPredocDualDegreeNumShortTerm();
                                }
                                break;
                            case 95:
                                // others full term
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setOtherNumFullTime(answerIntVal);
                                break;
                            case 97:
                                // others short term
                                if (answer != null)
                                    phs398TrainingBudgetYearDataType.setOtherNumShortTerm(answerIntVal);
                                break;
                            case 96:
                                // others full term stipend
                                if (answer != null)
                                    otherFullStipends = new BigDecimal(answer);
                                break;
                            case 98:
                                // others short term stipend
                                if (answer != null)
                                    otherShortStipends = new BigDecimal(answer);
                                break;
                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                FN_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmNonDegree.put("fulllevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmNonDegree.put("fulllevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmNonDegree.put("fulllevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmNonDegree.put("fulllevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmNonDegree.put("fulllevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmNonDegree.put("fulllevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmNonDegree.put("fulllevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmNonDegree.put("fulllevel7", answer);
                                break;
                            default:
                                break;
                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                SN_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmNonDegree.put("shortlevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmNonDegree.put("shortlevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmNonDegree.put("shortlevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmNonDegree.put("shortlevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmNonDegree.put("shortlevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmNonDegree.put("shortlevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmNonDegree.put("shortlevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmNonDegree.put("shortlevel7", answer);
                                break;
                            default:
                                break;

                            }
                        }
                    }
                }
            }
        }
        phs398TrainingBudgetYearDataType.setUndergraduateNumFirstYearSophomoreStipends(undergradFirstYearNum);
        phs398TrainingBudgetYearDataType.setUndergraduateNumJuniorSeniorStipends(undergradJrNum);
        phs398TrainingBudgetYearDataType.setOtherStipendsRequested(otherShortStipends.add(otherFullStipends));
        phs398TrainingBudgetYearDataType.setPredocTotalNumShortTerm(preDocCountShort);
        phs398TrainingBudgetYearDataType.setPredocTotalNumFullTime(preDocCountFull);
        cumOtherStipends = cumOtherStipends.add(phs398TrainingBudgetYearDataType.getOtherStipendsRequested());

        /***********************************************************
         * set post doc non degree full time total number
         ***********************************************************/

        int postDocNumNonDegreeFullTime = Integer.parseInt(hmNonDegree.get("fulllevel0"))
                + Integer.parseInt(hmNonDegree.get("fulllevel1"))
                + Integer.parseInt(hmNonDegree.get("fulllevel2"))
                + Integer.parseInt(hmNonDegree.get("fulllevel3"))
                + Integer.parseInt(hmNonDegree.get("fulllevel4"))
                + Integer.parseInt(hmNonDegree.get("fulllevel5"))
                + Integer.parseInt(hmNonDegree.get("fulllevel6"))
                + Integer.parseInt(hmNonDegree.get("fulllevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumNonDegreeFullTime(postDocNumNonDegreeFullTime);

        /***********************************************************
         * set post doc non degree short term total number
         ***********************************************************/

        int postDocNumNonDegreeShortTerm = Integer.parseInt(hmNonDegree.get("shortlevel0"))
                + Integer.parseInt(hmNonDegree.get("shortlevel1"))
                + Integer.parseInt(hmNonDegree.get("shortlevel2"))
                + Integer.parseInt(hmNonDegree.get("shortlevel3"))
                + Integer.parseInt(hmNonDegree.get("shortlevel4"))
                + Integer.parseInt(hmNonDegree.get("shortlevel5"))
                + Integer.parseInt(hmNonDegree.get("shortlevel6"))
                + Integer.parseInt(hmNonDegree.get("shortlevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumNonDegreeShortTerm(postDocNumNonDegreeShortTerm);

        /************************************************
         * set post doc non degree level numbers
         *************************************************/
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel0(Integer.parseInt(hmNonDegree.get("fulllevel0"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel0")));

        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel1(Integer.parseInt(hmNonDegree.get("fulllevel1"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel1")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel2(Integer.parseInt(hmNonDegree.get("fulllevel2"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel2")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel3(Integer.parseInt(hmNonDegree.get("fulllevel3"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel3")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel4(Integer.parseInt(hmNonDegree.get("fulllevel4"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel4")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel5(Integer.parseInt(hmNonDegree.get("fulllevel5"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel5")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel6(Integer.parseInt(hmNonDegree.get("fulllevel6"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel6")));
        phs398TrainingBudgetYearDataType
                .setPostdocNumNonDegreeStipendLevel7(Integer.parseInt(hmNonDegree.get("fulllevel7"))
                        + Integer.parseInt(hmNonDegree.get("shortlevel7")));

        answer = null;

        hmDegree.put("fulllevel0", "0");
        hmDegree.put("fulllevel1", "0");
        hmDegree.put("fulllevel2", "0");
        hmDegree.put("fulllevel3", "0");
        hmDegree.put("fulllevel4", "0");
        hmDegree.put("fulllevel5", "0");
        hmDegree.put("fulllevel6", "0");
        hmDegree.put("fulllevel7", "0");
        hmDegree.put("shortlevel0", "0");
        hmDegree.put("shortlevel1", "0");
        hmDegree.put("shortlevel2", "0");
        hmDegree.put("shortlevel3", "0");
        hmDegree.put("shortlevel4", "0");
        hmDegree.put("shortlevel5", "0");
        hmDegree.put("shortlevel6", "0");
        hmDegree.put("shortlevel7", "0");
        if (answerHeaders != null) {
            for (AnswerHeaderContract answerHeader : answerHeaders) {
                QuestionnaireContract questionnaire = getQuestionAnswerService()
                        .findQuestionnaireById(answerHeader.getQuestionnaireId());
                List<? extends QuestionnaireQuestionContract> questionnaireQuestions = questionnaire
                        .getQuestionnaireQuestions();
                for (QuestionnaireQuestionContract questionnaireQuestion : questionnaireQuestions) {
                    AnswerContract answerBO = getAnswer(questionnaireQuestion, answerHeader);
                    answer = answerBO.getAnswer();
                    QuestionContract question = questionnaireQuestion.getQuestion();
                    if (answer != null) {
                        int answerIntVal = 0;
                        try {
                            answerIntVal = Integer.parseInt(answer);
                        } catch (NumberFormatException ex) {
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                FD_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmDegree.put("fulllevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmDegree.put("fulllevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmDegree.put("fulllevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmDegree.put("fulllevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmDegree.put("fulllevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmDegree.put("fulllevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmDegree.put("fulllevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmDegree.put("fulllevel7", answer);
                                break;
                            default:
                                break;

                            }
                        }
                        if (isPostDocParentQuestionFromPeriodExists(questionnaireQuestion, budgetPeriod,
                                SD_INDEX)) {
                            switch (question.getQuestionSeqId()) {
                            case 86:
                                // trainees at stipend level 0
                                if (answer != null)
                                    hmDegree.put("shortlevel0", answer);
                                break;
                            case 87:
                                // trainees at stipend level 1
                                if (answer != null)
                                    hmDegree.put("shortlevel1", answer);
                                break;
                            case 88:
                                // trainees at stipend level 2
                                if (answer != null)
                                    hmDegree.put("shortlevel2", answer);
                                break;
                            case 89:
                                // trainees at stipend level 3
                                if (answer != null)
                                    hmDegree.put("shortlevel3", answer);
                                break;
                            case 90:
                                // trainees at stipend level 4
                                if (answer != null)
                                    hmDegree.put("shortlevel4", answer);
                                break;
                            case 91:
                                // trainees at stipend level 5
                                if (answer != null)
                                    hmDegree.put("shortlevel5", answer);
                                break;
                            case 92:
                                // trainees at stipend level 6
                                if (answer != null)
                                    hmDegree.put("shortlevel6", answer);
                                break;
                            case 93:
                                // trainees at stipend level 7
                                if (answer != null)
                                    hmDegree.put("shortlevel7", answer);
                                break;
                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }

        /******************************************************
         * set post doc degree seeking numbers for each level
         ******************************************************/
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel0(
                Integer.parseInt(hmDegree.get("fulllevel0")) + Integer.parseInt(hmDegree.get("shortlevel0")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel1(
                Integer.parseInt(hmDegree.get("fulllevel1")) + Integer.parseInt(hmDegree.get("shortlevel1")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel2(
                Integer.parseInt(hmDegree.get("fulllevel2")) + Integer.parseInt(hmDegree.get("shortlevel2")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel3(
                Integer.parseInt(hmDegree.get("fulllevel3")) + Integer.parseInt(hmDegree.get("shortlevel3")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel4(
                Integer.parseInt(hmDegree.get("fulllevel4")) + Integer.parseInt(hmDegree.get("shortlevel4")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel5(
                Integer.parseInt(hmDegree.get("fulllevel5")) + Integer.parseInt(hmDegree.get("shortlevel5")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel6(
                Integer.parseInt(hmDegree.get("fulllevel6")) + Integer.parseInt(hmDegree.get("shortlevel6")));
        phs398TrainingBudgetYearDataType.setPostdocNumDegreeStipendLevel7(
                Integer.parseInt(hmDegree.get("fulllevel7")) + Integer.parseInt(hmDegree.get("shortlevel7")));

        /************************************************
         * set post doc degree seeking full time number
         **********************************************/

        int postDocNumDegreeFulltime = Integer.parseInt(hmDegree.get("fulllevel0"))
                + Integer.parseInt(hmDegree.get("fulllevel1")) + Integer.parseInt(hmDegree.get("fulllevel2"))
                + Integer.parseInt(hmDegree.get("fulllevel3")) + Integer.parseInt(hmDegree.get("fulllevel4"))
                + Integer.parseInt(hmDegree.get("fulllevel5")) + Integer.parseInt(hmDegree.get("fulllevel6"))
                + Integer.parseInt(hmDegree.get("fulllevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumDegreeFullTime(postDocNumDegreeFulltime);

        /***********************************************
         *set post doc degree seeking short term number
         * ************************************************/

        int postDocNumDegreeShortTerm = Integer.parseInt(hmDegree.get("shortlevel0"))
                + Integer.parseInt(hmDegree.get("shortlevel1")) + Integer.parseInt(hmDegree.get("shortlevel2"))
                + Integer.parseInt(hmDegree.get("shortlevel3")) + Integer.parseInt(hmDegree.get("shortlevel4"))
                + Integer.parseInt(hmDegree.get("shortlevel5")) + Integer.parseInt(hmDegree.get("shortlevel6"))
                + Integer.parseInt(hmDegree.get("shortlevel7"));

        phs398TrainingBudgetYearDataType.setPostdocNumDegreeShortTerm(postDocNumDegreeShortTerm);

        // Total numbers of post docs
        phs398TrainingBudgetYearDataType
                .setPostdocTotalShortTerm(phs398TrainingBudgetYearDataType.getPostdocNumDegreeShortTerm()
                        + phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeShortTerm());

        phs398TrainingBudgetYearDataType
                .setPostdocTotalFullTime(phs398TrainingBudgetYearDataType.getPostdocNumDegreeFullTime()
                        + phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeFullTime());

        // total numbers of post docs for each level
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel0(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel0()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel0());

        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel1(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel1()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel1());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel2(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel2()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel2());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel3(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel3()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel3());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel4(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel4()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel4());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel5(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel5()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel5());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel6(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel6()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel6());
        phs398TrainingBudgetYearDataType.setPostdocTotalStipendLevel7(
                phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel7()
                        + phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel7());

        /******************************************************
         * get stipend amounts
         ******************************************************/

        // undergrad
        numPeople = phs398TrainingBudgetYearDataType.getUndergraduateNumFirstYearSophomoreStipends();
        stipendAmountF = getStipendAmount(budgetPeriod, UNDERGRADS, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getUndergraduateNumJuniorSeniorStipends();
        stipendAmountJ = getStipendAmount(budgetPeriod, UNDERGRADS, 1, numPeople);
        phs398TrainingBudgetYearDataType.setUndergraduateStipendsRequested(stipendAmountF.add(stipendAmountJ));

        cumUndergradStipends = cumUndergradStipends
                .add(phs398TrainingBudgetYearDataType.getUndergraduateStipendsRequested());

        // predoc
        numPeople = phs398TrainingBudgetYearDataType.getPredocSingleDegreeNumFullTime();
        stipendAmountPreSingFull = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getPredocDualDegreeNumFullTime();
        stipendAmountPreDualFull = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);

        numPeople = phs398TrainingBudgetYearDataType.getPredocSingleDegreeNumShortTerm();
        stipendAmountPreSingShort = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);
        numPeople = phs398TrainingBudgetYearDataType.getPredocDualDegreeNumShortTerm();
        stipendAmountPreDualShort = getStipendAmount(budgetPeriod, PREDOC, 0, numPeople);

        phs398TrainingBudgetYearDataType.setPredocSingleDegreeStipendsRequested(
                stipendAmountPreSingFull.add(stipendAmountPreSingShort));
        phs398TrainingBudgetYearDataType
                .setPredocDualDegreeStipendsRequested(stipendAmountPreDualFull.add(stipendAmountPreDualShort));
        phs398TrainingBudgetYearDataType.setPredocTotalStipendsRequested(stipendAmountPreSingFull
                .add(stipendAmountPreDualFull.add(stipendAmountPreSingShort).add(stipendAmountPreDualShort)));

        // cumulative amounts
        cumPreDocSingleStipends = cumPreDocSingleStipends.add(stipendAmountPreSingFull)
                .add(stipendAmountPreSingShort);
        cumPreDocDualStipends = cumPreDocDualStipends.add(stipendAmountPreDualFull)
                .add(stipendAmountPreDualShort);
        cumPreDocTotalStipends = cumPreDocSingleStipends.add(cumPreDocDualStipends);
        cumPreDocTotalTuition = cumPreDocDualTuition.add(cumPreDocSingleTuition);

        // postdoc

        numPostDocLevel0 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel0();
        stipendAmountNonDeg0 = getStipendAmount(budgetPeriod, POSTDOC, 0, numPostDocLevel0);
        numPostDocLevel0 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel0();
        stipendAmountDeg0 = getStipendAmount(budgetPeriod, POSTDOC, 0, numPostDocLevel0);

        numPostDocLevel1 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel1();
        stipendAmountNonDeg1 = getStipendAmount(budgetPeriod, POSTDOC, 1, numPostDocLevel1);
        numPostDocLevel1 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel1();
        stipendAmountDeg1 = getStipendAmount(budgetPeriod, POSTDOC, 1, numPostDocLevel1);

        numPostDocLevel2 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel2();
        stipendAmountNonDeg2 = getStipendAmount(budgetPeriod, POSTDOC, 2, numPostDocLevel2);
        numPostDocLevel2 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel2();
        stipendAmountDeg2 = getStipendAmount(budgetPeriod, POSTDOC, 2, numPostDocLevel2);

        numPostDocLevel3 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel3();
        stipendAmountNonDeg3 = getStipendAmount(budgetPeriod, POSTDOC, 3, numPostDocLevel3);
        numPostDocLevel3 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel3();
        stipendAmountDeg3 = getStipendAmount(budgetPeriod, POSTDOC, 3, numPostDocLevel3);

        numPostDocLevel4 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel4();
        stipendAmountNonDeg4 = getStipendAmount(budgetPeriod, POSTDOC, 4, numPostDocLevel4);
        numPostDocLevel4 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel4();
        stipendAmountDeg4 = getStipendAmount(budgetPeriod, POSTDOC, 4, numPostDocLevel4);

        numPostDocLevel5 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel5();
        stipendAmountNonDeg5 = getStipendAmount(budgetPeriod, POSTDOC, 5, numPostDocLevel5);
        numPostDocLevel5 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel5();
        stipendAmountDeg5 = getStipendAmount(budgetPeriod, POSTDOC, 5, numPostDocLevel5);

        numPostDocLevel6 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel6();
        stipendAmountNonDeg6 = getStipendAmount(budgetPeriod, POSTDOC, 6, numPostDocLevel6);
        numPostDocLevel6 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel6();
        stipendAmountDeg6 = getStipendAmount(budgetPeriod, POSTDOC, 6, numPostDocLevel6);

        numPostDocLevel7 = phs398TrainingBudgetYearDataType.getPostdocNumNonDegreeStipendLevel7();
        stipendAmountNonDeg7 = getStipendAmount(budgetPeriod, POSTDOC, 7, numPostDocLevel7);
        numPostDocLevel7 = phs398TrainingBudgetYearDataType.getPostdocNumDegreeStipendLevel7();
        stipendAmountDeg7 = getStipendAmount(budgetPeriod, POSTDOC, 7, numPostDocLevel7);

        phs398TrainingBudgetYearDataType.setPostdocDegreeStipendsRequested(stipendAmountDeg0
                .add(stipendAmountDeg1).add(stipendAmountDeg2).add(stipendAmountDeg3).add(stipendAmountDeg4)
                .add(stipendAmountDeg5).add(stipendAmountDeg6).add(stipendAmountDeg7));

        phs398TrainingBudgetYearDataType
                .setPostdocNonDegreeStipendsRequested(stipendAmountNonDeg0.add(stipendAmountNonDeg1)
                        .add(stipendAmountNonDeg2).add(stipendAmountNonDeg3).add(stipendAmountNonDeg4)
                        .add(stipendAmountNonDeg5).add(stipendAmountNonDeg6).add(stipendAmountNonDeg7));

        phs398TrainingBudgetYearDataType.setPostdocTotalStipendsRequested(
                phs398TrainingBudgetYearDataType.getPostdocNonDegreeStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocDegreeStipendsRequested()));

        /******************************************************
         * set total amounts
         ******************************************************/

        phs398TrainingBudgetYearDataType.setPostdocTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPostdocDegreeTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType.setPredocTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPredocDualDegreeTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPredocSingleDegreeTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType.setTotalTuitionAndFeesRequested(
                phs398TrainingBudgetYearDataType.getPredocTotalTuitionAndFeesRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocTotalTuitionAndFeesRequested().add(
                                phs398TrainingBudgetYearDataType.getUndergraduateTuitionAndFeesRequested()))
                        .add(phs398TrainingBudgetYearDataType.getOtherTuitionAndFeesRequested()));
        phs398TrainingBudgetYearDataType
                .setTotalStipendsRequested(phs398TrainingBudgetYearDataType.getPostdocTotalStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPredocTotalStipendsRequested()
                                .add(phs398TrainingBudgetYearDataType.getUndergraduateStipendsRequested()))
                        .add(phs398TrainingBudgetYearDataType.getOtherStipendsRequested()));
        phs398TrainingBudgetYearDataType.setTotalStipendsAndTuitionFeesRequested(
                phs398TrainingBudgetYearDataType.getTotalStipendsRequested()
                        .add(phs398TrainingBudgetYearDataType.getPostdocTotalTuitionAndFeesRequested()
                                .add(phs398TrainingBudgetYearDataType.getPredocTotalTuitionAndFeesRequested()
                                        .add(phs398TrainingBudgetYearDataType
                                                .getUndergraduateTuitionAndFeesRequested()
                                                .add(phs398TrainingBudgetYearDataType
                                                        .getOtherTuitionAndFeesRequested())))));

        // the total tdirect costs from r and r budget line, which is RESEARCH_DIRECT_COST, has to have the
        // total stipends and tuition subtracted from it.

        researchDirectCosts = budgetPeriod.getTotalDirectCost().subtract(trainingCost)
                .subtract(trainingTraveCost).subtract(consTrainingCost).bigDecimalValue();
        researchDirectCosts = researchDirectCosts
                .subtract(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested());
        phs398TrainingBudgetYearDataType.setResearchDirectCostsRequested(researchDirectCosts);
        if (phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested() != null) {
            Double researchDirectCostValue = phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested()
                    .doubleValue();
            if (researchDirectCostValue < ZERO) {
                String researchDirectCostValueStipend = researchDirectCostValue.toString();
                String budgetYear = budgetPeriod.getBudgetPeriod().toString();
                AuditError stipendError = new AuditError(AuditError.NO_FIELD_ERROR_KEY,
                        GRANTS_GOV_STIPEND_ERROR_MESSAGE, AuditError.GG_LINK);
                String errorMessage = stipendError.getMessageKey();
                errorMessage = errorMessage.replace(STIPEND_AMOUNT, researchDirectCostValueStipend);
                errorMessage = errorMessage.replace(BUDGET_PERIOD, budgetYear);
                stipendError.setMessageKey(errorMessage);
                getAuditErrors().add(stipendError);
            }
        }

        totalOtherDirectCostsRequested = budgetPeriod.getTotalDirectCost().bigDecimalValue();
        totalOtherDirectCostsRequested = totalOtherDirectCostsRequested
                .subtract(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested());
        phs398TrainingBudgetYearDataType.setTotalOtherDirectCostsRequested(totalOtherDirectCostsRequested);

        phs398TrainingBudgetYearDataType.setTotalDirectCostsRequested(
                phs398TrainingBudgetYearDataType.getTotalOtherDirectCostsRequested()
                        .add(phs398TrainingBudgetYearDataType.getTotalStipendsAndTuitionFeesRequested()));

        phs398TrainingBudgetYearDataType.setTotalDirectAndIndirectCostsRequested(
                phs398TrainingBudgetYearDataType.getTotalDirectCostsRequested()
                        .add(phs398TrainingBudgetYearDataType.getTotalIndirectCostsRequested()));

        /******************************************************
         * add to cumulative amounts
         ******************************************************/

        cumPostDocNonDegStipends = cumPostDocNonDegStipends
                .add(phs398TrainingBudgetYearDataType.getPostdocNonDegreeStipendsRequested());
        cumPostDocDegStipends = cumPostDocDegStipends
                .add(phs398TrainingBudgetYearDataType.getPostdocDegreeStipendsRequested());
        cumPostDocTotalStipends = cumPostDocNonDegStipends.add(cumPostDocDegStipends);

        cumResearchTotalDirectCosts = cumResearchTotalDirectCosts
                .add(phs398TrainingBudgetYearDataType.getResearchDirectCostsRequested());
        cumTotalOtherDirectCosts = cumTotalOtherDirectCosts
                .add(phs398TrainingBudgetYearDataType.getTotalOtherDirectCostsRequested());

    }

    // cumulative amounts
    trainingBudgetType.setCumulativeUndergraduateStipendsRequested(cumUndergradStipends);
    trainingBudgetType.setCumulativeUndergraduateTuitionAndFeesRequested(cumUndergradTuition);

    trainingBudgetType.setCumulativeOtherStipendsRequested(cumOtherStipends);
    trainingBudgetType.setCumulativeOtherTuitionAndFeesRequested(cumOtherTuition);
    trainingBudgetType.setCumulativePostdocDegreeStipendsRequested(cumPostDocDegStipends);
    trainingBudgetType.setCumulativePostdocDegreeTuitionAndFeesRequested(cumPostDocDegTuition);
    trainingBudgetType.setCumulativePostdocNonDegreeStipendsRequested(cumPostDocNonDegStipends);
    trainingBudgetType.setCumulativePostdocNonDegreeTuitionAndFeesRequested(cumPostDocNonDegTuition);
    trainingBudgetType.setCumulativePostdocTotalStipendsRequested(cumPostDocTotalStipends);
    trainingBudgetType.setCumulativePostdocTotalTuitionAndFeesRequested(cumPostDocTotalTuition);

    trainingBudgetType.setCumulativePredocDualDegreeStipendsRequested(cumPreDocDualStipends);
    trainingBudgetType.setCumulativePredocDualDegreeTuitionAndFeesRequested(cumPreDocDualTuition);
    trainingBudgetType.setCumulativePredocSingleDegreeStipendsRequested(cumPreDocSingleStipends);
    trainingBudgetType.setCumulativePredocSingleDegreeTuitionAndFeesRequested(cumPreDocSingleTuition);
    trainingBudgetType.setCumulativePredocTotalStipendsRequested(cumPreDocTotalStipends);
    trainingBudgetType.setCumulativePredocTotalTuitionAndFeesRequested(cumPreDocTotalTuition);

    trainingBudgetType.setCumulativeTotalStipendsRequested(cumPostDocTotalStipends.add(cumPreDocTotalStipends)
            .add(cumOtherStipends).add(cumUndergradStipends));

    trainingBudgetType.setCumulativeTuitionAndFeesRequested(
            cumPostDocTotalTuition.add(cumPreDocTotalTuition).add(cumOtherTuition).add(cumUndergradTuition));
    trainingBudgetType.setCumulativeTotalStipendsAndTuitionFeesRequested(
            trainingBudgetType.getCumulativeTotalStipendsRequested()
                    .add(trainingBudgetType.getCumulativeTuitionAndFeesRequested()));

    trainingBudgetType.setCumulativeConsortiumTrainingCostsRequested(cumConsCosts);
    trainingBudgetType.setCumulativeResearchDirectCostsRequested(cumResearchTotalDirectCosts);

    trainingBudgetType.setCumulativeTotalDirectCostsRequested(trainingBudgetType
            .getCumulativeTotalStipendsAndTuitionFeesRequested().add(cumTotalOtherDirectCosts));
    trainingBudgetType.setCumulativeTotalIndirectCostsRequested(cumTotalIndCosts1.add(cumTotalIndCosts2));
    trainingBudgetType.setCumulativeTotalOtherDirectCostsRequested(cumTotalOtherDirectCosts);
    trainingBudgetType.setCumulativeTotalDirectAndIndirectCostsRequested(trainingBudgetType
            .getCumulativeTotalDirectCostsRequested().add(cumTotalIndCosts1.add(cumTotalIndCosts2)));
    trainingBudgetType.setCumulativeTraineeTravelRequested(cumTravelCosts);
    trainingBudgetType.setCumulativeTrainingRelatedExpensesRequested(cumTrainingCosts);

    AttachedFileDataType attachedFileDataType = null;
    for (NarrativeContract narrative : developmentProposal.getNarratives()) {
        if (narrative.getNarrativeType().getCode() != null) {
            if (Integer.parseInt(
                    narrative.getNarrativeType().getCode()) == PHS_TRAINING_BUDGET_BUDGETJUSTIFICATION_130) {
                attachedFileDataType = getAttachedFileType(narrative);
                if (attachedFileDataType == null) {
                } else {
                    break;
                }
            }
        }
    }
    if (attachedFileDataType == null) {
        attachedFileDataType = AttachedFileDataType.Factory.newInstance();
    }
    trainingBudgetType.setBudgetJustification(attachedFileDataType);

    return trainingBudgetType;
}

From source file:com.feilong.core.date.DateUtil.java

/**
 *  {@link Date} ? {@link Calendar}, {@link GregorianCalendar}.
 * //from  w w  w  .  j  av a2  s  . com
 * <p>
 * {@link Calendar#getInstance()},???GregorianCalendar(),<br>
 *  java.util.Calendar.createCalendar(TimeZone, Locale) ,<br>
 * Locale(), {@link GregorianCalendar#GregorianCalendar(java.util.TimeZone, java.util.Locale)} 
 * </p>
 * 
 * <h3>{@link GregorianCalendar}</h3>
 * 
 * <blockquote>
 * <p>
 * /,?""
 * </p>
 * </blockquote>
 *
 * @param date
 *            ?
 * @return date null, {@link NullPointerException}
 * @see Calendar#getInstance()
 * @see GregorianCalendar
 * @see Calendar#setTime(Date)
 * @see Calendar#setTimeInMillis(long)
 * @see org.apache.commons.lang3.time.DateUtils#toCalendar(Date)
 */
public static Calendar toCalendar(Date date) {
    Validate.notNull(date, "date can't be null!");
    return DateUtils.toCalendar(date);
}

From source file:org.apache.sling.testing.mock.sling.resource.AbstractJcrResourceResolverTest.java

@Before
public final void setUp() throws RepositoryException {
    session = context.resourceResolver().adaptTo(Session.class);

    // prepare some test data using JCR API
    Node rootNode = getTestRootNode();
    Node node1 = rootNode.addNode("node1", JcrConstants.NT_UNSTRUCTURED);

    node1.setProperty("stringProp", STRING_VALUE);
    node1.setProperty("stringArrayProp", STRING_ARRAY_VALUE);
    node1.setProperty("integerProp", INTEGER_VALUE);
    node1.setProperty("doubleProp", DOUBLE_VALUE);
    node1.setProperty("booleanProp", BOOLEAN_VALUE);
    node1.setProperty("dateProp", DateUtils.toCalendar(DATE_VALUE));
    node1.setProperty("calendarProp", CALENDAR_VALUE);
    node1.setProperty("binaryProp",
            session.getValueFactory().createBinary(new ByteArrayInputStream(BINARY_VALUE)));

    node1.addNode("node11", JcrConstants.NT_UNSTRUCTURED);
    node1.addNode("node12", JcrConstants.NT_UNSTRUCTURED);

    session.save();/*w w  w  .  j  av a2 s .c  om*/
}

From source file:org.kuali.kra.iacuc.actions.print.IacucProtocolSummaryXmlStream.java

/**
 * Sets the principles.//from  w w w .ja  v  a2 s .co  m
 * 
 * @param protocol
 * @param protocolType
 * @return     
 */
private void setPrinciples(IacucProtocol protocol, ProtocolType protocolType) {
    List<PrinciplesType> principleTypesList = new ArrayList<PrinciplesType>();
    for (IacucPrinciples iacucPrinciples : protocol.getIacucPrinciples()) {
        PrinciplesType principleTypes = PrinciplesType.Factory.newInstance();
        principleTypes.setReductionPrinciple(iacucPrinciples.getReduction());
        principleTypes.setRefinementPrinciple(iacucPrinciples.getRefinement());
        principleTypes.setReplacementPrinciple(iacucPrinciples.getReplacement());
        principleTypesList.add(principleTypes);
    }

    if (protocol.getIacucPrinciples() != null && protocol.getIacucPrinciples().size() > 0
            && protocol.getIacucPrinciples().get(0).getSearchRequired() != null
            && protocol.getIacucPrinciples().get(0).getSearchRequired().equalsIgnoreCase(Constants.TRUE_FLAG)) {
        List<AlternateDbSearchType> alternateDbSearchTypeList = new ArrayList<AlternateDbSearchType>();
        for (IacucAlternateSearch iacucAlternateSearch : protocol.getIacucAlternateSearches()) {
            AlternateDbSearchType alternateDbSearchType = AlternateDbSearchType.Factory.newInstance();
            alternateDbSearchType.setSearchDate(DateUtils.toCalendar(iacucAlternateSearch.getSearchDate()));
            alternateDbSearchType.setYearsSearched(iacucAlternateSearch.getYearsSearched());
            if (iacucAlternateSearch.getDatabases() != null && iacucAlternateSearch.getDatabases().size() > 0) {
                alternateDbSearchType.setDatabasDesc(
                        iacucAlternateSearch.getDatabases().get(0).getAlternateSearchDatabaseName());
            }
            alternateDbSearchType.setKeywordsSearched(iacucAlternateSearch.getKeywords());
            alternateDbSearchType.setComments(iacucAlternateSearch.getComments());

            alternateDbSearchTypeList.add(alternateDbSearchType);
        }
        protocolType.setAlternateDbSearchArray(alternateDbSearchTypeList.toArray(new AlternateDbSearchType[0]));
    }
    protocolType.setPrinciplesArray(principleTypesList.toArray(new PrinciplesType[0]));
}

From source file:org.syphr.mythtv.ws.frontend.impl.FrontendService0_25.java

@Override
public boolean playRecording(long chanId, Date startTime) {
    return ServiceUtils
            .toPrimitive(service.playRecording(Integer.valueOf((int) chanId), DateUtils.toCalendar(startTime)));
}