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();
}
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations