1 | package clarin.cmdi.componentregistry.rss; |
---|
2 | |
---|
3 | import clarin.cmdi.componentregistry.DatesHelper; |
---|
4 | import clarin.cmdi.componentregistry.model.Comment; |
---|
5 | import java.util.Comparator; |
---|
6 | import java.util.List; |
---|
7 | |
---|
8 | /** |
---|
9 | * |
---|
10 | * @author olhsha |
---|
11 | */ |
---|
12 | public class RssCreatorComments extends RssCreator<Comment> { |
---|
13 | |
---|
14 | /** |
---|
15 | * |
---|
16 | * @param isPrivate if "true" then profiles and components from the user's |
---|
17 | * workspace, otherwise -- public (uri-parameter) |
---|
18 | * @param baseURI where the database is located |
---|
19 | * @param limit number of items to be displayed (uri-parameter) |
---|
20 | * @param descriptionId Id of the profile/component whose comments are |
---|
21 | * considered |
---|
22 | * @param descriptionName Name of the profile/component whose comments are |
---|
23 | * considered |
---|
24 | * @param descriptionType "profile" or "component" |
---|
25 | * @param comms the list of comments from which the list of rss-items for |
---|
26 | * the channel will be created |
---|
27 | * @param comparator compare comments by dates |
---|
28 | */ |
---|
29 | public RssCreatorComments(boolean isPrivate, String baseURI, int limit, |
---|
30 | String descriptionId, String descriptionName, String descriptionType, List<Comment> comms, Comparator<Comment> comparator) { |
---|
31 | super(isPrivate, baseURI, limit, comms); |
---|
32 | setChannelLink(baseURI + "?item=" + descriptionId + ((isPrivate) ? "&space=user" : "") + "&browserview=comments"); |
---|
33 | setChannelTitle((isPrivate ? "Private " : "Public ") + descriptionType + " \"" + descriptionName + "\""); |
---|
34 | setChannelDescription(String.format("Comments feed for the %s \"%s\"", descriptionType, descriptionName)); |
---|
35 | setComparator(comparator); |
---|
36 | } |
---|
37 | |
---|
38 | @Override |
---|
39 | protected RssItem fromArgToRssItem(Comment comm) { |
---|
40 | final String itemLink = getChannelLink() + "&commentId=" + comm.getId(); |
---|
41 | RssItem retval = new RssItem(); |
---|
42 | retval.setDescription(comm.getComment()); |
---|
43 | retval.setGuid(makeGuid(itemLink)); |
---|
44 | retval.setLink(itemLink); |
---|
45 | retval.setPubDate(DatesHelper.getRFCDateTime(comm.getCommentDate())); |
---|
46 | retval.setTitle(String.format("Comment %1$s\nby %2$s", comm.getId(), comm.getUserName())); |
---|
47 | return retval; |
---|
48 | } |
---|
49 | } |
---|