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();
}
}
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()));
}
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);
}
Aggregations