Search in sources :

Example 6 with DocumentDao

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);
    }
}
Also used : ListModelList(org.zkoss.zul.ListModelList) Author(com.joliciel.jochre.doc.Author) Comboitem(org.zkoss.zul.Comboitem) DocumentDao(com.joliciel.jochre.doc.DocumentDao) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 7 with DocumentDao

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");
    }
}
Also used : PdfDocumentProcessor(com.joliciel.jochre.pdf.PdfDocumentProcessor) DocumentDao(com.joliciel.jochre.doc.DocumentDao) JochreDocument(com.joliciel.jochre.doc.JochreDocument) File(java.io.File)

Aggregations

DocumentDao (com.joliciel.jochre.doc.DocumentDao)7 Author (com.joliciel.jochre.doc.Author)3 Comboitem (org.zkoss.zul.Comboitem)3 JochreSession (com.joliciel.jochre.JochreSession)2 JochreDocument (com.joliciel.jochre.doc.JochreDocument)2 Session (org.zkoss.zk.ui.Session)2 Listen (org.zkoss.zk.ui.select.annotation.Listen)2 ListModelList (org.zkoss.zul.ListModelList)2 JochrePage (com.joliciel.jochre.doc.JochrePage)1 GraphicsDao (com.joliciel.jochre.graphics.GraphicsDao)1 JochreImage (com.joliciel.jochre.graphics.JochreImage)1 PdfDocumentProcessor (com.joliciel.jochre.pdf.PdfDocumentProcessor)1 User (com.joliciel.jochre.security.User)1 AuthorListItemRenderer (com.joliciel.jochre.web.DocumentController.AuthorListItemRenderer)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 DefaultTreeModel (org.zkoss.zul.DefaultTreeModel)1 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)1 TreeNode (org.zkoss.zul.TreeNode)1