View Javadoc

1   package net.sourceforge.blogentis.feed;
2   
3   //-----------------------------------------------------------------------
4   // Blogentis - a blog publishing platform.
5   // Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   // This library is free software; you can redistribute it and/or
8   // modify it under the terms of the GNU Lesser General Public
9   // License as published by the Free Software Foundation; either
10  // version 2.1 of the License, or (at your option) any later version.
11  //
12  // This library is distributed in the hope that it will be useful,
13  // but WITHOUT ANY WARRANTY; without even the implied warranty of
14  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  // Lesser General Public License for more details.
16  //
17  // You should have received a copy of the GNU Lesser General Public
18  // License along with this library; if not, write to the Free Software
19  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: CommentFeed.java,v 1.1 2004/10/22 17:34:05 tassos Exp $
23  //
24  
25  import java.util.List;
26  import java.util.Map;
27  
28  import net.sourceforge.blogentis.om.CommentPeer;
29  import net.sourceforge.blogentis.om.PostPeer;
30  import net.sourceforge.blogentis.utils.AbsoluteLinkURL;
31  import net.sourceforge.blogentis.utils.BlogPropertyCache;
32  import net.sourceforge.blogentis.utils.PresentationalProperties;
33  
34  import org.apache.torque.TorqueException;
35  import org.apache.torque.util.Criteria;
36  import org.apache.turbine.util.RunData;
37  
38  /***
39   * @author abas
40   */
41  public class CommentFeed
42          extends Feed {
43      private static final String[] searchableColumns = {CommentPeer.TEXT,
44              CommentPeer.TITLE, CommentPeer.NAME};
45  
46      public CommentFeed(RunData data) {
47          super(data);
48      }
49  
50      protected PresentationalProperties getProperties() {
51          return BlogPropertyCache.getInstance().getPostProperties(pp.getBlog());
52      }
53  
54      public String getTimeColumn() {
55          return CommentPeer.POSTED_TIME;
56      }
57  
58      public String[] getSearchColumns() {
59          return searchableColumns;
60      }
61  
62      protected List getItems(Criteria c)
63              throws TorqueException {
64          c.addJoin(PostPeer.POST_ID, CommentPeer.POST_ID);
65          return CommentPeer.doSelect(c);
66      }
67  
68      protected void fixFeedDescription(Map m) {
69          AbsoluteLinkURL link = (AbsoluteLinkURL)m.get(FeedModifier.FEED_LINK);
70          if (pp.getPost() != null)
71              link.setTemplate(link.getTemplate() + "/all/comments");
72          m.put(FeedModifier.FEED_LINK, link);
73          m.put(FeedModifier.FEED_TITLE, "Comments on '"
74                  + m.get(FeedModifier.FEED_TITLE) + "'");
75      }
76  }