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