@RequestMapping(method = RequestMethod.GET) public ModelAndView showPopulatedForm( @RequestParam(value = "productId", required = true) Integer productId) { ModelAndView modelAndView = new ModelAndView("editSavingsProduct"); configurationDto = this.configurationServiceFacade.getAccountingConfiguration(); modelAndView.addObject("GLCodeMode", configurationDto.getGlCodeMode()); SavingsProductFormDto referenceData = this.adminServiceFacade.retrieveSavingsProductFormReferenceData(); SavingsProductDto savingsProductDto = adminServiceFacade.retrieveSavingsProductDetails(productId); SavingsProductFormBean savingsProductBean = new SavingsProductFormBeanAssembler().assembleReferenceData(referenceData); ProductDetailsDto productDto = savingsProductDto.getProductDetails(); GeneralProductBean productBean = new GeneralProductBeanAssembler() .assembleFrom(savingsProductBean.getGeneralDetails(), productDto); savingsProductBean.setGeneralDetails(productBean); savingsProductBean.setSelectedDepositType(savingsProductDto.getDepositType().toString()); savingsProductBean.setAmountForDeposit(savingsProductDto.getAmountForDeposit()); if (savingsProductDto.getGroupMandatorySavingsType() > 0) { savingsProductBean.setSelectedGroupSavingsApproach( savingsProductDto.getGroupMandatorySavingsType().toString()); } else { savingsProductBean.setSelectedGroupSavingsApproach(""); } savingsProductBean.setMaxWithdrawalAmount(savingsProductDto.getMaxWithdrawal()); savingsProductBean.setInterestRate(savingsProductDto.getInterestRate()); savingsProductBean.setSelectedInterestCalculation( savingsProductDto.getInterestCalculationType().toString()); savingsProductBean.setInterestCalculationFrequency( savingsProductDto.getInterestCalculationFrequency()); savingsProductBean.setSelectedFequencyPeriod( savingsProductDto.getInterestCalculationFrequencyPeriod().toString()); savingsProductBean.setInterestPostingMonthlyFrequency( savingsProductDto.getInterestPostingFrequency()); savingsProductBean.setMinBalanceRequiredForInterestCalculation( Long.toString(savingsProductDto.getMinBalanceForInterestCalculation().longValue())); savingsProductBean.setIsDaily(savingsProductDto.isDailyPosting()); savingsProductBean.setSelectedPrincipalGlCode(savingsProductDto.getDepositGlCode().toString()); savingsProductBean.setSelectedInterestGlCode(savingsProductDto.getInterestGlCode().toString()); savingsProductBean.setNotUpdateable(savingsProductDto.isOpenSavingsAccountsExist()); modelAndView.addObject("savingsProduct", savingsProductBean); return modelAndView; }
public SavingsProductFormBean assembleReferenceData(SavingsProductFormDto referenceData) { SavingsProductFormBean formBean = new SavingsProductFormBean(); GeneralProductBean productDetails = productBeanAssembler.assembleFromRefData(referenceData); formBean.setGeneralDetails(productDetails); // assembler for accounting section populatePrincipalGlCodesDropdown(referenceData, formBean); populateInterestGlCodesDropdown(referenceData, formBean); populateDepositTypesDropdown(referenceData, formBean); populateAppliesToDropdown(referenceData, formBean); populateInterestBalanceDropdown(referenceData, formBean); populateFrequencyPeriodDropdown(referenceData, formBean); return formBean; }