Package org.apache.roller.weblogger.pojos

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


           
            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

            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.getWeblogManager().saveWeblog(cat.getWebsite());       
View Full Code Here

        }
       
        // 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

       
        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

    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

    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

            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

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.