use of org.mifos.framework.exceptions.PersistenceException 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);
}
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class ClientServiceFacadeWebTier method getClientInformationDto.
@Override
public ClientInformationDto getClientInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = customerDao.findClientBySystemId(globalCustNum);
if (client == null) {
throw new MifosRuntimeException("Client not found for globalCustNum, levelId: " + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
ClientDisplayDto clientDisplay = this.customerDao.getClientDisplayDto(client.getCustomerId(), userContext);
Integer clientId = client.getCustomerId();
CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(clientId);
ClientPerformanceHistoryDto clientPerformanceHistory = assembleClientPerformanceHistoryDto(client.getClientPerformanceHistory(), clientId);
CustomerAddressDto clientAddress = this.customerDao.getCustomerAddressDto(client);
List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(clientId);
List<CustomerFlagDto> customerFlags = customerDao.getCustomerFlagDto(client.getCustomerFlags());
List<LoanDetailDto> loanDetail = customerDao.getLoanDetailDto(client.getOpenLoanAccounts());
List<LoanDetailDto> groupLoanDetail = customerDao.getLoanDetailDto(client.getOpenGroupLoanAccounts());
List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(clientId, userContext);
CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(client.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(clientId);
List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
} else {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
Boolean activeSurveys = Boolean.FALSE;
// Boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CLIENT);
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<LoanDetailDto> guarantedLoanAccounts = new ArrayList<LoanDetailDto>();
try {
List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByGurantorId(clientId);
if (guaranties != null && guaranties.size() > 0) {
for (GuarantyEntity guaranty : guaranties) {
if (guaranty != null && guaranty.getState() != null && guaranty.getState()) {
LoanBO loan = loanDao.findById(guaranty.getLoanId());
guarantedLoanAccounts.add(new LoanDetailDto(loan.getGlobalAccountNum(), loan.getLoanOffering().getPrdOfferingName(), loan.getAccountState().getId(), loan.getAccountState().getName(), loan.getLoanSummary().getOutstandingBalance().toString(), loan.getTotalAmountDue().toString(), loan.getAccountType().getAccountTypeId(), loan.getTotalAmountInArrears().toString()));
}
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException("Can not get guaranted loan accounts", e);
}
return new ClientInformationDto(clientDisplay, customerAccountSummary, clientPerformanceHistory, clientAddress, recentCustomerNotes, customerFlags, loanDetail, groupLoanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, closedLoanAccounts, closedSavingsAccounts, guarantedLoanAccounts);
}
use of org.mifos.framework.exceptions.PersistenceException 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.framework.exceptions.PersistenceException in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadMeetingDateForCustomer.
@Override
public CollectionSheetEntryFormDto loadMeetingDateForCustomer(final Integer customerId, final CollectionSheetEntryFormDto formDto) {
Short backDatedTransactionAllowed = Constants.NO;
java.util.Date meetingDate = null;
try {
meetingDate = customerPersistence.getLastMeetingDateForCustomer(customerId);
final boolean isBackDatedTrxnAllowed = AccountingRules.isBackDatedTxnAllowed();
if (meetingDate == null) {
meetingDate = DateUtils.getCurrentDateWithoutTimeStamp();
}
backDatedTransactionAllowed = isBackDatedTrxnAllowed ? Constants.YES : Constants.NO;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(formDto.getActiveBranchesList(), formDto.getPaymentTypesList(), formDto.getLoanOfficerList(), formDto.getCustomerList(), formDto.getReloadFormAutomatically(), formDto.getCenterHierarchyExists(), backDatedTransactionAllowed, meetingDate);
}
use of org.mifos.framework.exceptions.PersistenceException in project head by mifos.
the class AdminServiceFacadeWebTier method createProductCategory.
@Override
public void createProductCategory(CreateOrUpdateProductCategory productCategoryDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
this.loanProductDao.validateNameIsAvailableForCategory(productCategoryDto.getProductCategoryName(), productCategoryDto.getProductTypeEntityId());
HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
try {
// FIXME - delegate to globalNumberGenerationStrategy
StringBuilder globalPrdOfferingNum = new StringBuilder();
globalPrdOfferingNum.append(userContext.getBranchId());
globalPrdOfferingNum.append("-");
Short maxPrdID = legacyProductCategoryDao.getMaxPrdCategoryId();
globalPrdOfferingNum.append(StringUtils.leftPad(String.valueOf(maxPrdID != null ? maxPrdID + 1 : ProductDefinitionConstants.DEFAULTMAX), 3, '0'));
String globalNumber = globalPrdOfferingNum.toString();
ProductTypeEntity productType = new ProductTypeEntity(productCategoryDto.getProductTypeEntityId());
ProductCategoryBO productCategoryBO = new ProductCategoryBO(productType, productCategoryDto.getProductCategoryName(), productCategoryDto.getProductCategoryDesc(), globalNumber);
transactionHelper.startTransaction();
this.loanProductDao.save(productCategoryBO);
transactionHelper.commitTransaction();
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
Aggregations