[2289] | 1 | package clarin.cmdi.componentregistry.rss; |
---|
[2222] | 2 | |
---|
[2296] | 3 | import clarin.cmdi.componentregistry.DatesHelper; |
---|
[2222] | 4 | import clarin.cmdi.componentregistry.model.Comment; |
---|
[2291] | 5 | import java.util.Comparator; |
---|
[2289] | 6 | import java.util.List; |
---|
[2222] | 7 | |
---|
| 8 | /** |
---|
| 9 | * |
---|
| 10 | * @author olhsha |
---|
| 11 | */ |
---|
| 12 | public class RssCreatorComments extends RssCreator<Comment> { |
---|
[2296] | 13 | |
---|
[2287] | 14 | /** |
---|
| 15 | * |
---|
[5549] | 16 | * @param isPrivate if "true" then profiles and components from the user's |
---|
[2296] | 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 |
---|
[2287] | 28 | */ |
---|
[5549] | 29 | public RssCreatorComments(boolean isPrivate, String baseURI, int limit, |
---|
[2291] | 30 | String descriptionId, String descriptionName, String descriptionType, List<Comment> comms, Comparator<Comment> comparator) { |
---|
[5549] | 31 | super(isPrivate, baseURI, limit, comms); |
---|
| 32 | setChannelLink(baseURI + "?item=" + descriptionId + ((isPrivate) ? "&space=user" : "") + "&browserview=comments"); |
---|
| 33 | setChannelTitle((isPrivate ? "Private " : "Public ") + descriptionType + " \"" + descriptionName + "\""); |
---|
[2292] | 34 | setChannelDescription(String.format("Comments feed for the %s \"%s\"", descriptionType, descriptionName)); |
---|
| 35 | setComparator(comparator); |
---|
[2296] | 36 | } |
---|
| 37 | |
---|
[2287] | 38 | @Override |
---|
[2296] | 39 | protected RssItem fromArgToRssItem(Comment comm) { |
---|
| 40 | final String itemLink = getChannelLink() + "&commentId=" + comm.getId(); |
---|
[2289] | 41 | RssItem retval = new RssItem(); |
---|
[2296] | 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; |
---|
[2222] | 48 | } |
---|
| 49 | } |
---|