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.rolesadmin.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_ORGANIZATION) ||
053                            (type == RoleConstants.TYPE_REGULAR) ||
054                            (type == RoleConstants.TYPE_SITE)) {
055    
056                            return type;
057                    }
058                    else {
059                            return 0;
060                    }
061            }
062    
063            public String getTypeString() {
064                    if ((type == RoleConstants.TYPE_ORGANIZATION) ||
065                            (type == RoleConstants.TYPE_REGULAR) ||
066                            (type == RoleConstants.TYPE_SITE)) {
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    }