1
14
15 package com.liferay.portal.service.persistence;
16
17 import com.liferay.portal.NoSuchModelException;
18 import com.liferay.portal.NoSuchUserException;
19 import com.liferay.portal.SystemException;
20 import com.liferay.portal.kernel.annotation.BeanReference;
21 import com.liferay.portal.kernel.cache.CacheRegistry;
22 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
23 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
24 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
25 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
26 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
27 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29 import com.liferay.portal.kernel.dao.orm.FinderPath;
30 import com.liferay.portal.kernel.dao.orm.Query;
31 import com.liferay.portal.kernel.dao.orm.QueryPos;
32 import com.liferay.portal.kernel.dao.orm.QueryUtil;
33 import com.liferay.portal.kernel.dao.orm.SQLQuery;
34 import com.liferay.portal.kernel.dao.orm.Session;
35 import com.liferay.portal.kernel.dao.orm.Type;
36 import com.liferay.portal.kernel.log.Log;
37 import com.liferay.portal.kernel.log.LogFactoryUtil;
38 import com.liferay.portal.kernel.util.GetterUtil;
39 import com.liferay.portal.kernel.util.OrderByComparator;
40 import com.liferay.portal.kernel.util.SetUtil;
41 import com.liferay.portal.kernel.util.StringBundler;
42 import com.liferay.portal.kernel.util.StringPool;
43 import com.liferay.portal.kernel.util.StringUtil;
44 import com.liferay.portal.kernel.util.Validator;
45 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
46 import com.liferay.portal.model.ModelListener;
47 import com.liferay.portal.model.User;
48 import com.liferay.portal.model.impl.UserImpl;
49 import com.liferay.portal.model.impl.UserModelImpl;
50 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
51
52 import com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence;
53 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
54 import com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence;
55 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
56 import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
57 import com.liferay.portlet.messageboards.service.persistence.MBMessageFlagPersistence;
58 import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
59 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
60 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
61 import com.liferay.portlet.social.service.persistence.SocialRequestPersistence;
62 import com.liferay.portlet.tags.service.persistence.TagsAssetPersistence;
63
64 import java.io.Serializable;
65
66 import java.sql.Types;
67
68 import java.util.ArrayList;
69 import java.util.Collections;
70 import java.util.List;
71 import java.util.Set;
72
73
86 public class UserPersistenceImpl extends BasePersistenceImpl<User>
87 implements UserPersistence {
88 public static final String FINDER_CLASS_NAME_ENTITY = UserImpl.class.getName();
89 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
90 ".List";
91 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
92 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
93 "findByUuid", new String[] { String.class.getName() });
94 public static final FinderPath FINDER_PATH_FIND_BY_OBC_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
95 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
96 "findByUuid",
97 new String[] {
98 String.class.getName(),
99
100 "java.lang.Integer", "java.lang.Integer",
101 "com.liferay.portal.kernel.util.OrderByComparator"
102 });
103 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
104 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "countByUuid", new String[] { String.class.getName() });
106 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
107 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
108 "findByCompanyId", new String[] { Long.class.getName() });
109 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
110 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
111 "findByCompanyId",
112 new String[] {
113 Long.class.getName(),
114
115 "java.lang.Integer", "java.lang.Integer",
116 "com.liferay.portal.kernel.util.OrderByComparator"
117 });
118 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
119 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
120 "countByCompanyId", new String[] { Long.class.getName() });
121 public static final FinderPath FINDER_PATH_FETCH_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
122 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
123 "fetchByContactId", new String[] { Long.class.getName() });
124 public static final FinderPath FINDER_PATH_COUNT_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
125 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126 "countByContactId", new String[] { Long.class.getName() });
127 public static final FinderPath FINDER_PATH_FIND_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
128 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
129 "findByEmailAddress", new String[] { String.class.getName() });
130 public static final FinderPath FINDER_PATH_FIND_BY_OBC_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
131 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
132 "findByEmailAddress",
133 new String[] {
134 String.class.getName(),
135
136 "java.lang.Integer", "java.lang.Integer",
137 "com.liferay.portal.kernel.util.OrderByComparator"
138 });
139 public static final FinderPath FINDER_PATH_COUNT_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
140 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
141 "countByEmailAddress", new String[] { String.class.getName() });
142 public static final FinderPath FINDER_PATH_FETCH_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
143 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
144 "fetchByOpenId", new String[] { String.class.getName() });
145 public static final FinderPath FINDER_PATH_COUNT_BY_OPENID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
146 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
147 "countByOpenId", new String[] { String.class.getName() });
148 public static final FinderPath FINDER_PATH_FETCH_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
149 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
150 "fetchByPortraitId", new String[] { Long.class.getName() });
151 public static final FinderPath FINDER_PATH_COUNT_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
152 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
153 "countByPortraitId", new String[] { Long.class.getName() });
154 public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
155 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
156 "fetchByC_U",
157 new String[] { Long.class.getName(), Long.class.getName() });
158 public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
159 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
160 "countByC_U",
161 new String[] { Long.class.getName(), Long.class.getName() });
162 public static final FinderPath FINDER_PATH_FETCH_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
163 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
164 "fetchByC_DU",
165 new String[] { Long.class.getName(), Boolean.class.getName() });
166 public static final FinderPath FINDER_PATH_COUNT_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
167 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
168 "countByC_DU",
169 new String[] { Long.class.getName(), Boolean.class.getName() });
170 public static final FinderPath FINDER_PATH_FETCH_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
171 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
172 "fetchByC_SN",
173 new String[] { Long.class.getName(), String.class.getName() });
174 public static final FinderPath FINDER_PATH_COUNT_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
175 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
176 "countByC_SN",
177 new String[] { Long.class.getName(), String.class.getName() });
178 public static final FinderPath FINDER_PATH_FETCH_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
179 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
180 "fetchByC_EA",
181 new String[] { Long.class.getName(), String.class.getName() });
182 public static final FinderPath FINDER_PATH_COUNT_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
183 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
184 "countByC_EA",
185 new String[] { Long.class.getName(), String.class.getName() });
186 public static final FinderPath FINDER_PATH_FIND_BY_C_A = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
187 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
188 "findByC_A",
189 new String[] { Long.class.getName(), Boolean.class.getName() });
190 public static final FinderPath FINDER_PATH_FIND_BY_OBC_C_A = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
191 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
192 "findByC_A",
193 new String[] {
194 Long.class.getName(), Boolean.class.getName(),
195
196 "java.lang.Integer", "java.lang.Integer",
197 "com.liferay.portal.kernel.util.OrderByComparator"
198 });
199 public static final FinderPath FINDER_PATH_COUNT_BY_C_A = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
200 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
201 "countByC_A",
202 new String[] { Long.class.getName(), Boolean.class.getName() });
203 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
204 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
205 "findAll", new String[0]);
206 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
207 UserModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
208 "countAll", new String[0]);
209
210 public void cacheResult(User user) {
211 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
212 UserImpl.class, user.getPrimaryKey(), user);
213
214 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
215 new Object[] { new Long(user.getContactId()) }, user);
216
217 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
218 new Object[] { user.getOpenId() }, user);
219
220 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
221 new Object[] { new Long(user.getPortraitId()) }, user);
222
223 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
224 new Object[] {
225 new Long(user.getCompanyId()), new Long(user.getUserId())
226 }, user);
227
228 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
229 new Object[] {
230 new Long(user.getCompanyId()),
231 Boolean.valueOf(user.getDefaultUser())
232 }, user);
233
234 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
235 new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
236 user);
237
238 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
239 new Object[] { new Long(user.getCompanyId()), user.getEmailAddress() },
240 user);
241 }
242
243 public void cacheResult(List<User> users) {
244 for (User user : users) {
245 if (EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
246 UserImpl.class, user.getPrimaryKey(), this) == null) {
247 cacheResult(user);
248 }
249 }
250 }
251
252 public void clearCache() {
253 CacheRegistry.clear(UserImpl.class.getName());
254 EntityCacheUtil.clearCache(UserImpl.class.getName());
255 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
257 }
258
259 public User create(long userId) {
260 User user = new UserImpl();
261
262 user.setNew(true);
263 user.setPrimaryKey(userId);
264
265 String uuid = PortalUUIDUtil.generate();
266
267 user.setUuid(uuid);
268
269 return user;
270 }
271
272 public User remove(Serializable primaryKey)
273 throws NoSuchModelException, SystemException {
274 return remove(((Long)primaryKey).longValue());
275 }
276
277 public User remove(long userId) throws NoSuchUserException, SystemException {
278 Session session = null;
279
280 try {
281 session = openSession();
282
283 User user = (User)session.get(UserImpl.class, new Long(userId));
284
285 if (user == null) {
286 if (_log.isWarnEnabled()) {
287 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userId);
288 }
289
290 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
291 userId);
292 }
293
294 return remove(user);
295 }
296 catch (NoSuchUserException nsee) {
297 throw nsee;
298 }
299 catch (Exception e) {
300 throw processException(e);
301 }
302 finally {
303 closeSession(session);
304 }
305 }
306
307 public User remove(User user) throws SystemException {
308 for (ModelListener<User> listener : listeners) {
309 listener.onBeforeRemove(user);
310 }
311
312 user = removeImpl(user);
313
314 for (ModelListener<User> listener : listeners) {
315 listener.onAfterRemove(user);
316 }
317
318 return user;
319 }
320
321 protected User removeImpl(User user) throws SystemException {
322 user = toUnwrappedModel(user);
323
324 try {
325 clearGroups.clear(user.getPrimaryKey());
326 }
327 catch (Exception e) {
328 throw processException(e);
329 }
330 finally {
331 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
332 }
333
334 try {
335 clearOrganizations.clear(user.getPrimaryKey());
336 }
337 catch (Exception e) {
338 throw processException(e);
339 }
340 finally {
341 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
342 }
343
344 try {
345 clearPermissions.clear(user.getPrimaryKey());
346 }
347 catch (Exception e) {
348 throw processException(e);
349 }
350 finally {
351 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
352 }
353
354 try {
355 clearRoles.clear(user.getPrimaryKey());
356 }
357 catch (Exception e) {
358 throw processException(e);
359 }
360 finally {
361 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
362 }
363
364 try {
365 clearUserGroups.clear(user.getPrimaryKey());
366 }
367 catch (Exception e) {
368 throw processException(e);
369 }
370 finally {
371 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
372 }
373
374 Session session = null;
375
376 try {
377 session = openSession();
378
379 if (user.isCachedModel() || BatchSessionUtil.isEnabled()) {
380 Object staleObject = session.get(UserImpl.class,
381 user.getPrimaryKeyObj());
382
383 if (staleObject != null) {
384 session.evict(staleObject);
385 }
386 }
387
388 session.delete(user);
389
390 session.flush();
391 }
392 catch (Exception e) {
393 throw processException(e);
394 }
395 finally {
396 closeSession(session);
397 }
398
399 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
400
401 UserModelImpl userModelImpl = (UserModelImpl)user;
402
403 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
404 new Object[] { new Long(userModelImpl.getOriginalContactId()) });
405
406 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
407 new Object[] { userModelImpl.getOriginalOpenId() });
408
409 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
410 new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
411
412 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
413 new Object[] {
414 new Long(userModelImpl.getOriginalCompanyId()),
415 new Long(userModelImpl.getOriginalUserId())
416 });
417
418 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
419 new Object[] {
420 new Long(userModelImpl.getOriginalCompanyId()),
421 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
422 });
423
424 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
425 new Object[] {
426 new Long(userModelImpl.getOriginalCompanyId()),
427
428 userModelImpl.getOriginalScreenName()
429 });
430
431 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
432 new Object[] {
433 new Long(userModelImpl.getOriginalCompanyId()),
434
435 userModelImpl.getOriginalEmailAddress()
436 });
437
438 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
439 UserImpl.class, user.getPrimaryKey());
440
441 return user;
442 }
443
444
447 public User update(User user) throws SystemException {
448 if (_log.isWarnEnabled()) {
449 _log.warn(
450 "Using the deprecated update(User user) method. Use update(User user, boolean merge) instead.");
451 }
452
453 return update(user, false);
454 }
455
456 public User updateImpl(com.liferay.portal.model.User user, boolean merge)
457 throws SystemException {
458 user = toUnwrappedModel(user);
459
460 boolean isNew = user.isNew();
461
462 UserModelImpl userModelImpl = (UserModelImpl)user;
463
464 if (Validator.isNull(user.getUuid())) {
465 String uuid = PortalUUIDUtil.generate();
466
467 user.setUuid(uuid);
468 }
469
470 Session session = null;
471
472 try {
473 session = openSession();
474
475 BatchSessionUtil.update(session, user, merge);
476
477 user.setNew(false);
478 }
479 catch (Exception e) {
480 throw processException(e);
481 }
482 finally {
483 closeSession(session);
484 }
485
486 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
487
488 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
489 UserImpl.class, user.getPrimaryKey(), user);
490
491 if (!isNew &&
492 (user.getContactId() != userModelImpl.getOriginalContactId())) {
493 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
494 new Object[] { new Long(userModelImpl.getOriginalContactId()) });
495 }
496
497 if (isNew ||
498 (user.getContactId() != userModelImpl.getOriginalContactId())) {
499 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
500 new Object[] { new Long(user.getContactId()) }, user);
501 }
502
503 if (!isNew &&
504 (!Validator.equals(user.getOpenId(),
505 userModelImpl.getOriginalOpenId()))) {
506 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_OPENID,
507 new Object[] { userModelImpl.getOriginalOpenId() });
508 }
509
510 if (isNew ||
511 (!Validator.equals(user.getOpenId(),
512 userModelImpl.getOriginalOpenId()))) {
513 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
514 new Object[] { user.getOpenId() }, user);
515 }
516
517 if (!isNew &&
518 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
519 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
520 new Object[] { new Long(userModelImpl.getOriginalPortraitId()) });
521 }
522
523 if (isNew ||
524 (user.getPortraitId() != userModelImpl.getOriginalPortraitId())) {
525 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
526 new Object[] { new Long(user.getPortraitId()) }, user);
527 }
528
529 if (!isNew &&
530 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
531 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
532 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
533 new Object[] {
534 new Long(userModelImpl.getOriginalCompanyId()),
535 new Long(userModelImpl.getOriginalUserId())
536 });
537 }
538
539 if (isNew ||
540 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
541 (user.getUserId() != userModelImpl.getOriginalUserId()))) {
542 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
543 new Object[] {
544 new Long(user.getCompanyId()), new Long(user.getUserId())
545 }, user);
546 }
547
548 if (!isNew &&
549 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
550 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
551 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
552 new Object[] {
553 new Long(userModelImpl.getOriginalCompanyId()),
554 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
555 });
556 }
557
558 if (isNew ||
559 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
560 (user.getDefaultUser() != userModelImpl.getOriginalDefaultUser()))) {
561 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
562 new Object[] {
563 new Long(user.getCompanyId()),
564 Boolean.valueOf(user.getDefaultUser())
565 }, user);
566 }
567
568 if (!isNew &&
569 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
570 !Validator.equals(user.getScreenName(),
571 userModelImpl.getOriginalScreenName()))) {
572 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
573 new Object[] {
574 new Long(userModelImpl.getOriginalCompanyId()),
575
576 userModelImpl.getOriginalScreenName()
577 });
578 }
579
580 if (isNew ||
581 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
582 !Validator.equals(user.getScreenName(),
583 userModelImpl.getOriginalScreenName()))) {
584 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
585 new Object[] { new Long(user.getCompanyId()), user.getScreenName() },
586 user);
587 }
588
589 if (!isNew &&
590 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
591 !Validator.equals(user.getEmailAddress(),
592 userModelImpl.getOriginalEmailAddress()))) {
593 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
594 new Object[] {
595 new Long(userModelImpl.getOriginalCompanyId()),
596
597 userModelImpl.getOriginalEmailAddress()
598 });
599 }
600
601 if (isNew ||
602 ((user.getCompanyId() != userModelImpl.getOriginalCompanyId()) ||
603 !Validator.equals(user.getEmailAddress(),
604 userModelImpl.getOriginalEmailAddress()))) {
605 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
606 new Object[] {
607 new Long(user.getCompanyId()),
608
609 user.getEmailAddress()
610 }, user);
611 }
612
613 return user;
614 }
615
616 protected User toUnwrappedModel(User user) {
617 if (user instanceof UserImpl) {
618 return user;
619 }
620
621 UserImpl userImpl = new UserImpl();
622
623 userImpl.setNew(user.isNew());
624 userImpl.setPrimaryKey(user.getPrimaryKey());
625
626 userImpl.setUuid(user.getUuid());
627 userImpl.setUserId(user.getUserId());
628 userImpl.setCompanyId(user.getCompanyId());
629 userImpl.setCreateDate(user.getCreateDate());
630 userImpl.setModifiedDate(user.getModifiedDate());
631 userImpl.setDefaultUser(user.isDefaultUser());
632 userImpl.setContactId(user.getContactId());
633 userImpl.setPassword(user.getPassword());
634 userImpl.setPasswordEncrypted(user.isPasswordEncrypted());
635 userImpl.setPasswordReset(user.isPasswordReset());
636 userImpl.setPasswordModifiedDate(user.getPasswordModifiedDate());
637 userImpl.setReminderQueryQuestion(user.getReminderQueryQuestion());
638 userImpl.setReminderQueryAnswer(user.getReminderQueryAnswer());
639 userImpl.setGraceLoginCount(user.getGraceLoginCount());
640 userImpl.setScreenName(user.getScreenName());
641 userImpl.setEmailAddress(user.getEmailAddress());
642 userImpl.setOpenId(user.getOpenId());
643 userImpl.setPortraitId(user.getPortraitId());
644 userImpl.setLanguageId(user.getLanguageId());
645 userImpl.setTimeZoneId(user.getTimeZoneId());
646 userImpl.setGreeting(user.getGreeting());
647 userImpl.setComments(user.getComments());
648 userImpl.setFirstName(user.getFirstName());
649 userImpl.setMiddleName(user.getMiddleName());
650 userImpl.setLastName(user.getLastName());
651 userImpl.setJobTitle(user.getJobTitle());
652 userImpl.setLoginDate(user.getLoginDate());
653 userImpl.setLoginIP(user.getLoginIP());
654 userImpl.setLastLoginDate(user.getLastLoginDate());
655 userImpl.setLastLoginIP(user.getLastLoginIP());
656 userImpl.setLastFailedLoginDate(user.getLastFailedLoginDate());
657 userImpl.setFailedLoginAttempts(user.getFailedLoginAttempts());
658 userImpl.setLockout(user.isLockout());
659 userImpl.setLockoutDate(user.getLockoutDate());
660 userImpl.setAgreedToTermsOfUse(user.isAgreedToTermsOfUse());
661 userImpl.setActive(user.isActive());
662
663 return userImpl;
664 }
665
666 public User findByPrimaryKey(Serializable primaryKey)
667 throws NoSuchModelException, SystemException {
668 return findByPrimaryKey(((Long)primaryKey).longValue());
669 }
670
671 public User findByPrimaryKey(long userId)
672 throws NoSuchUserException, SystemException {
673 User user = fetchByPrimaryKey(userId);
674
675 if (user == null) {
676 if (_log.isWarnEnabled()) {
677 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userId);
678 }
679
680 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
681 userId);
682 }
683
684 return user;
685 }
686
687 public User fetchByPrimaryKey(Serializable primaryKey)
688 throws SystemException {
689 return fetchByPrimaryKey(((Long)primaryKey).longValue());
690 }
691
692 public User fetchByPrimaryKey(long userId) throws SystemException {
693 User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
694 UserImpl.class, userId, this);
695
696 if (user == null) {
697 Session session = null;
698
699 try {
700 session = openSession();
701
702 user = (User)session.get(UserImpl.class, new Long(userId));
703 }
704 catch (Exception e) {
705 throw processException(e);
706 }
707 finally {
708 if (user != null) {
709 cacheResult(user);
710 }
711
712 closeSession(session);
713 }
714 }
715
716 return user;
717 }
718
719 public List<User> findByUuid(String uuid) throws SystemException {
720 Object[] finderArgs = new Object[] { uuid };
721
722 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
723 finderArgs, this);
724
725 if (list == null) {
726 Session session = null;
727
728 try {
729 session = openSession();
730
731 StringBundler query = new StringBundler(2);
732
733 query.append(_SQL_SELECT_USER_WHERE);
734
735 if (uuid == null) {
736 query.append(_FINDER_COLUMN_UUID_UUID_1);
737 }
738 else {
739 if (uuid.equals(StringPool.BLANK)) {
740 query.append(_FINDER_COLUMN_UUID_UUID_3);
741 }
742 else {
743 query.append(_FINDER_COLUMN_UUID_UUID_2);
744 }
745 }
746
747 String sql = query.toString();
748
749 Query q = session.createQuery(sql);
750
751 QueryPos qPos = QueryPos.getInstance(q);
752
753 if (uuid != null) {
754 qPos.add(uuid);
755 }
756
757 list = q.list();
758 }
759 catch (Exception e) {
760 throw processException(e);
761 }
762 finally {
763 if (list == null) {
764 list = new ArrayList<User>();
765 }
766
767 cacheResult(list);
768
769 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
770 list);
771
772 closeSession(session);
773 }
774 }
775
776 return list;
777 }
778
779 public List<User> findByUuid(String uuid, int start, int end)
780 throws SystemException {
781 return findByUuid(uuid, start, end, null);
782 }
783
784 public List<User> findByUuid(String uuid, int start, int end,
785 OrderByComparator orderByComparator) throws SystemException {
786 Object[] finderArgs = new Object[] {
787 uuid,
788
789 String.valueOf(start), String.valueOf(end),
790 String.valueOf(orderByComparator)
791 };
792
793 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_UUID,
794 finderArgs, this);
795
796 if (list == null) {
797 Session session = null;
798
799 try {
800 session = openSession();
801
802 StringBundler query = null;
803
804 if (orderByComparator != null) {
805 query = new StringBundler(3 +
806 (orderByComparator.getOrderByFields().length * 3));
807 }
808 else {
809 query = new StringBundler(2);
810 }
811
812 query.append(_SQL_SELECT_USER_WHERE);
813
814 if (uuid == null) {
815 query.append(_FINDER_COLUMN_UUID_UUID_1);
816 }
817 else {
818 if (uuid.equals(StringPool.BLANK)) {
819 query.append(_FINDER_COLUMN_UUID_UUID_3);
820 }
821 else {
822 query.append(_FINDER_COLUMN_UUID_UUID_2);
823 }
824 }
825
826 if (orderByComparator != null) {
827 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
828 orderByComparator);
829 }
830
831 String sql = query.toString();
832
833 Query q = session.createQuery(sql);
834
835 QueryPos qPos = QueryPos.getInstance(q);
836
837 if (uuid != null) {
838 qPos.add(uuid);
839 }
840
841 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
842 }
843 catch (Exception e) {
844 throw processException(e);
845 }
846 finally {
847 if (list == null) {
848 list = new ArrayList<User>();
849 }
850
851 cacheResult(list);
852
853 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_UUID,
854 finderArgs, list);
855
856 closeSession(session);
857 }
858 }
859
860 return list;
861 }
862
863 public User findByUuid_First(String uuid,
864 OrderByComparator orderByComparator)
865 throws NoSuchUserException, SystemException {
866 List<User> list = findByUuid(uuid, 0, 1, orderByComparator);
867
868 if (list.isEmpty()) {
869 StringBundler msg = new StringBundler(4);
870
871 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
872
873 msg.append("uuid=");
874 msg.append(uuid);
875
876 msg.append(StringPool.CLOSE_CURLY_BRACE);
877
878 throw new NoSuchUserException(msg.toString());
879 }
880 else {
881 return list.get(0);
882 }
883 }
884
885 public User findByUuid_Last(String uuid, OrderByComparator orderByComparator)
886 throws NoSuchUserException, SystemException {
887 int count = countByUuid(uuid);
888
889 List<User> list = findByUuid(uuid, count - 1, count, orderByComparator);
890
891 if (list.isEmpty()) {
892 StringBundler msg = new StringBundler(4);
893
894 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
895
896 msg.append("uuid=");
897 msg.append(uuid);
898
899 msg.append(StringPool.CLOSE_CURLY_BRACE);
900
901 throw new NoSuchUserException(msg.toString());
902 }
903 else {
904 return list.get(0);
905 }
906 }
907
908 public User[] findByUuid_PrevAndNext(long userId, String uuid,
909 OrderByComparator orderByComparator)
910 throws NoSuchUserException, SystemException {
911 User user = findByPrimaryKey(userId);
912
913 int count = countByUuid(uuid);
914
915 Session session = null;
916
917 try {
918 session = openSession();
919
920 StringBundler query = null;
921
922 if (orderByComparator != null) {
923 query = new StringBundler(3 +
924 (orderByComparator.getOrderByFields().length * 3));
925 }
926 else {
927 query = new StringBundler(2);
928 }
929
930 query.append(_SQL_SELECT_USER_WHERE);
931
932 if (uuid == null) {
933 query.append(_FINDER_COLUMN_UUID_UUID_1);
934 }
935 else {
936 if (uuid.equals(StringPool.BLANK)) {
937 query.append(_FINDER_COLUMN_UUID_UUID_3);
938 }
939 else {
940 query.append(_FINDER_COLUMN_UUID_UUID_2);
941 }
942 }
943
944 if (orderByComparator != null) {
945 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
946 orderByComparator);
947 }
948
949 String sql = query.toString();
950
951 Query q = session.createQuery(sql);
952
953 QueryPos qPos = QueryPos.getInstance(q);
954
955 if (uuid != null) {
956 qPos.add(uuid);
957 }
958
959 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
960 orderByComparator, user);
961
962 User[] array = new UserImpl[3];
963
964 array[0] = (User)objArray[0];
965 array[1] = (User)objArray[1];
966 array[2] = (User)objArray[2];
967
968 return array;
969 }
970 catch (Exception e) {
971 throw processException(e);
972 }
973 finally {
974 closeSession(session);
975 }
976 }
977
978 public List<User> findByCompanyId(long companyId) throws SystemException {
979 Object[] finderArgs = new Object[] { new Long(companyId) };
980
981 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
982 finderArgs, this);
983
984 if (list == null) {
985 Session session = null;
986
987 try {
988 session = openSession();
989
990 StringBundler query = new StringBundler(2);
991
992 query.append(_SQL_SELECT_USER_WHERE);
993
994 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
995
996 String sql = query.toString();
997
998 Query q = session.createQuery(sql);
999
1000 QueryPos qPos = QueryPos.getInstance(q);
1001
1002 qPos.add(companyId);
1003
1004 list = q.list();
1005 }
1006 catch (Exception e) {
1007 throw processException(e);
1008 }
1009 finally {
1010 if (list == null) {
1011 list = new ArrayList<User>();
1012 }
1013
1014 cacheResult(list);
1015
1016 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
1017 finderArgs, list);
1018
1019 closeSession(session);
1020 }
1021 }
1022
1023 return list;
1024 }
1025
1026 public List<User> findByCompanyId(long companyId, int start, int end)
1027 throws SystemException {
1028 return findByCompanyId(companyId, start, end, null);
1029 }
1030
1031 public List<User> findByCompanyId(long companyId, int start, int end,
1032 OrderByComparator orderByComparator) throws SystemException {
1033 Object[] finderArgs = new Object[] {
1034 new Long(companyId),
1035
1036 String.valueOf(start), String.valueOf(end),
1037 String.valueOf(orderByComparator)
1038 };
1039
1040 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1041 finderArgs, this);
1042
1043 if (list == null) {
1044 Session session = null;
1045
1046 try {
1047 session = openSession();
1048
1049 StringBundler query = null;
1050
1051 if (orderByComparator != null) {
1052 query = new StringBundler(3 +
1053 (orderByComparator.getOrderByFields().length * 3));
1054 }
1055 else {
1056 query = new StringBundler(2);
1057 }
1058
1059 query.append(_SQL_SELECT_USER_WHERE);
1060
1061 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1062
1063 if (orderByComparator != null) {
1064 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1065 orderByComparator);
1066 }
1067
1068 String sql = query.toString();
1069
1070 Query q = session.createQuery(sql);
1071
1072 QueryPos qPos = QueryPos.getInstance(q);
1073
1074 qPos.add(companyId);
1075
1076 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1077 }
1078 catch (Exception e) {
1079 throw processException(e);
1080 }
1081 finally {
1082 if (list == null) {
1083 list = new ArrayList<User>();
1084 }
1085
1086 cacheResult(list);
1087
1088 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
1089 finderArgs, list);
1090
1091 closeSession(session);
1092 }
1093 }
1094
1095 return list;
1096 }
1097
1098 public User findByCompanyId_First(long companyId,
1099 OrderByComparator orderByComparator)
1100 throws NoSuchUserException, SystemException {
1101 List<User> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1102
1103 if (list.isEmpty()) {
1104 StringBundler msg = new StringBundler(4);
1105
1106 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1107
1108 msg.append("companyId=");
1109 msg.append(companyId);
1110
1111 msg.append(StringPool.CLOSE_CURLY_BRACE);
1112
1113 throw new NoSuchUserException(msg.toString());
1114 }
1115 else {
1116 return list.get(0);
1117 }
1118 }
1119
1120 public User findByCompanyId_Last(long companyId,
1121 OrderByComparator orderByComparator)
1122 throws NoSuchUserException, SystemException {
1123 int count = countByCompanyId(companyId);
1124
1125 List<User> list = findByCompanyId(companyId, count - 1, count,
1126 orderByComparator);
1127
1128 if (list.isEmpty()) {
1129 StringBundler msg = new StringBundler(4);
1130
1131 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1132
1133 msg.append("companyId=");
1134 msg.append(companyId);
1135
1136 msg.append(StringPool.CLOSE_CURLY_BRACE);
1137
1138 throw new NoSuchUserException(msg.toString());
1139 }
1140 else {
1141 return list.get(0);
1142 }
1143 }
1144
1145 public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1146 OrderByComparator orderByComparator)
1147 throws NoSuchUserException, SystemException {
1148 User user = findByPrimaryKey(userId);
1149
1150 int count = countByCompanyId(companyId);
1151
1152 Session session = null;
1153
1154 try {
1155 session = openSession();
1156
1157 StringBundler query = null;
1158
1159 if (orderByComparator != null) {
1160 query = new StringBundler(3 +
1161 (orderByComparator.getOrderByFields().length * 3));
1162 }
1163 else {
1164 query = new StringBundler(2);
1165 }
1166
1167 query.append(_SQL_SELECT_USER_WHERE);
1168
1169 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1170
1171 if (orderByComparator != null) {
1172 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1173 orderByComparator);
1174 }
1175
1176 String sql = query.toString();
1177
1178 Query q = session.createQuery(sql);
1179
1180 QueryPos qPos = QueryPos.getInstance(q);
1181
1182 qPos.add(companyId);
1183
1184 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1185 orderByComparator, user);
1186
1187 User[] array = new UserImpl[3];
1188
1189 array[0] = (User)objArray[0];
1190 array[1] = (User)objArray[1];
1191 array[2] = (User)objArray[2];
1192
1193 return array;
1194 }
1195 catch (Exception e) {
1196 throw processException(e);
1197 }
1198 finally {
1199 closeSession(session);
1200 }
1201 }
1202
1203 public User findByContactId(long contactId)
1204 throws NoSuchUserException, SystemException {
1205 User user = fetchByContactId(contactId);
1206
1207 if (user == null) {
1208 StringBundler msg = new StringBundler(4);
1209
1210 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1211
1212 msg.append("contactId=");
1213 msg.append(contactId);
1214
1215 msg.append(StringPool.CLOSE_CURLY_BRACE);
1216
1217 if (_log.isWarnEnabled()) {
1218 _log.warn(msg.toString());
1219 }
1220
1221 throw new NoSuchUserException(msg.toString());
1222 }
1223
1224 return user;
1225 }
1226
1227 public User fetchByContactId(long contactId) throws SystemException {
1228 return fetchByContactId(contactId, true);
1229 }
1230
1231 public User fetchByContactId(long contactId, boolean retrieveFromCache)
1232 throws SystemException {
1233 Object[] finderArgs = new Object[] { new Long(contactId) };
1234
1235 Object result = null;
1236
1237 if (retrieveFromCache) {
1238 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1239 finderArgs, this);
1240 }
1241
1242 if (result == null) {
1243 Session session = null;
1244
1245 try {
1246 session = openSession();
1247
1248 StringBundler query = new StringBundler(2);
1249
1250 query.append(_SQL_SELECT_USER_WHERE);
1251
1252 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
1253
1254 String sql = query.toString();
1255
1256 Query q = session.createQuery(sql);
1257
1258 QueryPos qPos = QueryPos.getInstance(q);
1259
1260 qPos.add(contactId);
1261
1262 List<User> list = q.list();
1263
1264 result = list;
1265
1266 User user = null;
1267
1268 if (list.isEmpty()) {
1269 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1270 finderArgs, list);
1271 }
1272 else {
1273 user = list.get(0);
1274
1275 cacheResult(user);
1276
1277 if ((user.getContactId() != contactId)) {
1278 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1279 finderArgs, user);
1280 }
1281 }
1282
1283 return user;
1284 }
1285 catch (Exception e) {
1286 throw processException(e);
1287 }
1288 finally {
1289 if (result == null) {
1290 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1291 finderArgs, new ArrayList<User>());
1292 }
1293
1294 closeSession(session);
1295 }
1296 }
1297 else {
1298 if (result instanceof List<?>) {
1299 return null;
1300 }
1301 else {
1302 return (User)result;
1303 }
1304 }
1305 }
1306
1307 public List<User> findByEmailAddress(String emailAddress)
1308 throws SystemException {
1309 Object[] finderArgs = new Object[] { emailAddress };
1310
1311 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1312 finderArgs, this);
1313
1314 if (list == null) {
1315 Session session = null;
1316
1317 try {
1318 session = openSession();
1319
1320 StringBundler query = new StringBundler(2);
1321
1322 query.append(_SQL_SELECT_USER_WHERE);
1323
1324 if (emailAddress == null) {
1325 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
1326 }
1327 else {
1328 if (emailAddress.equals(StringPool.BLANK)) {
1329 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
1330 }
1331 else {
1332 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
1333 }
1334 }
1335
1336 String sql = query.toString();
1337
1338 Query q = session.createQuery(sql);
1339
1340 QueryPos qPos = QueryPos.getInstance(q);
1341
1342 if (emailAddress != null) {
1343 qPos.add(emailAddress);
1344 }
1345
1346 list = q.list();
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (list == null) {
1353 list = new ArrayList<User>();
1354 }
1355
1356 cacheResult(list);
1357
1358 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_EMAILADDRESS,
1359 finderArgs, list);
1360
1361 closeSession(session);
1362 }
1363 }
1364
1365 return list;
1366 }
1367
1368 public List<User> findByEmailAddress(String emailAddress, int start, int end)
1369 throws SystemException {
1370 return findByEmailAddress(emailAddress, start, end, null);
1371 }
1372
1373 public List<User> findByEmailAddress(String emailAddress, int start,
1374 int end, OrderByComparator orderByComparator) throws SystemException {
1375 Object[] finderArgs = new Object[] {
1376 emailAddress,
1377
1378 String.valueOf(start), String.valueOf(end),
1379 String.valueOf(orderByComparator)
1380 };
1381
1382 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1383 finderArgs, this);
1384
1385 if (list == null) {
1386 Session session = null;
1387
1388 try {
1389 session = openSession();
1390
1391 StringBundler query = null;
1392
1393 if (orderByComparator != null) {
1394 query = new StringBundler(3 +
1395 (orderByComparator.getOrderByFields().length * 3));
1396 }
1397 else {
1398 query = new StringBundler(2);
1399 }
1400
1401 query.append(_SQL_SELECT_USER_WHERE);
1402
1403 if (emailAddress == null) {
1404 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
1405 }
1406 else {
1407 if (emailAddress.equals(StringPool.BLANK)) {
1408 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
1409 }
1410 else {
1411 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
1412 }
1413 }
1414
1415 if (orderByComparator != null) {
1416 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1417 orderByComparator);
1418 }
1419
1420 String sql = query.toString();
1421
1422 Query q = session.createQuery(sql);
1423
1424 QueryPos qPos = QueryPos.getInstance(q);
1425
1426 if (emailAddress != null) {
1427 qPos.add(emailAddress);
1428 }
1429
1430 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1431 }
1432 catch (Exception e) {
1433 throw processException(e);
1434 }
1435 finally {
1436 if (list == null) {
1437 list = new ArrayList<User>();
1438 }
1439
1440 cacheResult(list);
1441
1442 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_EMAILADDRESS,
1443 finderArgs, list);
1444
1445 closeSession(session);
1446 }
1447 }
1448
1449 return list;
1450 }
1451
1452 public User findByEmailAddress_First(String emailAddress,
1453 OrderByComparator orderByComparator)
1454 throws NoSuchUserException, SystemException {
1455 List<User> list = findByEmailAddress(emailAddress, 0, 1,
1456 orderByComparator);
1457
1458 if (list.isEmpty()) {
1459 StringBundler msg = new StringBundler(4);
1460
1461 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1462
1463 msg.append("emailAddress=");
1464 msg.append(emailAddress);
1465
1466 msg.append(StringPool.CLOSE_CURLY_BRACE);
1467
1468 throw new NoSuchUserException(msg.toString());
1469 }
1470 else {
1471 return list.get(0);
1472 }
1473 }
1474
1475 public User findByEmailAddress_Last(String emailAddress,
1476 OrderByComparator orderByComparator)
1477 throws NoSuchUserException, SystemException {
1478 int count = countByEmailAddress(emailAddress);
1479
1480 List<User> list = findByEmailAddress(emailAddress, count - 1, count,
1481 orderByComparator);
1482
1483 if (list.isEmpty()) {
1484 StringBundler msg = new StringBundler(4);
1485
1486 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1487
1488 msg.append("emailAddress=");
1489 msg.append(emailAddress);
1490
1491 msg.append(StringPool.CLOSE_CURLY_BRACE);
1492
1493 throw new NoSuchUserException(msg.toString());
1494 }
1495 else {
1496 return list.get(0);
1497 }
1498 }
1499
1500 public User[] findByEmailAddress_PrevAndNext(long userId,
1501 String emailAddress, OrderByComparator orderByComparator)
1502 throws NoSuchUserException, SystemException {
1503 User user = findByPrimaryKey(userId);
1504
1505 int count = countByEmailAddress(emailAddress);
1506
1507 Session session = null;
1508
1509 try {
1510 session = openSession();
1511
1512 StringBundler query = null;
1513
1514 if (orderByComparator != null) {
1515 query = new StringBundler(3 +
1516 (orderByComparator.getOrderByFields().length * 3));
1517 }
1518 else {
1519 query = new StringBundler(2);
1520 }
1521
1522 query.append(_SQL_SELECT_USER_WHERE);
1523
1524 if (emailAddress == null) {
1525 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
1526 }
1527 else {
1528 if (emailAddress.equals(StringPool.BLANK)) {
1529 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
1530 }
1531 else {
1532 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
1533 }
1534 }
1535
1536 if (orderByComparator != null) {
1537 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1538 orderByComparator);
1539 }
1540
1541 String sql = query.toString();
1542
1543 Query q = session.createQuery(sql);
1544
1545 QueryPos qPos = QueryPos.getInstance(q);
1546
1547 if (emailAddress != null) {
1548 qPos.add(emailAddress);
1549 }
1550
1551 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
1552 orderByComparator, user);
1553
1554 User[] array = new UserImpl[3];
1555
1556 array[0] = (User)objArray[0];
1557 array[1] = (User)objArray[1];
1558 array[2] = (User)objArray[2];
1559
1560 return array;
1561 }
1562 catch (Exception e) {
1563 throw processException(e);
1564 }
1565 finally {
1566 closeSession(session);
1567 }
1568 }
1569
1570 public User findByOpenId(String openId)
1571 throws NoSuchUserException, SystemException {
1572 User user = fetchByOpenId(openId);
1573
1574 if (user == null) {
1575 StringBundler msg = new StringBundler(4);
1576
1577 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1578
1579 msg.append("openId=");
1580 msg.append(openId);
1581
1582 msg.append(StringPool.CLOSE_CURLY_BRACE);
1583
1584 if (_log.isWarnEnabled()) {
1585 _log.warn(msg.toString());
1586 }
1587
1588 throw new NoSuchUserException(msg.toString());
1589 }
1590
1591 return user;
1592 }
1593
1594 public User fetchByOpenId(String openId) throws SystemException {
1595 return fetchByOpenId(openId, true);
1596 }
1597
1598 public User fetchByOpenId(String openId, boolean retrieveFromCache)
1599 throws SystemException {
1600 Object[] finderArgs = new Object[] { openId };
1601
1602 Object result = null;
1603
1604 if (retrieveFromCache) {
1605 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_OPENID,
1606 finderArgs, this);
1607 }
1608
1609 if (result == null) {
1610 Session session = null;
1611
1612 try {
1613 session = openSession();
1614
1615 StringBundler query = new StringBundler(2);
1616
1617 query.append(_SQL_SELECT_USER_WHERE);
1618
1619 if (openId == null) {
1620 query.append(_FINDER_COLUMN_OPENID_OPENID_1);
1621 }
1622 else {
1623 if (openId.equals(StringPool.BLANK)) {
1624 query.append(_FINDER_COLUMN_OPENID_OPENID_3);
1625 }
1626 else {
1627 query.append(_FINDER_COLUMN_OPENID_OPENID_2);
1628 }
1629 }
1630
1631 String sql = query.toString();
1632
1633 Query q = session.createQuery(sql);
1634
1635 QueryPos qPos = QueryPos.getInstance(q);
1636
1637 if (openId != null) {
1638 qPos.add(openId);
1639 }
1640
1641 List<User> list = q.list();
1642
1643 result = list;
1644
1645 User user = null;
1646
1647 if (list.isEmpty()) {
1648 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1649 finderArgs, list);
1650 }
1651 else {
1652 user = list.get(0);
1653
1654 cacheResult(user);
1655
1656 if ((user.getOpenId() == null) ||
1657 !user.getOpenId().equals(openId)) {
1658 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1659 finderArgs, user);
1660 }
1661 }
1662
1663 return user;
1664 }
1665 catch (Exception e) {
1666 throw processException(e);
1667 }
1668 finally {
1669 if (result == null) {
1670 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPENID,
1671 finderArgs, new ArrayList<User>());
1672 }
1673
1674 closeSession(session);
1675 }
1676 }
1677 else {
1678 if (result instanceof List<?>) {
1679 return null;
1680 }
1681 else {
1682 return (User)result;
1683 }
1684 }
1685 }
1686
1687 public User findByPortraitId(long portraitId)
1688 throws NoSuchUserException, SystemException {
1689 User user = fetchByPortraitId(portraitId);
1690
1691 if (user == null) {
1692 StringBundler msg = new StringBundler(4);
1693
1694 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1695
1696 msg.append("portraitId=");
1697 msg.append(portraitId);
1698
1699 msg.append(StringPool.CLOSE_CURLY_BRACE);
1700
1701 if (_log.isWarnEnabled()) {
1702 _log.warn(msg.toString());
1703 }
1704
1705 throw new NoSuchUserException(msg.toString());
1706 }
1707
1708 return user;
1709 }
1710
1711 public User fetchByPortraitId(long portraitId) throws SystemException {
1712 return fetchByPortraitId(portraitId, true);
1713 }
1714
1715 public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
1716 throws SystemException {
1717 Object[] finderArgs = new Object[] { new Long(portraitId) };
1718
1719 Object result = null;
1720
1721 if (retrieveFromCache) {
1722 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1723 finderArgs, this);
1724 }
1725
1726 if (result == null) {
1727 Session session = null;
1728
1729 try {
1730 session = openSession();
1731
1732 StringBundler query = new StringBundler(2);
1733
1734 query.append(_SQL_SELECT_USER_WHERE);
1735
1736 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
1737
1738 String sql = query.toString();
1739
1740 Query q = session.createQuery(sql);
1741
1742 QueryPos qPos = QueryPos.getInstance(q);
1743
1744 qPos.add(portraitId);
1745
1746 List<User> list = q.list();
1747
1748 result = list;
1749
1750 User user = null;
1751
1752 if (list.isEmpty()) {
1753 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1754 finderArgs, list);
1755 }
1756 else {
1757 user = list.get(0);
1758
1759 cacheResult(user);
1760
1761 if ((user.getPortraitId() != portraitId)) {
1762 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1763 finderArgs, user);
1764 }
1765 }
1766
1767 return user;
1768 }
1769 catch (Exception e) {
1770 throw processException(e);
1771 }
1772 finally {
1773 if (result == null) {
1774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
1775 finderArgs, new ArrayList<User>());
1776 }
1777
1778 closeSession(session);
1779 }
1780 }
1781 else {
1782 if (result instanceof List<?>) {
1783 return null;
1784 }
1785 else {
1786 return (User)result;
1787 }
1788 }
1789 }
1790
1791 public User findByC_U(long companyId, long userId)
1792 throws NoSuchUserException, SystemException {
1793 User user = fetchByC_U(companyId, userId);
1794
1795 if (user == null) {
1796 StringBundler msg = new StringBundler(6);
1797
1798 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1799
1800 msg.append("companyId=");
1801 msg.append(companyId);
1802
1803 msg.append(", userId=");
1804 msg.append(userId);
1805
1806 msg.append(StringPool.CLOSE_CURLY_BRACE);
1807
1808 if (_log.isWarnEnabled()) {
1809 _log.warn(msg.toString());
1810 }
1811
1812 throw new NoSuchUserException(msg.toString());
1813 }
1814
1815 return user;
1816 }
1817
1818 public User fetchByC_U(long companyId, long userId)
1819 throws SystemException {
1820 return fetchByC_U(companyId, userId, true);
1821 }
1822
1823 public User fetchByC_U(long companyId, long userId,
1824 boolean retrieveFromCache) throws SystemException {
1825 Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
1826
1827 Object result = null;
1828
1829 if (retrieveFromCache) {
1830 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
1831 finderArgs, this);
1832 }
1833
1834 if (result == null) {
1835 Session session = null;
1836
1837 try {
1838 session = openSession();
1839
1840 StringBundler query = new StringBundler(3);
1841
1842 query.append(_SQL_SELECT_USER_WHERE);
1843
1844 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
1845
1846 query.append(_FINDER_COLUMN_C_U_USERID_2);
1847
1848 String sql = query.toString();
1849
1850 Query q = session.createQuery(sql);
1851
1852 QueryPos qPos = QueryPos.getInstance(q);
1853
1854 qPos.add(companyId);
1855
1856 qPos.add(userId);
1857
1858 List<User> list = q.list();
1859
1860 result = list;
1861
1862 User user = null;
1863
1864 if (list.isEmpty()) {
1865 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1866 finderArgs, list);
1867 }
1868 else {
1869 user = list.get(0);
1870
1871 cacheResult(user);
1872
1873 if ((user.getCompanyId() != companyId) ||
1874 (user.getUserId() != userId)) {
1875 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1876 finderArgs, user);
1877 }
1878 }
1879
1880 return user;
1881 }
1882 catch (Exception e) {
1883 throw processException(e);
1884 }
1885 finally {
1886 if (result == null) {
1887 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
1888 finderArgs, new ArrayList<User>());
1889 }
1890
1891 closeSession(session);
1892 }
1893 }
1894 else {
1895 if (result instanceof List<?>) {
1896 return null;
1897 }
1898 else {
1899 return (User)result;
1900 }
1901 }
1902 }
1903
1904 public User findByC_DU(long companyId, boolean defaultUser)
1905 throws NoSuchUserException, SystemException {
1906 User user = fetchByC_DU(companyId, defaultUser);
1907
1908 if (user == null) {
1909 StringBundler msg = new StringBundler(6);
1910
1911 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1912
1913 msg.append("companyId=");
1914 msg.append(companyId);
1915
1916 msg.append(", defaultUser=");
1917 msg.append(defaultUser);
1918
1919 msg.append(StringPool.CLOSE_CURLY_BRACE);
1920
1921 if (_log.isWarnEnabled()) {
1922 _log.warn(msg.toString());
1923 }
1924
1925 throw new NoSuchUserException(msg.toString());
1926 }
1927
1928 return user;
1929 }
1930
1931 public User fetchByC_DU(long companyId, boolean defaultUser)
1932 throws SystemException {
1933 return fetchByC_DU(companyId, defaultUser, true);
1934 }
1935
1936 public User fetchByC_DU(long companyId, boolean defaultUser,
1937 boolean retrieveFromCache) throws SystemException {
1938 Object[] finderArgs = new Object[] {
1939 new Long(companyId), Boolean.valueOf(defaultUser)
1940 };
1941
1942 Object result = null;
1943
1944 if (retrieveFromCache) {
1945 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
1946 finderArgs, this);
1947 }
1948
1949 if (result == null) {
1950 Session session = null;
1951
1952 try {
1953 session = openSession();
1954
1955 StringBundler query = new StringBundler(3);
1956
1957 query.append(_SQL_SELECT_USER_WHERE);
1958
1959 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
1960
1961 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
1962
1963 String sql = query.toString();
1964
1965 Query q = session.createQuery(sql);
1966
1967 QueryPos qPos = QueryPos.getInstance(q);
1968
1969 qPos.add(companyId);
1970
1971 qPos.add(defaultUser);
1972
1973 List<User> list = q.list();
1974
1975 result = list;
1976
1977 User user = null;
1978
1979 if (list.isEmpty()) {
1980 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1981 finderArgs, list);
1982 }
1983 else {
1984 user = list.get(0);
1985
1986 cacheResult(user);
1987
1988 if ((user.getCompanyId() != companyId) ||
1989 (user.getDefaultUser() != defaultUser)) {
1990 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
1991 finderArgs, user);
1992 }
1993 }
1994
1995 return user;
1996 }
1997 catch (Exception e) {
1998 throw processException(e);
1999 }
2000 finally {
2001 if (result == null) {
2002 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
2003 finderArgs, new ArrayList<User>());
2004 }
2005
2006 closeSession(session);
2007 }
2008 }
2009 else {
2010 if (result instanceof List<?>) {
2011 return null;
2012 }
2013 else {
2014 return (User)result;
2015 }
2016 }
2017 }
2018
2019 public User findByC_SN(long companyId, String screenName)
2020 throws NoSuchUserException, SystemException {
2021 User user = fetchByC_SN(companyId, screenName);
2022
2023 if (user == null) {
2024 StringBundler msg = new StringBundler(6);
2025
2026 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2027
2028 msg.append("companyId=");
2029 msg.append(companyId);
2030
2031 msg.append(", screenName=");
2032 msg.append(screenName);
2033
2034 msg.append(StringPool.CLOSE_CURLY_BRACE);
2035
2036 if (_log.isWarnEnabled()) {
2037 _log.warn(msg.toString());
2038 }
2039
2040 throw new NoSuchUserException(msg.toString());
2041 }
2042
2043 return user;
2044 }
2045
2046 public User fetchByC_SN(long companyId, String screenName)
2047 throws SystemException {
2048 return fetchByC_SN(companyId, screenName, true);
2049 }
2050
2051 public User fetchByC_SN(long companyId, String screenName,
2052 boolean retrieveFromCache) throws SystemException {
2053 Object[] finderArgs = new Object[] { new Long(companyId), screenName };
2054
2055 Object result = null;
2056
2057 if (retrieveFromCache) {
2058 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
2059 finderArgs, this);
2060 }
2061
2062 if (result == null) {
2063 Session session = null;
2064
2065 try {
2066 session = openSession();
2067
2068 StringBundler query = new StringBundler(3);
2069
2070 query.append(_SQL_SELECT_USER_WHERE);
2071
2072 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
2073
2074 if (screenName == null) {
2075 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
2076 }
2077 else {
2078 if (screenName.equals(StringPool.BLANK)) {
2079 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
2080 }
2081 else {
2082 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
2083 }
2084 }
2085
2086 String sql = query.toString();
2087
2088 Query q = session.createQuery(sql);
2089
2090 QueryPos qPos = QueryPos.getInstance(q);
2091
2092 qPos.add(companyId);
2093
2094 if (screenName != null) {
2095 qPos.add(screenName);
2096 }
2097
2098 List<User> list = q.list();
2099
2100 result = list;
2101
2102 User user = null;
2103
2104 if (list.isEmpty()) {
2105 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2106 finderArgs, list);
2107 }
2108 else {
2109 user = list.get(0);
2110
2111 cacheResult(user);
2112
2113 if ((user.getCompanyId() != companyId) ||
2114 (user.getScreenName() == null) ||
2115 !user.getScreenName().equals(screenName)) {
2116 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2117 finderArgs, user);
2118 }
2119 }
2120
2121 return user;
2122 }
2123 catch (Exception e) {
2124 throw processException(e);
2125 }
2126 finally {
2127 if (result == null) {
2128 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2129 finderArgs, new ArrayList<User>());
2130 }
2131
2132 closeSession(session);
2133 }
2134 }
2135 else {
2136 if (result instanceof List<?>) {
2137 return null;
2138 }
2139 else {
2140 return (User)result;
2141 }
2142 }
2143 }
2144
2145 public User findByC_EA(long companyId, String emailAddress)
2146 throws NoSuchUserException, SystemException {
2147 User user = fetchByC_EA(companyId, emailAddress);
2148
2149 if (user == null) {
2150 StringBundler msg = new StringBundler(6);
2151
2152 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2153
2154 msg.append("companyId=");
2155 msg.append(companyId);
2156
2157 msg.append(", emailAddress=");
2158 msg.append(emailAddress);
2159
2160 msg.append(StringPool.CLOSE_CURLY_BRACE);
2161
2162 if (_log.isWarnEnabled()) {
2163 _log.warn(msg.toString());
2164 }
2165
2166 throw new NoSuchUserException(msg.toString());
2167 }
2168
2169 return user;
2170 }
2171
2172 public User fetchByC_EA(long companyId, String emailAddress)
2173 throws SystemException {
2174 return fetchByC_EA(companyId, emailAddress, true);
2175 }
2176
2177 public User fetchByC_EA(long companyId, String emailAddress,
2178 boolean retrieveFromCache) throws SystemException {
2179 Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
2180
2181 Object result = null;
2182
2183 if (retrieveFromCache) {
2184 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
2185 finderArgs, this);
2186 }
2187
2188 if (result == null) {
2189 Session session = null;
2190
2191 try {
2192 session = openSession();
2193
2194 StringBundler query = new StringBundler(3);
2195
2196 query.append(_SQL_SELECT_USER_WHERE);
2197
2198 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
2199
2200 if (emailAddress == null) {
2201 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
2202 }
2203 else {
2204 if (emailAddress.equals(StringPool.BLANK)) {
2205 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
2206 }
2207 else {
2208 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
2209 }
2210 }
2211
2212 String sql = query.toString();
2213
2214 Query q = session.createQuery(sql);
2215
2216 QueryPos qPos = QueryPos.getInstance(q);
2217
2218 qPos.add(companyId);
2219
2220 if (emailAddress != null) {
2221 qPos.add(emailAddress);
2222 }
2223
2224 List<User> list = q.list();
2225
2226 result = list;
2227
2228 User user = null;
2229
2230 if (list.isEmpty()) {
2231 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2232 finderArgs, list);
2233 }
2234 else {
2235 user = list.get(0);
2236
2237 cacheResult(user);
2238
2239 if ((user.getCompanyId() != companyId) ||
2240 (user.getEmailAddress() == null) ||
2241 !user.getEmailAddress().equals(emailAddress)) {
2242 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2243 finderArgs, user);
2244 }
2245 }
2246
2247 return user;
2248 }
2249 catch (Exception e) {
2250 throw processException(e);
2251 }
2252 finally {
2253 if (result == null) {
2254 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2255 finderArgs, new ArrayList<User>());
2256 }
2257
2258 closeSession(session);
2259 }
2260 }
2261 else {
2262 if (result instanceof List<?>) {
2263 return null;
2264 }
2265 else {
2266 return (User)result;
2267 }
2268 }
2269 }
2270
2271 public List<User> findByC_A(long companyId, boolean active)
2272 throws SystemException {
2273 Object[] finderArgs = new Object[] {
2274 new Long(companyId), Boolean.valueOf(active)
2275 };
2276
2277 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_C_A,
2278 finderArgs, this);
2279
2280 if (list == null) {
2281 Session session = null;
2282
2283 try {
2284 session = openSession();
2285
2286 StringBundler query = new StringBundler(3);
2287
2288 query.append(_SQL_SELECT_USER_WHERE);
2289
2290 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
2291
2292 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
2293
2294 String sql = query.toString();
2295
2296 Query q = session.createQuery(sql);
2297
2298 QueryPos qPos = QueryPos.getInstance(q);
2299
2300 qPos.add(companyId);
2301
2302 qPos.add(active);
2303
2304 list = q.list();
2305 }
2306 catch (Exception e) {
2307 throw processException(e);
2308 }
2309 finally {
2310 if (list == null) {
2311 list = new ArrayList<User>();
2312 }
2313
2314 cacheResult(list);
2315
2316 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_C_A, finderArgs,
2317 list);
2318
2319 closeSession(session);
2320 }
2321 }
2322
2323 return list;
2324 }
2325
2326 public List<User> findByC_A(long companyId, boolean active, int start,
2327 int end) throws SystemException {
2328 return findByC_A(companyId, active, start, end, null);
2329 }
2330
2331 public List<User> findByC_A(long companyId, boolean active, int start,
2332 int end, OrderByComparator orderByComparator) throws SystemException {
2333 Object[] finderArgs = new Object[] {
2334 new Long(companyId), Boolean.valueOf(active),
2335
2336 String.valueOf(start), String.valueOf(end),
2337 String.valueOf(orderByComparator)
2338 };
2339
2340 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_C_A,
2341 finderArgs, this);
2342
2343 if (list == null) {
2344 Session session = null;
2345
2346 try {
2347 session = openSession();
2348
2349 StringBundler query = null;
2350
2351 if (orderByComparator != null) {
2352 query = new StringBundler(4 +
2353 (orderByComparator.getOrderByFields().length * 3));
2354 }
2355 else {
2356 query = new StringBundler(3);
2357 }
2358
2359 query.append(_SQL_SELECT_USER_WHERE);
2360
2361 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
2362
2363 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
2364
2365 if (orderByComparator != null) {
2366 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2367 orderByComparator);
2368 }
2369
2370 String sql = query.toString();
2371
2372 Query q = session.createQuery(sql);
2373
2374 QueryPos qPos = QueryPos.getInstance(q);
2375
2376 qPos.add(companyId);
2377
2378 qPos.add(active);
2379
2380 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
2381 }
2382 catch (Exception e) {
2383 throw processException(e);
2384 }
2385 finally {
2386 if (list == null) {
2387 list = new ArrayList<User>();
2388 }
2389
2390 cacheResult(list);
2391
2392 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_C_A,
2393 finderArgs, list);
2394
2395 closeSession(session);
2396 }
2397 }
2398
2399 return list;
2400 }
2401
2402 public User findByC_A_First(long companyId, boolean active,
2403 OrderByComparator orderByComparator)
2404 throws NoSuchUserException, SystemException {
2405 List<User> list = findByC_A(companyId, active, 0, 1, orderByComparator);
2406
2407 if (list.isEmpty()) {
2408 StringBundler msg = new StringBundler(6);
2409
2410 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2411
2412 msg.append("companyId=");
2413 msg.append(companyId);
2414
2415 msg.append(", active=");
2416 msg.append(active);
2417
2418 msg.append(StringPool.CLOSE_CURLY_BRACE);
2419
2420 throw new NoSuchUserException(msg.toString());
2421 }
2422 else {
2423 return list.get(0);
2424 }
2425 }
2426
2427 public User findByC_A_Last(long companyId, boolean active,
2428 OrderByComparator orderByComparator)
2429 throws NoSuchUserException, SystemException {
2430 int count = countByC_A(companyId, active);
2431
2432 List<User> list = findByC_A(companyId, active, count - 1, count,
2433 orderByComparator);
2434
2435 if (list.isEmpty()) {
2436 StringBundler msg = new StringBundler(6);
2437
2438 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2439
2440 msg.append("companyId=");
2441 msg.append(companyId);
2442
2443 msg.append(", active=");
2444 msg.append(active);
2445
2446 msg.append(StringPool.CLOSE_CURLY_BRACE);
2447
2448 throw new NoSuchUserException(msg.toString());
2449 }
2450 else {
2451 return list.get(0);
2452 }
2453 }
2454
2455 public User[] findByC_A_PrevAndNext(long userId, long companyId,
2456 boolean active, OrderByComparator orderByComparator)
2457 throws NoSuchUserException, SystemException {
2458 User user = findByPrimaryKey(userId);
2459
2460 int count = countByC_A(companyId, active);
2461
2462 Session session = null;
2463
2464 try {
2465 session = openSession();
2466
2467 StringBundler query = null;
2468
2469 if (orderByComparator != null) {
2470 query = new StringBundler(4 +
2471 (orderByComparator.getOrderByFields().length * 3));
2472 }
2473 else {
2474 query = new StringBundler(3);
2475 }
2476
2477 query.append(_SQL_SELECT_USER_WHERE);
2478
2479 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
2480
2481 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
2482
2483 if (orderByComparator != null) {
2484 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2485 orderByComparator);
2486 }
2487
2488 String sql = query.toString();
2489
2490 Query q = session.createQuery(sql);
2491
2492 QueryPos qPos = QueryPos.getInstance(q);
2493
2494 qPos.add(companyId);
2495
2496 qPos.add(active);
2497
2498 Object[] objArray = QueryUtil.getPrevAndNext(q, count,
2499 orderByComparator, user);
2500
2501 User[] array = new UserImpl[3];
2502
2503 array[0] = (User)objArray[0];
2504 array[1] = (User)objArray[1];
2505 array[2] = (User)objArray[2];
2506
2507 return array;
2508 }
2509 catch (Exception e) {
2510 throw processException(e);
2511 }
2512 finally {
2513 closeSession(session);
2514 }
2515 }
2516
2517 public List<User> findAll() throws SystemException {
2518 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2519 }
2520
2521 public List<User> findAll(int start, int end) throws SystemException {
2522 return findAll(start, end, null);
2523 }
2524
2525 public List<User> findAll(int start, int end,
2526 OrderByComparator orderByComparator) throws SystemException {
2527 Object[] finderArgs = new Object[] {
2528 String.valueOf(start), String.valueOf(end),
2529 String.valueOf(orderByComparator)
2530 };
2531
2532 List<User> list = (List<User>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2533 finderArgs, this);
2534
2535 if (list == null) {
2536 Session session = null;
2537
2538 try {
2539 session = openSession();
2540
2541 StringBundler query = null;
2542 String sql = null;
2543
2544 if (orderByComparator != null) {
2545 query = new StringBundler(2 +
2546 (orderByComparator.getOrderByFields().length * 3));
2547
2548 query.append(_SQL_SELECT_USER);
2549
2550 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2551 orderByComparator);
2552
2553 sql = query.toString();
2554 }
2555
2556 sql = _SQL_SELECT_USER;
2557
2558 Query q = session.createQuery(sql);
2559
2560 if (orderByComparator == null) {
2561 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2562 end, false);
2563
2564 Collections.sort(list);
2565 }
2566 else {
2567 list = (List<User>)QueryUtil.list(q, getDialect(), start,
2568 end);
2569 }
2570 }
2571 catch (Exception e) {
2572 throw processException(e);
2573 }
2574 finally {
2575 if (list == null) {
2576 list = new ArrayList<User>();
2577 }
2578
2579 cacheResult(list);
2580
2581 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2582
2583 closeSession(session);
2584 }
2585 }
2586
2587 return list;
2588 }
2589
2590 public void removeByUuid(String uuid) throws SystemException {
2591 for (User user : findByUuid(uuid)) {
2592 remove(user);
2593 }
2594 }
2595
2596 public void removeByCompanyId(long companyId) throws SystemException {
2597 for (User user : findByCompanyId(companyId)) {
2598 remove(user);
2599 }
2600 }
2601
2602 public void removeByContactId(long contactId)
2603 throws NoSuchUserException, SystemException {
2604 User user = findByContactId(contactId);
2605
2606 remove(user);
2607 }
2608
2609 public void removeByEmailAddress(String emailAddress)
2610 throws SystemException {
2611 for (User user : findByEmailAddress(emailAddress)) {
2612 remove(user);
2613 }
2614 }
2615
2616 public void removeByOpenId(String openId)
2617 throws NoSuchUserException, SystemException {
2618 User user = findByOpenId(openId);
2619
2620 remove(user);
2621 }
2622
2623 public void removeByPortraitId(long portraitId)
2624 throws NoSuchUserException, SystemException {
2625 User user = findByPortraitId(portraitId);
2626
2627 remove(user);
2628 }
2629
2630 public void removeByC_U(long companyId, long userId)
2631 throws NoSuchUserException, SystemException {
2632 User user = findByC_U(companyId, userId);
2633
2634 remove(user);
2635 }
2636
2637 public void removeByC_DU(long companyId, boolean defaultUser)
2638 throws NoSuchUserException, SystemException {
2639 User user = findByC_DU(companyId, defaultUser);
2640
2641 remove(user);
2642 }
2643
2644 public void removeByC_SN(long companyId, String screenName)
2645 throws NoSuchUserException, SystemException {
2646 User user = findByC_SN(companyId, screenName);
2647
2648 remove(user);
2649 }
2650
2651 public void removeByC_EA(long companyId, String emailAddress)
2652 throws NoSuchUserException, SystemException {
2653 User user = findByC_EA(companyId, emailAddress);
2654
2655 remove(user);
2656 }
2657
2658 public void removeByC_A(long companyId, boolean active)
2659 throws SystemException {
2660 for (User user : findByC_A(companyId, active)) {
2661 remove(user);
2662 }
2663 }
2664
2665 public void removeAll() throws SystemException {
2666 for (User user : findAll()) {
2667 remove(user);
2668 }
2669 }
2670
2671 public int countByUuid(String uuid) throws SystemException {
2672 Object[] finderArgs = new Object[] { uuid };
2673
2674 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2675 finderArgs, this);
2676
2677 if (count == null) {
2678 Session session = null;
2679
2680 try {
2681 session = openSession();
2682
2683 StringBundler query = new StringBundler(2);
2684
2685 query.append(_SQL_COUNT_USER_WHERE);
2686
2687 if (uuid == null) {
2688 query.append(_FINDER_COLUMN_UUID_UUID_1);
2689 }
2690 else {
2691 if (uuid.equals(StringPool.BLANK)) {
2692 query.append(_FINDER_COLUMN_UUID_UUID_3);
2693 }
2694 else {
2695 query.append(_FINDER_COLUMN_UUID_UUID_2);
2696 }
2697 }
2698
2699 String sql = query.toString();
2700
2701 Query q = session.createQuery(sql);
2702
2703 QueryPos qPos = QueryPos.getInstance(q);
2704
2705 if (uuid != null) {
2706 qPos.add(uuid);
2707 }
2708
2709 count = (Long)q.uniqueResult();
2710 }
2711 catch (Exception e) {
2712 throw processException(e);
2713 }
2714 finally {
2715 if (count == null) {
2716 count = Long.valueOf(0);
2717 }
2718
2719 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2720 finderArgs, count);
2721
2722 closeSession(session);
2723 }
2724 }
2725
2726 return count.intValue();
2727 }
2728
2729 public int countByCompanyId(long companyId) throws SystemException {
2730 Object[] finderArgs = new Object[] { new Long(companyId) };
2731
2732 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
2733 finderArgs, this);
2734
2735 if (count == null) {
2736 Session session = null;
2737
2738 try {
2739 session = openSession();
2740
2741 StringBundler query = new StringBundler(2);
2742
2743 query.append(_SQL_COUNT_USER_WHERE);
2744
2745 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
2746
2747 String sql = query.toString();
2748
2749 Query q = session.createQuery(sql);
2750
2751 QueryPos qPos = QueryPos.getInstance(q);
2752
2753 qPos.add(companyId);
2754
2755 count = (Long)q.uniqueResult();
2756 }
2757 catch (Exception e) {
2758 throw processException(e);
2759 }
2760 finally {
2761 if (count == null) {
2762 count = Long.valueOf(0);
2763 }
2764
2765 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
2766 finderArgs, count);
2767
2768 closeSession(session);
2769 }
2770 }
2771
2772 return count.intValue();
2773 }
2774
2775 public int countByContactId(long contactId) throws SystemException {
2776 Object[] finderArgs = new Object[] { new Long(contactId) };
2777
2778 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CONTACTID,
2779 finderArgs, this);
2780
2781 if (count == null) {
2782 Session session = null;
2783
2784 try {
2785 session = openSession();
2786
2787 StringBundler query = new StringBundler(2);
2788
2789 query.append(_SQL_COUNT_USER_WHERE);
2790
2791 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
2792
2793 String sql = query.toString();
2794
2795 Query q = session.createQuery(sql);
2796
2797 QueryPos qPos = QueryPos.getInstance(q);
2798
2799 qPos.add(contactId);
2800
2801 count = (Long)q.uniqueResult();
2802 }
2803 catch (Exception e) {
2804 throw processException(e);
2805 }
2806 finally {
2807 if (count == null) {
2808 count = Long.valueOf(0);
2809 }
2810
2811 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID,
2812 finderArgs, count);
2813
2814 closeSession(session);
2815 }
2816 }
2817
2818 return count.intValue();
2819 }
2820
2821 public int countByEmailAddress(String emailAddress)
2822 throws SystemException {
2823 Object[] finderArgs = new Object[] { emailAddress };
2824
2825 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2826 finderArgs, this);
2827
2828 if (count == null) {
2829 Session session = null;
2830
2831 try {
2832 session = openSession();
2833
2834 StringBundler query = new StringBundler(2);
2835
2836 query.append(_SQL_COUNT_USER_WHERE);
2837
2838 if (emailAddress == null) {
2839 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2840 }
2841 else {
2842 if (emailAddress.equals(StringPool.BLANK)) {
2843 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2844 }
2845 else {
2846 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2847 }
2848 }
2849
2850 String sql = query.toString();
2851
2852 Query q = session.createQuery(sql);
2853
2854 QueryPos qPos = QueryPos.getInstance(q);
2855
2856 if (emailAddress != null) {
2857 qPos.add(emailAddress);
2858 }
2859
2860 count = (Long)q.uniqueResult();
2861 }
2862 catch (Exception e) {
2863 throw processException(e);
2864 }
2865 finally {
2866 if (count == null) {
2867 count = Long.valueOf(0);
2868 }
2869
2870 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
2871 finderArgs, count);
2872
2873 closeSession(session);
2874 }
2875 }
2876
2877 return count.intValue();
2878 }
2879
2880 public int countByOpenId(String openId) throws SystemException {
2881 Object[] finderArgs = new Object[] { openId };
2882
2883 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_OPENID,
2884 finderArgs, this);
2885
2886 if (count == null) {
2887 Session session = null;
2888
2889 try {
2890 session = openSession();
2891
2892 StringBundler query = new StringBundler(2);
2893
2894 query.append(_SQL_COUNT_USER_WHERE);
2895
2896 if (openId == null) {
2897 query.append(_FINDER_COLUMN_OPENID_OPENID_1);
2898 }
2899 else {
2900 if (openId.equals(StringPool.BLANK)) {
2901 query.append(_FINDER_COLUMN_OPENID_OPENID_3);
2902 }
2903 else {
2904 query.append(_FINDER_COLUMN_OPENID_OPENID_2);
2905 }
2906 }
2907
2908 String sql = query.toString();
2909
2910 Query q = session.createQuery(sql);
2911
2912 QueryPos qPos = QueryPos.getInstance(q);
2913
2914 if (openId != null) {
2915 qPos.add(openId);
2916 }
2917
2918 count = (Long)q.uniqueResult();
2919 }
2920 catch (Exception e) {
2921 throw processException(e);
2922 }
2923 finally {
2924 if (count == null) {
2925 count = Long.valueOf(0);
2926 }
2927
2928 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_OPENID,
2929 finderArgs, count);
2930
2931 closeSession(session);
2932 }
2933 }
2934
2935 return count.intValue();
2936 }
2937
2938 public int countByPortraitId(long portraitId) throws SystemException {
2939 Object[] finderArgs = new Object[] { new Long(portraitId) };
2940
2941 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2942 finderArgs, this);
2943
2944 if (count == null) {
2945 Session session = null;
2946
2947 try {
2948 session = openSession();
2949
2950 StringBundler query = new StringBundler(2);
2951
2952 query.append(_SQL_COUNT_USER_WHERE);
2953
2954 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
2955
2956 String sql = query.toString();
2957
2958 Query q = session.createQuery(sql);
2959
2960 QueryPos qPos = QueryPos.getInstance(q);
2961
2962 qPos.add(portraitId);
2963
2964 count = (Long)q.uniqueResult();
2965 }
2966 catch (Exception e) {
2967 throw processException(e);
2968 }
2969 finally {
2970 if (count == null) {
2971 count = Long.valueOf(0);
2972 }
2973
2974 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID,
2975 finderArgs, count);
2976
2977 closeSession(session);
2978 }
2979 }
2980
2981 return count.intValue();
2982 }
2983
2984 public int countByC_U(long companyId, long userId)
2985 throws SystemException {
2986 Object[] finderArgs = new Object[] { new Long(companyId), new Long(userId) };
2987
2988 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
2989 finderArgs, this);
2990
2991 if (count == null) {
2992 Session session = null;
2993
2994 try {
2995 session = openSession();
2996
2997 StringBundler query = new StringBundler(3);
2998
2999 query.append(_SQL_COUNT_USER_WHERE);
3000
3001 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
3002
3003 query.append(_FINDER_COLUMN_C_U_USERID_2);
3004
3005 String sql = query.toString();
3006
3007 Query q = session.createQuery(sql);
3008
3009 QueryPos qPos = QueryPos.getInstance(q);
3010
3011 qPos.add(companyId);
3012
3013 qPos.add(userId);
3014
3015 count = (Long)q.uniqueResult();
3016 }
3017 catch (Exception e) {
3018 throw processException(e);
3019 }
3020 finally {
3021 if (count == null) {
3022 count = Long.valueOf(0);
3023 }
3024
3025 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
3026 count);
3027
3028 closeSession(session);
3029 }
3030 }
3031
3032 return count.intValue();
3033 }
3034
3035 public int countByC_DU(long companyId, boolean defaultUser)
3036 throws SystemException {
3037 Object[] finderArgs = new Object[] {
3038 new Long(companyId), Boolean.valueOf(defaultUser)
3039 };
3040
3041 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DU,
3042 finderArgs, this);
3043
3044 if (count == null) {
3045 Session session = null;
3046
3047 try {
3048 session = openSession();
3049
3050 StringBundler query = new StringBundler(3);
3051
3052 query.append(_SQL_COUNT_USER_WHERE);
3053
3054 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
3055
3056 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
3057
3058 String sql = query.toString();
3059
3060 Query q = session.createQuery(sql);
3061
3062 QueryPos qPos = QueryPos.getInstance(q);
3063
3064 qPos.add(companyId);
3065
3066 qPos.add(defaultUser);
3067
3068 count = (Long)q.uniqueResult();
3069 }
3070 catch (Exception e) {
3071 throw processException(e);
3072 }
3073 finally {
3074 if (count == null) {
3075 count = Long.valueOf(0);
3076 }
3077
3078 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU,
3079 finderArgs, count);
3080
3081 closeSession(session);
3082 }
3083 }
3084
3085 return count.intValue();
3086 }
3087
3088 public int countByC_SN(long companyId, String screenName)
3089 throws SystemException {
3090 Object[] finderArgs = new Object[] { new Long(companyId), screenName };
3091
3092 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_SN,
3093 finderArgs, this);
3094
3095 if (count == null) {
3096 Session session = null;
3097
3098 try {
3099 session = openSession();
3100
3101 StringBundler query = new StringBundler(3);
3102
3103 query.append(_SQL_COUNT_USER_WHERE);
3104
3105 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
3106
3107 if (screenName == null) {
3108 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
3109 }
3110 else {
3111 if (screenName.equals(StringPool.BLANK)) {
3112 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
3113 }
3114 else {
3115 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
3116 }
3117 }
3118
3119 String sql = query.toString();
3120
3121 Query q = session.createQuery(sql);
3122
3123 QueryPos qPos = QueryPos.getInstance(q);
3124
3125 qPos.add(companyId);
3126
3127 if (screenName != null) {
3128 qPos.add(screenName);
3129 }
3130
3131 count = (Long)q.uniqueResult();
3132 }
3133 catch (Exception e) {
3134 throw processException(e);
3135 }
3136 finally {
3137 if (count == null) {
3138 count = Long.valueOf(0);
3139 }
3140
3141 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN,
3142 finderArgs, count);
3143
3144 closeSession(session);
3145 }
3146 }
3147
3148 return count.intValue();
3149 }
3150
3151 public int countByC_EA(long companyId, String emailAddress)
3152 throws SystemException {
3153 Object[] finderArgs = new Object[] { new Long(companyId), emailAddress };
3154
3155 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_EA,
3156 finderArgs, this);
3157
3158 if (count == null) {
3159 Session session = null;
3160
3161 try {
3162 session = openSession();
3163
3164 StringBundler query = new StringBundler(3);
3165
3166 query.append(_SQL_COUNT_USER_WHERE);
3167
3168 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
3169
3170 if (emailAddress == null) {
3171 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
3172 }
3173 else {
3174 if (emailAddress.equals(StringPool.BLANK)) {
3175 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
3176 }
3177 else {
3178 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
3179 }
3180 }
3181
3182 String sql = query.toString();
3183
3184 Query q = session.createQuery(sql);
3185
3186 QueryPos qPos = QueryPos.getInstance(q);
3187
3188 qPos.add(companyId);
3189
3190 if (emailAddress != null) {
3191 qPos.add(emailAddress);
3192 }
3193
3194 count = (Long)q.uniqueResult();
3195 }
3196 catch (Exception e) {
3197 throw processException(e);
3198 }
3199 finally {
3200 if (count == null) {
3201 count = Long.valueOf(0);
3202 }
3203
3204 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA,
3205 finderArgs, count);
3206
3207 closeSession(session);
3208 }
3209 }
3210
3211 return count.intValue();
3212 }
3213
3214 public int countByC_A(long companyId, boolean active)
3215 throws SystemException {
3216 Object[] finderArgs = new Object[] {
3217 new Long(companyId), Boolean.valueOf(active)
3218 };
3219
3220 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_A,
3221 finderArgs, this);
3222
3223 if (count == null) {
3224 Session session = null;
3225
3226 try {
3227 session = openSession();
3228
3229 StringBundler query = new StringBundler(3);
3230
3231 query.append(_SQL_COUNT_USER_WHERE);
3232
3233 query.append(_FINDER_COLUMN_C_A_COMPANYID_2);
3234
3235 query.append(_FINDER_COLUMN_C_A_ACTIVE_2);
3236
3237 String sql = query.toString();
3238
3239 Query q = session.createQuery(sql);
3240
3241 QueryPos qPos = QueryPos.getInstance(q);
3242
3243 qPos.add(companyId);
3244
3245 qPos.add(active);
3246
3247 count = (Long)q.uniqueResult();
3248 }
3249 catch (Exception e) {
3250 throw processException(e);
3251 }
3252 finally {
3253 if (count == null) {
3254 count = Long.valueOf(0);
3255 }
3256
3257 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_A, finderArgs,
3258 count);
3259
3260 closeSession(session);
3261 }
3262 }
3263
3264 return count.intValue();
3265 }
3266
3267 public int countAll() throws SystemException {
3268 Object[] finderArgs = new Object[0];
3269
3270 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3271 finderArgs, this);
3272
3273 if (count == null) {
3274 Session session = null;
3275
3276 try {
3277 session = openSession();
3278
3279 Query q = session.createQuery(_SQL_COUNT_USER);
3280
3281 count = (Long)q.uniqueResult();
3282 }
3283 catch (Exception e) {
3284 throw processException(e);
3285 }
3286 finally {
3287 if (count == null) {
3288 count = Long.valueOf(0);
3289 }
3290
3291 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3292 count);
3293
3294 closeSession(session);
3295 }
3296 }
3297
3298 return count.intValue();
3299 }
3300
3301 public List<com.liferay.portal.model.Group> getGroups(long pk)
3302 throws SystemException {
3303 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3304 }
3305
3306 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3307 int end) throws SystemException {
3308 return getGroups(pk, start, end, null);
3309 }
3310
3311 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3312 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
3313 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroups",
3314 new String[] {
3315 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3316 "com.liferay.portal.kernel.util.OrderByComparator"
3317 });
3318
3319 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
3320 int end, OrderByComparator orderByComparator) throws SystemException {
3321 Object[] finderArgs = new Object[] {
3322 new Long(pk), String.valueOf(start), String.valueOf(end),
3323 String.valueOf(orderByComparator)
3324 };
3325
3326 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
3327 finderArgs, this);
3328
3329 if (list == null) {
3330 Session session = null;
3331
3332 try {
3333 session = openSession();
3334
3335 String sql = null;
3336
3337 if (orderByComparator != null) {
3338 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
3339 .concat(orderByComparator.getOrderBy());
3340 }
3341
3342 else {
3343 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
3344 }
3345
3346 SQLQuery q = session.createSQLQuery(sql);
3347
3348 q.addEntity("Group_",
3349 com.liferay.portal.model.impl.GroupImpl.class);
3350
3351 QueryPos qPos = QueryPos.getInstance(q);
3352
3353 qPos.add(pk);
3354
3355 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
3356 getDialect(), start, end);
3357 }
3358 catch (Exception e) {
3359 throw processException(e);
3360 }
3361 finally {
3362 if (list == null) {
3363 list = new ArrayList<com.liferay.portal.model.Group>();
3364 }
3365
3366 groupPersistence.cacheResult(list);
3367
3368 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS, finderArgs,
3369 list);
3370
3371 closeSession(session);
3372 }
3373 }
3374
3375 return list;
3376 }
3377
3378 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3379 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
3380 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroupsSize",
3381 new String[] { Long.class.getName() });
3382
3383 public int getGroupsSize(long pk) throws SystemException {
3384 Object[] finderArgs = new Object[] { new Long(pk) };
3385
3386 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
3387 finderArgs, this);
3388
3389 if (count == null) {
3390 Session session = null;
3391
3392 try {
3393 session = openSession();
3394
3395 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
3396
3397 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3398
3399 QueryPos qPos = QueryPos.getInstance(q);
3400
3401 qPos.add(pk);
3402
3403 count = (Long)q.uniqueResult();
3404 }
3405 catch (Exception e) {
3406 throw processException(e);
3407 }
3408 finally {
3409 if (count == null) {
3410 count = Long.valueOf(0);
3411 }
3412
3413 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
3414 finderArgs, count);
3415
3416 closeSession(session);
3417 }
3418 }
3419
3420 return count.intValue();
3421 }
3422
3423 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
3424 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
3425 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsGroup",
3426 new String[] { Long.class.getName(), Long.class.getName() });
3427
3428 public boolean containsGroup(long pk, long groupPK)
3429 throws SystemException {
3430 Object[] finderArgs = new Object[] { new Long(pk), new Long(groupPK) };
3431
3432 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
3433 finderArgs, this);
3434
3435 if (value == null) {
3436 try {
3437 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
3438 }
3439 catch (Exception e) {
3440 throw processException(e);
3441 }
3442 finally {
3443 if (value == null) {
3444 value = Boolean.FALSE;
3445 }
3446
3447 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
3448 finderArgs, value);
3449 }
3450 }
3451
3452 return value.booleanValue();
3453 }
3454
3455 public boolean containsGroups(long pk) throws SystemException {
3456 if (getGroupsSize(pk) > 0) {
3457 return true;
3458 }
3459 else {
3460 return false;
3461 }
3462 }
3463
3464 public void addGroup(long pk, long groupPK) throws SystemException {
3465 try {
3466 addGroup.add(pk, groupPK);
3467 }
3468 catch (Exception e) {
3469 throw processException(e);
3470 }
3471 finally {
3472 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3473 }
3474 }
3475
3476 public void addGroup(long pk, com.liferay.portal.model.Group group)
3477 throws SystemException {
3478 try {
3479 addGroup.add(pk, group.getPrimaryKey());
3480 }
3481 catch (Exception e) {
3482 throw processException(e);
3483 }
3484 finally {
3485 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3486 }
3487 }
3488
3489 public void addGroups(long pk, long[] groupPKs) throws SystemException {
3490 try {
3491 for (long groupPK : groupPKs) {
3492 addGroup.add(pk, groupPK);
3493 }
3494 }
3495 catch (Exception e) {
3496 throw processException(e);
3497 }
3498 finally {
3499 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3500 }
3501 }
3502
3503 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
3504 throws SystemException {
3505 try {
3506 for (com.liferay.portal.model.Group group : groups) {
3507 addGroup.add(pk, group.getPrimaryKey());
3508 }
3509 }
3510 catch (Exception e) {
3511 throw processException(e);
3512 }
3513 finally {
3514 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3515 }
3516 }
3517
3518 public void clearGroups(long pk) throws SystemException {
3519 try {
3520 clearGroups.clear(pk);
3521 }
3522 catch (Exception e) {
3523 throw processException(e);
3524 }
3525 finally {
3526 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3527 }
3528 }
3529
3530 public void removeGroup(long pk, long groupPK) throws SystemException {
3531 try {
3532 removeGroup.remove(pk, groupPK);
3533 }
3534 catch (Exception e) {
3535 throw processException(e);
3536 }
3537 finally {
3538 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3539 }
3540 }
3541
3542 public void removeGroup(long pk, com.liferay.portal.model.Group group)
3543 throws SystemException {
3544 try {
3545 removeGroup.remove(pk, group.getPrimaryKey());
3546 }
3547 catch (Exception e) {
3548 throw processException(e);
3549 }
3550 finally {
3551 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3552 }
3553 }
3554
3555 public void removeGroups(long pk, long[] groupPKs)
3556 throws SystemException {
3557 try {
3558 for (long groupPK : groupPKs) {
3559 removeGroup.remove(pk, groupPK);
3560 }
3561 }
3562 catch (Exception e) {
3563 throw processException(e);
3564 }
3565 finally {
3566 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3567 }
3568 }
3569
3570 public void removeGroups(long pk,
3571 List<com.liferay.portal.model.Group> groups) throws SystemException {
3572 try {
3573 for (com.liferay.portal.model.Group group : groups) {
3574 removeGroup.remove(pk, group.getPrimaryKey());
3575 }
3576 }
3577 catch (Exception e) {
3578 throw processException(e);
3579 }
3580 finally {
3581 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3582 }
3583 }
3584
3585 public void setGroups(long pk, long[] groupPKs) throws SystemException {
3586 try {
3587 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
3588
3589 List<com.liferay.portal.model.Group> groups = getGroups(pk);
3590
3591 for (com.liferay.portal.model.Group group : groups) {
3592 if (!groupPKSet.contains(group.getPrimaryKey())) {
3593 removeGroup.remove(pk, group.getPrimaryKey());
3594 }
3595 else {
3596 groupPKSet.remove(group.getPrimaryKey());
3597 }
3598 }
3599
3600 for (Long groupPK : groupPKSet) {
3601 addGroup.add(pk, groupPK);
3602 }
3603 }
3604 catch (Exception e) {
3605 throw processException(e);
3606 }
3607 finally {
3608 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3609 }
3610 }
3611
3612 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
3613 throws SystemException {
3614 try {
3615 long[] groupPKs = new long[groups.size()];
3616
3617 for (int i = 0; i < groups.size(); i++) {
3618 com.liferay.portal.model.Group group = groups.get(i);
3619
3620 groupPKs[i] = group.getPrimaryKey();
3621 }
3622
3623 setGroups(pk, groupPKs);
3624 }
3625 catch (Exception e) {
3626 throw processException(e);
3627 }
3628 finally {
3629 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
3630 }
3631 }
3632
3633 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
3634 throws SystemException {
3635 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3636 }
3637
3638 public List<com.liferay.portal.model.Organization> getOrganizations(
3639 long pk, int start, int end) throws SystemException {
3640 return getOrganizations(pk, start, end, null);
3641 }
3642
3643 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3644 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
3645 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getOrganizations",
3646 new String[] {
3647 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3648 "com.liferay.portal.kernel.util.OrderByComparator"
3649 });
3650
3651 public List<com.liferay.portal.model.Organization> getOrganizations(
3652 long pk, int start, int end, OrderByComparator orderByComparator)
3653 throws SystemException {
3654 Object[] finderArgs = new Object[] {
3655 new Long(pk), String.valueOf(start), String.valueOf(end),
3656 String.valueOf(orderByComparator)
3657 };
3658
3659 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
3660 finderArgs, this);
3661
3662 if (list == null) {
3663 Session session = null;
3664
3665 try {
3666 session = openSession();
3667
3668 String sql = null;
3669
3670 if (orderByComparator != null) {
3671 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
3672 .concat(orderByComparator.getOrderBy());
3673 }
3674
3675 else {
3676 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
3677 }
3678
3679 SQLQuery q = session.createSQLQuery(sql);
3680
3681 q.addEntity("Organization_",
3682 com.liferay.portal.model.impl.OrganizationImpl.class);
3683
3684 QueryPos qPos = QueryPos.getInstance(q);
3685
3686 qPos.add(pk);
3687
3688 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
3689 getDialect(), start, end);
3690 }
3691 catch (Exception e) {
3692 throw processException(e);
3693 }
3694 finally {
3695 if (list == null) {
3696 list = new ArrayList<com.liferay.portal.model.Organization>();
3697 }
3698
3699 organizationPersistence.cacheResult(list);
3700
3701 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
3702 finderArgs, list);
3703
3704 closeSession(session);
3705 }
3706 }
3707
3708 return list;
3709 }
3710
3711 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3712 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
3713 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
3714 "getOrganizationsSize", new String[] { Long.class.getName() });
3715
3716 public int getOrganizationsSize(long pk) throws SystemException {
3717 Object[] finderArgs = new Object[] { new Long(pk) };
3718
3719 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3720 finderArgs, this);
3721
3722 if (count == null) {
3723 Session session = null;
3724
3725 try {
3726 session = openSession();
3727
3728 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
3729
3730 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
3731
3732 QueryPos qPos = QueryPos.getInstance(q);
3733
3734 qPos.add(pk);
3735
3736 count = (Long)q.uniqueResult();
3737 }
3738 catch (Exception e) {
3739 throw processException(e);
3740 }
3741 finally {
3742 if (count == null) {
3743 count = Long.valueOf(0);
3744 }
3745
3746 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
3747 finderArgs, count);
3748
3749 closeSession(session);
3750 }
3751 }
3752
3753 return count.intValue();
3754 }
3755
3756 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
3757 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
3758 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
3759 "containsOrganization",
3760 new String[] { Long.class.getName(), Long.class.getName() });
3761
3762 public boolean containsOrganization(long pk, long organizationPK)
3763 throws SystemException {
3764 Object[] finderArgs = new Object[] {
3765 new Long(pk),
3766
3767 new Long(organizationPK)
3768 };
3769
3770 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3771 finderArgs, this);
3772
3773 if (value == null) {
3774 try {
3775 value = Boolean.valueOf(containsOrganization.contains(pk,
3776 organizationPK));
3777 }
3778 catch (Exception e) {
3779 throw processException(e);
3780 }
3781 finally {
3782 if (value == null) {
3783 value = Boolean.FALSE;
3784 }
3785
3786 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
3787 finderArgs, value);
3788 }
3789 }
3790
3791 return value.booleanValue();
3792 }
3793
3794 public boolean containsOrganizations(long pk) throws SystemException {
3795 if (getOrganizationsSize(pk) > 0) {
3796 return true;
3797 }
3798 else {
3799 return false;
3800 }
3801 }
3802
3803 public void addOrganization(long pk, long organizationPK)
3804 throws SystemException {
3805 try {
3806 addOrganization.add(pk, organizationPK);
3807 }
3808 catch (Exception e) {
3809 throw processException(e);
3810 }
3811 finally {
3812 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3813 }
3814 }
3815
3816 public void addOrganization(long pk,
3817 com.liferay.portal.model.Organization organization)
3818 throws SystemException {
3819 try {
3820 addOrganization.add(pk, organization.getPrimaryKey());
3821 }
3822 catch (Exception e) {
3823 throw processException(e);
3824 }
3825 finally {
3826 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3827 }
3828 }
3829
3830 public void addOrganizations(long pk, long[] organizationPKs)
3831 throws SystemException {
3832 try {
3833 for (long organizationPK : organizationPKs) {
3834 addOrganization.add(pk, organizationPK);
3835 }
3836 }
3837 catch (Exception e) {
3838 throw processException(e);
3839 }
3840 finally {
3841 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3842 }
3843 }
3844
3845 public void addOrganizations(long pk,
3846 List<com.liferay.portal.model.Organization> organizations)
3847 throws SystemException {
3848 try {
3849 for (com.liferay.portal.model.Organization organization : organizations) {
3850 addOrganization.add(pk, organization.getPrimaryKey());
3851 }
3852 }
3853 catch (Exception e) {
3854 throw processException(e);
3855 }
3856 finally {
3857 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3858 }
3859 }
3860
3861 public void clearOrganizations(long pk) throws SystemException {
3862 try {
3863 clearOrganizations.clear(pk);
3864 }
3865 catch (Exception e) {
3866 throw processException(e);
3867 }
3868 finally {
3869 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3870 }
3871 }
3872
3873 public void removeOrganization(long pk, long organizationPK)
3874 throws SystemException {
3875 try {
3876 removeOrganization.remove(pk, organizationPK);
3877 }
3878 catch (Exception e) {
3879 throw processException(e);
3880 }
3881 finally {
3882 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3883 }
3884 }
3885
3886 public void removeOrganization(long pk,
3887 com.liferay.portal.model.Organization organization)
3888 throws SystemException {
3889 try {
3890 removeOrganization.remove(pk, organization.getPrimaryKey());
3891 }
3892 catch (Exception e) {
3893 throw processException(e);
3894 }
3895 finally {
3896 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3897 }
3898 }
3899
3900 public void removeOrganizations(long pk, long[] organizationPKs)
3901 throws SystemException {
3902 try {
3903 for (long organizationPK : organizationPKs) {
3904 removeOrganization.remove(pk, organizationPK);
3905 }
3906 }
3907 catch (Exception e) {
3908 throw processException(e);
3909 }
3910 finally {
3911 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3912 }
3913 }
3914
3915 public void removeOrganizations(long pk,
3916 List<com.liferay.portal.model.Organization> organizations)
3917 throws SystemException {
3918 try {
3919 for (com.liferay.portal.model.Organization organization : organizations) {
3920 removeOrganization.remove(pk, organization.getPrimaryKey());
3921 }
3922 }
3923 catch (Exception e) {
3924 throw processException(e);
3925 }
3926 finally {
3927 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3928 }
3929 }
3930
3931 public void setOrganizations(long pk, long[] organizationPKs)
3932 throws SystemException {
3933 try {
3934 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
3935
3936 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
3937
3938 for (com.liferay.portal.model.Organization organization : organizations) {
3939 if (!organizationPKSet.contains(organization.getPrimaryKey())) {
3940 removeOrganization.remove(pk, organization.getPrimaryKey());
3941 }
3942 else {
3943 organizationPKSet.remove(organization.getPrimaryKey());
3944 }
3945 }
3946
3947 for (Long organizationPK : organizationPKSet) {
3948 addOrganization.add(pk, organizationPK);
3949 }
3950 }
3951 catch (Exception e) {
3952 throw processException(e);
3953 }
3954 finally {
3955 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3956 }
3957 }
3958
3959 public void setOrganizations(long pk,
3960 List<com.liferay.portal.model.Organization> organizations)
3961 throws SystemException {
3962 try {
3963 long[] organizationPKs = new long[organizations.size()];
3964
3965 for (int i = 0; i < organizations.size(); i++) {
3966 com.liferay.portal.model.Organization organization = organizations.get(i);
3967
3968 organizationPKs[i] = organization.getPrimaryKey();
3969 }
3970
3971 setOrganizations(pk, organizationPKs);
3972 }
3973 catch (Exception e) {
3974 throw processException(e);
3975 }
3976 finally {
3977 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
3978 }
3979 }
3980
3981 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
3982 throws SystemException {
3983 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3984 }
3985
3986 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
3987 int start, int end) throws SystemException {
3988 return getPermissions(pk, start, end, null);
3989 }
3990
3991 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
3992 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
3993 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
3994 "getPermissions",
3995 new String[] {
3996 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3997 "com.liferay.portal.kernel.util.OrderByComparator"
3998 });
3999
4000 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
4001 int start, int end, OrderByComparator orderByComparator)
4002 throws SystemException {
4003 Object[] finderArgs = new Object[] {
4004 new Long(pk), String.valueOf(start), String.valueOf(end),
4005 String.valueOf(orderByComparator)
4006 };
4007
4008 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
4009 finderArgs, this);
4010
4011 if (list == null) {
4012 Session session = null;
4013
4014 try {
4015 session = openSession();
4016
4017 String sql = null;
4018
4019 if (orderByComparator != null) {
4020 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
4021 .concat(orderByComparator.getOrderBy());
4022 }
4023
4024 sql = _SQL_GETPERMISSIONS;
4025
4026 SQLQuery q = session.createSQLQuery(sql);
4027
4028 q.addEntity("Permission_",
4029 com.liferay.portal.model.impl.PermissionImpl.class);
4030
4031 QueryPos qPos = QueryPos.getInstance(q);
4032
4033 qPos.add(pk);
4034
4035 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
4036 getDialect(), start, end);
4037 }
4038 catch (Exception e) {
4039 throw processException(e);
4040 }
4041 finally {
4042 if (list == null) {
4043 list = new ArrayList<com.liferay.portal.model.Permission>();
4044 }
4045
4046 permissionPersistence.cacheResult(list);
4047
4048 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
4049 finderArgs, list);
4050
4051 closeSession(session);
4052 }
4053 }
4054
4055 return list;
4056 }
4057
4058 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4059 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
4060 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
4061 "getPermissionsSize", new String[] { Long.class.getName() });
4062
4063 public int getPermissionsSize(long pk) throws SystemException {
4064 Object[] finderArgs = new Object[] { new Long(pk) };
4065
4066 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
4067 finderArgs, this);
4068
4069 if (count == null) {
4070 Session session = null;
4071
4072 try {
4073 session = openSession();
4074
4075 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
4076
4077 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4078
4079 QueryPos qPos = QueryPos.getInstance(q);
4080
4081 qPos.add(pk);
4082
4083 count = (Long)q.uniqueResult();
4084 }
4085 catch (Exception e) {
4086 throw processException(e);
4087 }
4088 finally {
4089 if (count == null) {
4090 count = Long.valueOf(0);
4091 }
4092
4093 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
4094 finderArgs, count);
4095
4096 closeSession(session);
4097 }
4098 }
4099
4100 return count.intValue();
4101 }
4102
4103 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
4104 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
4105 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
4106 "containsPermission",
4107 new String[] { Long.class.getName(), Long.class.getName() });
4108
4109 public boolean containsPermission(long pk, long permissionPK)
4110 throws SystemException {
4111 Object[] finderArgs = new Object[] { new Long(pk), new Long(permissionPK) };
4112
4113 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
4114 finderArgs, this);
4115
4116 if (value == null) {
4117 try {
4118 value = Boolean.valueOf(containsPermission.contains(pk,
4119 permissionPK));
4120 }
4121 catch (Exception e) {
4122 throw processException(e);
4123 }
4124 finally {
4125 if (value == null) {
4126 value = Boolean.FALSE;
4127 }
4128
4129 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
4130 finderArgs, value);
4131 }
4132 }
4133
4134 return value.booleanValue();
4135 }
4136
4137 public boolean containsPermissions(long pk) throws SystemException {
4138 if (getPermissionsSize(pk) > 0) {
4139 return true;
4140 }
4141 else {
4142 return false;
4143 }
4144 }
4145
4146 public void addPermission(long pk, long permissionPK)
4147 throws SystemException {
4148 try {
4149 addPermission.add(pk, permissionPK);
4150 }
4151 catch (Exception e) {
4152 throw processException(e);
4153 }
4154 finally {
4155 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4156 }
4157 }
4158
4159 public void addPermission(long pk,
4160 com.liferay.portal.model.Permission permission)
4161 throws SystemException {
4162 try {
4163 addPermission.add(pk, permission.getPrimaryKey());
4164 }
4165 catch (Exception e) {
4166 throw processException(e);
4167 }
4168 finally {
4169 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4170 }
4171 }
4172
4173 public void addPermissions(long pk, long[] permissionPKs)
4174 throws SystemException {
4175 try {
4176 for (long permissionPK : permissionPKs) {
4177 addPermission.add(pk, permissionPK);
4178 }
4179 }
4180 catch (Exception e) {
4181 throw processException(e);
4182 }
4183 finally {
4184 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4185 }
4186 }
4187
4188 public void addPermissions(long pk,
4189 List<com.liferay.portal.model.Permission> permissions)
4190 throws SystemException {
4191 try {
4192 for (com.liferay.portal.model.Permission permission : permissions) {
4193 addPermission.add(pk, permission.getPrimaryKey());
4194 }
4195 }
4196 catch (Exception e) {
4197 throw processException(e);
4198 }
4199 finally {
4200 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4201 }
4202 }
4203
4204 public void clearPermissions(long pk) throws SystemException {
4205 try {
4206 clearPermissions.clear(pk);
4207 }
4208 catch (Exception e) {
4209 throw processException(e);
4210 }
4211 finally {
4212 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4213 }
4214 }
4215
4216 public void removePermission(long pk, long permissionPK)
4217 throws SystemException {
4218 try {
4219 removePermission.remove(pk, permissionPK);
4220 }
4221 catch (Exception e) {
4222 throw processException(e);
4223 }
4224 finally {
4225 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4226 }
4227 }
4228
4229 public void removePermission(long pk,
4230 com.liferay.portal.model.Permission permission)
4231 throws SystemException {
4232 try {
4233 removePermission.remove(pk, permission.getPrimaryKey());
4234 }
4235 catch (Exception e) {
4236 throw processException(e);
4237 }
4238 finally {
4239 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4240 }
4241 }
4242
4243 public void removePermissions(long pk, long[] permissionPKs)
4244 throws SystemException {
4245 try {
4246 for (long permissionPK : permissionPKs) {
4247 removePermission.remove(pk, permissionPK);
4248 }
4249 }
4250 catch (Exception e) {
4251 throw processException(e);
4252 }
4253 finally {
4254 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4255 }
4256 }
4257
4258 public void removePermissions(long pk,
4259 List<com.liferay.portal.model.Permission> permissions)
4260 throws SystemException {
4261 try {
4262 for (com.liferay.portal.model.Permission permission : permissions) {
4263 removePermission.remove(pk, permission.getPrimaryKey());
4264 }
4265 }
4266 catch (Exception e) {
4267 throw processException(e);
4268 }
4269 finally {
4270 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4271 }
4272 }
4273
4274 public void setPermissions(long pk, long[] permissionPKs)
4275 throws SystemException {
4276 try {
4277 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
4278
4279 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
4280
4281 for (com.liferay.portal.model.Permission permission : permissions) {
4282 if (!permissionPKSet.contains(permission.getPrimaryKey())) {
4283 removePermission.remove(pk, permission.getPrimaryKey());
4284 }
4285 else {
4286 permissionPKSet.remove(permission.getPrimaryKey());
4287 }
4288 }
4289
4290 for (Long permissionPK : permissionPKSet) {
4291 addPermission.add(pk, permissionPK);
4292 }
4293 }
4294 catch (Exception e) {
4295 throw processException(e);
4296 }
4297 finally {
4298 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4299 }
4300 }
4301
4302 public void setPermissions(long pk,
4303 List<com.liferay.portal.model.Permission> permissions)
4304 throws SystemException {
4305 try {
4306 long[] permissionPKs = new long[permissions.size()];
4307
4308 for (int i = 0; i < permissions.size(); i++) {
4309 com.liferay.portal.model.Permission permission = permissions.get(i);
4310
4311 permissionPKs[i] = permission.getPrimaryKey();
4312 }
4313
4314 setPermissions(pk, permissionPKs);
4315 }
4316 catch (Exception e) {
4317 throw processException(e);
4318 }
4319 finally {
4320 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
4321 }
4322 }
4323
4324 public List<com.liferay.portal.model.Role> getRoles(long pk)
4325 throws SystemException {
4326 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4327 }
4328
4329 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4330 int end) throws SystemException {
4331 return getRoles(pk, start, end, null);
4332 }
4333
4334 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4335 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
4336 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRoles",
4337 new String[] {
4338 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4339 "com.liferay.portal.kernel.util.OrderByComparator"
4340 });
4341
4342 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
4343 int end, OrderByComparator orderByComparator) throws SystemException {
4344 Object[] finderArgs = new Object[] {
4345 new Long(pk), String.valueOf(start), String.valueOf(end),
4346 String.valueOf(orderByComparator)
4347 };
4348
4349 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
4350 finderArgs, this);
4351
4352 if (list == null) {
4353 Session session = null;
4354
4355 try {
4356 session = openSession();
4357
4358 String sql = null;
4359
4360 if (orderByComparator != null) {
4361 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
4362 .concat(orderByComparator.getOrderBy());
4363 }
4364
4365 else {
4366 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
4367 }
4368
4369 SQLQuery q = session.createSQLQuery(sql);
4370
4371 q.addEntity("Role_",
4372 com.liferay.portal.model.impl.RoleImpl.class);
4373
4374 QueryPos qPos = QueryPos.getInstance(q);
4375
4376 qPos.add(pk);
4377
4378 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
4379 getDialect(), start, end);
4380 }
4381 catch (Exception e) {
4382 throw processException(e);
4383 }
4384 finally {
4385 if (list == null) {
4386 list = new ArrayList<com.liferay.portal.model.Role>();
4387 }
4388
4389 rolePersistence.cacheResult(list);
4390
4391 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES, finderArgs,
4392 list);
4393
4394 closeSession(session);
4395 }
4396 }
4397
4398 return list;
4399 }
4400
4401 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4402 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
4403 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRolesSize",
4404 new String[] { Long.class.getName() });
4405
4406 public int getRolesSize(long pk) throws SystemException {
4407 Object[] finderArgs = new Object[] { new Long(pk) };
4408
4409 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
4410 finderArgs, this);
4411
4412 if (count == null) {
4413 Session session = null;
4414
4415 try {
4416 session = openSession();
4417
4418 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
4419
4420 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4421
4422 QueryPos qPos = QueryPos.getInstance(q);
4423
4424 qPos.add(pk);
4425
4426 count = (Long)q.uniqueResult();
4427 }
4428 catch (Exception e) {
4429 throw processException(e);
4430 }
4431 finally {
4432 if (count == null) {
4433 count = Long.valueOf(0);
4434 }
4435
4436 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
4437 finderArgs, count);
4438
4439 closeSession(session);
4440 }
4441 }
4442
4443 return count.intValue();
4444 }
4445
4446 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
4447 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
4448 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsRole",
4449 new String[] { Long.class.getName(), Long.class.getName() });
4450
4451 public boolean containsRole(long pk, long rolePK) throws SystemException {
4452 Object[] finderArgs = new Object[] { new Long(pk), new Long(rolePK) };
4453
4454 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
4455 finderArgs, this);
4456
4457 if (value == null) {
4458 try {
4459 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
4460 }
4461 catch (Exception e) {
4462 throw processException(e);
4463 }
4464 finally {
4465 if (value == null) {
4466 value = Boolean.FALSE;
4467 }
4468
4469 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
4470 finderArgs, value);
4471 }
4472 }
4473
4474 return value.booleanValue();
4475 }
4476
4477 public boolean containsRoles(long pk) throws SystemException {
4478 if (getRolesSize(pk) > 0) {
4479 return true;
4480 }
4481 else {
4482 return false;
4483 }
4484 }
4485
4486 public void addRole(long pk, long rolePK) throws SystemException {
4487 try {
4488 addRole.add(pk, rolePK);
4489 }
4490 catch (Exception e) {
4491 throw processException(e);
4492 }
4493 finally {
4494 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4495 }
4496 }
4497
4498 public void addRole(long pk, com.liferay.portal.model.Role role)
4499 throws SystemException {
4500 try {
4501 addRole.add(pk, role.getPrimaryKey());
4502 }
4503 catch (Exception e) {
4504 throw processException(e);
4505 }
4506 finally {
4507 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4508 }
4509 }
4510
4511 public void addRoles(long pk, long[] rolePKs) throws SystemException {
4512 try {
4513 for (long rolePK : rolePKs) {
4514 addRole.add(pk, rolePK);
4515 }
4516 }
4517 catch (Exception e) {
4518 throw processException(e);
4519 }
4520 finally {
4521 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4522 }
4523 }
4524
4525 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
4526 throws SystemException {
4527 try {
4528 for (com.liferay.portal.model.Role role : roles) {
4529 addRole.add(pk, role.getPrimaryKey());
4530 }
4531 }
4532 catch (Exception e) {
4533 throw processException(e);
4534 }
4535 finally {
4536 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4537 }
4538 }
4539
4540 public void clearRoles(long pk) throws SystemException {
4541 try {
4542 clearRoles.clear(pk);
4543 }
4544 catch (Exception e) {
4545 throw processException(e);
4546 }
4547 finally {
4548 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4549 }
4550 }
4551
4552 public void removeRole(long pk, long rolePK) throws SystemException {
4553 try {
4554 removeRole.remove(pk, rolePK);
4555 }
4556 catch (Exception e) {
4557 throw processException(e);
4558 }
4559 finally {
4560 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4561 }
4562 }
4563
4564 public void removeRole(long pk, com.liferay.portal.model.Role role)
4565 throws SystemException {
4566 try {
4567 removeRole.remove(pk, role.getPrimaryKey());
4568 }
4569 catch (Exception e) {
4570 throw processException(e);
4571 }
4572 finally {
4573 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4574 }
4575 }
4576
4577 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
4578 try {
4579 for (long rolePK : rolePKs) {
4580 removeRole.remove(pk, rolePK);
4581 }
4582 }
4583 catch (Exception e) {
4584 throw processException(e);
4585 }
4586 finally {
4587 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4588 }
4589 }
4590
4591 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
4592 throws SystemException {
4593 try {
4594 for (com.liferay.portal.model.Role role : roles) {
4595 removeRole.remove(pk, role.getPrimaryKey());
4596 }
4597 }
4598 catch (Exception e) {
4599 throw processException(e);
4600 }
4601 finally {
4602 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4603 }
4604 }
4605
4606 public void setRoles(long pk, long[] rolePKs) throws SystemException {
4607 try {
4608 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
4609
4610 List<com.liferay.portal.model.Role> roles = getRoles(pk);
4611
4612 for (com.liferay.portal.model.Role role : roles) {
4613 if (!rolePKSet.contains(role.getPrimaryKey())) {
4614 removeRole.remove(pk, role.getPrimaryKey());
4615 }
4616 else {
4617 rolePKSet.remove(role.getPrimaryKey());
4618 }
4619 }
4620
4621 for (Long rolePK : rolePKSet) {
4622 addRole.add(pk, rolePK);
4623 }
4624 }
4625 catch (Exception e) {
4626 throw processException(e);
4627 }
4628 finally {
4629 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4630 }
4631 }
4632
4633 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
4634 throws SystemException {
4635 try {
4636 long[] rolePKs = new long[roles.size()];
4637
4638 for (int i = 0; i < roles.size(); i++) {
4639 com.liferay.portal.model.Role role = roles.get(i);
4640
4641 rolePKs[i] = role.getPrimaryKey();
4642 }
4643
4644 setRoles(pk, rolePKs);
4645 }
4646 catch (Exception e) {
4647 throw processException(e);
4648 }
4649 finally {
4650 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
4651 }
4652 }
4653
4654 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
4655 throws SystemException {
4656 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4657 }
4658
4659 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4660 int start, int end) throws SystemException {
4661 return getUserGroups(pk, start, end, null);
4662 }
4663
4664 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4665 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4666 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUserGroups",
4667 new String[] {
4668 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4669 "com.liferay.portal.kernel.util.OrderByComparator"
4670 });
4671
4672 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
4673 int start, int end, OrderByComparator orderByComparator)
4674 throws SystemException {
4675 Object[] finderArgs = new Object[] {
4676 new Long(pk), String.valueOf(start), String.valueOf(end),
4677 String.valueOf(orderByComparator)
4678 };
4679
4680 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
4681 finderArgs, this);
4682
4683 if (list == null) {
4684 Session session = null;
4685
4686 try {
4687 session = openSession();
4688
4689 String sql = null;
4690
4691 if (orderByComparator != null) {
4692 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
4693 .concat(orderByComparator.getOrderBy());
4694 }
4695
4696 else {
4697 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
4698 }
4699
4700 SQLQuery q = session.createSQLQuery(sql);
4701
4702 q.addEntity("UserGroup",
4703 com.liferay.portal.model.impl.UserGroupImpl.class);
4704
4705 QueryPos qPos = QueryPos.getInstance(q);
4706
4707 qPos.add(pk);
4708
4709 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
4710 getDialect(), start, end);
4711 }
4712 catch (Exception e) {
4713 throw processException(e);
4714 }
4715 finally {
4716 if (list == null) {
4717 list = new ArrayList<com.liferay.portal.model.UserGroup>();
4718 }
4719
4720 userGroupPersistence.cacheResult(list);
4721
4722 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
4723 finderArgs, list);
4724
4725 closeSession(session);
4726 }
4727 }
4728
4729 return list;
4730 }
4731
4732 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4733 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4734 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
4735 "getUserGroupsSize", new String[] { Long.class.getName() });
4736
4737 public int getUserGroupsSize(long pk) throws SystemException {
4738 Object[] finderArgs = new Object[] { new Long(pk) };
4739
4740 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4741 finderArgs, this);
4742
4743 if (count == null) {
4744 Session session = null;
4745
4746 try {
4747 session = openSession();
4748
4749 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
4750
4751 q.addScalar(COUNT_COLUMN_NAME, Type.LONG);
4752
4753 QueryPos qPos = QueryPos.getInstance(q);
4754
4755 qPos.add(pk);
4756
4757 count = (Long)q.uniqueResult();
4758 }
4759 catch (Exception e) {
4760 throw processException(e);
4761 }
4762 finally {
4763 if (count == null) {
4764 count = Long.valueOf(0);
4765 }
4766
4767 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
4768 finderArgs, count);
4769
4770 closeSession(session);
4771 }
4772 }
4773
4774 return count.intValue();
4775 }
4776
4777 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
4778 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
4779 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
4780 "containsUserGroup",
4781 new String[] { Long.class.getName(), Long.class.getName() });
4782
4783 public boolean containsUserGroup(long pk, long userGroupPK)
4784 throws SystemException {
4785 Object[] finderArgs = new Object[] { new Long(pk), new Long(userGroupPK) };
4786
4787 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
4788 finderArgs, this);
4789
4790 if (value == null) {
4791 try {
4792 value = Boolean.valueOf(containsUserGroup.contains(pk,
4793 userGroupPK));
4794 }
4795 catch (Exception e) {
4796 throw processException(e);
4797 }
4798 finally {
4799 if (value == null) {
4800 value = Boolean.FALSE;
4801 }
4802
4803 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
4804 finderArgs, value);
4805 }
4806 }
4807
4808 return value.booleanValue();
4809 }
4810
4811 public boolean containsUserGroups(long pk) throws SystemException {
4812 if (getUserGroupsSize(pk) > 0) {
4813 return true;
4814 }
4815 else {
4816 return false;
4817 }
4818 }
4819
4820 public void addUserGroup(long pk, long userGroupPK)
4821 throws SystemException {
4822 try {
4823 addUserGroup.add(pk, userGroupPK);
4824 }
4825 catch (Exception e) {
4826 throw processException(e);
4827 }
4828 finally {
4829 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4830 }
4831 }
4832
4833 public void addUserGroup(long pk,
4834 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4835 try {
4836 addUserGroup.add(pk, userGroup.getPrimaryKey());
4837 }
4838 catch (Exception e) {
4839 throw processException(e);
4840 }
4841 finally {
4842 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4843 }
4844 }
4845
4846 public void addUserGroups(long pk, long[] userGroupPKs)
4847 throws SystemException {
4848 try {
4849 for (long userGroupPK : userGroupPKs) {
4850 addUserGroup.add(pk, userGroupPK);
4851 }
4852 }
4853 catch (Exception e) {
4854 throw processException(e);
4855 }
4856 finally {
4857 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4858 }
4859 }
4860
4861 public void addUserGroups(long pk,
4862 List<com.liferay.portal.model.UserGroup> userGroups)
4863 throws SystemException {
4864 try {
4865 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4866 addUserGroup.add(pk, userGroup.getPrimaryKey());
4867 }
4868 }
4869 catch (Exception e) {
4870 throw processException(e);
4871 }
4872 finally {
4873 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4874 }
4875 }
4876
4877 public void clearUserGroups(long pk) throws SystemException {
4878 try {
4879 clearUserGroups.clear(pk);
4880 }
4881 catch (Exception e) {
4882 throw processException(e);
4883 }
4884 finally {
4885 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4886 }
4887 }
4888
4889 public void removeUserGroup(long pk, long userGroupPK)
4890 throws SystemException {
4891 try {
4892 removeUserGroup.remove(pk, userGroupPK);
4893 }
4894 catch (Exception e) {
4895 throw processException(e);
4896 }
4897 finally {
4898 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4899 }
4900 }
4901
4902 public void removeUserGroup(long pk,
4903 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
4904 try {
4905 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4906 }
4907 catch (Exception e) {
4908 throw processException(e);
4909 }
4910 finally {
4911 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4912 }
4913 }
4914
4915 public void removeUserGroups(long pk, long[] userGroupPKs)
4916 throws SystemException {
4917 try {
4918 for (long userGroupPK : userGroupPKs) {
4919 removeUserGroup.remove(pk, userGroupPK);
4920 }
4921 }
4922 catch (Exception e) {
4923 throw processException(e);
4924 }
4925 finally {
4926 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4927 }
4928 }
4929
4930 public void removeUserGroups(long pk,
4931 List<com.liferay.portal.model.UserGroup> userGroups)
4932 throws SystemException {
4933 try {
4934 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4935 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4936 }
4937 }
4938 catch (Exception e) {
4939 throw processException(e);
4940 }
4941 finally {
4942 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4943 }
4944 }
4945
4946 public void setUserGroups(long pk, long[] userGroupPKs)
4947 throws SystemException {
4948 try {
4949 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
4950
4951 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
4952
4953 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
4954 if (!userGroupPKSet.contains(userGroup.getPrimaryKey())) {
4955 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
4956 }
4957 else {
4958 userGroupPKSet.remove(userGroup.getPrimaryKey());
4959 }
4960 }
4961
4962 for (Long userGroupPK : userGroupPKSet) {
4963 addUserGroup.add(pk, userGroupPK);
4964 }
4965 }
4966 catch (Exception e) {
4967 throw processException(e);
4968 }
4969 finally {
4970 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4971 }
4972 }
4973
4974 public void setUserGroups(long pk,
4975 List<com.liferay.portal.model.UserGroup> userGroups)
4976 throws SystemException {
4977 try {
4978 long[] userGroupPKs = new long[userGroups.size()];
4979
4980 for (int i = 0; i < userGroups.size(); i++) {
4981 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
4982
4983 userGroupPKs[i] = userGroup.getPrimaryKey();
4984 }
4985
4986 setUserGroups(pk, userGroupPKs);
4987 }
4988 catch (Exception e) {
4989 throw processException(e);
4990 }
4991 finally {
4992 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
4993 }
4994 }
4995
4996 public void afterPropertiesSet() {
4997 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
4998 com.liferay.portal.util.PropsUtil.get(
4999 "value.object.listener.com.liferay.portal.model.User")));
5000
5001 if (listenerClassNames.length > 0) {
5002 try {
5003 List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
5004
5005 for (String listenerClassName : listenerClassNames) {
5006 listenersList.add((ModelListener<User>)Class.forName(
5007 listenerClassName).newInstance());
5008 }
5009
5010 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5011 }
5012 catch (Exception e) {
5013 _log.error(e);
5014 }
5015 }
5016
5017 containsGroup = new ContainsGroup(this);
5018
5019 addGroup = new AddGroup(this);
5020 clearGroups = new ClearGroups(this);
5021 removeGroup = new RemoveGroup(this);
5022
5023 containsOrganization = new ContainsOrganization(this);
5024
5025 addOrganization = new AddOrganization(this);
5026 clearOrganizations = new ClearOrganizations(this);
5027 removeOrganization = new RemoveOrganization(this);
5028
5029 containsPermission = new ContainsPermission(this);
5030
5031 addPermission = new AddPermission(this);
5032 clearPermissions = new ClearPermissions(this);
5033 removePermission = new RemovePermission(this);
5034
5035 containsRole = new ContainsRole(this);
5036
5037 addRole = new AddRole(this);
5038 clearRoles = new ClearRoles(this);
5039 removeRole = new RemoveRole(this);
5040
5041 containsUserGroup = new ContainsUserGroup(this);
5042
5043 addUserGroup = new AddUserGroup(this);
5044 clearUserGroups = new ClearUserGroups(this);
5045 removeUserGroup = new RemoveUserGroup(this);
5046 }
5047
5048 @BeanReference(type = AccountPersistence.class)
5049 protected AccountPersistence accountPersistence;
5050 @BeanReference(type = AddressPersistence.class)
5051 protected AddressPersistence addressPersistence;
5052 @BeanReference(type = BrowserTrackerPersistence.class)
5053 protected BrowserTrackerPersistence browserTrackerPersistence;
5054 @BeanReference(type = ClassNamePersistence.class)
5055 protected ClassNamePersistence classNamePersistence;
5056 @BeanReference(type = CompanyPersistence.class)
5057 protected CompanyPersistence companyPersistence;
5058 @BeanReference(type = ContactPersistence.class)
5059 protected ContactPersistence contactPersistence;
5060 @BeanReference(type = CountryPersistence.class)
5061 protected CountryPersistence countryPersistence;
5062 @BeanReference(type = EmailAddressPersistence.class)
5063 protected EmailAddressPersistence emailAddressPersistence;
5064 @BeanReference(type = GroupPersistence.class)
5065 protected GroupPersistence groupPersistence;
5066 @BeanReference(type = ImagePersistence.class)
5067 protected ImagePersistence imagePersistence;
5068 @BeanReference(type = LayoutPersistence.class)
5069 protected LayoutPersistence layoutPersistence;
5070 @BeanReference(type = LayoutSetPersistence.class)
5071 protected LayoutSetPersistence layoutSetPersistence;
5072 @BeanReference(type = ListTypePersistence.class)
5073 protected ListTypePersistence listTypePersistence;
5074 @BeanReference(type = LockPersistence.class)
5075 protected LockPersistence lockPersistence;
5076 @BeanReference(type = MembershipRequestPersistence.class)
5077 protected MembershipRequestPersistence membershipRequestPersistence;
5078 @BeanReference(type = OrganizationPersistence.class)
5079 protected OrganizationPersistence organizationPersistence;
5080 @BeanReference(type = OrgGroupPermissionPersistence.class)
5081 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
5082 @BeanReference(type = OrgGroupRolePersistence.class)
5083 protected OrgGroupRolePersistence orgGroupRolePersistence;
5084 @BeanReference(type = OrgLaborPersistence.class)
5085 protected OrgLaborPersistence orgLaborPersistence;
5086 @BeanReference(type = PasswordPolicyPersistence.class)
5087 protected PasswordPolicyPersistence passwordPolicyPersistence;
5088 @BeanReference(type = PasswordPolicyRelPersistence.class)
5089 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
5090 @BeanReference(type = PasswordTrackerPersistence.class)
5091 protected PasswordTrackerPersistence passwordTrackerPersistence;
5092 @BeanReference(type = PermissionPersistence.class)
5093 protected PermissionPersistence permissionPersistence;
5094 @BeanReference(type = PhonePersistence.class)
5095 protected PhonePersistence phonePersistence;
5096 @BeanReference(type = PluginSettingPersistence.class)
5097 protected PluginSettingPersistence pluginSettingPersistence;
5098 @BeanReference(type = PortletPersistence.class)
5099 protected PortletPersistence portletPersistence;
5100 @BeanReference(type = PortletItemPersistence.class)
5101 protected PortletItemPersistence portletItemPersistence;
5102 @BeanReference(type = PortletPreferencesPersistence.class)
5103 protected PortletPreferencesPersistence portletPreferencesPersistence;
5104 @BeanReference(type = RegionPersistence.class)
5105 protected RegionPersistence regionPersistence;
5106 @BeanReference(type = ReleasePersistence.class)
5107 protected ReleasePersistence releasePersistence;
5108 @BeanReference(type = ResourcePersistence.class)
5109 protected ResourcePersistence resourcePersistence;
5110 @BeanReference(type = ResourceActionPersistence.class)
5111 protected ResourceActionPersistence resourceActionPersistence;
5112 @BeanReference(type = ResourceCodePersistence.class)
5113 protected ResourceCodePersistence resourceCodePersistence;
5114 @BeanReference(type = ResourcePermissionPersistence.class)
5115 protected ResourcePermissionPersistence resourcePermissionPersistence;
5116 @BeanReference(type = RolePersistence.class)
5117 protected RolePersistence rolePersistence;
5118 @BeanReference(type = ServiceComponentPersistence.class)
5119 protected ServiceComponentPersistence serviceComponentPersistence;
5120 @BeanReference(type = ShardPersistence.class)
5121 protected ShardPersistence shardPersistence;
5122 @BeanReference(type = SubscriptionPersistence.class)
5123 protected SubscriptionPersistence subscriptionPersistence;
5124 @BeanReference(type = UserPersistence.class)
5125 protected UserPersistence userPersistence;
5126 @BeanReference(type = UserGroupPersistence.class)
5127 protected UserGroupPersistence userGroupPersistence;
5128 @BeanReference(type = UserGroupGroupRolePersistence.class)
5129 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
5130 @BeanReference(type = UserGroupRolePersistence.class)
5131 protected UserGroupRolePersistence userGroupRolePersistence;
5132 @BeanReference(type = UserIdMapperPersistence.class)
5133 protected UserIdMapperPersistence userIdMapperPersistence;
5134 @BeanReference(type = UserTrackerPersistence.class)
5135 protected UserTrackerPersistence userTrackerPersistence;
5136 @BeanReference(type = UserTrackerPathPersistence.class)
5137 protected UserTrackerPathPersistence userTrackerPathPersistence;
5138 @BeanReference(type = WebDAVPropsPersistence.class)
5139 protected WebDAVPropsPersistence webDAVPropsPersistence;
5140 @BeanReference(type = WebsitePersistence.class)
5141 protected WebsitePersistence websitePersistence;
5142 @BeanReference(type = AnnouncementsDeliveryPersistence.class)
5143 protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
5144 @BeanReference(type = BlogsStatsUserPersistence.class)
5145 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
5146 @BeanReference(type = DLFileRankPersistence.class)
5147 protected DLFileRankPersistence dlFileRankPersistence;
5148 @BeanReference(type = ExpandoValuePersistence.class)
5149 protected ExpandoValuePersistence expandoValuePersistence;
5150 @BeanReference(type = MBBanPersistence.class)
5151 protected MBBanPersistence mbBanPersistence;
5152 @BeanReference(type = MBMessageFlagPersistence.class)
5153 protected MBMessageFlagPersistence mbMessageFlagPersistence;
5154 @BeanReference(type = MBStatsUserPersistence.class)
5155 protected MBStatsUserPersistence mbStatsUserPersistence;
5156 @BeanReference(type = ShoppingCartPersistence.class)
5157 protected ShoppingCartPersistence shoppingCartPersistence;
5158 @BeanReference(type = SocialActivityPersistence.class)
5159 protected SocialActivityPersistence socialActivityPersistence;
5160 @BeanReference(type = SocialRequestPersistence.class)
5161 protected SocialRequestPersistence socialRequestPersistence;
5162 @BeanReference(type = TagsAssetPersistence.class)
5163 protected TagsAssetPersistence tagsAssetPersistence;
5164 protected ContainsGroup containsGroup;
5165 protected AddGroup addGroup;
5166 protected ClearGroups clearGroups;
5167 protected RemoveGroup removeGroup;
5168 protected ContainsOrganization containsOrganization;
5169 protected AddOrganization addOrganization;
5170 protected ClearOrganizations clearOrganizations;
5171 protected RemoveOrganization removeOrganization;
5172 protected ContainsPermission containsPermission;
5173 protected AddPermission addPermission;
5174 protected ClearPermissions clearPermissions;
5175 protected RemovePermission removePermission;
5176 protected ContainsRole containsRole;
5177 protected AddRole addRole;
5178 protected ClearRoles clearRoles;
5179 protected RemoveRole removeRole;
5180 protected ContainsUserGroup containsUserGroup;
5181 protected AddUserGroup addUserGroup;
5182 protected ClearUserGroups clearUserGroups;
5183 protected RemoveUserGroup removeUserGroup;
5184
5185 protected class ContainsGroup {
5186 protected ContainsGroup(UserPersistenceImpl persistenceImpl) {
5187 super();
5188
5189 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5190 _SQL_CONTAINSGROUP,
5191 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5192 }
5193
5194 protected boolean contains(long userId, long groupId) {
5195 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5196 new Long(userId), new Long(groupId)
5197 });
5198
5199 if (results.size() > 0) {
5200 Integer count = results.get(0);
5201
5202 if (count.intValue() > 0) {
5203 return true;
5204 }
5205 }
5206
5207 return false;
5208 }
5209
5210 private MappingSqlQuery _mappingSqlQuery;
5211 }
5212
5213 protected class AddGroup {
5214 protected AddGroup(UserPersistenceImpl persistenceImpl) {
5215 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5216 "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
5217 new int[] { Types.BIGINT, Types.BIGINT });
5218 _persistenceImpl = persistenceImpl;
5219 }
5220
5221 protected void add(long userId, long groupId) throws SystemException {
5222 if (!_persistenceImpl.containsGroup.contains(userId, groupId)) {
5223 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
5224
5225 for (ModelListener<User> listener : listeners) {
5226 listener.onBeforeAddAssociation(userId,
5227 com.liferay.portal.model.Group.class.getName(), groupId);
5228 }
5229
5230 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5231 listener.onBeforeAddAssociation(groupId,
5232 User.class.getName(), userId);
5233 }
5234
5235 _sqlUpdate.update(new Object[] {
5236 new Long(userId), new Long(groupId)
5237 });
5238
5239 for (ModelListener<User> listener : listeners) {
5240 listener.onAfterAddAssociation(userId,
5241 com.liferay.portal.model.Group.class.getName(), groupId);
5242 }
5243
5244 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5245 listener.onAfterAddAssociation(groupId,
5246 User.class.getName(), userId);
5247 }
5248 }
5249 }
5250
5251 private SqlUpdate _sqlUpdate;
5252 private UserPersistenceImpl _persistenceImpl;
5253 }
5254
5255 protected class ClearGroups {
5256 protected ClearGroups(UserPersistenceImpl persistenceImpl) {
5257 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5258 "DELETE FROM Users_Groups WHERE userId = ?",
5259 new int[] { Types.BIGINT });
5260 }
5261
5262 protected void clear(long userId) throws SystemException {
5263 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
5264
5265 List<com.liferay.portal.model.Group> groups = null;
5266
5267 if ((listeners.length > 0) || (groupListeners.length > 0)) {
5268 groups = getGroups(userId);
5269
5270 for (com.liferay.portal.model.Group group : groups) {
5271 for (ModelListener<User> listener : listeners) {
5272 listener.onBeforeRemoveAssociation(userId,
5273 com.liferay.portal.model.Group.class.getName(),
5274 group.getPrimaryKey());
5275 }
5276
5277 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5278 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
5279 User.class.getName(), userId);
5280 }
5281 }
5282 }
5283
5284 _sqlUpdate.update(new Object[] { new Long(userId) });
5285
5286 if ((listeners.length > 0) || (groupListeners.length > 0)) {
5287 for (com.liferay.portal.model.Group group : groups) {
5288 for (ModelListener<User> listener : listeners) {
5289 listener.onAfterRemoveAssociation(userId,
5290 com.liferay.portal.model.Group.class.getName(),
5291 group.getPrimaryKey());
5292 }
5293
5294 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5295 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
5296 User.class.getName(), userId);
5297 }
5298 }
5299 }
5300 }
5301
5302 private SqlUpdate _sqlUpdate;
5303 }
5304
5305 protected class RemoveGroup {
5306 protected RemoveGroup(UserPersistenceImpl persistenceImpl) {
5307 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5308 "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
5309 new int[] { Types.BIGINT, Types.BIGINT });
5310 _persistenceImpl = persistenceImpl;
5311 }
5312
5313 protected void remove(long userId, long groupId)
5314 throws SystemException {
5315 if (_persistenceImpl.containsGroup.contains(userId, groupId)) {
5316 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
5317
5318 for (ModelListener<User> listener : listeners) {
5319 listener.onBeforeRemoveAssociation(userId,
5320 com.liferay.portal.model.Group.class.getName(), groupId);
5321 }
5322
5323 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5324 listener.onBeforeRemoveAssociation(groupId,
5325 User.class.getName(), userId);
5326 }
5327
5328 _sqlUpdate.update(new Object[] {
5329 new Long(userId), new Long(groupId)
5330 });
5331
5332 for (ModelListener<User> listener : listeners) {
5333 listener.onAfterRemoveAssociation(userId,
5334 com.liferay.portal.model.Group.class.getName(), groupId);
5335 }
5336
5337 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
5338 listener.onAfterRemoveAssociation(groupId,
5339 User.class.getName(), userId);
5340 }
5341 }
5342 }
5343
5344 private SqlUpdate _sqlUpdate;
5345 private UserPersistenceImpl _persistenceImpl;
5346 }
5347
5348 protected class ContainsOrganization {
5349 protected ContainsOrganization(UserPersistenceImpl persistenceImpl) {
5350 super();
5351
5352 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5353 _SQL_CONTAINSORGANIZATION,
5354 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5355 }
5356
5357 protected boolean contains(long userId, long organizationId) {
5358 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5359 new Long(userId), new Long(organizationId)
5360 });
5361
5362 if (results.size() > 0) {
5363 Integer count = results.get(0);
5364
5365 if (count.intValue() > 0) {
5366 return true;
5367 }
5368 }
5369
5370 return false;
5371 }
5372
5373 private MappingSqlQuery _mappingSqlQuery;
5374 }
5375
5376 protected class AddOrganization {
5377 protected AddOrganization(UserPersistenceImpl persistenceImpl) {
5378 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5379 "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
5380 new int[] { Types.BIGINT, Types.BIGINT });
5381 _persistenceImpl = persistenceImpl;
5382 }
5383
5384 protected void add(long userId, long organizationId)
5385 throws SystemException {
5386 if (!_persistenceImpl.containsOrganization.contains(userId,
5387 organizationId)) {
5388 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5389 organizationPersistence.getListeners();
5390
5391 for (ModelListener<User> listener : listeners) {
5392 listener.onBeforeAddAssociation(userId,
5393 com.liferay.portal.model.Organization.class.getName(),
5394 organizationId);
5395 }
5396
5397 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5398 listener.onBeforeAddAssociation(organizationId,
5399 User.class.getName(), userId);
5400 }
5401
5402 _sqlUpdate.update(new Object[] {
5403 new Long(userId), new Long(organizationId)
5404 });
5405
5406 for (ModelListener<User> listener : listeners) {
5407 listener.onAfterAddAssociation(userId,
5408 com.liferay.portal.model.Organization.class.getName(),
5409 organizationId);
5410 }
5411
5412 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5413 listener.onAfterAddAssociation(organizationId,
5414 User.class.getName(), userId);
5415 }
5416 }
5417 }
5418
5419 private SqlUpdate _sqlUpdate;
5420 private UserPersistenceImpl _persistenceImpl;
5421 }
5422
5423 protected class ClearOrganizations {
5424 protected ClearOrganizations(UserPersistenceImpl persistenceImpl) {
5425 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5426 "DELETE FROM Users_Orgs WHERE userId = ?",
5427 new int[] { Types.BIGINT });
5428 }
5429
5430 protected void clear(long userId) throws SystemException {
5431 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5432 organizationPersistence.getListeners();
5433
5434 List<com.liferay.portal.model.Organization> organizations = null;
5435
5436 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
5437 organizations = getOrganizations(userId);
5438
5439 for (com.liferay.portal.model.Organization organization : organizations) {
5440 for (ModelListener<User> listener : listeners) {
5441 listener.onBeforeRemoveAssociation(userId,
5442 com.liferay.portal.model.Organization.class.getName(),
5443 organization.getPrimaryKey());
5444 }
5445
5446 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5447 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
5448 User.class.getName(), userId);
5449 }
5450 }
5451 }
5452
5453 _sqlUpdate.update(new Object[] { new Long(userId) });
5454
5455 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
5456 for (com.liferay.portal.model.Organization organization : organizations) {
5457 for (ModelListener<User> listener : listeners) {
5458 listener.onAfterRemoveAssociation(userId,
5459 com.liferay.portal.model.Organization.class.getName(),
5460 organization.getPrimaryKey());
5461 }
5462
5463 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5464 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
5465 User.class.getName(), userId);
5466 }
5467 }
5468 }
5469 }
5470
5471 private SqlUpdate _sqlUpdate;
5472 }
5473
5474 protected class RemoveOrganization {
5475 protected RemoveOrganization(UserPersistenceImpl persistenceImpl) {
5476 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5477 "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
5478 new int[] { Types.BIGINT, Types.BIGINT });
5479 _persistenceImpl = persistenceImpl;
5480 }
5481
5482 protected void remove(long userId, long organizationId)
5483 throws SystemException {
5484 if (_persistenceImpl.containsOrganization.contains(userId,
5485 organizationId)) {
5486 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
5487 organizationPersistence.getListeners();
5488
5489 for (ModelListener<User> listener : listeners) {
5490 listener.onBeforeRemoveAssociation(userId,
5491 com.liferay.portal.model.Organization.class.getName(),
5492 organizationId);
5493 }
5494
5495 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5496 listener.onBeforeRemoveAssociation(organizationId,
5497 User.class.getName(), userId);
5498 }
5499
5500 _sqlUpdate.update(new Object[] {
5501 new Long(userId), new Long(organizationId)
5502 });
5503
5504 for (ModelListener<User> listener : listeners) {
5505 listener.onAfterRemoveAssociation(userId,
5506 com.liferay.portal.model.Organization.class.getName(),
5507 organizationId);
5508 }
5509
5510 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
5511 listener.onAfterRemoveAssociation(organizationId,
5512 User.class.getName(), userId);
5513 }
5514 }
5515 }
5516
5517 private SqlUpdate _sqlUpdate;
5518 private UserPersistenceImpl _persistenceImpl;
5519 }
5520
5521 protected class ContainsPermission {
5522 protected ContainsPermission(UserPersistenceImpl persistenceImpl) {
5523 super();
5524
5525 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5526 _SQL_CONTAINSPERMISSION,
5527 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5528 }
5529
5530 protected boolean contains(long userId, long permissionId) {
5531 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5532 new Long(userId), new Long(permissionId)
5533 });
5534
5535 if (results.size() > 0) {
5536 Integer count = results.get(0);
5537
5538 if (count.intValue() > 0) {
5539 return true;
5540 }
5541 }
5542
5543 return false;
5544 }
5545
5546 private MappingSqlQuery _mappingSqlQuery;
5547 }
5548
5549 protected class AddPermission {
5550 protected AddPermission(UserPersistenceImpl persistenceImpl) {
5551 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5552 "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)",
5553 new int[] { Types.BIGINT, Types.BIGINT });
5554 _persistenceImpl = persistenceImpl;
5555 }
5556
5557 protected void add(long userId, long permissionId)
5558 throws SystemException {
5559 if (!_persistenceImpl.containsPermission.contains(userId,
5560 permissionId)) {
5561 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5562 permissionPersistence.getListeners();
5563
5564 for (ModelListener<User> listener : listeners) {
5565 listener.onBeforeAddAssociation(userId,
5566 com.liferay.portal.model.Permission.class.getName(),
5567 permissionId);
5568 }
5569
5570 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5571 listener.onBeforeAddAssociation(permissionId,
5572 User.class.getName(), userId);
5573 }
5574
5575 _sqlUpdate.update(new Object[] {
5576 new Long(userId), new Long(permissionId)
5577 });
5578
5579 for (ModelListener<User> listener : listeners) {
5580 listener.onAfterAddAssociation(userId,
5581 com.liferay.portal.model.Permission.class.getName(),
5582 permissionId);
5583 }
5584
5585 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5586 listener.onAfterAddAssociation(permissionId,
5587 User.class.getName(), userId);
5588 }
5589 }
5590 }
5591
5592 private SqlUpdate _sqlUpdate;
5593 private UserPersistenceImpl _persistenceImpl;
5594 }
5595
5596 protected class ClearPermissions {
5597 protected ClearPermissions(UserPersistenceImpl persistenceImpl) {
5598 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5599 "DELETE FROM Users_Permissions WHERE userId = ?",
5600 new int[] { Types.BIGINT });
5601 }
5602
5603 protected void clear(long userId) throws SystemException {
5604 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5605 permissionPersistence.getListeners();
5606
5607 List<com.liferay.portal.model.Permission> permissions = null;
5608
5609 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
5610 permissions = getPermissions(userId);
5611
5612 for (com.liferay.portal.model.Permission permission : permissions) {
5613 for (ModelListener<User> listener : listeners) {
5614 listener.onBeforeRemoveAssociation(userId,
5615 com.liferay.portal.model.Permission.class.getName(),
5616 permission.getPrimaryKey());
5617 }
5618
5619 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5620 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
5621 User.class.getName(), userId);
5622 }
5623 }
5624 }
5625
5626 _sqlUpdate.update(new Object[] { new Long(userId) });
5627
5628 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
5629 for (com.liferay.portal.model.Permission permission : permissions) {
5630 for (ModelListener<User> listener : listeners) {
5631 listener.onAfterRemoveAssociation(userId,
5632 com.liferay.portal.model.Permission.class.getName(),
5633 permission.getPrimaryKey());
5634 }
5635
5636 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5637 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
5638 User.class.getName(), userId);
5639 }
5640 }
5641 }
5642 }
5643
5644 private SqlUpdate _sqlUpdate;
5645 }
5646
5647 protected class RemovePermission {
5648 protected RemovePermission(UserPersistenceImpl persistenceImpl) {
5649 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5650 "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?",
5651 new int[] { Types.BIGINT, Types.BIGINT });
5652 _persistenceImpl = persistenceImpl;
5653 }
5654
5655 protected void remove(long userId, long permissionId)
5656 throws SystemException {
5657 if (_persistenceImpl.containsPermission.contains(userId,
5658 permissionId)) {
5659 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
5660 permissionPersistence.getListeners();
5661
5662 for (ModelListener<User> listener : listeners) {
5663 listener.onBeforeRemoveAssociation(userId,
5664 com.liferay.portal.model.Permission.class.getName(),
5665 permissionId);
5666 }
5667
5668 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5669 listener.onBeforeRemoveAssociation(permissionId,
5670 User.class.getName(), userId);
5671 }
5672
5673 _sqlUpdate.update(new Object[] {
5674 new Long(userId), new Long(permissionId)
5675 });
5676
5677 for (ModelListener<User> listener : listeners) {
5678 listener.onAfterRemoveAssociation(userId,
5679 com.liferay.portal.model.Permission.class.getName(),
5680 permissionId);
5681 }
5682
5683 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
5684 listener.onAfterRemoveAssociation(permissionId,
5685 User.class.getName(), userId);
5686 }
5687 }
5688 }
5689
5690 private SqlUpdate _sqlUpdate;
5691 private UserPersistenceImpl _persistenceImpl;
5692 }
5693
5694 protected class ContainsRole {
5695 protected ContainsRole(UserPersistenceImpl persistenceImpl) {
5696 super();
5697
5698 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5699 _SQL_CONTAINSROLE,
5700 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5701 }
5702
5703 protected boolean contains(long userId, long roleId) {
5704 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5705 new Long(userId), new Long(roleId)
5706 });
5707
5708 if (results.size() > 0) {
5709 Integer count = results.get(0);
5710
5711 if (count.intValue() > 0) {
5712 return true;
5713 }
5714 }
5715
5716 return false;
5717 }
5718
5719 private MappingSqlQuery _mappingSqlQuery;
5720 }
5721
5722 protected class AddRole {
5723 protected AddRole(UserPersistenceImpl persistenceImpl) {
5724 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5725 "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
5726 new int[] { Types.BIGINT, Types.BIGINT });
5727 _persistenceImpl = persistenceImpl;
5728 }
5729
5730 protected void add(long userId, long roleId) throws SystemException {
5731 if (!_persistenceImpl.containsRole.contains(userId, roleId)) {
5732 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5733
5734 for (ModelListener<User> listener : listeners) {
5735 listener.onBeforeAddAssociation(userId,
5736 com.liferay.portal.model.Role.class.getName(), roleId);
5737 }
5738
5739 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5740 listener.onBeforeAddAssociation(roleId,
5741 User.class.getName(), userId);
5742 }
5743
5744 _sqlUpdate.update(new Object[] {
5745 new Long(userId), new Long(roleId)
5746 });
5747
5748 for (ModelListener<User> listener : listeners) {
5749 listener.onAfterAddAssociation(userId,
5750 com.liferay.portal.model.Role.class.getName(), roleId);
5751 }
5752
5753 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5754 listener.onAfterAddAssociation(roleId,
5755 User.class.getName(), userId);
5756 }
5757 }
5758 }
5759
5760 private SqlUpdate _sqlUpdate;
5761 private UserPersistenceImpl _persistenceImpl;
5762 }
5763
5764 protected class ClearRoles {
5765 protected ClearRoles(UserPersistenceImpl persistenceImpl) {
5766 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5767 "DELETE FROM Users_Roles WHERE userId = ?",
5768 new int[] { Types.BIGINT });
5769 }
5770
5771 protected void clear(long userId) throws SystemException {
5772 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5773
5774 List<com.liferay.portal.model.Role> roles = null;
5775
5776 if ((listeners.length > 0) || (roleListeners.length > 0)) {
5777 roles = getRoles(userId);
5778
5779 for (com.liferay.portal.model.Role role : roles) {
5780 for (ModelListener<User> listener : listeners) {
5781 listener.onBeforeRemoveAssociation(userId,
5782 com.liferay.portal.model.Role.class.getName(),
5783 role.getPrimaryKey());
5784 }
5785
5786 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5787 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
5788 User.class.getName(), userId);
5789 }
5790 }
5791 }
5792
5793 _sqlUpdate.update(new Object[] { new Long(userId) });
5794
5795 if ((listeners.length > 0) || (roleListeners.length > 0)) {
5796 for (com.liferay.portal.model.Role role : roles) {
5797 for (ModelListener<User> listener : listeners) {
5798 listener.onAfterRemoveAssociation(userId,
5799 com.liferay.portal.model.Role.class.getName(),
5800 role.getPrimaryKey());
5801 }
5802
5803 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5804 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
5805 User.class.getName(), userId);
5806 }
5807 }
5808 }
5809 }
5810
5811 private SqlUpdate _sqlUpdate;
5812 }
5813
5814 protected class RemoveRole {
5815 protected RemoveRole(UserPersistenceImpl persistenceImpl) {
5816 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5817 "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
5818 new int[] { Types.BIGINT, Types.BIGINT });
5819 _persistenceImpl = persistenceImpl;
5820 }
5821
5822 protected void remove(long userId, long roleId)
5823 throws SystemException {
5824 if (_persistenceImpl.containsRole.contains(userId, roleId)) {
5825 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
5826
5827 for (ModelListener<User> listener : listeners) {
5828 listener.onBeforeRemoveAssociation(userId,
5829 com.liferay.portal.model.Role.class.getName(), roleId);
5830 }
5831
5832 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5833 listener.onBeforeRemoveAssociation(roleId,
5834 User.class.getName(), userId);
5835 }
5836
5837 _sqlUpdate.update(new Object[] {
5838 new Long(userId), new Long(roleId)
5839 });
5840
5841 for (ModelListener<User> listener : listeners) {
5842 listener.onAfterRemoveAssociation(userId,
5843 com.liferay.portal.model.Role.class.getName(), roleId);
5844 }
5845
5846 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
5847 listener.onAfterRemoveAssociation(roleId,
5848 User.class.getName(), userId);
5849 }
5850 }
5851 }
5852
5853 private SqlUpdate _sqlUpdate;
5854 private UserPersistenceImpl _persistenceImpl;
5855 }
5856
5857 protected class ContainsUserGroup {
5858 protected ContainsUserGroup(UserPersistenceImpl persistenceImpl) {
5859 super();
5860
5861 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5862 _SQL_CONTAINSUSERGROUP,
5863 new int[] { Types.BIGINT, Types.BIGINT }, RowMapper.COUNT);
5864 }
5865
5866 protected boolean contains(long userId, long userGroupId) {
5867 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5868 new Long(userId), new Long(userGroupId)
5869 });
5870
5871 if (results.size() > 0) {
5872 Integer count = results.get(0);
5873
5874 if (count.intValue() > 0) {
5875 return true;
5876 }
5877 }
5878
5879 return false;
5880 }
5881
5882 private MappingSqlQuery _mappingSqlQuery;
5883 }
5884
5885 protected class AddUserGroup {
5886 protected AddUserGroup(UserPersistenceImpl persistenceImpl) {
5887 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5888 "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
5889 new int[] { Types.BIGINT, Types.BIGINT });
5890 _persistenceImpl = persistenceImpl;
5891 }
5892
5893 protected void add(long userId, long userGroupId)
5894 throws SystemException {
5895 if (!_persistenceImpl.containsUserGroup.contains(userId, userGroupId)) {
5896 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5897 userGroupPersistence.getListeners();
5898
5899 for (ModelListener<User> listener : listeners) {
5900 listener.onBeforeAddAssociation(userId,
5901 com.liferay.portal.model.UserGroup.class.getName(),
5902 userGroupId);
5903 }
5904
5905 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5906 listener.onBeforeAddAssociation(userGroupId,
5907 User.class.getName(), userId);
5908 }
5909
5910 _sqlUpdate.update(new Object[] {
5911 new Long(userId), new Long(userGroupId)
5912 });
5913
5914 for (ModelListener<User> listener : listeners) {
5915 listener.onAfterAddAssociation(userId,
5916 com.liferay.portal.model.UserGroup.class.getName(),
5917 userGroupId);
5918 }
5919
5920 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5921 listener.onAfterAddAssociation(userGroupId,
5922 User.class.getName(), userId);
5923 }
5924 }
5925 }
5926
5927 private SqlUpdate _sqlUpdate;
5928 private UserPersistenceImpl _persistenceImpl;
5929 }
5930
5931 protected class ClearUserGroups {
5932 protected ClearUserGroups(UserPersistenceImpl persistenceImpl) {
5933 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5934 "DELETE FROM Users_UserGroups WHERE userId = ?",
5935 new int[] { Types.BIGINT });
5936 }
5937
5938 protected void clear(long userId) throws SystemException {
5939 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5940 userGroupPersistence.getListeners();
5941
5942 List<com.liferay.portal.model.UserGroup> userGroups = null;
5943
5944 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5945 userGroups = getUserGroups(userId);
5946
5947 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5948 for (ModelListener<User> listener : listeners) {
5949 listener.onBeforeRemoveAssociation(userId,
5950 com.liferay.portal.model.UserGroup.class.getName(),
5951 userGroup.getPrimaryKey());
5952 }
5953
5954 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5955 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
5956 User.class.getName(), userId);
5957 }
5958 }
5959 }
5960
5961 _sqlUpdate.update(new Object[] { new Long(userId) });
5962
5963 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
5964 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
5965 for (ModelListener<User> listener : listeners) {
5966 listener.onAfterRemoveAssociation(userId,
5967 com.liferay.portal.model.UserGroup.class.getName(),
5968 userGroup.getPrimaryKey());
5969 }
5970
5971 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
5972 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
5973 User.class.getName(), userId);
5974 }
5975 }
5976 }
5977 }
5978
5979 private SqlUpdate _sqlUpdate;
5980 }
5981
5982 protected class RemoveUserGroup {
5983 protected RemoveUserGroup(UserPersistenceImpl persistenceImpl) {
5984 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5985 "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
5986 new int[] { Types.BIGINT, Types.BIGINT });
5987 _persistenceImpl = persistenceImpl;
5988 }
5989
5990 protected void remove(long userId, long userGroupId)
5991 throws SystemException {
5992 if (_persistenceImpl.containsUserGroup.contains(userId, userGroupId)) {
5993 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
5994 userGroupPersistence.getListeners();
5995
5996 for (ModelListener<User> listener : listeners) {
5997 listener.onBeforeRemoveAssociation(userId,
5998 com.liferay.portal.model.UserGroup.class.getName(),
5999 userGroupId);
6000 }
6001
6002 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6003 listener.onBeforeRemoveAssociation(userGroupId,
6004 User.class.getName(), userId);
6005 }
6006
6007 _sqlUpdate.update(new Object[] {
6008 new Long(userId), new Long(userGroupId)
6009 });
6010
6011 for (ModelListener<User> listener : listeners) {
6012 listener.onAfterRemoveAssociation(userId,
6013 com.liferay.portal.model.UserGroup.class.getName(),
6014 userGroupId);
6015 }
6016
6017 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
6018 listener.onAfterRemoveAssociation(userGroupId,
6019 User.class.getName(), userId);
6020 }
6021 }
6022 }
6023
6024 private SqlUpdate _sqlUpdate;
6025 private UserPersistenceImpl _persistenceImpl;
6026 }
6027
6028 private static final String _SQL_SELECT_USER = "SELECT user FROM User user";
6029 private static final String _SQL_SELECT_USER_WHERE = "SELECT user FROM User user WHERE ";
6030 private static final String _SQL_COUNT_USER = "SELECT COUNT(user) FROM User user";
6031 private static final String _SQL_COUNT_USER_WHERE = "SELECT COUNT(user) FROM User user WHERE ";
6032 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
6033 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
6034 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
6035 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
6036 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
6037 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
6038 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
6039 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
6040 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
6041 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
6042 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
6043 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
6044 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
6045 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
6046 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
6047 private static final String _FINDER_COLUMN_UUID_UUID_1 = "user.uuid IS NULL";
6048 private static final String _FINDER_COLUMN_UUID_UUID_2 = "user.uuid = ?";
6049 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(user.uuid IS NULL OR user.uuid = ?)";
6050 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "user.companyId = ?";
6051 private static final String _FINDER_COLUMN_CONTACTID_CONTACTID_2 = "user.contactId = ?";
6052 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1 = "user.emailAddress IS NULL";
6053 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2 = "user.emailAddress = ?";
6054 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
6055 private static final String _FINDER_COLUMN_OPENID_OPENID_1 = "user.openId IS NULL";
6056 private static final String _FINDER_COLUMN_OPENID_OPENID_2 = "user.openId = ?";
6057 private static final String _FINDER_COLUMN_OPENID_OPENID_3 = "(user.openId IS NULL OR user.openId = ?)";
6058 private static final String _FINDER_COLUMN_PORTRAITID_PORTRAITID_2 = "user.portraitId = ?";
6059 private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "user.companyId = ? AND ";
6060 private static final String _FINDER_COLUMN_C_U_USERID_2 = "user.userId = ?";
6061 private static final String _FINDER_COLUMN_C_DU_COMPANYID_2 = "user.companyId = ? AND ";
6062 private static final String _FINDER_COLUMN_C_DU_DEFAULTUSER_2 = "user.defaultUser = ?";
6063 private static final String _FINDER_COLUMN_C_SN_COMPANYID_2 = "user.companyId = ? AND ";
6064 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_1 = "user.screenName IS NULL";
6065 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_2 = "user.screenName = ?";
6066 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_3 = "(user.screenName IS NULL OR user.screenName = ?)";
6067 private static final String _FINDER_COLUMN_C_EA_COMPANYID_2 = "user.companyId = ? AND ";
6068 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_1 = "user.emailAddress IS NULL";
6069 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_2 = "user.emailAddress = ?";
6070 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
6071 private static final String _FINDER_COLUMN_C_A_COMPANYID_2 = "user.companyId = ? AND ";
6072 private static final String _FINDER_COLUMN_C_A_ACTIVE_2 = "user.active = ?";
6073 private static final String _ORDER_BY_ENTITY_ALIAS = "user.";
6074 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No User exists with the primary key ";
6075 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No User exists with the key {";
6076 private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
6077}