Search in sources :

Example 46 with SystemException

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

the class QuestionnaireValidatorImpl method validateForDefineQuestionGroup.

@Override
public void validateForDefineQuestionGroup(QuestionGroupDetail questionGroupDetail) throws SystemException {
    validateQuestionGroupTitle(questionGroupDetail);
    validateQuestionGroupSections(questionGroupDetail.getSectionDetails());
    List<EventSourceDto> eventSourceDtos = questionGroupDetail.getEventSources();
    if (eventSourceDtos == null || eventSourceDtos.size() == 0) {
        throw new SystemException(INVALID_EVENT_SOURCE);
    } else {
        for (EventSourceDto eventSourceDto : eventSourceDtos) {
            validateForEventSource(eventSourceDto);
        }
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) EventSourceDto(org.mifos.platform.questionnaire.service.dtos.EventSourceDto)

Example 47 with SystemException

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

the class QuestionnaireServiceTest method shouldDefineQuestionWithAnswerChoices.

@Test
public void shouldDefineQuestionWithAnswerChoices() throws SystemException {
    ChoiceDto choice1 = new ChoiceDto("choice1");
    ChoiceDto choice2 = new ChoiceDto("choice2");
    List<ChoiceDto> answerChoices = asList(choice1, choice2);
    QuestionDetail questionDefinition = new QuestionDetail(QUESTION_TITLE, QuestionType.MULTI_SELECT);
    questionDefinition.setAnswerChoices(answerChoices);
    try {
        QuestionDetail questionDetail = questionnaireService.defineQuestion(questionDefinition);
        verify(questionDao, times(1)).saveOrUpdate(any(QuestionEntity.class));
        Assert.assertNotNull(questionDetail);
        Assert.assertEquals(QUESTION_TITLE, questionDetail.getText());
        Assert.assertEquals(QuestionType.MULTI_SELECT, questionDetail.getType());
        Assert.assertEquals(choice1.getValue(), questionDetail.getAnswerChoices().get(0).getValue());
        Assert.assertEquals(choice2.getValue(), questionDetail.getAnswerChoices().get(1).getValue());
    } catch (SystemException e) {
        Assert.fail("Should not have thrown the validation exception");
    }
    verify(questionnaireValidator).validateForDefineQuestion(questionDefinition);
    verify(questionDao).saveOrUpdate(any(QuestionEntity.class));
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) ChoiceDto(org.mifos.platform.questionnaire.service.dtos.ChoiceDto) QuestionDetail(org.mifos.platform.questionnaire.service.QuestionDetail) SectionQuestionDetail(org.mifos.platform.questionnaire.service.SectionQuestionDetail) Test(org.junit.Test)

Example 48 with SystemException

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

the class TestObjectFactory method createSavingsProduct.

public static SavingsOfferingBO createSavingsProduct(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus status, final Double recommendedAmount, final RecommendedAmountUnit recommendedAmountUnit, final Double intRate, final Double maxAmtWithdrawl, final Double minAmtForInt, final SavingsType savingsType, final InterestCalcType interestCalculationType, final MeetingBO intCalcMeeting, final MeetingBO intPostMeeting, final Short depGLCode, final Short withGLCode) {
    GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, depGLCode);
    GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, withGLCode);
    ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, SAMPLE_CATEGORY);
    PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
    SavingsTypeEntity savingsTypeEntity = new SavingsTypeEntity(savingsType);
    InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(interestCalculationType);
    RecommendedAmntUnitEntity amountUnit = new RecommendedAmntUnitEntity(recommendedAmountUnit);
    SavingsOfferingBO product;
    try {
        product = new SavingsOfferingBO(TestUtils.makeUserWithLocales(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, amountUnit, savingsTypeEntity, intCalType, intCalcMeeting, intPostMeeting, TestUtils.createMoney(recommendedAmount), TestUtils.createMoney(maxAmtWithdrawl), TestUtils.createMoney(minAmtForInt), intRate, depglCodeEntity, intglCodeEntity);
    } catch (ProductDefinitionException e) {
        throw new RuntimeException(e);
    } catch (SystemException e) {
        throw new RuntimeException(e);
    }
    PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(status);
    product.setPrdStatus(prdStatus);
    return (SavingsOfferingBO) testObjectPersistence.persist(product);
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) SystemException(org.mifos.framework.exceptions.SystemException) ProductCategoryBO(org.mifos.accounts.productdefinition.business.ProductCategoryBO) InterestCalcTypeEntity(org.mifos.accounts.productdefinition.business.InterestCalcTypeEntity) ProductDefinitionException(org.mifos.accounts.productdefinition.exceptions.ProductDefinitionException) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity) PrdStatusEntity(org.mifos.accounts.productdefinition.business.PrdStatusEntity) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) PrdApplicableMasterEntity(org.mifos.accounts.productdefinition.business.PrdApplicableMasterEntity)

Example 49 with SystemException

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

the class ReportsPersistence method deleteReportsDataSource.

public void deleteReportsDataSource(ReportsDataSource reportsDataSource) throws ApplicationException, SystemException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        StaticHibernateUtil.startTransaction();
        session.delete(reportsDataSource);
        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 50 with SystemException

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

the class ReportsPersistence method createReportsParamsMap.

/**
     * Creates a link between a report and a parameter
     */
public void createReportsParamsMap(ReportsParamsMapValue reportsParamsMapValue) throws ApplicationException, SystemException {
    Session session = null;
    try {
        session = StaticHibernateUtil.getSessionTL();
        StaticHibernateUtil.startTransaction();
        session.save(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)

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