use of org.mifos.framework.exceptions.PersistenceException 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);
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class LegacyMasterDao method findMasterDataEntityWithLocale.
@SuppressWarnings("unchecked")
public <T extends MasterDataEntity> T findMasterDataEntityWithLocale(final Class<T> entityType, final Short entityId) throws PersistenceException {
Session session = getSession();
List<T> masterEntities = session.createQuery("from " + entityType.getName() + " masterEntity where masterEntity.id = " + entityId).list();
if (masterEntities != null && masterEntities.size() > 0) {
T masterDataEntity = masterEntities.get(0);
Hibernate.initialize(masterDataEntity.getNames());
return masterDataEntity;
}
throw new PersistenceException("errors.entityNotFound");
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveNotAllowedProductsForMix.
@Override
public List<PrdOfferingDto> retrieveNotAllowedProductsForMix(Integer productTypeId, Integer productId) {
try {
List<PrdOfferingDto> notAllowedProductDtos = new ArrayList<PrdOfferingDto>();
List<PrdOfferingBO> allowedProducts = new PrdOfferingPersistence().getNotAllowedPrdOfferingsForMixProduct(productId.toString(), productTypeId.toString());
for (PrdOfferingBO product : allowedProducts) {
notAllowedProductDtos.add(product.toDto());
}
return notAllowedProductDtos;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class AdminServiceFacadeWebTier method updateAcceptedPaymentTypes.
@Override
public void updateAcceptedPaymentTypes(String[] chosenAcceptedFees, String[] chosenAcceptedLoanDisbursements, String[] chosenAcceptedLoanRepayments, String[] chosenAcceptedSavingDeposits, String[] chosenAcceptedSavingWithdrawals) {
LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
List<AcceptedPaymentType> deletedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
List<AcceptedPaymentType> addedPaymentTypeList = new ArrayList<AcceptedPaymentType>();
List<PaymentTypeDto> allPayments = getAllPaymentTypes(null);
AcceptedPaymentTypeDto oldAcceptedPaymentTypeDto = retrieveAcceptedPaymentTypes();
for (int i = 0; i < TrxnTypes.values().length; i++) {
TrxnTypes transactionType = TrxnTypes.values()[i];
List<PaymentTypeDto> selectedPaymentTypes = new ArrayList<PaymentTypeDto>();
List<PaymentTypeDto> outList = null;
if (transactionType == TrxnTypes.fee) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedFees, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutFeeList();
} else if (transactionType == TrxnTypes.loan_disbursement) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanDisbursements, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutDisbursementList();
} else if (transactionType == TrxnTypes.loan_repayment) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedLoanRepayments, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutRepaymentList();
} else if (transactionType == TrxnTypes.savings_deposit) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingDeposits, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutDepositList();
} else if (transactionType == TrxnTypes.savings_withdrawal) {
selectedPaymentTypes = populateSelectedPayments(chosenAcceptedSavingWithdrawals, allPayments);
outList = oldAcceptedPaymentTypeDto.getOutWithdrawalList();
} else {
throw new MifosRuntimeException("Unknown account action for accepted payment type " + transactionType.toString());
}
process(selectedPaymentTypes, outList, deletedPaymentTypeList, addedPaymentTypeList, persistence, transactionType);
}
try {
if (addedPaymentTypeList.size() > 0) {
persistence.addAcceptedPaymentTypes(addedPaymentTypeList);
StaticHibernateUtil.commitTransaction();
}
if (deletedPaymentTypeList.size() > 0) {
persistence.deleteAcceptedPaymentTypes(deletedPaymentTypeList);
StaticHibernateUtil.commitTransaction();
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations