Search in sources :

Example 6 with ImportedFilesEntity

use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.

the class ImportedFilesServiceImpl method saveImportedFileName.

@Override
public void saveImportedFileName(String fileName, PersonnelBO submittedBy, List<AccountTrxDto> idsToUndoImport, Boolean phaseOut, Boolean undoable) {
    Timestamp submittedOn = new Timestamp(new DateTimeService().getCurrentDateTime().getMillis());
    Set<AccountTrxnEntity> accTrxEnt = new HashSet<AccountTrxnEntity>();
    ImportedFilesEntity importedFile = new ImportedFilesEntity(fileName, submittedOn, submittedBy, accTrxEnt, phaseOut, undoable);
    if (null != idsToUndoImport) {
        for (AccountTrxDto trx : idsToUndoImport) {
            accTrxEnt.add(importedFileDao.getAccTrxById(trx.getId()));
        }
        importedFile.setImportedTrxn(accTrxEnt);
    }
    try {
        hibernateTransactionHelper.startTransaction();
        importedFileDao.saveImportedFile(importedFile);
        hibernateTransactionHelper.commitTransaction();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountTrxDto(org.mifos.dto.domain.AccountTrxDto) Timestamp(java.sql.Timestamp) DateTimeService(org.mifos.framework.util.DateTimeService) ImportedFilesEntity(org.mifos.application.importexport.business.ImportedFilesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException) HashSet(java.util.HashSet) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ImportedFilesEntity (org.mifos.application.importexport.business.ImportedFilesEntity)6 Timestamp (java.sql.Timestamp)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 DateTime (org.joda.time.DateTime)1 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)1 AccountTrxDto (org.mifos.dto.domain.AccountTrxDto)1 ImportedFileDto (org.mifos.dto.screen.ImportedFileDto)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1