use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class UpdateDocumentController method onClick$btnAddAuthor.
@Listen("onClick = #btnAddAuthor")
public void onClick$btnAddAuthor(Event event) {
LOG.debug("onClick$btnAddAuthor");
try {
int authorId = 0;
Comboitem selectedItem = cmbAuthors.getSelectedItem();
if (selectedItem != null)
authorId = (Integer) selectedItem.getValue();
if (authorId != 0) {
LOG.debug("authorId: " + authorId);
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
Author author = documentDao.loadAuthor(authorId);
if (!this.currentDoc.getAuthors().contains(author)) {
this.currentDoc.getAuthors().add(author);
ListModelList<Author> model = new ListModelList<Author>(this.currentDoc.getAuthors(), true);
lstAuthors.setModel(model);
}
}
} catch (Exception e) {
LOG.error("Failure in onClick$btnAddAuthor", e);
throw new RuntimeException(e);
}
}
use of com.joliciel.jochre.doc.DocumentDao in project jochre by urieli.
the class Jochre method doCommandUpdateImages.
/**
* Update the images in an existing Jochre document.
*
* @param filename
* the PDF file containing the images
* @param docId
* the id of the document to update
* @param pŠ°ges
* the pages to process, empty means all
*/
public void doCommandUpdateImages(String filename, int docId, Set<Integer> pages) {
if (filename.length() == 0)
throw new RuntimeException("Missing argument: file");
if (docId < 0)
throw new RuntimeException("Missing argument: docId");
DocumentDao documentDao = DocumentDao.getInstance(jochreSession);
JochreDocument doc = documentDao.loadJochreDocument(docId);
if (filename.toLowerCase().endsWith(".pdf")) {
File pdfFile = new File(filename);
PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor(pdfFile, pages, new PdfImageUpdater(doc));
pdfDocumentProcessor.process();
} else {
throw new RuntimeException("Unrecognised file extension");
}
}
Aggregations