mirror of
https://github.com/sismics/docs.git
synced 2025-12-15 02:36:24 +00:00
Order of files attached to document
This commit is contained in:
@@ -80,32 +80,12 @@ public class FileDao {
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the content of a file.
|
||||
* Update a file.
|
||||
*
|
||||
* @param file File to update
|
||||
* @return Updated file
|
||||
*/
|
||||
public File updateContent(File file) {
|
||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||
|
||||
// Get the file
|
||||
Query q = em.createQuery("select f from File f where f.id = :id and f.deleteDate is null");
|
||||
q.setParameter("id", file.getId());
|
||||
File fileFromDb = (File) q.getSingleResult();
|
||||
|
||||
// Update the file
|
||||
fileFromDb.setContent(file.getContent());
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the document of a file.
|
||||
*
|
||||
* @param file File to update
|
||||
* @return Updated file
|
||||
*/
|
||||
public File updateDocument(File file) {
|
||||
public File update(File file) {
|
||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||
|
||||
// Get the file
|
||||
@@ -115,6 +95,8 @@ public class FileDao {
|
||||
|
||||
// Update the file
|
||||
fileFromDb.setDocumentId(file.getDocumentId());
|
||||
fileFromDb.setContent(file.getContent());
|
||||
fileFromDb.setOrder(file.getOrder());
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public class FileCreatedAsyncListener {
|
||||
final File file = fileCreatedAsyncEvent.getFile();
|
||||
long startTime = System.currentTimeMillis();
|
||||
final String content = FileUtil.extractContent(fileCreatedAsyncEvent.getDocument(), file, fileCreatedAsyncEvent.getInputStream());
|
||||
fileCreatedAsyncEvent.getInputStream().close();
|
||||
log.info(MessageFormat.format("File content extracted in {0}ms", System.currentTimeMillis() - startTime));
|
||||
|
||||
// Store the OCR-ization result in the database
|
||||
@@ -48,7 +49,7 @@ public class FileCreatedAsyncListener {
|
||||
public void run() {
|
||||
FileDao fileDao = new FileDao();
|
||||
file.setContent(content);
|
||||
fileDao.updateContent(file);
|
||||
fileDao.update(file);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user