Package net.stinfoservices.pacifiq.server.model

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


    public void testSave() throws Exception {
        try {
            DatabaseConnection connection = new DatabaseConnection(dataSource.getConnection());
            IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(this.getClass().getResource("/dbunit/dao/admin/document-create_no-id.xml")
                    .openStream());
            Document document = new Document();
            Document ndocument;

            document.setId(null);
            document.setName(DEFAULT_DOCUMENT_NAME);
            document.setVersion(1);
            ndocument = documentDAO.save(document);
            assertNotNull(ndocument);
            assertEquals(ndocument.getName(), document.getName());
            entityManager.getTransaction().commit();
            DatabaseAssertionMode.NON_STRICT.getDatabaseAssertion().assertEquals(expectedDataSet,
                    connection.createDataSet(expectedDataSet.getTableNames()));
            connection.close();
        } catch (DatabaseUnitException e) {
View Full Code Here


    @DatabaseTearDown(value = UPDATE_DATASET, type = DatabaseOperation.DELETE_ALL)
    public void testSave2() throws Exception {
        try {
            DatabaseConnection connection = new DatabaseConnection(dataSource.getConnection());
            IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(this.getClass().getResource(UPDATE_DATASET).openStream());
            Document document = new Document();
            Document ndocument;

            document.setId(1L);
            document.setName(UPDATED_DOCUMENT_NAME);
            document.setVersion(1);
            ndocument = documentDAO.save(document);
            assertNotNull(ndocument);
            assertEquals(ndocument.getName(), document.getName());
            entityManager.getTransaction().commit();
            DatabaseAssertionMode.NON_STRICT.getDatabaseAssertion().assertEquals(expectedDataSet,
                    connection.createDataSet(expectedDataSet.getTableNames()));
            connection.close();
        } catch (DatabaseUnitException e) {
View Full Code Here

    @DatabaseSetup(value = CREATE_DATASET)
    @ExpectedDatabase(value = EMPTY_DATASET, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = EMPTY_DATASET, type = DatabaseOperation.DELETE)
    @Override
    public void testRemove() throws Exception {
        Document document = new Document();

        document.setId(1L);
        document.setName(DEFAULT_DOCUMENT_NAME);
        document.setVersion(1);
        documentDAO.remove(document);
    }
View Full Code Here

    @Test
    @DatabaseSetup(value = UPDATE_DATASET)
    @ExpectedDatabase(value = EMPTY_DATASET, assertionMode = DatabaseAssertionMode.NON_STRICT)
    @DatabaseTearDown(value = EMPTY_DATASET, type = DatabaseOperation.DELETE)
    public void testRemove2() throws Exception {
        Document document = new Document();

        document.setId(1L);
        document.setName(UPDATED_DOCUMENT_NAME);
        document.setVersion(2);
        documentDAO.remove(document);
    }
View Full Code Here

        }

        try {
            List<Document> result = entityManager.createQuery("SELECT o FROM " + IModel.DATABASE_PRE + "Document o WHERE o.name = :name")
                    .setParameter("name", name).getResultList();
            Document d = null;

            if (result.size() > 0) {
                d = result.get(0);
            }
View Full Code Here

        if (document == null) {
            return (null);
        }

        try {
            Document d = entityManager.merge(document);

            entityManager.persist(d);
            d = entityManager.find(Document.class, d.getId());
            LOGGER.info(MessageFormat.format(ResourceBundle.getBundle("system").getString("OBJECT_SAVED"), this.getClass().getSimpleName(),
                    d.getName()));

            return (d);
        } catch (Exception ex) {
            throw new CustomException(ex);
        }
View Full Code Here

        if (document == null) {
            return;
        }

        try {
            Document ndocument = entityManager.merge(document);

            entityManager.remove(ndocument);
            LOGGER.info(MessageFormat.format(ResourceBundle.getBundle("system").getString("OBJECT_DELETED"), this.getClass().getSimpleName(),
                    ndocument.getName()));
        } catch (Exception ex) {
            throw new CustomException(ex);
        }
    }
View Full Code Here

    }

    @Override
    @Transactional(readOnly = false)
    public void updateName(Long id, String name) throws Exception {
        Document doc = documentDAO.find(id);

        doc.setName(name);
        documentDAO.save(doc);
    }
View Full Code Here

    }

    @Override
    @Transactional(readOnly = false)
    public void updateDescription(Long id, String description) throws Exception {
        Document doc = documentDAO.find(id);

        doc.setDescription(description);
        documentDAO.save(doc);
    }
View Full Code Here

    }

    @Override
    @Transactional(readOnly = false)
    public void updateDate(Long id, Date date) throws Exception {
        Document doc = documentDAO.find(id);

        doc.setDate(date);
        documentDAO.save(doc);
    }
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.