001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.social.kernel.util;
016    
017    import com.liferay.portal.kernel.service.ServiceContext;
018    import com.liferay.social.kernel.model.SocialActivity;
019    import com.liferay.social.kernel.model.SocialActivityFeedEntry;
020    import com.liferay.social.kernel.model.SocialActivitySet;
021    import com.liferay.social.kernel.service.SocialActivityInterpreterLocalServiceUtil;
022    
023    /**
024     * @author Adolfo P??rez
025     */
026    public class SocialActivityDescriptor {
027    
028            public SocialActivityDescriptor(SocialActivity activity) {
029                    _activity = activity;
030                    _activitySet = null;
031            }
032    
033            public SocialActivityDescriptor(SocialActivitySet activitySet) {
034                    _activity = null;
035                    _activitySet = activitySet;
036            }
037    
038            public long getCreateDate() {
039                    if (_activity != null) {
040                            return _activity.getCreateDate();
041                    }
042    
043                    return _activitySet.getCreateDate();
044            }
045    
046            public long getUserId() {
047                    if (_activity != null) {
048                            return _activity.getUserId();
049                    }
050    
051                    return _activitySet.getUserId();
052            }
053    
054            public SocialActivityFeedEntry interpret(
055                    String selector, ServiceContext serviceContext) {
056    
057                    if (_activity != null) {
058                            return SocialActivityInterpreterLocalServiceUtil.interpret(
059                                    selector, _activity, serviceContext);
060                    }
061    
062                    return SocialActivityInterpreterLocalServiceUtil.interpret(
063                            selector, _activitySet, serviceContext);
064            }
065    
066            private final SocialActivity _activity;
067            private final SocialActivitySet _activitySet;
068    
069    }