Search in sources :

Example 1 with FundCodeEntity

use of org.mifos.application.master.business.FundCodeEntity in project head by mifos.

the class WebTierFundServiceFacade method createFund.

@Override
public void createFund(FundDto fundDto) {
    List<FundCodeEntity> fundCodeEntities = fundDao.findAllFundCodes();
    Short fundCodeId = Short.valueOf(fundDto.getCode().getId());
    FundCodeEntity fundCode = null;
    for (FundCodeEntity fundCodeEntity : fundCodeEntities) {
        if (fundCodeEntity.getFundCodeId().equals(fundCodeId)) {
            fundCode = fundCodeEntity;
            break;
        }
    }
    FundBO fundBO = new FundBO(fundCode, fundDto.getName());
    if (this.fundDao.countOfFundByName(fundDto.getName().trim()) > 0) {
        throw new org.mifos.service.BusinessRuleException(FundConstants.DUPLICATE_FUNDNAME_EXCEPTION);
    }
    try {
        StaticHibernateUtil.startTransaction();
        this.fundDao.save(fundBO);
        StaticHibernateUtil.commitTransaction();
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new MifosRuntimeException(e.getMessage(), e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : FundCodeEntity(org.mifos.application.master.business.FundCodeEntity) BusinessRuleException(org.mifos.service.BusinessRuleException) FundBO(org.mifos.accounts.fund.business.FundBO) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with FundCodeEntity

use of org.mifos.application.master.business.FundCodeEntity in project head by mifos.

the class FundDaoHibernateIntegrationTest method shouldSaveFund.

@Test
public void shouldSaveFund() throws Exception {
    // setup
    FundCodeEntity newfundCode = new FundCodeEntity("99");
    IntegrationTestObjectMother.createFundCode(newfundCode);
    FundBO newfund = new FundBO(newfundCode, "testFundSave");
    // exercise test
    StaticHibernateUtil.startTransaction();
    fundDao.save(newfund);
    StaticHibernateUtil.flushSession();
    assertThat(newfund.getFundId(), is(notNullValue()));
}
Also used : FundCodeEntity(org.mifos.application.master.business.FundCodeEntity) FundBO(org.mifos.accounts.fund.business.FundBO) Test(org.junit.Test)

Example 3 with FundCodeEntity

use of org.mifos.application.master.business.FundCodeEntity in project head by mifos.

the class FundDaoHibernateIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() throws Exception {
    databaseCleaner.clean();
    fundCode = new FundCodeEntity("55");
    fundName = "testFund";
    fund = new FundBO(fundCode, fundName);
    IntegrationTestObjectMother.createFundCode(fundCode);
    IntegrationTestObjectMother.createFund(fund);
}
Also used : FundCodeEntity(org.mifos.application.master.business.FundCodeEntity) FundBO(org.mifos.accounts.fund.business.FundBO) Before(org.junit.Before)

Aggregations

FundBO (org.mifos.accounts.fund.business.FundBO)3 FundCodeEntity (org.mifos.application.master.business.FundCodeEntity)3 Before (org.junit.Before)1 Test (org.junit.Test)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1