Search in sources :

Example 6 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CenterServiceFacadeWebTier method retrieveChangeLogs.

@Override
public List<AuditLogDto> retrieveChangeLogs(Integer centerId) {
    try {
        List<AuditLogDto> auditLogs = new ArrayList<AuditLogDto>();
        Short entityType = EntityType.CENTER.getValue();
        AuditBusinessService auditBusinessService = new AuditBusinessService();
        List<AuditLogView> centerAuditLogs = auditBusinessService.getAuditLogRecords(entityType, centerId);
        for (AuditLogView auditLogView : centerAuditLogs) {
            auditLogs.add(auditLogView.toDto());
        }
        return auditLogs;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AuditBusinessService(org.mifos.framework.components.audit.business.service.AuditBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) AuditLogView(org.mifos.framework.components.audit.util.helpers.AuditLogView) AuditLogDto(org.mifos.dto.domain.AuditLogDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CheckListServiceFacadeWebTier method updateCustomerChecklist.

@Override
public void updateCustomerChecklist(Short checklistId, Short levelId, Short stateId, Short checklistStatus, String checklistName, List<String> details) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(levelId));
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
    try {
        hibernateTransactionHelper.startTransaction();
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) new CheckListPersistence().getCheckList(checklistId);
        customerCheckList.update(customerLevelEntity, customerStatusEntity, checklistName, checklistStatus, details, userContext.getLocaleId(), userContext.getId());
        customerDao.save(customerCheckList);
        hibernateTransactionHelper.commitTransaction();
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (PersistenceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CheckListServiceFacadeWebTier method retreiveAllCustomerCheckLists.

@Override
public List<CustomerCheckBoxItemDto> retreiveAllCustomerCheckLists() {
    try {
        List<CustomerCheckListBO> customerCheckLists = new CheckListBusinessService().retreiveAllCustomerCheckLists();
        List<CustomerCheckBoxItemDto> dtoList = new ArrayList<CustomerCheckBoxItemDto>();
        for (CustomerCheckListBO bo : customerCheckLists) {
            String lookUpName = bo.getCustomerStatus().getLookUpValue() != null ? bo.getCustomerStatus().getLookUpValue().getLookUpName() : null;
            CustomerCheckBoxItemDto dto = new CustomerCheckBoxItemDto(bo.getChecklistId(), bo.getChecklistName(), bo.getChecklistStatus(), null, lookUpName, bo.getCustomerStatus().getId(), bo.getCustomerLevel().getId());
            if (dto.getLookUpName() != null) {
                dto.setName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(dto.getLookUpName()));
            }
            dtoList.add(dto);
        }
        return dtoList;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) CheckListBusinessService(org.mifos.customers.checklist.business.service.CheckListBusinessService) CustomerCheckBoxItemDto(org.mifos.dto.screen.CustomerCheckBoxItemDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 9 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CheckListServiceFacadeWebTier method createAccountChecklist.

@Override
public void createAccountChecklist(Short productId, Short stateId, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        ProductTypeEntity productTypeEntity = null;
        for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
            if (productId.equals(prdTypeEntity.getProductTypeID())) {
                productTypeEntity = prdTypeEntity;
                break;
            }
        }
        hibernateTransactionHelper.startTransaction();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
        AccountCheckListBO accountCheckListBO = new AccountCheckListBO(productTypeEntity, accountStateEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckListBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 10 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CheckListServiceFacadeWebTier method retrieveChecklistMasterData.

@Override
public List<CheckListMasterDto> retrieveChecklistMasterData() {
    try {
        Short localeIdNotUsed = null;
        List<CheckListMasterDto> masterData = new CheckListPersistence().getCheckListMasterData(localeIdNotUsed);
        for (CheckListMasterDto checkListMasterDto : masterData) {
            if (checkListMasterDto.isCustomer()) {
                checkListMasterDto.setMasterTypeName(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(checkListMasterDto.getLookupKey()));
            } else {
                checkListMasterDto.setMasterTypeName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(checkListMasterDto.getLookupKey()));
            }
        }
        return masterData;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CheckListMasterDto(org.mifos.dto.domain.CheckListMasterDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

MifosRuntimeException (org.mifos.core.MifosRuntimeException)305 PersistenceException (org.mifos.framework.exceptions.PersistenceException)136 ArrayList (java.util.ArrayList)102 BusinessRuleException (org.mifos.service.BusinessRuleException)95 UserContext (org.mifos.security.util.UserContext)94 MifosUser (org.mifos.security.MifosUser)87 AccountException (org.mifos.accounts.exceptions.AccountException)79 ServiceException (org.mifos.framework.exceptions.ServiceException)69 ApplicationException (org.mifos.framework.exceptions.ApplicationException)48 LoanBO (org.mifos.accounts.loan.business.LoanBO)41 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)39 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)37 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)36 LocalDate (org.joda.time.LocalDate)35 CustomerBO (org.mifos.customers.business.CustomerBO)29 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)28 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)27 CustomerException (org.mifos.customers.exceptions.CustomerException)27 Money (org.mifos.framework.util.helpers.Money)27 AccountBO (org.mifos.accounts.business.AccountBO)25