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.taglib.ui;
016    
017    import com.liferay.portlet.asset.model.AssetTag;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import java.util.ArrayList;
021    import java.util.List;
022    
023    import javax.portlet.PortletURL;
024    
025    import javax.servlet.http.HttpServletRequest;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class AssetTagsSummaryTag<R> extends IncludeTag {
031    
032            public String getAssetTagNames() {
033                    return _assetTagNames;
034            }
035    
036            public PortletURL getPortletURL() {
037                    return _portletURL;
038            }
039    
040            public void setAssetTagNames(String assetTagNames) {
041                    _assetTagNames = assetTagNames;
042            }
043    
044            public void setClassName(String className) {
045                    _className = className;
046            }
047    
048            public void setClassPK(long classPK) {
049                    _classPK = classPK;
050            }
051    
052            public void setMessage(String message) {
053                    _message = message;
054            }
055    
056            public void setParamName(String paramName) {
057                    _paramName = paramName;
058            }
059    
060            public void setPortletURL(PortletURL portletURL) {
061                    _portletURL = portletURL;
062            }
063    
064            @Override
065            protected void cleanUp() {
066                    _assetTagNames = null;
067                    _className = null;
068                    _classPK = 0;
069                    _message = null;
070                    _paramName = null;
071                    _portletURL = null;
072            }
073    
074            @Override
075            protected String getPage() {
076                    return _PAGE;
077            }
078    
079            @Override
080            protected void setAttributes(HttpServletRequest request) {
081                    List<AssetTag> assetTags = new ArrayList<>();
082    
083                    AssetTagsAvailableTag<R> assetTagsAvailableTag =
084                            (AssetTagsAvailableTag<R>)findAncestorWithClass(
085                                    this, AssetTagsAvailableTag.class);
086    
087                    if (assetTagsAvailableTag != null) {
088                            assetTags = assetTagsAvailableTag.getAssetTags();
089                    }
090    
091                    request.setAttribute(
092                            "liferay-ui:asset-categories-summary:assetTags", assetTags);
093    
094                    request.setAttribute(
095                            "liferay-ui:asset-tags-summary:assetTagNames", _assetTagNames);
096                    request.setAttribute(
097                            "liferay-ui:asset-tags-summary:className", _className);
098                    request.setAttribute(
099                            "liferay-ui:asset-tags-summary:classPK", String.valueOf(_classPK));
100                    request.setAttribute("liferay-ui:asset-tags-summary:message", _message);
101                    request.setAttribute(
102                            "liferay-ui:asset-tags-summary:paramName", _paramName);
103                    request.setAttribute(
104                            "liferay-ui:asset-tags-summary:portletURL", _portletURL);
105            }
106    
107            private static final String _PAGE =
108                    "/html/taglib/ui/asset_tags_summary/page.jsp";
109    
110            private String _assetTagNames;
111            private String _className;
112            private long _classPK;
113            private String _message;
114            private String _paramName;
115            private PortletURL _portletURL;
116    
117    }