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.usersadmin.search;
016    
017    import com.liferay.portal.kernel.dao.search.DisplayTerms;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.ParamUtil;
020    import com.liferay.portal.kernel.util.Validator;
021    import com.liferay.portal.kernel.workflow.WorkflowConstants;
022    
023    import javax.portlet.PortletRequest;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class UserDisplayTerms extends DisplayTerms {
029    
030            public static final String EMAIL_ADDRESS = "emailAddress";
031    
032            public static final String FIRST_NAME = "firstName";
033    
034            public static final String LAST_NAME = "lastName";
035    
036            public static final String MIDDLE_NAME = "middleName";
037    
038            public static final String ORGANIZATION_ID = "organizationId";
039    
040            public static final String ROLE_ID = "roleId";
041    
042            public static final String SCREEN_NAME = "screenName";
043    
044            public static final String STATUS = "status";
045    
046            public static final String USER_GROUP_ID = "userGroupId";
047    
048            public UserDisplayTerms(PortletRequest portletRequest) {
049                    super(portletRequest);
050    
051                    String statusString = ParamUtil.getString(portletRequest, STATUS);
052    
053                    if (Validator.isNotNull(statusString)) {
054                            status = GetterUtil.getInteger(statusString);
055                    }
056    
057                    emailAddress = ParamUtil.getString(portletRequest, EMAIL_ADDRESS);
058                    firstName = ParamUtil.getString(portletRequest, FIRST_NAME);
059                    lastName = ParamUtil.getString(portletRequest, LAST_NAME);
060                    middleName = ParamUtil.getString(portletRequest, MIDDLE_NAME);
061                    organizationId = ParamUtil.getLong(portletRequest, ORGANIZATION_ID);
062                    roleId = ParamUtil.getLong(portletRequest, ROLE_ID);
063                    screenName = ParamUtil.getString(portletRequest, SCREEN_NAME);
064                    userGroupId = ParamUtil.getLong(portletRequest, USER_GROUP_ID);
065            }
066    
067            public String getEmailAddress() {
068                    return emailAddress;
069            }
070    
071            public String getFirstName() {
072                    return firstName;
073            }
074    
075            public String getLastName() {
076                    return lastName;
077            }
078    
079            public String getMiddleName() {
080                    return middleName;
081            }
082    
083            public long getOrganizationId() {
084                    return organizationId;
085            }
086    
087            public long getRoleId() {
088                    return roleId;
089            }
090    
091            public String getScreenName() {
092                    return screenName;
093            }
094    
095            public int getStatus() {
096                    return status;
097            }
098    
099            public long getUserGroupId() {
100                    return userGroupId;
101            }
102    
103            public boolean isActive() {
104                    if (status == WorkflowConstants.STATUS_APPROVED) {
105                            return true;
106                    }
107                    else {
108                            return false;
109                    }
110            }
111    
112            public void setStatus(int status) {
113                    this.status = status;
114            }
115    
116            protected String emailAddress;
117            protected String firstName;
118            protected String lastName;
119            protected String middleName;
120            protected long organizationId;
121            protected long roleId;
122            protected String screenName;
123            protected int status;
124            protected long userGroupId;
125    
126    }