[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory ...

Christian Bauer christian at hibernate.org
Mon Oct 1 15:08:04 EDT 2007


  User: cbauer  
  Date: 07/10/01 15:08:04

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory  
                        BlogDAO.java BlogDirectory.java
  Log:
  Tagging of content, JBSEAM-1851
  
  Revision  Changes    Path
  1.8       +13 -6     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDAO.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BlogDAO.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDAO.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- BlogDAO.java	25 Sep 2007 14:30:44 -0000	1.7
  +++ BlogDAO.java	1 Oct 2007 19:08:04 -0000	1.8
  @@ -27,7 +27,8 @@
                                                              long maxResults,
                                                              Integer year,
                                                              Integer month,
  -                                                           Integer day) {
  +                                                           Integer day,
  +                                                           String tag) {
   
           StringBuilder queryString = new StringBuilder();
   
  @@ -51,6 +52,7 @@
           if (year != null) queryString.append("and year(n1.createdOn) = :limitYear").append(" ");
           if (month != null) queryString.append("and month(n1.createdOn) = :limitMonth").append(" ");
           if (day != null) queryString.append("and day(n1.createdOn) = :limitDay").append(" ");
  +        if (tag != null && tag.length()>0) queryString.append("and n1.tags like :tag").append(" ");
   
           queryString.append("group by").append(" ");
           for (int i = 0; i < startNode.getTreeSuperclassPropertiesForGrouping().length; i++) {
  @@ -73,6 +75,7 @@
           if (year != null) nestedSetQuery.setParameter("limitYear", year);
           if (month != null) nestedSetQuery.setParameter("limitMonth", month);
           if (day != null) nestedSetQuery.setParameter("limitDay", day);
  +        if (tag != null && tag.length()>0) nestedSetQuery.setParameter("tag", "%" + tag + "%");
   
           nestedSetQuery.setFirstResult( new Long(firstResult).intValue() );
           nestedSetQuery.setMaxResults( new Long(maxResults).intValue() );
  @@ -81,17 +84,18 @@
           return (List<BlogEntry>)nestedSetQuery.list();
       }
   
  -    public Long countBlogEntries(Node startNode, Node ignoreNode, Integer year, Integer month, Integer day ) {
  -        return countBlogEntries(startNode, ignoreNode, false, false, false, year, month, day).get(0).getNumOfEntries();
  +    public Long countBlogEntries(Node startNode, Node ignoreNode, Integer year, Integer month, Integer day, String tag) {
  +        return countBlogEntries(startNode, ignoreNode, false, false, false, year, month, day, tag).get(0).getNumOfEntries();
       }
   
  -    public List<BlogEntryCount> countAllBlogEntriesGroupByYearMonth(Node startNode, Node ignoreNode) {
  -        return countBlogEntries(startNode, ignoreNode, true, true, false, null, null, null);
  +    public List<BlogEntryCount> countAllBlogEntriesGroupByYearMonth(Node startNode, Node ignoreNode, String tag) {
  +        return countBlogEntries(startNode, ignoreNode, true, true, false, null, null, null, tag);
       }
   
       private List<BlogEntryCount> countBlogEntries(Node startNode, Node ignoreNode,
                                                    boolean projectYear, boolean projectMonth, boolean projectDay,
  -                                                 Integer limitYear, Integer limitMonth, Integer limitDay) {
  +                                                 Integer limitYear, Integer limitMonth, Integer limitDay,
  +                                                 String tag) {
   
           StringBuilder queryString = new StringBuilder();
   
  @@ -117,6 +121,8 @@
           if (limitMonth!= null) queryString.append("and month(n1.createdOn) = :limitMonth").append(" ");
           if (limitDay != null) queryString.append("and day(n1.createdOn) = :limitDay").append(" ");
   
  +        if (tag != null && tag.length()>0) queryString.append("and n1.tags like :tag").append(" ");
  +
           if (projectYear || projectMonth || projectDay)  queryString.append("group by").append(" ");
           if (projectYear)    queryString.append("year(n1.createdOn)");
           if (projectMonth)   queryString.append(", month(n1.createdOn)");
  @@ -139,6 +145,7 @@
           if (limitYear != null) nestedSetQuery.setParameter("limitYear", limitYear);
           if (limitMonth!= null) nestedSetQuery.setParameter("limitMonth", limitMonth);
           if (limitDay != null) nestedSetQuery.setParameter("limitDay", limitDay);
  +        if (tag != null && tag.length()>0) nestedSetQuery.setParameter("tag", "%" + tag + "%");
   
           nestedSetQuery.setResultTransformer(Transformers.aliasToBean(BlogEntryCount.class));
   
  
  
  
  1.17      +18 -7     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BlogDirectory.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/blogdirectory/BlogDirectory.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -b -r1.16 -r1.17
  --- BlogDirectory.java	31 Aug 2007 13:38:13 -0000	1.16
  +++ BlogDirectory.java	1 Oct 2007 19:08:04 -0000	1.17
  @@ -16,6 +16,7 @@
   import org.jboss.seam.wiki.core.dao.NodeDAO;
   import org.jboss.seam.wiki.core.model.Directory;
   import org.jboss.seam.wiki.core.model.Document;
  +import org.jboss.seam.wiki.util.WikiUtil;
   
   import java.io.Serializable;
   import java.util.*;
  @@ -39,13 +40,11 @@
       @In
       Document currentDocument;
   
  -    @RequestParameter
  -    Boolean allEntries;
  -
       private Integer page = 0;
       private Integer year;
       private Integer month;
       private Integer day;
  +    private String tag;
   
       @RequestParameter
       public void setPage(Integer page) {
  @@ -65,6 +64,10 @@
       public void setDay(Integer day) {
           this.day = day;
       }
  +    @RequestParameter
  +    public void setTag(String tag) {
  +        this.tag = tag;
  +    }
   
       private long numOfBlogEntries;
       private long totalNumOfBlogEntries;
  @@ -92,7 +95,9 @@
       }
   
       private void queryNumOfBlogEntries() {
  -        numOfBlogEntries = blogDAO.countBlogEntries(currentDirectory, currentDocument, year, month, day);
  +        System.out.println("########## TAG: " + tag);
  +        numOfBlogEntries = blogDAO.countBlogEntries(currentDirectory, currentDocument, year, month, day, tag);
  +        System.out.println("####################### NUMBER OF BLOG ENTRIES: " + numOfBlogEntries);
       }
   
       private void queryBlogEntries() {
  @@ -104,12 +109,13 @@
                       true,
                       page * pageSize,
                       pageSize,
  -                    year, month, day
  +                    year, month, day,
  +                    tag
               );
       }
   
       private void queryBlogEntryCountsByYearAndMonth() {
  -        blogEntryCountsByYearAndMonth = blogDAO.countAllBlogEntriesGroupByYearMonth(currentDirectory, currentDocument);
  +        blogEntryCountsByYearAndMonth = blogDAO.countAllBlogEntriesGroupByYearMonth(currentDirectory, currentDocument, tag);
           for (BlogEntryCount blogEntryCount : blogEntryCountsByYearAndMonth) {
               totalNumOfBlogEntries = totalNumOfBlogEntries + blogEntryCount.getNumOfEntries();
           }
  @@ -127,7 +133,8 @@
                       true,
                       0,
                       recentBlogEntriesCount,
  -                    null, null, null
  +                    null, null, null,
  +                    null
               );
   
           // Now aggregate by day
  @@ -225,6 +232,10 @@
           return dateAsString(year, month, day);
       }
   
  +    public String getTagUrl() {
  +        return tag != null && tag.length()>0 ? "/Tag/" + WikiUtil.encodeURL(tag) : "";
  +    }
  +
       // Utilities
   
       public static String dateAsString(Integer year, Integer month, Integer day) {
  
  
  



More information about the jboss-cvs-commits mailing list