use of com.xpn.xwiki.plugin.activitystream.plugin.ActivityEvent in project xwiki-platform by xwiki.
the class DefaultWatchListEventFeedManager method getFeed.
@Override
@SuppressWarnings("unchecked")
public SyndFeed getFeed(String user, int entryNumber) throws XWikiException {
XWikiContext context = contextProvider.get();
Collection<String> wikis = store.getWatchedElements(user, WatchedElementType.WIKI);
Collection<String> spaces = store.getWatchedElements(user, WatchedElementType.SPACE);
Collection<String> documents = store.getWatchedElements(user, WatchedElementType.DOCUMENT);
List<Object> parameters = new ArrayList<Object>();
ActivityStreamPluginApi asApi = (ActivityStreamPluginApi) context.getWiki().getPluginApi("activitystream", context);
parameters.addAll(wikis);
parameters.addAll(spaces);
parameters.addAll(documents);
Transformer transformer = new ConstantTransformer("?");
List<String> wikisPlaceholders = ListUtils.transformedList(new ArrayList<String>(), transformer);
wikisPlaceholders.addAll(wikis);
List<String> spacesPlaceholders = ListUtils.transformedList(new ArrayList<String>(), transformer);
spacesPlaceholders.addAll(spaces);
List<String> documentsPlaceholders = ListUtils.transformedList(new ArrayList<String>(), transformer);
documentsPlaceholders.addAll(documents);
String listItemsJoint = ",";
String concatWiki = " or concat(act.wiki,'";
String query = "1=0";
if (!wikis.isEmpty()) {
query += " or act.wiki in (" + StringUtils.join(wikisPlaceholders, listItemsJoint) + ')';
}
if (!spaces.isEmpty()) {
query += concatWiki + DefaultWatchListStore.WIKI_SPACE_SEP + "',act.space) in (" + StringUtils.join(spacesPlaceholders, listItemsJoint) + ')';
}
if (!documents.isEmpty()) {
query += concatWiki + DefaultWatchListStore.WIKI_SPACE_SEP + "',act.page) in (" + StringUtils.join(documentsPlaceholders, listItemsJoint) + ')';
}
List<ActivityEvent> events = asApi.searchEvents(query, false, true, entryNumber, 0, parameters);
SyndFeed feed = asApi.getFeed(events);
setFeedMetaData(feed, context);
return feed;
}
Aggregations