Skip to content

Commit

Permalink
AMP-30885: Configure Internal projects for Ecowas
Browse files Browse the repository at this point in the history
  • Loading branch information
brianbrix committed Nov 3, 2024
1 parent bfb52c0 commit 0296165
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0296165

Please sign in to comment.