1 package net.sourceforge.blogentis.feed;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 }