001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.messageboards.trash;
016    
017    import com.liferay.portal.kernel.trash.BaseTrashRenderer;
018    import com.liferay.portal.kernel.util.HtmlUtil;
019    import com.liferay.portal.theme.ThemeDisplay;
020    import com.liferay.portlet.asset.AssetRendererFactoryRegistryUtil;
021    import com.liferay.portlet.asset.model.AssetRendererFactory;
022    import com.liferay.portlet.messageboards.model.MBCategory;
023    
024    import java.util.Locale;
025    
026    /**
027     * @author Eduardo Garcia
028     */
029    public class MBCategoryTrashRenderer extends BaseTrashRenderer {
030    
031            public static final String TYPE = "category";
032    
033            public MBCategoryTrashRenderer(MBCategory category) {
034                    _category = category;
035            }
036    
037            @Override
038            public String getClassName() {
039                    return MBCategory.class.getName();
040            }
041    
042            @Override
043            public long getClassPK() {
044                    return _category.getPrimaryKey();
045            }
046    
047            @Override
048            public String getIconPath(ThemeDisplay themeDisplay) {
049                    return themeDisplay.getPathThemeImages() + "/common/category.png";
050            }
051    
052            @Override
053            public String getPortletId() {
054                    AssetRendererFactory assetRendererFactory =
055                            AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
056                                    MBCategory.class.getName());
057    
058                    return assetRendererFactory.getPortletId();
059            }
060    
061            @Override
062            public String getSummary(Locale locale) {
063                    return HtmlUtil.stripHtml(_category.getDescription());
064            }
065    
066            @Override
067            public String getTitle(Locale locale) {
068                    return _category.getName();
069            }
070    
071            @Override
072            public String getType() {
073                    return TYPE;
074            }
075    
076            private MBCategory _category;
077    
078    }