Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogCategoryData


        perms.setPending(false);
        perms.setPermissionMask(PermissionsData.ADMIN);
        this.strategy.store(perms);
       
        // add default categories
        WeblogCategoryData rootCat = new WeblogCategoryData(
                null,      // id
                newWeblog, // newWeblog
                null,      // parent
                "root",    // name
                "root",    // description
                null );    // image
        this.strategy.store(rootCat);
       
        String cats = RollerConfig.getProperty("newuser.categories");
        WeblogCategoryData firstCat = rootCat;
        if (cats != null) {
            String[] splitcats = cats.split(",");
            for (int i=0; i<splitcats.length; i++) {
                WeblogCategoryData c = new WeblogCategoryData(
                        null,            // id
                        newWeblog,       // newWeblog
                        rootCat,         // parent
                        splitcats[i],    // name
                        splitcats[i],    // description
View Full Code Here


        RollerRequest rreq = RollerRequest.getRollerRequest(request);
        WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
        WeblogCategoryFormEx form = (WeblogCategoryFormEx)actionForm;
       
        BasePageModel pageModel = null;
        WeblogCategoryData parentCat = null;
        if (null!=rreq.getWeblogCategory() && null==request.getParameter("correct"))
        {
            // If request specifies Category and we are not correcting an
            // already submitted form then load that Category into the form.
            WeblogCategoryData cd = rreq.getWeblogCategory();
            form.copyFrom(cd, request.getLocale());
            request.setAttribute("state","edit");
                            
            parentCat = cd.getParent();           
            pageModel = new BasePageModel(
                "categoryForm.edit.title", request, response, mapping);
            pageModel.setWebsite(cd.getWebsite());
        }
        else if (null != request.getParameter("correct"))
        {
            // We are correcting a previously submtted form.
            // already submitted form then load that Category into the form.
            WeblogCategoryData cd = rreq.getWeblogCategory();
            request.setAttribute("state","correcting");   
           
            parentCat = wmgr.getWeblogCategory(cd.getId());         
            pageModel = new BasePageModel(
                "categoryForm.correct.title", request, response, mapping);
            pageModel.setWebsite(cd.getWebsite());
        }
        else
        {
            // We are adding a new Category
            request.setAttribute("state","add");
           
            String pid = request.getParameter(RequestConstants.PARENT_ID);
            parentCat = wmgr.getWeblogCategory(pid);            
            form.setParentId(parentCat.getId());
           
            pageModel = new BasePageModel(
                "categoryForm.add.title", request, response, mapping);
            pageModel.setWebsite(parentCat.getWebsite());
        }
       
        // Build cat path for display on page
        if (null != parentCat)
        {
            LinkedList categoryPath = new LinkedList();
            categoryPath.add(0, parentCat);
            WeblogCategoryData parent = parentCat.getParent();
            while (parent != null)
            {
                categoryPath.add(0, parent);
                parent = parent.getParent();  
            }
            request.setAttribute("parentCategory", parentCat);
            request.setAttribute("categoryPath", categoryPath);
        }
       
View Full Code Here

       
        RollerContext rollerCtx = RollerContext.getRollerContext( );
       
        WebsiteData weblog = null;
        WeblogEntryData entry = null;
        WeblogCategoryData category = null;
        Template page = null;
        FolderData folder = null// don't even know how this is involved :/
        Date date = null;
        boolean isDay = false;
        boolean isMonth = false;
View Full Code Here

            if(entry != null) {
                weblog = entry.getWebsite();
            }
        } else if (request.getParameter(RequestConstants.WEBLOGCATEGORY_ID) != null) {
            String catId = request.getParameter(RequestConstants.WEBLOGCATEGORY_ID);
            WeblogCategoryData cat = roller.getWeblogManager().getWeblogCategory(catId);
            if(cat != null) {
                weblog = cat.getWebsite();
            }
        } else if (request.getParameter(RequestConstants.FOLDER_ID) != null) {
            String folderId = request.getParameter(RequestConstants.FOLDER_ID);
            FolderData folder = roller.getBookmarkManager().getFolder(folderId);
            if(folder != null) {
View Full Code Here

            ret = (List)mCategories.get("zzz_null_zzz");
        }
       
        if (null == ret) {
            try {
                WeblogCategoryData category = null;
                if (categoryName != null) {
                    category = mWeblogMgr.getWeblogCategoryByPath(
                            mWebsite, null, categoryName);
                } else {
                    category = mWebsite.getDefaultCategory();
                }
               
                List mRet = category.getWeblogCategories();
               
                // wrap pojos
                ret = new ArrayList(mRet.size());
                Iterator it = mRet.iterator();
                int i=0;
View Full Code Here

     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testWeblogCategoryCRUD() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
        WeblogCategoryData cat = null;
        List cats = null;
       
        // we need to know how many categories we start the test with
        int numCats = mgr.getRootWeblogCategory(testWeblog).getWeblogCategories().size();
       
        // add a new category
        WeblogCategoryData newCat = new WeblogCategoryData();
        newCat.setName("catTestCategory");
        newCat.setParent(testWeblog.getDefaultCategory());
        newCat.setWebsite(testWeblog);
        mgr.saveWeblogCategory(newCat);
        String id = newCat.getId();
        TestUtils.endSession(true);
       
        // make sure category was added
        cat = null;
        cat = mgr.getWeblogCategory(id);
View Full Code Here

    }
   
   
    public void testWeblogCategoryPaths() throws Exception {
       
        WeblogCategoryData root = null;
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        root = mgr.getRootWeblogCategory(testWeblog);
       
        WeblogCategoryData f1 = new WeblogCategoryData();
        f1.setName("f1");
        f1.setParent(root);
        f1.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f1);
       
        WeblogCategoryData f2 = new WeblogCategoryData();
        f2.setName("f2");
        f2.setParent(f1);
        f2.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f2);
       
        WeblogCategoryData f3 = new WeblogCategoryData();
        f3.setName("f3");
        f3.setParent(f2);
        f3.setWebsite(testWeblog);
        mgr.saveWeblogCategory(f3);
       
        TestUtils.endSession(true);
       
        // check count of descendents and ancestors
        f1 = mgr.getWeblogCategory(f1.getId());
        assertEquals(2, f1.getAllDescendentAssocs().size());
        assertEquals(1, f1.getAncestorAssocs().size());
       
        f2 = mgr.getWeblogCategory(f2.getId());
        assertEquals(1, f2.getAllDescendentAssocs().size());
        assertEquals(2, f2.getAncestorAssocs().size());
       
        f3 = mgr.getWeblogCategory(f3.getId());
        assertEquals(0, f3.getAllDescendentAssocs().size());
        assertEquals(3, f3.getAncestorAssocs().size());
       
        // test get by path
        assertEquals("f1",
                mgr.getWeblogCategoryByPath(testWeblog, null, "f1").getName());
       
View Full Code Here

    public void testMoveWeblogCategory() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        // add some categories and entries to test with
        WeblogCategoryData dest = new WeblogCategoryData();
        dest.setName("c0");
        dest.setParent(mgr.getRootWeblogCategory(testWeblog));
        dest.setWebsite(testWeblog);
        mgr.saveWeblogCategory(dest);
       
        WeblogCategoryData c1 = new WeblogCategoryData();
        c1.setName("c1");
        c1.setParent(mgr.getRootWeblogCategory(testWeblog));
        c1.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c1);
       
        WeblogCategoryData c2 = new WeblogCategoryData();
        c2.setName("c2");
        c2.setParent(c1);
        c2.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c2);
       
        WeblogCategoryData c3 = new WeblogCategoryData();
        c3.setName("c3");
        c3.setParent(c2);
        c3.setWebsite(testWeblog);
        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());
       
        WeblogEntryData e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
        WeblogEntryData e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
        WeblogEntryData e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
       
        TestUtils.endSession(true);
       
        // 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
        c1.setParent(dest);
        mgr.saveWeblogCategory(c1);
        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

    public void testMoveWeblogCategoryContents() throws Exception {
       
        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
       
        // add some categories and entries to test with
        WeblogCategoryData dest = new WeblogCategoryData();
        dest.setName("c0");
        dest.setParent(mgr.getRootWeblogCategory(testWeblog));
        dest.setWebsite(testWeblog);
        mgr.saveWeblogCategory(dest);
       
        WeblogCategoryData c1 = new WeblogCategoryData();
        c1.setName("c1");
        c1.setParent(mgr.getRootWeblogCategory(testWeblog));
        c1.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c1);
       
        WeblogCategoryData c2 = new WeblogCategoryData();
        c2.setName("c2");
        c2.setParent(c1);
        c2.setWebsite(testWeblog);
        mgr.saveWeblogCategory(c2);
       
        WeblogCategoryData c3 = new WeblogCategoryData();
        c3.setName("c3");
        c3.setParent(c2);
        c3.setWebsite(testWeblog);
        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());
       
        WeblogEntryData e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
        WeblogEntryData e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
        WeblogEntryData e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.WeblogCategoryData

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.