use of org.mifos.service.BusinessRuleException 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();
}
}
use of org.mifos.service.BusinessRuleException 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();
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class ClientServiceFacadeWebTier method transferClientToGroup.
@Override
public String transferClientToGroup(Integer groupId, String clientGlobalCustNum, Integer previousClientVersionNo) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client;
try {
client = this.customerService.transferClientTo(userContext, groupId, clientGlobalCustNum, previousClientVersionNo);
return client.getGlobalCustNum();
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class CoaServiceFacadeWebTier method delete.
@Override
public void delete(Short id) {
try {
COABO coaBo = legacyAccountDao.getPersistentObject(COABO.class, id);
if (coaBo == null || !isModifiable(coaBo)) {
throw new BusinessRuleException(CANNOT_MODIFY);
}
legacyAccountDao.deleteLedgerAccount(coaBo.getAccountId());
reloadCache();
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveLoanProductFormReferenceData.
@Override
public LoanProductFormDto retrieveLoanProductFormReferenceData() {
try {
LoanPrdBusinessService service = new LoanPrdBusinessService();
List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
List<ProductCategoryBO> productCategories = service.getActiveLoanProductCategories();
for (ProductCategoryBO category : productCategories) {
productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
}
List<ListElement> applicableForOptions = new ArrayList<ListElement>();
List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveLoanApplicableProductCategories();
for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> gracePeriodTypeOptions = new ArrayList<ListElement>();
List<GracePeriodTypeEntity> gracePeriodTypes = this.loanProductDao.retrieveGracePeriodTypes();
for (GracePeriodTypeEntity gracePeriodTypeEntity : gracePeriodTypes) {
gracePeriodTypeOptions.add(new ListElement(gracePeriodTypeEntity.getId().intValue(), gracePeriodTypeEntity.getName()));
}
List<ListElement> interestCalcTypesOptions = new ArrayList<ListElement>();
List<InterestTypesEntity> interestCalcTypes = this.loanProductDao.retrieveInterestTypes();
for (InterestTypesEntity entity : interestCalcTypes) {
interestCalcTypesOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> sourceOfFunds = new ArrayList<ListElement>();
List<FundBO> funds = this.fundDao.findAllFunds();
for (FundBO fund : funds) {
sourceOfFunds.add(new ListElement(fund.getFundId().intValue(), fund.getFundName()));
}
List<ListElement> loanFee = new ArrayList<ListElement>();
List<FeeBO> fees = feeDao.getAllAppllicableFeeForLoanCreation();
for (FeeBO fee : fees) {
loanFee.add(new ListElement(fee.getFeeId().intValue(), fee.getFeeName()));
}
List<ListElement> principalGlCodes = new ArrayList<ListElement>();
List<GLCodeEntity> principalGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.PRINCIPALPOSTING, FinancialConstants.CREDIT);
for (GLCodeEntity glCode : principalGlCodeEntities) {
principalGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
}
List<ListElement> interestGlCodes = new ArrayList<ListElement>();
List<GLCodeEntity> interestGlCodeEntities = new FinancialBusinessService().getGLCodes(FinancialActionConstants.INTERESTPOSTING, FinancialConstants.CREDIT);
for (GLCodeEntity glCode : interestGlCodeEntities) {
interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode()));
}
List<ListElement> statusOptions = new ArrayList<ListElement>();
List<PrdStatusEntity> applicableStatuses = service.getApplicablePrdStatus(Short.valueOf("1"));
for (PrdStatusEntity entity : applicableStatuses) {
statusOptions.add(new ListElement(entity.getOfferingStatusId().intValue(), entity.getPrdState().getName()));
}
boolean multiCurrencyEnabled = AccountingRules.isMultiCurrencyEnabled();
List<ListElement> currencyOptions = new ArrayList<ListElement>();
if (multiCurrencyEnabled) {
LinkedList<MifosCurrency> currencies = AccountingRules.getCurrencies();
for (MifosCurrency mifosCurrency : currencies) {
currencyOptions.add(new ListElement(mifosCurrency.getCurrencyId().intValue(), mifosCurrency.getCurrencyCode()));
}
}
return new LoanProductFormDto(productCategoryOptions, gracePeriodTypeOptions, sourceOfFunds, loanFee, principalGlCodes, interestGlCodes, interestCalcTypesOptions, applicableForOptions, statusOptions, currencyOptions, multiCurrencyEnabled);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (SystemException e) {
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations