Search in sources :

Example 6 with ServiceException

use of org.mifos.framework.exceptions.ServiceException 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 7 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveAllProductMix.

@Override
public ProductDto retrieveAllProductMix() {
    try {
        List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
        List<PrdOfferingBO> prdOfferingList = new ProductMixBusinessService().getPrdOfferingMix();
        List<ProductCategoryTypeDto> pcList = new ArrayList<ProductCategoryTypeDto>();
        for (ProductCategoryBO pcBO : productCategoryList) {
            ProductCategoryTypeDto pcDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
            pcList.add(pcDto);
        }
        List<ProductMixDto> pmList = new ArrayList<ProductMixDto>();
        for (PrdOfferingBO poBO : prdOfferingList) {
            ProductMixDto pmDto = new ProductMixDto(poBO.getPrdCategory().getProductType().getProductTypeID(), poBO.getPrdOfferingId(), poBO.getPrdType().getProductTypeID(), poBO.getPrdOfferingName());
            pmList.add(pmDto);
        }
        ProductDto productDto = new ProductDto(pcList, pmList);
        return productDto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ProductMixBusinessService(org.mifos.accounts.productsmix.business.service.ProductMixBusinessService) ArrayList(java.util.ArrayList) ProductMixDto(org.mifos.dto.screen.ProductMixDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) PrdOfferingBO(org.mifos.accounts.productdefinition.business.PrdOfferingBO) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductDto(org.mifos.dto.screen.ProductDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveAllProductCategories.

@Override
public ProductCategoryDisplayDto retrieveAllProductCategories() {
    try {
        List<ProductCategoryBO> productCategoryList = new ProductCategoryBusinessService().getAllCategories();
        List<ProductCategoryTypeDto> pcTypeList = new ArrayList<ProductCategoryTypeDto>();
        List<ProductCategoryDto> pcList = new ArrayList<ProductCategoryDto>();
        for (ProductCategoryBO pcBO : productCategoryList) {
            ProductCategoryTypeDto pcTypeDto = new ProductCategoryTypeDto(pcBO.getProductType().getProductTypeID(), pcBO.getProductType().getLookUpValue().getLookUpName());
            pcTypeList.add(pcTypeDto);
            ProductCategoryDto pcDto = new ProductCategoryDto(pcBO.getProductCategoryName(), pcBO.getPrdCategoryStatus().getId(), pcBO.getGlobalPrdCategoryNum());
            pcList.add(pcDto);
        }
        ProductCategoryDisplayDto productCategoryDisplayDto = new ProductCategoryDisplayDto(pcTypeList, pcList);
        return productCategoryDisplayDto;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ProductCategoryDisplayDto(org.mifos.dto.screen.ProductCategoryDisplayDto) ServiceException(org.mifos.framework.exceptions.ServiceException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) ArrayList(java.util.ArrayList) ProductCategoryDto(org.mifos.dto.screen.ProductCategoryDto) ProductCategoryTypeDto(org.mifos.dto.screen.ProductCategoryTypeDto) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 9 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class GroupPerformanceHistoryEntity method updateOnDisbursement.

public void updateOnDisbursement(LoanBO loan, Money disburseAmount) throws AccountException {
    LoanOfferingBO loanOffering = loan.getLoanOffering();
    updateLoanCounter(loanOffering, YesNoFlag.YES);
    try {
        if ((configService.isNewGlimEnabled() || configService.isGlimEnabled()) && loan.getAccountId() != null) {
            CollectionUtils.forAllDo(accountBusinessService.getCoSigningClientsForGlim(loan.getAccountId()), new UpdateClientPerfHistoryForGroupLoanOnDisbursement(loan));
        }
    } catch (ServiceException e) {
        throw new AccountException(e);
    }
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) AccountException(org.mifos.accounts.exceptions.AccountException) UpdateClientPerfHistoryForGroupLoanOnDisbursement(org.mifos.customers.group.business.GroupPerformanceHistoryUpdater.UpdateClientPerfHistoryForGroupLoanOnDisbursement) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO)

Example 10 with ServiceException

use of org.mifos.framework.exceptions.ServiceException in project head by mifos.

the class MultipleLoanAccountsCreationActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    logger.debug("Inside validate method");
    String method = request.getParameter(Methods.method.toString());
    ActionErrors errors = new ActionErrors();
    try {
        if (method.equals(Methods.get.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForLoad(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        } else if (method.equals(Methods.create.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            validateLoanAmounts(errors, this.getUserContext(request).getPreferredLocale(), clientDetails);
            checkValidationForCreate(errors, request);
        } else if (method.equals(Methods.getLoanOfficers.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
        } else if (method.equals(Methods.getCenters.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
        } else if (method.equals(Methods.getPrdOfferings.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
            checkValidationForCenter(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        }
    } catch (PageExpiredException e) {
        errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
    } catch (ServiceException e) {
        errors.add(ExceptionConstants.SERVICEEXCEPTION, new ActionMessage(ExceptionConstants.SERVICEEXCEPTION));
    }
    if (!errors.isEmpty()) {
        request.setAttribute("methodCalled", method);
    }
    logger.debug("outside validate method");
    return errors;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ServiceException (org.mifos.framework.exceptions.ServiceException)93 PersistenceException (org.mifos.framework.exceptions.PersistenceException)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)39 Test (org.junit.Test)34 ExpectedException (org.springframework.test.annotation.ExpectedException)29 ArrayList (java.util.ArrayList)24 UserContext (org.mifos.security.util.UserContext)19 AccountBO (org.mifos.accounts.business.AccountBO)17 MifosUser (org.mifos.security.MifosUser)16 LoanBO (org.mifos.accounts.loan.business.LoanBO)15 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)14 AccountException (org.mifos.accounts.exceptions.AccountException)13 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 BusinessRuleException (org.mifos.service.BusinessRuleException)11 Date (java.util.Date)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 BigDecimal (java.math.BigDecimal)6 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)6 DateTimeService (org.mifos.framework.util.DateTimeService)6 LocalDate (org.joda.time.LocalDate)5