Package org.jboss.seam.wiki.core.model

Examples of org.jboss.seam.wiki.core.model.WikiDirectory


    public void loadDirectoryById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();
                assert d.getName().equals("AAA");
            }
        }.run();
    }
View Full Code Here


    public void getDirectoryPath() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 4l)
                                .getSingleResult();
                assert d.getName().equals("DDD");
                assert d.getPath().size() == 3;
                assert d.getPath().get(0).getId().equals(1l);
                assert d.getPath().get(1).getId().equals(3l);
                assert d.getPath().get(2).getId().equals(4l);
            }
        }.run();
    }
View Full Code Here

    public void updateDirectoryById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();
                d.setName("AAA2");
                em.flush();

                em.clear();
                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();
                assert d.getName().equals("AAA2");
            }
        }.run();
    }
View Full Code Here

    public void insertDirectoryById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                WikiDirectory newDir = new WikiDirectory();
                newDir.setName("FFF");
                newDir.setWikiname("FFF");
                newDir.setAreaNumber(d.getAreaNumber());
                newDir.setCreatedBy(em.find(User.class, 1l));
                newDir.setParent(d);

                em.persist(newDir);
                em.flush();

                em.clear();
                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();
                assert d.getName().equals("AAA");

                em.clear();
                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();
                assert d.getName().equals("CCC");

                em.clear();
                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", newDir.getId())
                                .getSingleResult();
                assert d.getName().equals("FFF");
            }
        }.run();
    }
View Full Code Here

    public void findParents() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 4l)
                                .getSingleResult();

                List<WikiDirectory> parents = d.getParentsRecursive();

                Assert.assertEquals(parents.size(), 2);
                Assert.assertEquals(parents.get(0).getId(), new Long(3));
                Assert.assertEquals(parents.get(1).getId(), new Long(1));
            }
        }.run();

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                List<WikiDirectory> parents = d.getParentsRecursive();

                Assert.assertEquals(parents.size(), 1);
                Assert.assertEquals(parents.get(0).getId(), new Long(1));
            }
        }.run();
View Full Code Here

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);

                FaqBrowserDAO dao = (FaqBrowserDAO)getInstance(FaqBrowserDAO.class);

                // Start in a subdirectory of the FAQ root
                WikiDirectory faqSubDir = nodeDAO.findWikiDirectory(302l);
                WikiDirectory root = dao.findFaqRootDir(faqSubDir);
                assert root.getId().equals(300l);

                // Start in the root directory (should be the same)
                WikiDirectory faqDir = nodeDAO.findWikiDirectory(300l);
                root = dao.findFaqRootDir(faqDir);
                assert root.getId().equals(300l);

            }
        }.run();
View Full Code Here

    public void insertDocumentById() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                WikiDocument newDoc = new WikiDocument();
                newDoc.setName("Four");
                newDoc.setWikiname("Four");
                newDoc.setAreaNumber(d.getAreaNumber());
                newDoc.setCreatedBy(em.find(User.class, 1l));
                newDoc.setContent("Testdocument Four");
                newDoc.setParent(d);

                em.persist(newDoc);
                em.flush();

                em.clear();
                WikiDocument doc = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", newDoc.getId())
                                .getSingleResult();
                assert doc.getName().equals("Four");
                assert doc.getParent().getId().equals(d.getId());
                assert doc.getAreaNumber().equals(d.getAreaNumber());
                assert doc.getLastModifiedBy() == null;
                assert doc.getLastModifiedOn() == null;
            }
        }.run();
    }
View Full Code Here

    // Loads the same instance into a different persistence context
    @Factory(value = "restrictedWikiRoot", scope = ScopeType.PAGE, autoCreate = true)
    public WikiDirectory loadWikiRootRestricted() {
        log.debug("loading wiki root into restricted PC");
        EntityManager em = (EntityManager)Component.getInstance("restrictedEntityManager");
        WikiDirectory wikiroot = (WikiDirectory) Component.getInstance("wikiRoot");
        try {
            return (WikiDirectory) em
                    .createQuery("select d from WikiDirectory d left join fetch d.feed where d.id = :id")
                    .setParameter("id", wikiroot.getId())
                    .setHint("org.hibernate.comment", "Loading wikiRootRestricted")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
        } catch (RuntimeException ex) {
            throw new RuntimeException("You need to INSERT at least one parentless directory into the database", ex);
View Full Code Here

        if (!database.equals(Database.MYSQL)) return;

        new FacesRequest() {
            protected void invokeApplication() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(100l);

                ForumDAO dao = (ForumDAO)getInstance(ForumDAO.class);

                Map<Long, ForumInfo> forums = dao.findForums(forumDir);
View Full Code Here

        loginMember();

        new FacesRequest() {
            protected void invokeApplication() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(100l);

                ForumDAO dao = (ForumDAO)getInstance(ForumDAO.class);

                Map<Long, ForumInfo> forums = dao.findForums(forumDir);
View Full Code Here

TOP

Related Classes of org.jboss.seam.wiki.core.model.WikiDirectory

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.