1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.enterpriseadmin.search;
24  
25  import com.liferay.portal.kernel.dao.search.SearchContainer;
26  import com.liferay.portal.kernel.util.JavaConstants;
27  import com.liferay.portal.util.PortletKeys;
28  
29  import java.util.ArrayList;
30  import java.util.List;
31  
32  import javax.portlet.PortletConfig;
33  import javax.portlet.PortletURL;
34  import javax.portlet.RenderRequest;
35  
36  /**
37   * <a href="UserSearch.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Brian Wing Shun Chan
40   *
41   */
42  public class UserSearch extends SearchContainer {
43  
44      static List headerNames = new ArrayList();
45  
46      static {
47          headerNames.add("name");
48          headerNames.add("screen-name");
49          //headerNames.add("email-address");
50          headerNames.add("job-title");
51          headerNames.add("organization");
52          headerNames.add("location");
53          //headerNames.add("city");
54          //headerNames.add("region");
55          //headerNames.add("country");
56      }
57  
58      public static final String EMPTY_RESULTS_MESSAGE = "no-users-were-found";
59  
60      public UserSearch(RenderRequest req, PortletURL iteratorURL) {
61          super(req, new UserDisplayTerms(req), new UserSearchTerms(req),
62                DEFAULT_CUR_PARAM, DEFAULT_DELTA, iteratorURL, headerNames,
63                EMPTY_RESULTS_MESSAGE);
64  
65          PortletConfig portletConfig = (PortletConfig)req.getAttribute(
66              JavaConstants.JAVAX_PORTLET_CONFIG);
67  
68          UserDisplayTerms displayTerms = (UserDisplayTerms)getDisplayTerms();
69          UserSearchTerms searchTerms = (UserSearchTerms)getSearchTerms();
70  
71          if (!portletConfig.getPortletName().equals(
72                  PortletKeys.ENTERPRISE_ADMIN)) {
73  
74              displayTerms.setActive(true);
75              searchTerms.setActive(true);
76          }
77  
78          iteratorURL.setParameter(
79              UserDisplayTerms.FIRST_NAME, displayTerms.getFirstName());
80          iteratorURL.setParameter(
81              UserDisplayTerms.MIDDLE_NAME, displayTerms.getMiddleName());
82          iteratorURL.setParameter(
83              UserDisplayTerms.LAST_NAME, displayTerms.getLastName());
84          iteratorURL.setParameter(
85              UserDisplayTerms.SCREEN_NAME, displayTerms.getScreenName());
86          iteratorURL.setParameter(
87              UserDisplayTerms.EMAIL_ADDRESS, displayTerms.getEmailAddress());
88          iteratorURL.setParameter(
89              UserDisplayTerms.ACTIVE, String.valueOf(displayTerms.isActive()));
90          iteratorURL.setParameter(
91              UserDisplayTerms.ORGANIZATION_ID,
92              String.valueOf(displayTerms.getOrganizationId()));
93          iteratorURL.setParameter(
94              UserDisplayTerms.ROLE_ID, String.valueOf(displayTerms.getRoleId()));
95          iteratorURL.setParameter(
96              UserDisplayTerms.USER_GROUP_ID,
97              String.valueOf(displayTerms.getUserGroupId()));
98      }
99  
100 }