001    /**
002     * Copyright (c) 2000-2013 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.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            public String getClassName() {
038                    return MBCategory.class.getName();
039            }
040    
041            public long getClassPK() {
042                    return _category.getPrimaryKey();
043            }
044    
045            @Override
046            public String getIconPath(ThemeDisplay themeDisplay) {
047                    return themeDisplay.getPathThemeImages() + "/common/category.png";
048            }
049    
050            public String getPortletId() {
051                    AssetRendererFactory assetRendererFactory =
052                            AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(
053                                    MBCategory.class.getName());
054    
055                    return assetRendererFactory.getPortletId();
056            }
057    
058            public String getSummary(Locale locale) {
059                    return HtmlUtil.stripHtml(_category.getDescription());
060            }
061    
062            public String getTitle(Locale locale) {
063                    return _category.getName();
064            }
065    
066            public String getType() {
067                    return TYPE;
068            }
069    
070            private MBCategory _category;
071    
072    }