001
014
015 package com.liferay.portlet.social.service.impl;
016
017 import com.liferay.portal.theme.ThemeDisplay;
018 import com.liferay.portal.util.PortalUtil;
019 import com.liferay.portlet.social.model.SocialActivity;
020 import com.liferay.portlet.social.model.SocialActivityFeedEntry;
021 import com.liferay.portlet.social.model.SocialActivityInterpreter;
022 import com.liferay.portlet.social.model.impl.SocialActivityInterpreterImpl;
023 import com.liferay.portlet.social.service.base.SocialActivityInterpreterLocalServiceBaseImpl;
024
025 import java.util.ArrayList;
026 import java.util.List;
027
028
031 public class SocialActivityInterpreterLocalServiceImpl
032 extends SocialActivityInterpreterLocalServiceBaseImpl {
033
034 public void addActivityInterpreter(
035 SocialActivityInterpreter activityInterpreter) {
036
037 _activityInterpreters.add(activityInterpreter);
038 }
039
040 public void deleteActivityInterpreter(
041 SocialActivityInterpreter activityInterpreter) {
042
043 if (activityInterpreter != null) {
044 _activityInterpreters.remove(activityInterpreter);
045 }
046 }
047
048 public SocialActivityFeedEntry interpret(
049 SocialActivity activity, ThemeDisplay themeDisplay) {
050
051 if (activity.getMirrorActivityId() > 0) {
052 SocialActivity mirrorActivity = null;
053
054 try {
055 mirrorActivity = socialActivityLocalService.getActivity(
056 activity.getMirrorActivityId());
057 }
058 catch (Exception e) {
059 }
060
061 if (mirrorActivity != null) {
062 activity = mirrorActivity;
063 }
064 }
065
066 String className = PortalUtil.getClassName(activity.getClassNameId());
067
068 for (int i = 0; i < _activityInterpreters.size(); i++) {
069 SocialActivityInterpreterImpl activityInterpreter =
070 (SocialActivityInterpreterImpl)_activityInterpreters.get(i);
071
072 if (activityInterpreter.hasClassName(className)) {
073 SocialActivityFeedEntry activityFeedEntry =
074 activityInterpreter.interpret(activity, themeDisplay);
075
076 if (activityFeedEntry != null) {
077 activityFeedEntry.setPortletId(
078 activityInterpreter.getPortletId());
079
080 return activityFeedEntry;
081 }
082 }
083 }
084
085 return null;
086 }
087
088 private List<SocialActivityInterpreter> _activityInterpreters =
089 new ArrayList<SocialActivityInterpreter>();
090
091 }