Examples of WeblogCategory


Examples of org.apache.roller.weblogger.pojos.WeblogCategory

       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testUser = TestUtils.getManagedUser(testUser);
        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
       
        // add some categories and entries to test with
        WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
        mgr.saveWeblogCategory(dest);
       
        WeblogCategory c1 = new WeblogCategory(testWeblog, root, "c1", null, null);
        mgr.saveWeblogCategory(c1);
       
        WeblogCategory c2 = new WeblogCategory(testWeblog, c1, "c2", null, null);
        mgr.saveWeblogCategory(c2);
       
        WeblogCategory c3 = new WeblogCategory(testWeblog, c2, "c3", null, null);
        mgr.saveWeblogCategory(c3);
       
        TestUtils.endSession(true);
       
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
        dest = mgr.getWeblogCategory(dest.getId());
       
        WeblogEntry e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
        WeblogEntry e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
        WeblogEntry e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
       
        TestUtils.endSession(true);
       
        // need to query for cats again because we closed the session
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
        dest = mgr.getWeblogCategory(dest.getId());
       
        // verify number of entries in each category
        assertEquals(0, dest.retrieveWeblogEntries(true).size());
        assertEquals(0, dest.retrieveWeblogEntries(false).size());
        assertEquals(1, c1.retrieveWeblogEntries(false).size());
        assertEquals(3, c1.retrieveWeblogEntries(true).size());
       
        // move contents of source category c1 to destination catetory dest
        mgr.moveWeblogCategory(c1, dest);
        TestUtils.endSession(true);
       
        // after move, verify number of entries in each category
        dest = mgr.getWeblogCategory(dest.getId());
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
       
        assertEquals(3, dest.retrieveWeblogEntries(true).size());
        assertEquals(0, dest.retrieveWeblogEntries(false).size());
       
        assertEquals(dest, c1.getParent());
        assertEquals(c1,   c2.getParent());
        assertEquals(c2,   c3.getParent());
       
        assertEquals(1, c1.retrieveWeblogEntries(false).size());
        assertEquals(1, c2.retrieveWeblogEntries(false).size());
        assertEquals(1, c3.retrieveWeblogEntries(false).size());
       
        List entries = c1.retrieveWeblogEntries(true);
        assertEquals(3, entries.size());
    }
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

       
        WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testUser = TestUtils.getManagedUser(testUser);
        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
       
        // add some categories and entries to test with
        WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
        mgr.saveWeblogCategory(dest);
       
        WeblogCategory c1 = new WeblogCategory(testWeblog, root, "c1", null, null);
        mgr.saveWeblogCategory(c1);
       
        WeblogCategory c2 = new WeblogCategory(testWeblog, c1, "c2", null, null);
        mgr.saveWeblogCategory(c2);
       
        WeblogCategory c3 = new WeblogCategory(testWeblog, c2, "c3", null, null);
        mgr.saveWeblogCategory(c3);
       
        TestUtils.endSession(true);
       
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
        dest = mgr.getWeblogCategory(dest.getId());
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testUser = TestUtils.getManagedUser(testUser);
        WeblogEntry e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
        WeblogEntry e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
        WeblogEntry e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
       
        TestUtils.endSession(true);
       
        // need to query for cats again since session was closed
        c1 = mgr.getWeblogCategory(c1.getId());
        c2 = mgr.getWeblogCategory(c2.getId());
        c3 = mgr.getWeblogCategory(c3.getId());
        dest = mgr.getWeblogCategory(dest.getId());
       
        // verify number of entries in each category
        assertEquals(0, dest.retrieveWeblogEntries(true).size());
        assertEquals(0, dest.retrieveWeblogEntries(false).size());
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

                    allCategories.add(cat);
                }
            }
           
            // build category path
            WeblogCategory parent = getCategory().getParent();
            if(parent != null) {
                List categoryPath = new LinkedList();
                categoryPath.add(0, getCategory());
                while (parent != null) {
                    categoryPath.add(0, parent);
                    parent = parent.getParent();
                }
                setCategoryPath(categoryPath);
            }
        } catch (WebloggerException ex) {
            log.error("Error building categories list", ex);
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

           
            log.debug("Moving categories to category - "+getTargetCategoryId());
           
            // Move subCategories to new category.
            String[] cats = getSelectedCategories();
            WeblogCategory parent = wmgr.getWeblogCategory(getTargetCategoryId());
            if(cats != null) {
                for (int i = 0; i < cats.length; i++) {
                    WeblogCategory cd =
                            wmgr.getWeblogCategory(cats[i]);
                   
                    // Don't move category into itself.
                    if (!cd.getId().equals(parent.getId()) &&
                            !parent.descendentOf(cd)) {
                        wmgr.moveWeblogCategory(cd, parent);
                    } else {
                        addMessage("categoriesForm.warn.notMoving", cd.getName());
                    }
                }
               
                // flush changes
                WebloggerFactory.getWeblogger().flush();
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

            if (isDuplicateWeblogCategoryName(cat)) {
                throw new WebloggerException("Duplicate category name, cannot save category");
            }
            // Newly added object. If it has a parent,
            // maintain relationship from both sides
            WeblogCategory parent = cat.getParent();
            if(parent != null) {
                parent.getWeblogCategories().add(cat);
            }
        }
       
        // update weblog last modified date.  date updated by saveWebsite()
        roller.getUserManager().saveWebsite(cat.getWebsite());       
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

        }
       
        // remove cat
        this.strategy.remove(cat);
        //relationship management for the other side
        WeblogCategory parent = cat.getParent();
        if(parent != null) {
            parent.getWeblogCategories().remove(cat);
        }
       
        // update website default cats if needed
        if(cat.getWebsite().getBloggerCategory().equals(cat)) {
            WeblogCategory rootCat = this.getRootWeblogCategory(cat.getWebsite());
            cat.getWebsite().setBloggerCategory(rootCat);
            this.strategy.store(cat.getWebsite());
        }
       
        if(cat.getWebsite().getDefaultCategory().equals(cat)) {
            WeblogCategory rootCat = this.getRootWeblogCategory(cat.getWebsite());
            cat.getWebsite().setDefaultCategory(rootCat);
            this.strategy.store(cat.getWebsite());
        }
       
        // update weblog last modified date.  date updated by saveWebsite()
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

        // validation
        myValidate();
       
        if(!hasActionErrors()) try {
           
            WeblogCategory newCategory = new WeblogCategory(
                    getActionWeblog(),
                    getCategory(),
                    getBean().getName(),
                    getBean().getDescription(),
                    getBean().getImage());
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

       
        log.debug("Moving category "+srcCat.getPath() +
                " under "+destCat.getPath());
       
       
        WeblogCategory oldParent = srcCat.getParent();
        if(oldParent != null) {
            oldParent.getWeblogCategories().remove(srcCat);
        }
        srcCat.setParent(destCat);
        destCat.getWeblogCategories().add(srcCat);
       
        if("/".equals(destCat.getPath())) {
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

    private void updatePathTree(WeblogCategory cat)
    throws WebloggerException {
       
        log.debug("Updating path tree for category "+cat.getPath());
       
        WeblogCategory childCat = null;
        Iterator childCats = cat.getWeblogCategories().iterator();
        while(childCats.hasNext()) {
            childCat = (WeblogCategory) childCats.next();
           
            log.debug("OLD child category path was "+childCat.getPath());
           
            // update path and save
            if("/".equals(cat.getPath())) {
                childCat.setPath("/" + childCat.getName());
            } else {
                childCat.setPath(cat.getPath() + "/" + childCat.getName());
            }
            saveWeblogCategory(childCat);
           
            log.debug("NEW child category path is "+ childCat.getPath());
           
            // then make recursive call to update this cats children
            updatePathTree(childCat);
        }
    }
View Full Code Here

Examples of org.apache.roller.weblogger.pojos.WeblogCategory

    public List getNextPrevEntries(WeblogEntry current, String catName,
            String locale, int maxEntries, boolean next)
            throws WebloggerException {
        Query query = null;
        List results = null;
        WeblogCategory category = null;
       
        if (catName != null && !catName.trim().equals("/")) {
            category = getWeblogCategoryByPath(current.getWebsite(), null,
                    catName);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.