1
22
23 package com.liferay.portlet.calendar.social;
24
25 import com.liferay.portal.kernel.util.StringPool;
26 import com.liferay.portal.theme.ThemeDisplay;
27 import com.liferay.portlet.calendar.model.CalEvent;
28 import com.liferay.portlet.calendar.service.CalEventLocalServiceUtil;
29 import com.liferay.portlet.social.model.BaseSocialActivityInterpreter;
30 import com.liferay.portlet.social.model.SocialActivity;
31 import com.liferay.portlet.social.model.SocialActivityFeedEntry;
32
33
39 public class CalendarActivityInterpreter extends BaseSocialActivityInterpreter {
40
41 public String[] getClassNames() {
42 return _CLASS_NAMES;
43 }
44
45 protected SocialActivityFeedEntry doInterpret(
46 SocialActivity activity, ThemeDisplay themeDisplay)
47 throws Exception {
48
49 String creatorUserName = getUserName(
50 activity.getUserId(), themeDisplay);
51
52 int activityType = activity.getType();
53
54
56 CalEvent event = CalEventLocalServiceUtil.getEvent(
57 activity.getClassPK());
58
59 String link =
60 themeDisplay.getURLPortal() + themeDisplay.getPathMain() +
61 "/calendar/find_event?eventId=" + activity.getClassPK();
62
63
65 String title = StringPool.BLANK;
66
67 if (activityType == CalendarActivityKeys.ADD_EVENT) {
68 title = themeDisplay.translate(
69 "activity-calendar-add-event", creatorUserName);
70 }
71 else if (activityType == CalendarActivityKeys.UPDATE_EVENT) {
72 title = themeDisplay.translate(
73 "activity-calendar-update-event", creatorUserName);
74 }
75
76
78 StringBuilder sb = new StringBuilder();
79
80 sb.append("<a href=\"");
81 sb.append(link);
82 sb.append("\">");
83 sb.append(cleanContent(event.getTitle()));
84 sb.append("</a><br />");
85 sb.append(cleanContent(event.getDescription()));
86
87 String body = sb.toString();
88
89 return new SocialActivityFeedEntry(link, title, body);
90 }
91
92 private static final String[] _CLASS_NAMES = new String[] {
93 CalEvent.class.getName()
94 };
95
96 }