From 02961658c13fea44c9e633f19c247b6aab3bb2c0 Mon Sep 17 00:00:00 2001 From: brianbrix Date: Sun, 3 Nov 2024 20:58:19 +0300 Subject: [PATCH] AMP-30885: Configure Internal projects for Ecowas --- .../dataimporter/util/ImportedFileUtil.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/amp/WEB-INF/src/org/digijava/module/aim/action/dataimporter/util/ImportedFileUtil.java b/amp/WEB-INF/src/org/digijava/module/aim/action/dataimporter/util/ImportedFileUtil.java index 50f3935b9c4..15ff57dd023 100644 --- a/amp/WEB-INF/src/org/digijava/module/aim/action/dataimporter/util/ImportedFileUtil.java +++ b/amp/WEB-INF/src/org/digijava/module/aim/action/dataimporter/util/ImportedFileUtil.java @@ -36,30 +36,14 @@ public static String generateSHA256Hash(File file) throws IOException, NoSuchAlg public static ImportedFilesRecord saveFile(File file, String filename) throws IOException, NoSuchAlgorithmException { Session session = PersistenceManager.getRequestDBSession(); - String generatedHash = generateSHA256Hash(file); logger.info("Saving File hash is " + generatedHash); - - String sql = "INSERT INTO imported_files_record (id, file_hash, import_status, file_name) VALUES (nextval('IMPORTED_FILES_RECORD_SEQ'), :fileHash, :importStatus, :fileName) RETURNING id"; - Query query = session.createSQLQuery(sql); - query.setParameter("fileHash", generatedHash); - query.setParameter("importStatus", ImportStatus.UPLOADED); - query.setParameter("fileName", filename); - -// query.executeUpdate(); - - Long newId = ((Number) query.uniqueResult()).longValue(); - - - - - // Return the record with the populated ID ImportedFilesRecord importedFilesRecord = new ImportedFilesRecord(); - importedFilesRecord.setId(newId); importedFilesRecord.setFileHash(generatedHash); importedFilesRecord.setImportStatus(ImportStatus.UPLOADED); importedFilesRecord.setFileName(filename); - + session.saveOrUpdate(importedFilesRecord); + session.flush(); return importedFilesRecord; }