Search in sources :

Example 6 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class ReportsPersistence method deleteReportsParamsMap.

/**
     * Deletes a link between report and a parameter
     */
public void deleteReportsParamsMap(ReportsParamsMapValue reportsParamsMapValue) throws ApplicationException, SystemException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        StaticHibernateUtil.startTransaction();
        session.delete(reportsParamsMapValue);
        session.flush();
        StaticHibernateUtil.commitTransaction();
    } catch (HibernateProcessException hpe) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ApplicationException(hpe);
    } catch (HibernateException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 7 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class ReportsPersistence method deleteReportParams.

public void deleteReportParams(ReportsParamsValue reportsParams) throws ApplicationException, SystemException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        StaticHibernateUtil.startTransaction();
        session.delete(reportsParams);
        session.flush();
        StaticHibernateUtil.commitTransaction();
    } catch (HibernateProcessException hpe) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ApplicationException(hpe);
    } catch (HibernateException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 8 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class ReportsPersistence method updateReportsJasperMap.

/**
     * sets a link between report and a jasper file
     */
public void updateReportsJasperMap(ReportsJasperMap reportsJasperMap) throws ApplicationException, SystemException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        StaticHibernateUtil.startTransaction();
        session.update(reportsJasperMap);
        session.flush();
        StaticHibernateUtil.commitTransaction();
    } catch (HibernateProcessException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ApplicationException(e);
    } catch (HibernateException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new ReportException(ReportsConstants.CREATE_FAILED_EXCEPTION, e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) HibernateException(org.hibernate.HibernateException) ReportException(org.mifos.reports.exceptions.ReportException) SystemException(org.mifos.framework.exceptions.SystemException) ReportException(org.mifos.reports.exceptions.ReportException) HibernateProcessException(org.mifos.framework.exceptions.HibernateProcessException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) HibernateException(org.hibernate.HibernateException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) Session(org.hibernate.Session)

Example 9 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class QuestionnaireValidatorImpl method validateForDefineQuestionGroup.

@Override
public void validateForDefineQuestionGroup(QuestionGroupDto questionGroupDto, boolean withDuplicateQuestionTextCheck) {
    ValidationException parentException = new ValidationException(GENERIC_VALIDATION);
    validateQuestionGroupTitle(questionGroupDto, parentException);
    List<EventSourceDto> eventSourceDtos = questionGroupDto.getEventSourceDtos();
    if (eventSourceDtos == null || eventSourceDtos.size() == 0) {
        throw new SystemException(INVALID_EVENT_SOURCE);
    } else {
        for (EventSourceDto eventSourceDto : eventSourceDtos) {
            validateEventSource(eventSourceDto, parentException);
        }
    }
    validateSections(questionGroupDto.getSections(), parentException, withDuplicateQuestionTextCheck);
    if (parentException.hasChildExceptions()) {
        throw parentException;
    }
}
Also used : ValidationException(org.mifos.platform.validations.ValidationException) SystemException(org.mifos.framework.exceptions.SystemException) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 10 with SystemException

use of org.mifos.framework.exceptions.SystemException in project head by mifos.

the class QuestionnaireServiceTest method shouldThrowValidationExceptionWhenQuestionTitleIsNull.

@SuppressWarnings({ "ThrowableInstanceNeverThrown" })
@Test(expected = SystemException.class)
public void shouldThrowValidationExceptionWhenQuestionTitleIsNull() throws SystemException {
    QuestionDetail questionDefinition = new QuestionDetail(null, QuestionType.INVALID);
    doThrow(new SystemException(QuestionnaireConstants.QUESTION_TEXT_NOT_PROVIDED)).when(questionnaireValidator).validateForDefineQuestion(questionDefinition);
    questionnaireService.defineQuestion(questionDefinition);
    verify(questionnaireValidator).validateForDefineQuestion(questionDefinition);
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Aggregations

SystemException (org.mifos.framework.exceptions.SystemException)53 Test (org.junit.Test)21 ApplicationException (org.mifos.framework.exceptions.ApplicationException)13 QuestionDetail (org.mifos.platform.questionnaire.service.QuestionDetail)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 SectionQuestionDetail (org.mifos.platform.questionnaire.service.SectionQuestionDetail)10 HibernateException (org.hibernate.HibernateException)7 Session (org.hibernate.Session)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 HibernateProcessException (org.mifos.framework.exceptions.HibernateProcessException)7 ReportException (org.mifos.reports.exceptions.ReportException)7 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 BusinessRuleException (org.mifos.service.BusinessRuleException)4 IOException (java.io.IOException)3 ResultSet (java.sql.ResultSet)3 Statement (java.sql.Statement)3 ArrayList (java.util.ArrayList)3 MessageMatcher (org.mifos.platform.matchers.MessageMatcher)3 EventSourceDto (org.mifos.platform.questionnaire.service.dtos.EventSourceDto)3 PreparedStatement (java.sql.PreparedStatement)2