Search in sources :

Example 61 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class CollectionSheetDaoHibernate method findAmountDueWhenInterestIsDueAtDibursementTime.

private Double findAmountDueWhenInterestIsDueAtDibursementTime(final Integer accountId) {
    final Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("ACCOUNT_ID", accountId);
    try {
        final Object[] loanScheduleData = (Object[]) execUniqueResultNamedQuery("findFirstLoanSchedule", queryParameters);
        final Integer loanScheduleId = Integer.valueOf(loanScheduleData[0].toString());
        final Double firstScheduledPaymentAmount = calculateAmountDueFromLoanScheduleFields(loanScheduleData);
        final Map<String, Object> feeQueryParameters = new HashMap<String, Object>();
        queryParameters.put("LOAN_SCHEDULE_ID", loanScheduleId);
        final Object[] loanScheduleFee = (Object[]) execUniqueResultNamedQuery("findLoanFeeSchedulesForALoanSchedule", feeQueryParameters);
        final Double feesDueOnLoanSchedule = calculateFeesDueOnLoanSchedule(loanScheduleFee);
        return firstScheduledPaymentAmount.doubleValue() + feesDueOnLoanSchedule.doubleValue();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : HashMap(java.util.HashMap) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 62 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeNamedQueryWithResultTransformer.

@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> nameQueryParameters, final Class<?> className) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName).setResultTransformer(Transformers.aliasToBean(className));
        query.setProperties(nameQueryParameters);
        return query.list();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 63 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeUniqueResultNamedQueryWithResultTransformer.

@Override
public final Object executeUniqueResultNamedQueryWithResultTransformer(final String queryName, final Map<String, ?> nameQueryParameters, final Class<?> className) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName).setResultTransformer(Transformers.aliasToBean(className));
        query.setProperties(nameQueryParameters);
        return query.uniqueResult();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 64 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeNamedQuery.

@SuppressWarnings("unchecked")
@Override
public final List<? extends Object> executeNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.list();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 65 with MifosRuntimeException

use of org.mifos.core.MifosRuntimeException in project head by mifos.

the class GenericDaoHibernate method executeUniqueResultNamedQuery.

@Override
public final Object executeUniqueResultNamedQuery(final String queryName, final Map<String, ?> queryParameters) {
    try {
        Session session = getSession();
        Query query = session.getNamedQuery(queryName);
        query.setProperties(queryParameters);
        return query.uniqueResult();
    } catch (Exception e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : Query(org.hibernate.Query) MifosRuntimeException(org.mifos.core.MifosRuntimeException) Session(org.hibernate.Session) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

MifosRuntimeException (org.mifos.core.MifosRuntimeException)305 PersistenceException (org.mifos.framework.exceptions.PersistenceException)136 ArrayList (java.util.ArrayList)102 BusinessRuleException (org.mifos.service.BusinessRuleException)95 UserContext (org.mifos.security.util.UserContext)94 MifosUser (org.mifos.security.MifosUser)87 AccountException (org.mifos.accounts.exceptions.AccountException)79 ServiceException (org.mifos.framework.exceptions.ServiceException)69 ApplicationException (org.mifos.framework.exceptions.ApplicationException)48 LoanBO (org.mifos.accounts.loan.business.LoanBO)41 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)39 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)37 MeetingException (org.mifos.application.meeting.exceptions.MeetingException)36 LocalDate (org.joda.time.LocalDate)35 CustomerBO (org.mifos.customers.business.CustomerBO)29 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)28 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)27 CustomerException (org.mifos.customers.exceptions.CustomerException)27 Money (org.mifos.framework.util.helpers.Money)27 AccountBO (org.mifos.accounts.business.AccountBO)25