01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.user;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.ofbiz.base.util.Debug;
23: import org.ofbiz.base.util.UtilMisc;
24: import org.ofbiz.entity.GenericDelegator;
25: import org.ofbiz.entity.GenericEntityException;
26:
27: /**
28: * @author john
29: *
30: * To change this generated comment edit the template variable "typecomment":
31: * Window>Preferences>Java>Templates.
32: * To enable and disable the creation of type comments go to
33: * Window>Preferences>Java>Code Generation.
34: */
35: public class UserHelper {
36: public static final String module = UserHelper.class.getName();
37:
38: UserHelper() {
39: }
40:
41: /**
42: * DOCUMENT ME!
43: *
44: * @param companyAccountId
45: * @param delegator
46: *
47: * @return
48: */
49: public static List getCompanyUsers(String companyAccountId,
50: GenericDelegator delegator) {
51: // Get all users in the current user's company.
52: ArrayList orderBy = new ArrayList();
53: orderBy.add("lastName");
54: orderBy.add("firstName");
55:
56: List userList = new ArrayList();
57:
58: try {
59: userList = delegator.findByAnd("Contact", UtilMisc.toMap(
60: "contactTypeId", "user", "accountId",
61: companyAccountId), orderBy);
62:
63: Debug.logVerbose("User count = "
64: + String.valueOf(userList.size()), module);
65: } catch (GenericEntityException e) {
66: Debug.logError("Error retrieving the user list: ", module);
67: Debug.logError(e.getLocalizedMessage(), module);
68:
69: return null;
70: }
71:
72: return userList;
73: }
74: }
|