001    /**
002     * Copyright (c) 2000-2010 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.enterpriseadmin.search;
016    
017    import com.liferay.portal.kernel.dao.search.DisplayTerms;
018    import com.liferay.portal.kernel.util.ParamUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.portal.model.RoleConstants;
021    
022    import javax.portlet.PortletRequest;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class RoleDisplayTerms extends DisplayTerms {
028    
029            public static final String DESCRIPTION = "description";
030    
031            public static final String NAME = "name";
032    
033            public static final String TYPE = "type";
034    
035            public RoleDisplayTerms(PortletRequest portletRequest) {
036                    super(portletRequest);
037    
038                    description = ParamUtil.getString(portletRequest, DESCRIPTION);
039                    name = ParamUtil.getString(portletRequest, NAME);
040                    type = ParamUtil.getInteger(portletRequest, TYPE);
041            }
042    
043            public String getDescription() {
044                    return description;
045            }
046    
047            public String getName() {
048                    return name;
049            }
050    
051            public int getType() {
052                    if ((type == RoleConstants.TYPE_COMMUNITY) ||
053                            (type == RoleConstants.TYPE_ORGANIZATION) ||
054                            (type == RoleConstants.TYPE_REGULAR)) {
055    
056                            return type;
057                    }
058                    else {
059                            return 0;
060                    }
061            }
062    
063            public String getTypeString() {
064                    if ((type == RoleConstants.TYPE_COMMUNITY) ||
065                            (type == RoleConstants.TYPE_ORGANIZATION) ||
066                            (type == RoleConstants.TYPE_REGULAR)) {
067    
068                            return String.valueOf(type);
069                    }
070                    else {
071                            return StringPool.BLANK;
072                    }
073            }
074    
075            protected String description;
076            protected String name;
077            protected int type;
078    
079    }