Search in sources :

Example 1 with ProductMixDetailsDto

use of org.mifos.dto.screen.ProductMixDetailsDto in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveProductMixDetails.

@Override
public ProductMixDetailsDto retrieveProductMixDetails(Short prdOfferingId, String productType) {
    try {
        ProductMixBusinessService service = new ProductMixBusinessService();
        PrdOfferingBO product = service.getPrdOfferingByID(prdOfferingId);
        List<PrdOfferingBO> allowedPrdOfferingList = service.getAllowedPrdOfferingsByType(prdOfferingId.toString(), productType);
        List<PrdOfferingBO> notAllowedPrdOfferingList = service.getNotAllowedPrdOfferingsByType(prdOfferingId.toString());
        List<PrdOfferingDto> allowedPrdOfferingNames = new ArrayList<PrdOfferingDto>();
        List<PrdOfferingDto> notAllowedPrdOfferingNames = new ArrayList<PrdOfferingDto>();
        for (PrdOfferingBO prdOffering : allowedPrdOfferingList) {
            allowedPrdOfferingNames.add(prdOffering.toDto());
        }
        for (PrdOfferingBO prdOffering : notAllowedPrdOfferingList) {
            notAllowedPrdOfferingNames.add(prdOffering.toDto());
        }
        ProductMixDetailsDto dto = new ProductMixDetailsDto(prdOfferingId, product.getPrdOfferingName(), product.getPrdType().getProductTypeID(), allowedPrdOfferingNames, notAllowedPrdOfferingNames);
        return dto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ArrayList(java.util.ArrayList) PrdOfferingDto(org.mifos.dto.domain.PrdOfferingDto) ProductMixDetailsDto(org.mifos.dto.screen.ProductMixDetailsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with ProductMixDetailsDto

use of org.mifos.dto.screen.ProductMixDetailsDto in project head by mifos.

the class EditProductMixController method showEditForm.

@RequestMapping(method = RequestMethod.GET)
@ModelAttribute("formBean")
public ProductMixFormBean showEditForm(@RequestParam(value = "productId", required = true) Integer productId) {
    List<ProductTypeDto> productTypes = this.adminServiceFacade.retrieveProductTypesApplicableToProductMix();
    ProductMixFormBean formBean = productMixAssembler.createFormBean(productTypes);
    formBean.setProductId(productId.toString());
    formBean.setProductTypeId("1");
    ProductMixDetailsDto productMixDetails = adminServiceFacade.retrieveProductMixDetails(productId.shortValue(), formBean.getProductTypeId());
    Map<String, String> productNameOptions = new LinkedHashMap<String, String>();
    productNameOptions.put(productMixDetails.getPrdOfferingId().toString(), productMixDetails.getPrdOfferingName());
    formBean.setProductNameOptions(productNameOptions);
    populateAllowedNotAllowedOptions(formBean, productMixDetails);
    return formBean;
}
Also used : ProductTypeDto(org.mifos.dto.domain.ProductTypeDto) ProductMixDetailsDto(org.mifos.dto.screen.ProductMixDetailsDto) LinkedHashMap(java.util.LinkedHashMap) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ProductMixDetailsDto (org.mifos.dto.screen.ProductMixDetailsDto)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 PrdOfferingBO (org.mifos.accounts.productdefinition.business.PrdOfferingBO)1 ProductMixBusinessService (org.mifos.accounts.productsmix.business.service.ProductMixBusinessService)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PrdOfferingDto (org.mifos.dto.domain.PrdOfferingDto)1 ProductTypeDto (org.mifos.dto.domain.ProductTypeDto)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1