Package net.stinfoservices.pacifiq.server.model

Examples of net.stinfoservices.pacifiq.server.model.Document


        return dto;
    }

    @Override
    public DocumentDTO findDocument(Long id) throws Exception {
        Document document = documentDAO.find(id);
        DocumentDTO documentDTO = new DocumentDTO(document, DTOPath.DOCUMENT_DOC);
        return documentDTO;
    }
View Full Code Here


        }

        dsp5.getRelatedDocuments().clear();
        if (dto.getRelatedDocuments() != null) {
            for (Long documentId : dto.getRelatedDocuments().keySet()) {
                Document document = documentDAO.find(documentId);
                dsp5.getRelatedDocuments().add(document);
            }
        }

        dsp5.getRelatedLicenses().clear();
View Full Code Here

        }

        taa.getRelatedDocuments().clear();
        if (dto.getDocuments() != null) {
            for (Long docId : dto.getDocuments().keySet()) {
                Document doc = documentDAO.find(docId);
                taa.getRelatedDocuments().add(doc);
            }
        }

        taa.getParties().clear();
View Full Code Here

     * @throws Exception
     *             if an error occurs in the DAO while requesting the database.
     */
    private void applyDiffTCN(TCN tcn, TCNDTO dto) throws Exception {
        tcn.setFreeText(dto.getFreeText());
        Document doc = documentDAO.find(dto.getDocument().getId());
        tcn.setDocument(doc);
    }
View Full Code Here

    DocumentDAO documentDAO;

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("name");
        Document document;
        try {
            document = documentDAO.findByName(name);
            if (document == null) {
                // Pb
                throw new NullPointerException();
            } else {
                /* Code for download */

                String filename = document.getFilename();
                String fileType = filename.substring(filename.indexOf(".") + 1, filename.length());

                if (fileType.trim().equalsIgnoreCase("txt")) {
                    response.setContentType("text/plain");
                } else if (fileType.trim().equalsIgnoreCase("doc")) {
                    response.setContentType("application/msword");
                } else if (fileType.trim().equalsIgnoreCase("xls")) {
                    response.setContentType("application/vnd.ms-excel");
                } else if (fileType.trim().equalsIgnoreCase("pdf")) {
                    response.setContentType("application/pdf");
                } else if (fileType.trim().equalsIgnoreCase("ppt")) {
                    response.setContentType("application/ppt");
                } else {
                    response.setContentType("application/octet-stream");
                }

                response.setHeader("Content-Disposition", "buffer; filename=\"" + filename + "\"");
                response.setHeader("cache-control", "no-cache");
                byte[] fileBytes = document.getBuffer();

                ServletOutputStream outs = response.getOutputStream();
                outs.write(fileBytes);
                outs.flush();
                outs.close();
View Full Code Here

    @DatabaseSetup(value = DATASET_DOCUMENT_DOCUMENT)
    @ExpectedDatabase(value = DATASET_DOCUMENT_DOCUMENT, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = DATASET_DOCUMENT_DOCUMENT, type = DatabaseOperation.DELETE)
    @Test
    public void testClone() throws Exception {
        Document doc = documentDAO.find(1L);
        assertNotNull(doc);

        DocumentDTO dto = new DocumentDTO(doc, DTOPath.DOCUMENT_DOC);
        DocumentDTO dtoClone = dto.clone();
        assertEquals(dtoClone.getName(), dto.getName());
View Full Code Here

    @DatabaseSetup(value = DATASET_DOCUMENT_DOCUMENT)
    @ExpectedDatabase(value = DATASET_DOCUMENT_DOCUMENT, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = DATASET_DOCUMENT_DOCUMENT, type = DatabaseOperation.DELETE)
    @Test
    public void testSerialize() throws Exception {
        Document doc = documentDAO.find(1L);
        assertNotNull(doc);
        DocumentDTO dto = new DocumentDTO(doc, DTOPath.DOCUMENT_DOC);

        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bytes);
View Full Code Here

    @Test
    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFind() throws Exception {
        Document document = documentDAO.find(1L);
        Document documentc = new Document();

        documentc.setId(1L);
        documentc.setName(UPDATED_DOCUMENT_NAME);
        documentc.setVersion(2);
        assertNotNull(document);
        assertSame(2, document.getVersion());
        assertEquals(documentc.getName(), document.getName());
        assertEquals(documentc, document);
        assertNull(documentDAO.find(2L));
        assertNull(documentDAO.find(0L));
    }
View Full Code Here

    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFindAll() throws Exception {
        List<Document> documents = documentDAO.findAll();
        Document document = new Document();

        document.setId(1L);
        document.setName(UPDATED_DOCUMENT_NAME);
        document.setVersion(2);
        assertSame(1, documents.size());
        assertNotNull(documents.get(0));
        assertEquals(documents.get(0), document);
    }
View Full Code Here

    @DatabaseSetup(value = UPDATE_DATASET)
    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testFindEntries() throws Exception {
        List<Document> documents = documentDAO.findEntries(0, 1);
        Document document = new Document();

        document.setId(1L);
        document.setName(UPDATED_DOCUMENT_NAME);
        document.setVersion(2);
        assertSame(1, documents.size());
        assertNotNull(documents.get(0));
        assertEquals(documents.get(0), document);
        documents = documentDAO.findEntries(0, 0);
        assertSame(0, documents.size());
View Full Code Here

TOP

Related Classes of net.stinfoservices.pacifiq.server.model.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.