Search in sources :

Example 36 with MifosRuntimeException

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

the class RolesPermissionServiceFacadeWebTier method deleteRole.

@Override
public void deleteRole(Integer versionNo, Short roleId) throws Exception {
    RolesPermissionsBusinessService rolesPermissionsBusinessService = new RolesPermissionsBusinessService();
    RoleBO role = rolesPermissionsBusinessService.getRole(roleId);
    role.setVersionNo(versionNo);
    validateIfRoleAssignedToPersonnel(role);
    try {
        StaticHibernateUtil.startTransaction();
        legacyRolesPermissionsDao.delete(role);
        StaticHibernateUtil.flushSession();
        for (ActivityEntity ae : legacyRolesPermissionsDao.getActivities()) {
            StaticHibernateUtil.getSessionTL().refresh(ae);
        }
        StaticHibernateUtil.commitTransaction();
    } catch (PersistenceException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 37 with MifosRuntimeException

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

the class RolesPermissionServiceFacadeWebTier method getRoleActivitiesRestrictions.

@Override
public List<ActivityRestrictionDto> getRoleActivitiesRestrictions(Short roleId) {
    try {
        List<ActivityRestrictionDto> activityRestrictionDtoList = new ArrayList<ActivityRestrictionDto>();
        List<RoleActivityRestrictionBO> activityRestrictionBOList = legacyRolesPermissionsDao.getRoleActivitiesRestrictions(roleId);
        for (RoleActivityRestrictionBO activityRestrictionBO : activityRestrictionBOList) {
            Integer activityRestrictionId = activityRestrictionBO.getId();
            Short activityRestrictionTypeId = activityRestrictionBO.getActivityRestrictionType().getId();
            BigDecimal restrictionAmountValue = activityRestrictionBO.getRestrictionAmountValue();
            ActivityRestrictionDto activityRestrictionDto = new ActivityRestrictionDto(roleId, activityRestrictionId, activityRestrictionTypeId, restrictionAmountValue);
            activityRestrictionDtoList.add(activityRestrictionDto);
        }
        return activityRestrictionDtoList;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ActivityRestrictionDto(org.mifos.dto.domain.ActivityRestrictionDto) RoleActivityRestrictionBO(org.mifos.security.rolesandpermission.business.RoleActivityRestrictionBO) BigDecimal(java.math.BigDecimal) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 38 with MifosRuntimeException

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

the class SaveCollectionSheetAssembler method clientAttendanceAssemblerfromDto.

public List<ClientAttendanceBO> clientAttendanceAssemblerfromDto(final List<SaveCollectionSheetCustomerDto> saveCollectionSheetCustomers, final LocalDate transactionDate, final Short branchId, final String searchId) {
    List<ClientAttendanceBO> clientAttendanceList = null;
    try {
        clientAttendanceList = clientAttendanceDao.findClientAttendance(branchId, searchId, transactionDate);
        for (SaveCollectionSheetCustomerDto saveCollectionSheetCustomer : saveCollectionSheetCustomers) {
            ClientBO client = customerDao.findClientById(saveCollectionSheetCustomer.getCustomerId());
            if (null != client) {
                ClientAttendanceBO clientAttendance = findClientAttendance(clientAttendanceList, client);
                if (clientAttendance == null) {
                    clientAttendance = new ClientAttendanceBO();
                    clientAttendance.setCustomer(client);
                    clientAttendance.setMeetingDate(DateUtils.getDateFromLocalDate(transactionDate));
                }
                clientAttendance.setAttendance(saveCollectionSheetCustomer.getAttendanceId());
                clientAttendanceList.add(clientAttendance);
            }
        }
    } catch (PersistenceException e) {
        throw new MifosRuntimeException("Failure assembling client attendance list.", e);
    }
    return clientAttendanceList;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ClientAttendanceBO(org.mifos.customers.client.business.ClientAttendanceBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 39 with MifosRuntimeException

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

the class HierarchyManager method compareOfficeInHierarchy.

public BranchLocation compareOfficeInHierarchy(UserContext user, Short officeId) {
    Assert.notNull(officeId, "officeId should not be null");
    Assert.notNull(user, "userContext should not be null");
    short userBranch = user.getBranchId().shortValue();
    if (userBranch == officeId) {
        return BranchLocation.SAME;
    }
    /*
         * Look into the map now if the passed officeid's searchid on which user wants to perform action starts with the
         * user's office searchid it means that office falls under that user hiererchy
         */
    String userOfficeSearchId = hierarchyMap.get(user.getBranchId()).getSearchId();
    OfficeCacheDto cachedOffice = hierarchyMap.get(officeId);
    if (cachedOffice == null) {
        try {
            // repopulate cachedmap
            init();
            cachedOffice = hierarchyMap.get(officeId);
        } catch (SystemException e) {
            throw new MifosRuntimeException(e);
        } catch (OfficeException e) {
            throw new MifosRuntimeException(e);
        }
        if (cachedOffice == null) {
            throw new IllegalArgumentException("office with id [" + officeId + "] does not exist");
        }
    }
    String operatedOfficeSearchId = cachedOffice.getSearchId();
    if (operatedOfficeSearchId.startsWith(userOfficeSearchId)) {
        return BranchLocation.BELOW;
    }
    return BranchLocation.ABOVE_OR_DIFFERENT;
}
Also used : OfficeException(org.mifos.customers.office.exceptions.OfficeException) SystemException(org.mifos.framework.exceptions.SystemException) OfficeCacheDto(org.mifos.security.util.OfficeCacheDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 40 with MifosRuntimeException

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

the class LoanServiceFacadeWebTier method retrieveOriginalLoanSchedule.

@Override
public OriginalScheduleInfoDto retrieveOriginalLoanSchedule(Integer accountId) {
    try {
        List<OriginalLoanScheduleEntity> loanScheduleEntities = loanBusinessService.retrieveOriginalLoanSchedule(accountId);
        ArrayList<RepaymentScheduleInstallment> repaymentScheduleInstallments = new ArrayList<RepaymentScheduleInstallment>();
        for (OriginalLoanScheduleEntity loanScheduleEntity : loanScheduleEntities) {
            repaymentScheduleInstallments.add(loanScheduleEntity.toDto());
        }
        LoanBO loan = this.loanDao.findById(accountId);
        return new OriginalScheduleInfoDto(loan.getLoanAmount().toString(), loan.getDisbursementDate(), repaymentScheduleInstallments);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) OriginalLoanScheduleEntity(org.mifos.accounts.loan.business.OriginalLoanScheduleEntity) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) PersistenceException(org.mifos.framework.exceptions.PersistenceException) 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