Package org.apache.roller.weblogger.pojos

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


    public void saveWeblogEntry(WeblogEntry entry) throws WebloggerException {

        if (entry.getCategory() == null) {

            // Entry is invalid without category, so use weblog client cat
            WeblogCategory cat = entry.getWebsite().getBloggerCategory();
            if (cat == null) {
                // Sill no category, so use first one found
                cat = (WeblogCategory)
                    entry.getWebsite().getWeblogCategories().iterator().next();
            }
View Full Code Here

      return Collections.emptyList();
    }

        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

            String      sortOrder,
            String      locale,
            int         offset,
            int         length) throws WebloggerException {
       
        WeblogCategory cat = null;
        if (StringUtils.isNotEmpty(catName) && website != null) {
            cat = getWeblogCategoryByPath(website, catName);
            if (cat == null) catName = null;
        }
        if (catName != null && catName.trim().equals("/")) {
            catName = null;
        }
       
        List params = new ArrayList();
        int size = 0;
        StringBuffer queryString = new StringBuffer();
       
        //queryString.append("SELECT e FROM WeblogEntry e WHERE ");
        if (tags == null || tags.size()==0) {
            queryString.append("SELECT e FROM WeblogEntry e WHERE ");
        } else {
            queryString.append("SELECT e FROM WeblogEntry e JOIN e.tags t WHERE ");
            queryString.append("(");
            for(int i = 0; i < tags.size(); i++) {
                if (i != 0) queryString.append(" OR ");
                params.add(size++, tags.get(i));
                queryString.append(" t.name = ?").append(size);               
            }
            queryString.append(") AND ");
        }
       
        if (website != null) {
            params.add(size++, website.getId());
            queryString.append("e.website.id = ?").append(size);
        } else {
            params.add(size++, Boolean.TRUE);
            queryString.append("e.website.enabled = ?").append(size);
        }
       
        /*if (tags != null && tags.size() > 0) {
            // A JOIN with WeblogEntryTag in parent quert will cause a DISTINCT in SELECT clause
            // WeblogEntry has a clob field and many databases do not link DISTINCT for CLOB fields
            // Hence as a workaround using corelated EXISTS query.
            queryString.append(" AND EXISTS (SELECT t FROM WeblogEntryTag t WHERE "
                    + " t.weblogEntry = e AND t.name IN (");
            final String PARAM_SEPERATOR = ", ";
            for(int i = 0; i < tags.size(); i++) {
                params.add(size++, tags.get(i));
                queryString.append("?").append(size).append(PARAM_SEPERATOR);
            }
            // Remove the trailing PARAM_SEPERATOR
            queryString.delete(queryString.length() - PARAM_SEPERATOR.length(),
                    queryString.length());

            // Close the brace FOR IN clause and EXIST clause
            queryString.append(" ) )");
        }*/

        if (user != null) {
            params.add(size++, user.getUserName());
            queryString.append(" AND e.creatorUserName = ?").append(size);
        }
       
        if (startDate != null) {
            Timestamp start = new Timestamp(startDate.getTime());
            params.add(size++, start);
            queryString.append(" AND e.pubTime >= ?").append(size);
        }
       
        if (endDate != null) {
            Timestamp end = new Timestamp(endDate.getTime());
            params.add(size++, end);
            queryString.append(" AND e.pubTime <= ?").append(size);
        }
       
        if (cat != null && website != null) {
            params.add(size++, cat.getId());
            queryString.append(" AND e.category.id = ?").append(size);
        }
               
        if (status != null) {
            params.add(size++, status);
View Full Code Here

     */
    public boolean isDuplicateWeblogCategoryName(WeblogCategory cat)
    throws WebloggerException {
       
        // ensure that no sibling categories share the same name
        WeblogCategory parent = cat.getParent();
        if (null != parent) {
            return (getWeblogCategoryByPath(
                    cat.getWebsite(), cat.getPath()) != null);
        }
       
View Full Code Here

            return true;
        }
       
        Iterator cats = cat.getWeblogCategories().iterator();
        while (cats.hasNext()) {
            WeblogCategory childCat = (WeblogCategory)cats.next();
            if (childCat.isInUse()) {
                return true;
            }
        }
       
        if (cat.getWebsite().getBloggerCategory().equals(cat)) {
View Full Code Here

                                                         String name,
                                                         WeblogCategory parent)
            throws Exception {
       
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
        WeblogCategory root = mgr.getRootWeblogCategory(weblog);
       
        WeblogCategory catParent = root;
        if(parent != null) {
            catParent = parent;
        }
        WeblogCategory testCat = new WeblogCategory(weblog, catParent, name, null, null);
        mgr.saveWeblogCategory(testCat);
       
        // flush to db
        WebloggerFactory.getWeblogger().flush();
       
        // query for object
        WeblogCategory cat = mgr.getWeblogCategory(testCat.getId());
       
        if(cat == null)
            throw new WebloggerException("error setting up weblog category");
       
        return cat;
View Full Code Here

     */
    public static void teardownWeblogCategory(String id) throws Exception {
       
        // lookup the cat
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
        WeblogCategory cat = mgr.getWeblogCategory(id);
       
        // remove the cat
        mgr.removeWeblogCategory(cat);
       
        // flush to db
View Full Code Here

        entry.setText(getText());
        entry.setTagsAsString(getTagsAsString());
       
        // figure out the category selected
        if (getCategoryId() != null) {
            WeblogCategory cat = null;
            try {
                WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
                cat = wmgr.getWeblogCategory(getCategoryId());
            } catch (WebloggerException ex) {
                log.error("Error getting category by id", ex);
            }
           
            if(cat == null) {
                throw new WebloggerException("Category could not be found - "+getCategoryId());
            } else if(!entry.getWebsite().equals(cat.getWebsite())) {
                throw new WebloggerException("Illegal category, not owned by action weblog");
            } else {
                entry.setCategory(cat);
            }
        } else {
View Full Code Here

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

TOP

Related Classes of org.apache.roller.weblogger.pojos.WeblogCategory

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.