use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class AdminServiceFacadeWebTier method retrieveSavingsProductFormReferenceData.
@Override
public SavingsProductFormDto retrieveSavingsProductFormReferenceData() {
try {
SavingsPrdBusinessService service = new SavingsPrdBusinessService();
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()));
}
List<ListElement> penaltiesOptions = new ArrayList<ListElement>();
List<PenaltyBO> applicablePenalties = this.penaltyDao.findAllSavingPenalties();
for (PenaltyBO entity : applicablePenalties) {
penaltiesOptions.add(new ListElement(entity.getPenaltyId().intValue(), entity.getPenaltyName()));
}
List<ListElement> productCategoryOptions = new ArrayList<ListElement>();
List<ProductCategoryBO> productCategories = service.getActiveSavingsProductCategories();
for (ProductCategoryBO category : productCategories) {
productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName()));
}
List<ListElement> applicableForOptions = new ArrayList<ListElement>();
List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao.retrieveSavingsApplicableProductCategories();
for (PrdApplicableMasterEntity entity : applicableCustomerTypes) {
applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> savingsTypeOptions = new ArrayList<ListElement>();
List<SavingsTypeEntity> savingsTypes = this.loanProductDao.retrieveSavingsTypes();
for (SavingsTypeEntity entity : savingsTypes) {
savingsTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> recommendedAmountTypeOptions = new ArrayList<ListElement>();
List<RecommendedAmntUnitEntity> recommendedAmountTypes = this.loanProductDao.retrieveRecommendedAmountTypes();
for (RecommendedAmntUnitEntity entity : recommendedAmountTypes) {
recommendedAmountTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> interestCalcTypeOptions = new ArrayList<ListElement>();
List<InterestCalcTypeEntity> interestCalcTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
for (InterestCalcTypeEntity entity : interestCalcTypes) {
interestCalcTypeOptions.add(new ListElement(entity.getId().intValue(), entity.getName()));
}
List<ListElement> timePeriodOptions = new ArrayList<ListElement>();
List<RecurrenceTypeEntity> applicableRecurrences = savingsProductDao.getSavingsApplicableRecurrenceTypes();
for (RecurrenceTypeEntity entity : applicableRecurrences) {
timePeriodOptions.add(new ListElement(entity.getRecurrenceId().intValue(), entity.getRecurrenceName()));
}
List<GLCodeEntity> depositGlCodeList = new ArrayList<GLCodeEntity>();
depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.MANDATORYDEPOSIT, FinancialConstants.CREDIT));
depositGlCodeList.addAll(new FinancialBusinessService().getGLCodes(FinancialActionConstants.VOLUNTARYDEPOSIT, FinancialConstants.CREDIT));
List<ListElement> depositGlCodeOptions = new ArrayList<ListElement>();
for (GLCodeEntity glCode : depositGlCodeList) {
depositGlCodeOptions.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
}
List<GLCodeEntity> interestGlCodeList = new FinancialBusinessService().getGLCodes(FinancialActionConstants.SAVINGS_INTERESTPOSTING, FinancialConstants.DEBIT);
List<ListElement> interestGlCodes = new ArrayList<ListElement>();
for (GLCodeEntity glCode : interestGlCodeList) {
interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode(), glCode.getAssociatedCOA().getAccountName()));
}
return new SavingsProductFormDto(productCategoryOptions, applicableForOptions, savingsTypeOptions, recommendedAmountTypeOptions, interestCalcTypeOptions, timePeriodOptions, depositGlCodeOptions, interestGlCodes, statusOptions);
} 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.SystemException in project head by mifos.
the class CenterServiceFacadeWebTier method revertLastChargesPayment.
@Override
public void revertLastChargesPayment(String globalCustNum, String adjustmentNote) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
customerBO.updateDetails(userContext);
if (customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate() != null) {
customerBO.getCustomerAccount().updateDetails(userContext);
try {
if (customerBO.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForAdjustment(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForAdjustment(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), userContext, customerBO.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
customerBO.adjustPmnt(adjustmentNote, loggedInUser);
this.customerDao.save(customerBO);
this.transactionHelper.commitTransaction();
} catch (SystemException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
}
}
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QGFlowsServiceImpl method applyToAllLoanProducts.
@Override
public void applyToAllLoanProducts(Integer questionGroupId) throws SystemException {
LoanPrdBusinessService loanPrdBusinessService = new LoanPrdBusinessService();
try {
List<LoanOfferingBO> offerings = loanPrdBusinessService.getAllLoanOfferings((short) 1);
if (offerings.size() > 0) {
QuestionGroupReference questionGroupReference = new QuestionGroupReference();
questionGroupReference.setQuestionGroupId(questionGroupId);
for (LoanOfferingBO offering : offerings) {
offering.getQuestionGroups().add(questionGroupReference);
offering.save();
}
StaticHibernateUtil.commitTransaction();
}
} catch (ServiceException e) {
throw new SystemException(e);
} catch (ProductDefinitionException e) {
throw new SystemException(e);
}
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class QuestionGroupController method defineQuestionGroup.
@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
public String defineQuestionGroup(QuestionGroupForm questionGroupForm, RequestContext requestContext, boolean createMode) {
String result = "success";
if (!questionGroupHasErrors(questionGroupForm, requestContext)) {
QuestionGroupDetail questionGroupDetail = null;
try {
if (createMode) {
questionGroupForm.setActive(true);
}
if (questionGroupForm.isActive()) {
questionGroupDetail = questionnaireServiceFacade.createActiveQuestionGroup(questionGroupForm.getQuestionGroupDetail());
} else {
questionGroupDetail = questionnaireServiceFacade.createQuestionGroup(questionGroupForm.getQuestionGroupDetail());
}
if (containsCreateLoanEventSource(questionGroupForm.getEventSources()) && questionGroupForm.getApplyToAllLoanProducts()) {
questionnaireServiceFacade.applyToAllLoanProducts(questionGroupDetail.getId());
}
List<QuestionLinkDetail> questionLinkDetails = setFilledQuestionDetailForQuestionLinks(questionGroupForm.getQuestionLinks(), questionGroupDetail);
List<SectionLinkDetail> sectionLinkDetails = setFilledSectionDetailForQuestionLinks(questionGroupForm.getSectionLinks(), questionGroupDetail);
questionnaireServiceFacade.createQuestionLinks(questionLinkDetails);
questionnaireServiceFacade.createSectionLinks(sectionLinkDetails);
} catch (AccessDeniedException e) {
constructAndLogSystemError(requestContext.getMessageContext(), new SystemException(QuestionnaireConstants.MISSING_PERMISSION_TO_ACTIVATE_QG, e));
result = "failure";
} catch (SystemException e) {
constructAndLogSystemError(requestContext.getMessageContext(), e);
result = "failure";
}
} else {
result = "failure";
}
return result;
}
use of org.mifos.framework.exceptions.SystemException in project head by mifos.
the class Upgrade method largestLookupId.
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = { "OBL_UNSATISFIED_OBLIGATION" }, justification = "The statement and results are closed.")
@SuppressWarnings("PMD.CloseResource")
protected int largestLookupId(Connection connection) throws SQLException {
Statement statement = connection.createStatement();
ResultSet results = statement.executeQuery("select max(lookup_id) from lookup_value");
if (!results.next()) {
throw new SystemException(SystemException.DEFAULT_KEY, "Did not find an existing lookup_id in lookup_value table");
}
int largestLookupId = results.getInt(1);
results.close();
statement.close();
return largestLookupId;
}
Aggregations