use of org.mifos.dto.screen.ProductMixPreviewDto in project head by mifos.
the class ProductMixAssembler method createProductMixPreview.
public ProductMixPreviewDto createProductMixPreview(ProductMixFormBean formBean) {
String selectedProductTypeNameKey = formBean.getProductTypeOptions().get(formBean.getProductTypeId());
String selectedProductName = formBean.getProductNameOptions().get(formBean.getProductId());
List<String> allowedProductMix = findMatchingProducts(formBean, formBean.getAllowed());
List<String> notAllowedProductMix = findMatchingProducts(formBean, formBean.getNotAllowed());
ProductMixPreviewDto preview = new ProductMixPreviewDto();
preview.setProductTypeNameKey(selectedProductTypeNameKey);
preview.setProductName(selectedProductName);
preview.setAllowedProductMix(allowedProductMix);
preview.setNotAllowedProductMix(notAllowedProductMix);
return preview;
}
use of org.mifos.dto.screen.ProductMixPreviewDto in project head by mifos.
the class DefineProductMixController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = CANCEL_PARAM, required = false) String canceBtn, @RequestParam(value = PREVIEW_PARAM, required = false) String previewBtn, @ModelAttribute("formBean") ProductMixFormBean formBean, BindingResult result, SessionStatus status) {
ModelAndView mav = new ModelAndView("defineProductMix");
ProductMixFormValidator formValidator = new ProductMixFormValidator();
if (StringUtils.isNotBlank(canceBtn)) {
mav = new ModelAndView(REDIRECT_TO_ADMIN_SCREEN);
status.setComplete();
}
if (StringUtils.isBlank(formBean.getProductTypeId())) {
List<ProductTypeDto> productTypes = this.adminServiceFacade.retrieveProductTypesApplicableToProductMix();
mav.addObject("formBean", productMixAssembler.createFormBean(productTypes));
validateForPreview(formValidator, formBean, result, previewBtn);
} else if (StringUtils.isNotBlank(formBean.getProductTypeId()) && StringUtils.isBlank(formBean.getProductId())) {
populateProductNameOptions(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
} else if (StringUtils.isNotBlank(formBean.getProductTypeId()) && StringUtils.isNotBlank(formBean.getProductId()) && (formBean.getAllowed() == null && formBean.getNotAllowed() == null)) {
populateAllowedNotAllowedOptions(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
} else {
checkAndFixFormStringArrys(formBean);
validateForPreview(formValidator, formBean, result, previewBtn);
ProductMixPreviewDto preview = this.productMixAssembler.createProductMixPreview(formBean);
mav = new ModelAndView("previewProductMix");
mav.addObject("ref", preview);
mav.addObject("formView", "defineProductMix");
}
return mav;
}
Aggregations