use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method undoFullImport.
@Override
public void undoFullImport(String importTransactionsFileName) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
TreeSet<String> accountsWithAdjustedPayments = new TreeSet<String>();
try {
ImportedFilesEntity filesEntity = this.importedFilesService.getImportedFileByName(importTransactionsFileName);
List<AccountTrxnEntity> trxUndo = new ArrayList<AccountTrxnEntity>(filesEntity.getImportedTrxn());
List<ImportedAccPaymentDto> accPaymentList = new ArrayList<ImportedAccPaymentDto>();
for (AccountTrxnEntity trxn : trxUndo) {
try {
validateForAdjustedPayments(trxn, accountsWithAdjustedPayments);
accPaymentList.add(new ImportedAccPaymentDto(trxn.getAccount().getGlobalAccountNum(), trxn.getAccountPayment().getPaymentId()));
} catch (BusinessRuleException e) {
//nothing to do
}
}
for (ImportedAccPaymentDto accDto : accPaymentList) {
try {
this.accountServiceFacade.applyHistoricalAdjustment(accDto.getGlobalNum(), accDto.getPaymentId(), IMPORT_UNDONE, userContext.getId(), null);
} catch (MifosRuntimeException e) {
// TODO: validation will be added with MIFOS-5779
}
}
this.importedFilesService.saveImportedFileName(filesEntity.getFileName(), filesEntity.getSubmittedBy(), null, Boolean.TRUE, filesEntity.getUndoable());
} catch (Exception e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method isAlreadyImported.
@Override
public boolean isAlreadyImported(String importTransactionsFileName) {
ImportedFilesEntity importedFile = importedFilesService.getImportedFileByName(importTransactionsFileName);
if (importedFile != null) {
logger.debug(importTransactionsFileName + " has already been submitted");
logger.debug("Submitted by" + importedFile.getSubmittedBy());
logger.debug("Submitted on" + importedFile.getSubmittedOn());
return true;
}
return false;
}
use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.
the class ImportedFilesDaoHibernateIntegrationTest method testSaveConstraintVoilation.
/**
* ignoring as can't get first
*/
@Test(expected = MifosRuntimeException.class)
public void testSaveConstraintVoilation() throws Exception {
Short personnelId = new Short("1");
PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
Timestamp timeStamp = new Timestamp(123134554L);
String fileName = "testFile.xls";
ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
StaticHibernateUtil.startTransaction();
importedFilesDao.saveImportedFile(expected);
StaticHibernateUtil.flushSession();
ImportedFilesEntity shouldViolateConstraint = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
importedFilesDao.saveImportedFile(shouldViolateConstraint);
StaticHibernateUtil.flushSession();
}
use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.
the class ImportedFilesDaoHibernateIntegrationTest method testSaveAndFind.
@Test
public void testSaveAndFind() throws Exception {
Short personnelId = new Short("1");
PersonnelBO personnelBO = TestObjectFactory.getPersonnel(personnelId);
Timestamp timeStamp = new Timestamp(123134554L);
String fileName = "testFile.xls";
ImportedFilesEntity expected = new ImportedFilesEntity(fileName, timeStamp, personnelBO, null, false, false);
StaticHibernateUtil.startTransaction();
importedFilesDao.saveImportedFile(expected);
StaticHibernateUtil.flushSession();
ImportedFilesEntity actual = importedFilesDao.findImportedFileByName(fileName);
Assert.assertEquals(fileName, actual.getFileName());
Assert.assertEquals(personnelId, actual.getSubmittedBy().getPersonnelId());
Assert.assertEquals(timeStamp, actual.getSubmittedOn());
}
use of org.mifos.application.importexport.business.ImportedFilesEntity in project head by mifos.
the class ImportTransactionsServiceFacadeWebTier method getImportedFiles.
@Override
public List<ImportedFileDto> getImportedFiles() {
List<ImportedFileDto> importedFilesDto = new ArrayList<ImportedFileDto>();
List<ImportedFilesEntity> importedFiles = this.importedFilesService.getImportedFiles();
DateTime date;
for (ImportedFilesEntity fileEntity : importedFiles) {
date = new DateTime(fileEntity.getSubmittedOn().getTime());
importedFilesDto.add(new ImportedFileDto(fileEntity.getFileName(), date, fileEntity.getPhaseOut(), fileEntity.getUndoable()));
}
return importedFilesDto;
}
Aggregations