001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchUserException;
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
022 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
023 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
025 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
026 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
028 import com.liferay.portal.kernel.dao.orm.FinderPath;
029 import com.liferay.portal.kernel.dao.orm.Query;
030 import com.liferay.portal.kernel.dao.orm.QueryPos;
031 import com.liferay.portal.kernel.dao.orm.QueryUtil;
032 import com.liferay.portal.kernel.dao.orm.SQLQuery;
033 import com.liferay.portal.kernel.dao.orm.Session;
034 import com.liferay.portal.kernel.exception.SystemException;
035 import com.liferay.portal.kernel.log.Log;
036 import com.liferay.portal.kernel.log.LogFactoryUtil;
037 import com.liferay.portal.kernel.util.GetterUtil;
038 import com.liferay.portal.kernel.util.InstanceFactory;
039 import com.liferay.portal.kernel.util.OrderByComparator;
040 import com.liferay.portal.kernel.util.SetUtil;
041 import com.liferay.portal.kernel.util.StringBundler;
042 import com.liferay.portal.kernel.util.StringPool;
043 import com.liferay.portal.kernel.util.StringUtil;
044 import com.liferay.portal.kernel.util.Validator;
045 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046 import com.liferay.portal.model.CacheModel;
047 import com.liferay.portal.model.ModelListener;
048 import com.liferay.portal.model.User;
049 import com.liferay.portal.model.impl.UserImpl;
050 import com.liferay.portal.model.impl.UserModelImpl;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.announcements.service.persistence.AnnouncementsDeliveryPersistence;
054 import com.liferay.portlet.asset.service.persistence.AssetEntryPersistence;
055 import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
056 import com.liferay.portlet.documentlibrary.service.persistence.DLFileRankPersistence;
057 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
058 import com.liferay.portlet.messageboards.service.persistence.MBBanPersistence;
059 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
060 import com.liferay.portlet.messageboards.service.persistence.MBStatsUserPersistence;
061 import com.liferay.portlet.messageboards.service.persistence.MBThreadFlagPersistence;
062 import com.liferay.portlet.shopping.service.persistence.ShoppingCartPersistence;
063 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
064 import com.liferay.portlet.social.service.persistence.SocialRequestPersistence;
065
066 import java.io.Serializable;
067
068 import java.util.ArrayList;
069 import java.util.Collections;
070 import java.util.List;
071 import java.util.Set;
072
073
085 public class UserPersistenceImpl extends BasePersistenceImpl<User>
086 implements UserPersistence {
087
092 public static final String FINDER_CLASS_NAME_ENTITY = UserImpl.class.getName();
093 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
094 ".List1";
095 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
096 ".List2";
097 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
098 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
099 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
100 new String[] {
101 String.class.getName(),
102
103 "java.lang.Integer", "java.lang.Integer",
104 "com.liferay.portal.kernel.util.OrderByComparator"
105 });
106 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
107 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
108 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
109 new String[] { String.class.getName() },
110 UserModelImpl.UUID_COLUMN_BITMASK);
111 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
112 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
113 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
114 new String[] { String.class.getName() });
115 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
116 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
117 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
118 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
119 new String[] {
120 Long.class.getName(),
121
122 "java.lang.Integer", "java.lang.Integer",
123 "com.liferay.portal.kernel.util.OrderByComparator"
124 });
125 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
126 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
127 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
128 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
129 new String[] { Long.class.getName() },
130 UserModelImpl.COMPANYID_COLUMN_BITMASK);
131 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
132 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
133 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
134 new String[] { Long.class.getName() });
135 public static final FinderPath FINDER_PATH_FETCH_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
136 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
137 FINDER_CLASS_NAME_ENTITY, "fetchByContactId",
138 new String[] { Long.class.getName() },
139 UserModelImpl.CONTACTID_COLUMN_BITMASK);
140 public static final FinderPath FINDER_PATH_COUNT_BY_CONTACTID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
141 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
142 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByContactId",
143 new String[] { Long.class.getName() });
144 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_EMAILADDRESS =
145 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
146 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
147 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByEmailAddress",
148 new String[] {
149 String.class.getName(),
150
151 "java.lang.Integer", "java.lang.Integer",
152 "com.liferay.portal.kernel.util.OrderByComparator"
153 });
154 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS =
155 new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
156 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
157 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByEmailAddress",
158 new String[] { String.class.getName() },
159 UserModelImpl.EMAILADDRESS_COLUMN_BITMASK);
160 public static final FinderPath FINDER_PATH_COUNT_BY_EMAILADDRESS = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
161 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
162 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByEmailAddress",
163 new String[] { String.class.getName() });
164 public static final FinderPath FINDER_PATH_FETCH_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
165 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
166 FINDER_CLASS_NAME_ENTITY, "fetchByPortraitId",
167 new String[] { Long.class.getName() },
168 UserModelImpl.PORTRAITID_COLUMN_BITMASK);
169 public static final FinderPath FINDER_PATH_COUNT_BY_PORTRAITID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
170 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
171 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByPortraitId",
172 new String[] { Long.class.getName() });
173 public static final FinderPath FINDER_PATH_FETCH_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
174 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
175 FINDER_CLASS_NAME_ENTITY, "fetchByC_U",
176 new String[] { Long.class.getName(), Long.class.getName() },
177 UserModelImpl.COMPANYID_COLUMN_BITMASK |
178 UserModelImpl.USERID_COLUMN_BITMASK);
179 public static final FinderPath FINDER_PATH_COUNT_BY_C_U = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
180 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
181 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U",
182 new String[] { Long.class.getName(), Long.class.getName() });
183 public static final FinderPath FINDER_PATH_FETCH_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
184 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
185 FINDER_CLASS_NAME_ENTITY, "fetchByC_DU",
186 new String[] { Long.class.getName(), Boolean.class.getName() },
187 UserModelImpl.COMPANYID_COLUMN_BITMASK |
188 UserModelImpl.DEFAULTUSER_COLUMN_BITMASK);
189 public static final FinderPath FINDER_PATH_COUNT_BY_C_DU = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
190 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
191 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_DU",
192 new String[] { Long.class.getName(), Boolean.class.getName() });
193 public static final FinderPath FINDER_PATH_FETCH_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
194 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
195 FINDER_CLASS_NAME_ENTITY, "fetchByC_SN",
196 new String[] { Long.class.getName(), String.class.getName() },
197 UserModelImpl.COMPANYID_COLUMN_BITMASK |
198 UserModelImpl.SCREENNAME_COLUMN_BITMASK);
199 public static final FinderPath FINDER_PATH_COUNT_BY_C_SN = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
200 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
201 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_SN",
202 new String[] { Long.class.getName(), String.class.getName() });
203 public static final FinderPath FINDER_PATH_FETCH_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
204 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
205 FINDER_CLASS_NAME_ENTITY, "fetchByC_EA",
206 new String[] { Long.class.getName(), String.class.getName() },
207 UserModelImpl.COMPANYID_COLUMN_BITMASK |
208 UserModelImpl.EMAILADDRESS_COLUMN_BITMASK);
209 public static final FinderPath FINDER_PATH_COUNT_BY_C_EA = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
210 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
211 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_EA",
212 new String[] { Long.class.getName(), String.class.getName() });
213 public static final FinderPath FINDER_PATH_FETCH_BY_C_FID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
214 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
215 FINDER_CLASS_NAME_ENTITY, "fetchByC_FID",
216 new String[] { Long.class.getName(), Long.class.getName() },
217 UserModelImpl.COMPANYID_COLUMN_BITMASK |
218 UserModelImpl.FACEBOOKID_COLUMN_BITMASK);
219 public static final FinderPath FINDER_PATH_COUNT_BY_C_FID = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
220 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
221 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_FID",
222 new String[] { Long.class.getName(), Long.class.getName() });
223 public static final FinderPath FINDER_PATH_FETCH_BY_C_O = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
224 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
225 FINDER_CLASS_NAME_ENTITY, "fetchByC_O",
226 new String[] { Long.class.getName(), String.class.getName() },
227 UserModelImpl.COMPANYID_COLUMN_BITMASK |
228 UserModelImpl.OPENID_COLUMN_BITMASK);
229 public static final FinderPath FINDER_PATH_COUNT_BY_C_O = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
230 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
231 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_O",
232 new String[] { Long.class.getName(), String.class.getName() });
233 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
234 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
235 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_S",
236 new String[] {
237 Long.class.getName(), Integer.class.getName(),
238
239 "java.lang.Integer", "java.lang.Integer",
240 "com.liferay.portal.kernel.util.OrderByComparator"
241 });
242 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
243 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
244 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_S",
245 new String[] { Long.class.getName(), Integer.class.getName() },
246 UserModelImpl.COMPANYID_COLUMN_BITMASK |
247 UserModelImpl.STATUS_COLUMN_BITMASK);
248 public static final FinderPath FINDER_PATH_COUNT_BY_C_S = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
249 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
250 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_S",
251 new String[] { Long.class.getName(), Integer.class.getName() });
252 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
253 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
254 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
255 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
256 UserModelImpl.FINDER_CACHE_ENABLED, UserImpl.class,
257 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
258 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(UserModelImpl.ENTITY_CACHE_ENABLED,
259 UserModelImpl.FINDER_CACHE_ENABLED, Long.class,
260 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
261
262
267 public void cacheResult(User user) {
268 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
269 UserImpl.class, user.getPrimaryKey(), user);
270
271 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
272 new Object[] { Long.valueOf(user.getContactId()) }, user);
273
274 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
275 new Object[] { Long.valueOf(user.getPortraitId()) }, user);
276
277 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
278 new Object[] {
279 Long.valueOf(user.getCompanyId()),
280 Long.valueOf(user.getUserId())
281 }, user);
282
283 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
284 new Object[] {
285 Long.valueOf(user.getCompanyId()),
286 Boolean.valueOf(user.getDefaultUser())
287 }, user);
288
289 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
290 new Object[] { Long.valueOf(user.getCompanyId()), user.getScreenName() },
291 user);
292
293 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
294 new Object[] {
295 Long.valueOf(user.getCompanyId()),
296
297 user.getEmailAddress()
298 }, user);
299
300 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
301 new Object[] {
302 Long.valueOf(user.getCompanyId()),
303 Long.valueOf(user.getFacebookId())
304 }, user);
305
306 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
307 new Object[] { Long.valueOf(user.getCompanyId()), user.getOpenId() },
308 user);
309
310 user.resetOriginalValues();
311 }
312
313
318 public void cacheResult(List<User> users) {
319 for (User user : users) {
320 if (EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
321 UserImpl.class, user.getPrimaryKey()) == null) {
322 cacheResult(user);
323 }
324 else {
325 user.resetOriginalValues();
326 }
327 }
328 }
329
330
337 @Override
338 public void clearCache() {
339 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
340 CacheRegistryUtil.clear(UserImpl.class.getName());
341 }
342
343 EntityCacheUtil.clearCache(UserImpl.class.getName());
344
345 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
346 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
347 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
348 }
349
350
357 @Override
358 public void clearCache(User user) {
359 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
360 UserImpl.class, user.getPrimaryKey());
361
362 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
363 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
364
365 clearUniqueFindersCache(user);
366 }
367
368 @Override
369 public void clearCache(List<User> users) {
370 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
371 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
372
373 for (User user : users) {
374 EntityCacheUtil.removeResult(UserModelImpl.ENTITY_CACHE_ENABLED,
375 UserImpl.class, user.getPrimaryKey());
376
377 clearUniqueFindersCache(user);
378 }
379 }
380
381 protected void clearUniqueFindersCache(User user) {
382 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
383 new Object[] { Long.valueOf(user.getContactId()) });
384
385 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
386 new Object[] { Long.valueOf(user.getPortraitId()) });
387
388 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
389 new Object[] {
390 Long.valueOf(user.getCompanyId()),
391 Long.valueOf(user.getUserId())
392 });
393
394 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
395 new Object[] {
396 Long.valueOf(user.getCompanyId()),
397 Boolean.valueOf(user.getDefaultUser())
398 });
399
400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
401 new Object[] { Long.valueOf(user.getCompanyId()), user.getScreenName() });
402
403 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
404 new Object[] {
405 Long.valueOf(user.getCompanyId()),
406
407 user.getEmailAddress()
408 });
409
410 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID,
411 new Object[] {
412 Long.valueOf(user.getCompanyId()),
413 Long.valueOf(user.getFacebookId())
414 });
415
416 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O,
417 new Object[] { Long.valueOf(user.getCompanyId()), user.getOpenId() });
418 }
419
420
426 public User create(long userId) {
427 User user = new UserImpl();
428
429 user.setNew(true);
430 user.setPrimaryKey(userId);
431
432 String uuid = PortalUUIDUtil.generate();
433
434 user.setUuid(uuid);
435
436 return user;
437 }
438
439
447 public User remove(long userId) throws NoSuchUserException, SystemException {
448 return remove(Long.valueOf(userId));
449 }
450
451
459 @Override
460 public User remove(Serializable primaryKey)
461 throws NoSuchUserException, SystemException {
462 Session session = null;
463
464 try {
465 session = openSession();
466
467 User user = (User)session.get(UserImpl.class, primaryKey);
468
469 if (user == null) {
470 if (_log.isWarnEnabled()) {
471 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
472 }
473
474 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
475 primaryKey);
476 }
477
478 return remove(user);
479 }
480 catch (NoSuchUserException nsee) {
481 throw nsee;
482 }
483 catch (Exception e) {
484 throw processException(e);
485 }
486 finally {
487 closeSession(session);
488 }
489 }
490
491 @Override
492 protected User removeImpl(User user) throws SystemException {
493 user = toUnwrappedModel(user);
494
495 try {
496 clearGroups.clear(user.getPrimaryKey());
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
503 }
504
505 try {
506 clearOrganizations.clear(user.getPrimaryKey());
507 }
508 catch (Exception e) {
509 throw processException(e);
510 }
511 finally {
512 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
513 }
514
515 try {
516 clearPermissions.clear(user.getPrimaryKey());
517 }
518 catch (Exception e) {
519 throw processException(e);
520 }
521 finally {
522 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
523 }
524
525 try {
526 clearRoles.clear(user.getPrimaryKey());
527 }
528 catch (Exception e) {
529 throw processException(e);
530 }
531 finally {
532 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
533 }
534
535 try {
536 clearTeams.clear(user.getPrimaryKey());
537 }
538 catch (Exception e) {
539 throw processException(e);
540 }
541 finally {
542 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
543 }
544
545 try {
546 clearUserGroups.clear(user.getPrimaryKey());
547 }
548 catch (Exception e) {
549 throw processException(e);
550 }
551 finally {
552 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
553 }
554
555 Session session = null;
556
557 try {
558 session = openSession();
559
560 BatchSessionUtil.delete(session, user);
561 }
562 catch (Exception e) {
563 throw processException(e);
564 }
565 finally {
566 closeSession(session);
567 }
568
569 clearCache(user);
570
571 return user;
572 }
573
574 @Override
575 public User updateImpl(com.liferay.portal.model.User user, boolean merge)
576 throws SystemException {
577 user = toUnwrappedModel(user);
578
579 boolean isNew = user.isNew();
580
581 UserModelImpl userModelImpl = (UserModelImpl)user;
582
583 if (Validator.isNull(user.getUuid())) {
584 String uuid = PortalUUIDUtil.generate();
585
586 user.setUuid(uuid);
587 }
588
589 Session session = null;
590
591 try {
592 session = openSession();
593
594 BatchSessionUtil.update(session, user, merge);
595
596 user.setNew(false);
597 }
598 catch (Exception e) {
599 throw processException(e);
600 }
601 finally {
602 closeSession(session);
603 }
604
605 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
606
607 if (isNew || !UserModelImpl.COLUMN_BITMASK_ENABLED) {
608 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
609 }
610
611 else {
612 if ((userModelImpl.getColumnBitmask() &
613 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
614 Object[] args = new Object[] { userModelImpl.getOriginalUuid() };
615
616 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
617 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
618 args);
619
620 args = new Object[] { userModelImpl.getUuid() };
621
622 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
623 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
624 args);
625 }
626
627 if ((userModelImpl.getColumnBitmask() &
628 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
629 Object[] args = new Object[] {
630 Long.valueOf(userModelImpl.getOriginalCompanyId())
631 };
632
633 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
634 args);
635 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
636 args);
637
638 args = new Object[] { Long.valueOf(userModelImpl.getCompanyId()) };
639
640 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
641 args);
642 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
643 args);
644 }
645
646 if ((userModelImpl.getColumnBitmask() &
647 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS.getColumnBitmask()) != 0) {
648 Object[] args = new Object[] {
649 userModelImpl.getOriginalEmailAddress()
650 };
651
652 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
653 args);
654 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS,
655 args);
656
657 args = new Object[] { userModelImpl.getEmailAddress() };
658
659 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
660 args);
661 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS,
662 args);
663 }
664
665 if ((userModelImpl.getColumnBitmask() &
666 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S.getColumnBitmask()) != 0) {
667 Object[] args = new Object[] {
668 Long.valueOf(userModelImpl.getOriginalCompanyId()),
669 Integer.valueOf(userModelImpl.getOriginalStatus())
670 };
671
672 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
673 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
674 args);
675
676 args = new Object[] {
677 Long.valueOf(userModelImpl.getCompanyId()),
678 Integer.valueOf(userModelImpl.getStatus())
679 };
680
681 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_S, args);
682 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S,
683 args);
684 }
685 }
686
687 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
688 UserImpl.class, user.getPrimaryKey(), user);
689
690 if (isNew) {
691 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
692 new Object[] { Long.valueOf(user.getContactId()) }, user);
693
694 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
695 new Object[] { Long.valueOf(user.getPortraitId()) }, user);
696
697 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
698 new Object[] {
699 Long.valueOf(user.getCompanyId()),
700 Long.valueOf(user.getUserId())
701 }, user);
702
703 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
704 new Object[] {
705 Long.valueOf(user.getCompanyId()),
706 Boolean.valueOf(user.getDefaultUser())
707 }, user);
708
709 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
710 new Object[] {
711 Long.valueOf(user.getCompanyId()),
712
713 user.getScreenName()
714 }, user);
715
716 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
717 new Object[] {
718 Long.valueOf(user.getCompanyId()),
719
720 user.getEmailAddress()
721 }, user);
722
723 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
724 new Object[] {
725 Long.valueOf(user.getCompanyId()),
726 Long.valueOf(user.getFacebookId())
727 }, user);
728
729 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
730 new Object[] { Long.valueOf(user.getCompanyId()), user.getOpenId() },
731 user);
732 }
733 else {
734 if ((userModelImpl.getColumnBitmask() &
735 FINDER_PATH_FETCH_BY_CONTACTID.getColumnBitmask()) != 0) {
736 Object[] args = new Object[] {
737 Long.valueOf(userModelImpl.getOriginalContactId())
738 };
739
740 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CONTACTID,
741 args);
742
743 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
744 args);
745
746 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
747 new Object[] { Long.valueOf(user.getContactId()) }, user);
748 }
749
750 if ((userModelImpl.getColumnBitmask() &
751 FINDER_PATH_FETCH_BY_PORTRAITID.getColumnBitmask()) != 0) {
752 Object[] args = new Object[] {
753 Long.valueOf(userModelImpl.getOriginalPortraitId())
754 };
755
756 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTRAITID,
757 args);
758
759 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
760 args);
761
762 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
763 new Object[] { Long.valueOf(user.getPortraitId()) }, user);
764 }
765
766 if ((userModelImpl.getColumnBitmask() &
767 FINDER_PATH_FETCH_BY_C_U.getColumnBitmask()) != 0) {
768 Object[] args = new Object[] {
769 Long.valueOf(userModelImpl.getOriginalCompanyId()),
770 Long.valueOf(userModelImpl.getOriginalUserId())
771 };
772
773 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
774
775 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
776
777 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
778 new Object[] {
779 Long.valueOf(user.getCompanyId()),
780 Long.valueOf(user.getUserId())
781 }, user);
782 }
783
784 if ((userModelImpl.getColumnBitmask() &
785 FINDER_PATH_FETCH_BY_C_DU.getColumnBitmask()) != 0) {
786 Object[] args = new Object[] {
787 Long.valueOf(userModelImpl.getOriginalCompanyId()),
788 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
789 };
790
791 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DU, args);
792
793 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU, args);
794
795 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
796 new Object[] {
797 Long.valueOf(user.getCompanyId()),
798 Boolean.valueOf(user.getDefaultUser())
799 }, user);
800 }
801
802 if ((userModelImpl.getColumnBitmask() &
803 FINDER_PATH_FETCH_BY_C_SN.getColumnBitmask()) != 0) {
804 Object[] args = new Object[] {
805 Long.valueOf(userModelImpl.getOriginalCompanyId()),
806
807 userModelImpl.getOriginalScreenName()
808 };
809
810 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_SN, args);
811
812 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN, args);
813
814 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
815 new Object[] {
816 Long.valueOf(user.getCompanyId()),
817
818 user.getScreenName()
819 }, user);
820 }
821
822 if ((userModelImpl.getColumnBitmask() &
823 FINDER_PATH_FETCH_BY_C_EA.getColumnBitmask()) != 0) {
824 Object[] args = new Object[] {
825 Long.valueOf(userModelImpl.getOriginalCompanyId()),
826
827 userModelImpl.getOriginalEmailAddress()
828 };
829
830 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_EA, args);
831
832 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA, args);
833
834 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
835 new Object[] {
836 Long.valueOf(user.getCompanyId()),
837
838 user.getEmailAddress()
839 }, user);
840 }
841
842 if ((userModelImpl.getColumnBitmask() &
843 FINDER_PATH_FETCH_BY_C_FID.getColumnBitmask()) != 0) {
844 Object[] args = new Object[] {
845 Long.valueOf(userModelImpl.getOriginalCompanyId()),
846 Long.valueOf(userModelImpl.getOriginalFacebookId())
847 };
848
849 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_FID, args);
850
851 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID, args);
852
853 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
854 new Object[] {
855 Long.valueOf(user.getCompanyId()),
856 Long.valueOf(user.getFacebookId())
857 }, user);
858 }
859
860 if ((userModelImpl.getColumnBitmask() &
861 FINDER_PATH_FETCH_BY_C_O.getColumnBitmask()) != 0) {
862 Object[] args = new Object[] {
863 Long.valueOf(userModelImpl.getOriginalCompanyId()),
864
865 userModelImpl.getOriginalOpenId()
866 };
867
868 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_O, args);
869
870 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O, args);
871
872 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
873 new Object[] {
874 Long.valueOf(user.getCompanyId()),
875
876 user.getOpenId()
877 }, user);
878 }
879 }
880
881 return user;
882 }
883
884 protected User toUnwrappedModel(User user) {
885 if (user instanceof UserImpl) {
886 return user;
887 }
888
889 UserImpl userImpl = new UserImpl();
890
891 userImpl.setNew(user.isNew());
892 userImpl.setPrimaryKey(user.getPrimaryKey());
893
894 userImpl.setUuid(user.getUuid());
895 userImpl.setUserId(user.getUserId());
896 userImpl.setCompanyId(user.getCompanyId());
897 userImpl.setCreateDate(user.getCreateDate());
898 userImpl.setModifiedDate(user.getModifiedDate());
899 userImpl.setDefaultUser(user.isDefaultUser());
900 userImpl.setContactId(user.getContactId());
901 userImpl.setPassword(user.getPassword());
902 userImpl.setPasswordEncrypted(user.isPasswordEncrypted());
903 userImpl.setPasswordReset(user.isPasswordReset());
904 userImpl.setPasswordModifiedDate(user.getPasswordModifiedDate());
905 userImpl.setDigest(user.getDigest());
906 userImpl.setReminderQueryQuestion(user.getReminderQueryQuestion());
907 userImpl.setReminderQueryAnswer(user.getReminderQueryAnswer());
908 userImpl.setGraceLoginCount(user.getGraceLoginCount());
909 userImpl.setScreenName(user.getScreenName());
910 userImpl.setEmailAddress(user.getEmailAddress());
911 userImpl.setFacebookId(user.getFacebookId());
912 userImpl.setOpenId(user.getOpenId());
913 userImpl.setPortraitId(user.getPortraitId());
914 userImpl.setLanguageId(user.getLanguageId());
915 userImpl.setTimeZoneId(user.getTimeZoneId());
916 userImpl.setGreeting(user.getGreeting());
917 userImpl.setComments(user.getComments());
918 userImpl.setFirstName(user.getFirstName());
919 userImpl.setMiddleName(user.getMiddleName());
920 userImpl.setLastName(user.getLastName());
921 userImpl.setJobTitle(user.getJobTitle());
922 userImpl.setLoginDate(user.getLoginDate());
923 userImpl.setLoginIP(user.getLoginIP());
924 userImpl.setLastLoginDate(user.getLastLoginDate());
925 userImpl.setLastLoginIP(user.getLastLoginIP());
926 userImpl.setLastFailedLoginDate(user.getLastFailedLoginDate());
927 userImpl.setFailedLoginAttempts(user.getFailedLoginAttempts());
928 userImpl.setLockout(user.isLockout());
929 userImpl.setLockoutDate(user.getLockoutDate());
930 userImpl.setAgreedToTermsOfUse(user.isAgreedToTermsOfUse());
931 userImpl.setEmailAddressVerified(user.isEmailAddressVerified());
932 userImpl.setStatus(user.getStatus());
933
934 return userImpl;
935 }
936
937
945 @Override
946 public User findByPrimaryKey(Serializable primaryKey)
947 throws NoSuchModelException, SystemException {
948 return findByPrimaryKey(((Long)primaryKey).longValue());
949 }
950
951
959 public User findByPrimaryKey(long userId)
960 throws NoSuchUserException, SystemException {
961 User user = fetchByPrimaryKey(userId);
962
963 if (user == null) {
964 if (_log.isWarnEnabled()) {
965 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userId);
966 }
967
968 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
969 userId);
970 }
971
972 return user;
973 }
974
975
982 @Override
983 public User fetchByPrimaryKey(Serializable primaryKey)
984 throws SystemException {
985 return fetchByPrimaryKey(((Long)primaryKey).longValue());
986 }
987
988
995 public User fetchByPrimaryKey(long userId) throws SystemException {
996 User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
997 UserImpl.class, userId);
998
999 if (user == _nullUser) {
1000 return null;
1001 }
1002
1003 if (user == null) {
1004 Session session = null;
1005
1006 boolean hasException = false;
1007
1008 try {
1009 session = openSession();
1010
1011 user = (User)session.get(UserImpl.class, Long.valueOf(userId));
1012 }
1013 catch (Exception e) {
1014 hasException = true;
1015
1016 throw processException(e);
1017 }
1018 finally {
1019 if (user != null) {
1020 cacheResult(user);
1021 }
1022 else if (!hasException) {
1023 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
1024 UserImpl.class, userId, _nullUser);
1025 }
1026
1027 closeSession(session);
1028 }
1029 }
1030
1031 return user;
1032 }
1033
1034
1041 public List<User> findByUuid(String uuid) throws SystemException {
1042 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1043 }
1044
1045
1058 public List<User> findByUuid(String uuid, int start, int end)
1059 throws SystemException {
1060 return findByUuid(uuid, start, end, null);
1061 }
1062
1063
1077 public List<User> findByUuid(String uuid, int start, int end,
1078 OrderByComparator orderByComparator) throws SystemException {
1079 FinderPath finderPath = null;
1080 Object[] finderArgs = null;
1081
1082 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1083 (orderByComparator == null)) {
1084 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1085 finderArgs = new Object[] { uuid };
1086 }
1087 else {
1088 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1089 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1090 }
1091
1092 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1093 finderArgs, this);
1094
1095 if ((list != null) && !list.isEmpty()) {
1096 for (User user : list) {
1097 if (!Validator.equals(uuid, user.getUuid())) {
1098 list = null;
1099
1100 break;
1101 }
1102 }
1103 }
1104
1105 if (list == null) {
1106 StringBundler query = null;
1107
1108 if (orderByComparator != null) {
1109 query = new StringBundler(3 +
1110 (orderByComparator.getOrderByFields().length * 3));
1111 }
1112 else {
1113 query = new StringBundler(2);
1114 }
1115
1116 query.append(_SQL_SELECT_USER_WHERE);
1117
1118 if (uuid == null) {
1119 query.append(_FINDER_COLUMN_UUID_UUID_1);
1120 }
1121 else {
1122 if (uuid.equals(StringPool.BLANK)) {
1123 query.append(_FINDER_COLUMN_UUID_UUID_3);
1124 }
1125 else {
1126 query.append(_FINDER_COLUMN_UUID_UUID_2);
1127 }
1128 }
1129
1130 if (orderByComparator != null) {
1131 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1132 orderByComparator);
1133 }
1134
1135 String sql = query.toString();
1136
1137 Session session = null;
1138
1139 try {
1140 session = openSession();
1141
1142 Query q = session.createQuery(sql);
1143
1144 QueryPos qPos = QueryPos.getInstance(q);
1145
1146 if (uuid != null) {
1147 qPos.add(uuid);
1148 }
1149
1150 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1151 }
1152 catch (Exception e) {
1153 throw processException(e);
1154 }
1155 finally {
1156 if (list == null) {
1157 FinderCacheUtil.removeResult(finderPath, finderArgs);
1158 }
1159 else {
1160 cacheResult(list);
1161
1162 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1163 }
1164
1165 closeSession(session);
1166 }
1167 }
1168
1169 return list;
1170 }
1171
1172
1181 public User findByUuid_First(String uuid,
1182 OrderByComparator orderByComparator)
1183 throws NoSuchUserException, SystemException {
1184 User user = fetchByUuid_First(uuid, orderByComparator);
1185
1186 if (user != null) {
1187 return user;
1188 }
1189
1190 StringBundler msg = new StringBundler(4);
1191
1192 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1193
1194 msg.append("uuid=");
1195 msg.append(uuid);
1196
1197 msg.append(StringPool.CLOSE_CURLY_BRACE);
1198
1199 throw new NoSuchUserException(msg.toString());
1200 }
1201
1202
1210 public User fetchByUuid_First(String uuid,
1211 OrderByComparator orderByComparator) throws SystemException {
1212 List<User> list = findByUuid(uuid, 0, 1, orderByComparator);
1213
1214 if (!list.isEmpty()) {
1215 return list.get(0);
1216 }
1217
1218 return null;
1219 }
1220
1221
1230 public User findByUuid_Last(String uuid, OrderByComparator orderByComparator)
1231 throws NoSuchUserException, SystemException {
1232 User user = fetchByUuid_Last(uuid, orderByComparator);
1233
1234 if (user != null) {
1235 return user;
1236 }
1237
1238 StringBundler msg = new StringBundler(4);
1239
1240 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1241
1242 msg.append("uuid=");
1243 msg.append(uuid);
1244
1245 msg.append(StringPool.CLOSE_CURLY_BRACE);
1246
1247 throw new NoSuchUserException(msg.toString());
1248 }
1249
1250
1258 public User fetchByUuid_Last(String uuid,
1259 OrderByComparator orderByComparator) throws SystemException {
1260 int count = countByUuid(uuid);
1261
1262 List<User> list = findByUuid(uuid, count - 1, count, orderByComparator);
1263
1264 if (!list.isEmpty()) {
1265 return list.get(0);
1266 }
1267
1268 return null;
1269 }
1270
1271
1281 public User[] findByUuid_PrevAndNext(long userId, String uuid,
1282 OrderByComparator orderByComparator)
1283 throws NoSuchUserException, SystemException {
1284 User user = findByPrimaryKey(userId);
1285
1286 Session session = null;
1287
1288 try {
1289 session = openSession();
1290
1291 User[] array = new UserImpl[3];
1292
1293 array[0] = getByUuid_PrevAndNext(session, user, uuid,
1294 orderByComparator, true);
1295
1296 array[1] = user;
1297
1298 array[2] = getByUuid_PrevAndNext(session, user, uuid,
1299 orderByComparator, false);
1300
1301 return array;
1302 }
1303 catch (Exception e) {
1304 throw processException(e);
1305 }
1306 finally {
1307 closeSession(session);
1308 }
1309 }
1310
1311 protected User getByUuid_PrevAndNext(Session session, User user,
1312 String uuid, OrderByComparator orderByComparator, boolean previous) {
1313 StringBundler query = null;
1314
1315 if (orderByComparator != null) {
1316 query = new StringBundler(6 +
1317 (orderByComparator.getOrderByFields().length * 6));
1318 }
1319 else {
1320 query = new StringBundler(3);
1321 }
1322
1323 query.append(_SQL_SELECT_USER_WHERE);
1324
1325 if (uuid == null) {
1326 query.append(_FINDER_COLUMN_UUID_UUID_1);
1327 }
1328 else {
1329 if (uuid.equals(StringPool.BLANK)) {
1330 query.append(_FINDER_COLUMN_UUID_UUID_3);
1331 }
1332 else {
1333 query.append(_FINDER_COLUMN_UUID_UUID_2);
1334 }
1335 }
1336
1337 if (orderByComparator != null) {
1338 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1339
1340 if (orderByConditionFields.length > 0) {
1341 query.append(WHERE_AND);
1342 }
1343
1344 for (int i = 0; i < orderByConditionFields.length; i++) {
1345 query.append(_ORDER_BY_ENTITY_ALIAS);
1346 query.append(orderByConditionFields[i]);
1347
1348 if ((i + 1) < orderByConditionFields.length) {
1349 if (orderByComparator.isAscending() ^ previous) {
1350 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1351 }
1352 else {
1353 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1354 }
1355 }
1356 else {
1357 if (orderByComparator.isAscending() ^ previous) {
1358 query.append(WHERE_GREATER_THAN);
1359 }
1360 else {
1361 query.append(WHERE_LESSER_THAN);
1362 }
1363 }
1364 }
1365
1366 query.append(ORDER_BY_CLAUSE);
1367
1368 String[] orderByFields = orderByComparator.getOrderByFields();
1369
1370 for (int i = 0; i < orderByFields.length; i++) {
1371 query.append(_ORDER_BY_ENTITY_ALIAS);
1372 query.append(orderByFields[i]);
1373
1374 if ((i + 1) < orderByFields.length) {
1375 if (orderByComparator.isAscending() ^ previous) {
1376 query.append(ORDER_BY_ASC_HAS_NEXT);
1377 }
1378 else {
1379 query.append(ORDER_BY_DESC_HAS_NEXT);
1380 }
1381 }
1382 else {
1383 if (orderByComparator.isAscending() ^ previous) {
1384 query.append(ORDER_BY_ASC);
1385 }
1386 else {
1387 query.append(ORDER_BY_DESC);
1388 }
1389 }
1390 }
1391 }
1392
1393 String sql = query.toString();
1394
1395 Query q = session.createQuery(sql);
1396
1397 q.setFirstResult(0);
1398 q.setMaxResults(2);
1399
1400 QueryPos qPos = QueryPos.getInstance(q);
1401
1402 if (uuid != null) {
1403 qPos.add(uuid);
1404 }
1405
1406 if (orderByComparator != null) {
1407 Object[] values = orderByComparator.getOrderByConditionValues(user);
1408
1409 for (Object value : values) {
1410 qPos.add(value);
1411 }
1412 }
1413
1414 List<User> list = q.list();
1415
1416 if (list.size() == 2) {
1417 return list.get(1);
1418 }
1419 else {
1420 return null;
1421 }
1422 }
1423
1424
1431 public List<User> findByCompanyId(long companyId) throws SystemException {
1432 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1433 null);
1434 }
1435
1436
1449 public List<User> findByCompanyId(long companyId, int start, int end)
1450 throws SystemException {
1451 return findByCompanyId(companyId, start, end, null);
1452 }
1453
1454
1468 public List<User> findByCompanyId(long companyId, int start, int end,
1469 OrderByComparator orderByComparator) throws SystemException {
1470 FinderPath finderPath = null;
1471 Object[] finderArgs = null;
1472
1473 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1474 (orderByComparator == null)) {
1475 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1476 finderArgs = new Object[] { companyId };
1477 }
1478 else {
1479 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1480 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1481 }
1482
1483 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1484 finderArgs, this);
1485
1486 if ((list != null) && !list.isEmpty()) {
1487 for (User user : list) {
1488 if ((companyId != user.getCompanyId())) {
1489 list = null;
1490
1491 break;
1492 }
1493 }
1494 }
1495
1496 if (list == null) {
1497 StringBundler query = null;
1498
1499 if (orderByComparator != null) {
1500 query = new StringBundler(3 +
1501 (orderByComparator.getOrderByFields().length * 3));
1502 }
1503 else {
1504 query = new StringBundler(2);
1505 }
1506
1507 query.append(_SQL_SELECT_USER_WHERE);
1508
1509 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1510
1511 if (orderByComparator != null) {
1512 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1513 orderByComparator);
1514 }
1515
1516 String sql = query.toString();
1517
1518 Session session = null;
1519
1520 try {
1521 session = openSession();
1522
1523 Query q = session.createQuery(sql);
1524
1525 QueryPos qPos = QueryPos.getInstance(q);
1526
1527 qPos.add(companyId);
1528
1529 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1530 }
1531 catch (Exception e) {
1532 throw processException(e);
1533 }
1534 finally {
1535 if (list == null) {
1536 FinderCacheUtil.removeResult(finderPath, finderArgs);
1537 }
1538 else {
1539 cacheResult(list);
1540
1541 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1542 }
1543
1544 closeSession(session);
1545 }
1546 }
1547
1548 return list;
1549 }
1550
1551
1560 public User findByCompanyId_First(long companyId,
1561 OrderByComparator orderByComparator)
1562 throws NoSuchUserException, SystemException {
1563 User user = fetchByCompanyId_First(companyId, orderByComparator);
1564
1565 if (user != null) {
1566 return user;
1567 }
1568
1569 StringBundler msg = new StringBundler(4);
1570
1571 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1572
1573 msg.append("companyId=");
1574 msg.append(companyId);
1575
1576 msg.append(StringPool.CLOSE_CURLY_BRACE);
1577
1578 throw new NoSuchUserException(msg.toString());
1579 }
1580
1581
1589 public User fetchByCompanyId_First(long companyId,
1590 OrderByComparator orderByComparator) throws SystemException {
1591 List<User> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1592
1593 if (!list.isEmpty()) {
1594 return list.get(0);
1595 }
1596
1597 return null;
1598 }
1599
1600
1609 public User findByCompanyId_Last(long companyId,
1610 OrderByComparator orderByComparator)
1611 throws NoSuchUserException, SystemException {
1612 User user = fetchByCompanyId_Last(companyId, orderByComparator);
1613
1614 if (user != null) {
1615 return user;
1616 }
1617
1618 StringBundler msg = new StringBundler(4);
1619
1620 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1621
1622 msg.append("companyId=");
1623 msg.append(companyId);
1624
1625 msg.append(StringPool.CLOSE_CURLY_BRACE);
1626
1627 throw new NoSuchUserException(msg.toString());
1628 }
1629
1630
1638 public User fetchByCompanyId_Last(long companyId,
1639 OrderByComparator orderByComparator) throws SystemException {
1640 int count = countByCompanyId(companyId);
1641
1642 List<User> list = findByCompanyId(companyId, count - 1, count,
1643 orderByComparator);
1644
1645 if (!list.isEmpty()) {
1646 return list.get(0);
1647 }
1648
1649 return null;
1650 }
1651
1652
1662 public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1663 OrderByComparator orderByComparator)
1664 throws NoSuchUserException, SystemException {
1665 User user = findByPrimaryKey(userId);
1666
1667 Session session = null;
1668
1669 try {
1670 session = openSession();
1671
1672 User[] array = new UserImpl[3];
1673
1674 array[0] = getByCompanyId_PrevAndNext(session, user, companyId,
1675 orderByComparator, true);
1676
1677 array[1] = user;
1678
1679 array[2] = getByCompanyId_PrevAndNext(session, user, companyId,
1680 orderByComparator, false);
1681
1682 return array;
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 closeSession(session);
1689 }
1690 }
1691
1692 protected User getByCompanyId_PrevAndNext(Session session, User user,
1693 long companyId, OrderByComparator orderByComparator, boolean previous) {
1694 StringBundler query = null;
1695
1696 if (orderByComparator != null) {
1697 query = new StringBundler(6 +
1698 (orderByComparator.getOrderByFields().length * 6));
1699 }
1700 else {
1701 query = new StringBundler(3);
1702 }
1703
1704 query.append(_SQL_SELECT_USER_WHERE);
1705
1706 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1707
1708 if (orderByComparator != null) {
1709 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1710
1711 if (orderByConditionFields.length > 0) {
1712 query.append(WHERE_AND);
1713 }
1714
1715 for (int i = 0; i < orderByConditionFields.length; i++) {
1716 query.append(_ORDER_BY_ENTITY_ALIAS);
1717 query.append(orderByConditionFields[i]);
1718
1719 if ((i + 1) < orderByConditionFields.length) {
1720 if (orderByComparator.isAscending() ^ previous) {
1721 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1722 }
1723 else {
1724 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1725 }
1726 }
1727 else {
1728 if (orderByComparator.isAscending() ^ previous) {
1729 query.append(WHERE_GREATER_THAN);
1730 }
1731 else {
1732 query.append(WHERE_LESSER_THAN);
1733 }
1734 }
1735 }
1736
1737 query.append(ORDER_BY_CLAUSE);
1738
1739 String[] orderByFields = orderByComparator.getOrderByFields();
1740
1741 for (int i = 0; i < orderByFields.length; i++) {
1742 query.append(_ORDER_BY_ENTITY_ALIAS);
1743 query.append(orderByFields[i]);
1744
1745 if ((i + 1) < orderByFields.length) {
1746 if (orderByComparator.isAscending() ^ previous) {
1747 query.append(ORDER_BY_ASC_HAS_NEXT);
1748 }
1749 else {
1750 query.append(ORDER_BY_DESC_HAS_NEXT);
1751 }
1752 }
1753 else {
1754 if (orderByComparator.isAscending() ^ previous) {
1755 query.append(ORDER_BY_ASC);
1756 }
1757 else {
1758 query.append(ORDER_BY_DESC);
1759 }
1760 }
1761 }
1762 }
1763
1764 String sql = query.toString();
1765
1766 Query q = session.createQuery(sql);
1767
1768 q.setFirstResult(0);
1769 q.setMaxResults(2);
1770
1771 QueryPos qPos = QueryPos.getInstance(q);
1772
1773 qPos.add(companyId);
1774
1775 if (orderByComparator != null) {
1776 Object[] values = orderByComparator.getOrderByConditionValues(user);
1777
1778 for (Object value : values) {
1779 qPos.add(value);
1780 }
1781 }
1782
1783 List<User> list = q.list();
1784
1785 if (list.size() == 2) {
1786 return list.get(1);
1787 }
1788 else {
1789 return null;
1790 }
1791 }
1792
1793
1801 public User findByContactId(long contactId)
1802 throws NoSuchUserException, SystemException {
1803 User user = fetchByContactId(contactId);
1804
1805 if (user == null) {
1806 StringBundler msg = new StringBundler(4);
1807
1808 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1809
1810 msg.append("contactId=");
1811 msg.append(contactId);
1812
1813 msg.append(StringPool.CLOSE_CURLY_BRACE);
1814
1815 if (_log.isWarnEnabled()) {
1816 _log.warn(msg.toString());
1817 }
1818
1819 throw new NoSuchUserException(msg.toString());
1820 }
1821
1822 return user;
1823 }
1824
1825
1832 public User fetchByContactId(long contactId) throws SystemException {
1833 return fetchByContactId(contactId, true);
1834 }
1835
1836
1844 public User fetchByContactId(long contactId, boolean retrieveFromCache)
1845 throws SystemException {
1846 Object[] finderArgs = new Object[] { contactId };
1847
1848 Object result = null;
1849
1850 if (retrieveFromCache) {
1851 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1852 finderArgs, this);
1853 }
1854
1855 if (result instanceof User) {
1856 User user = (User)result;
1857
1858 if ((contactId != user.getContactId())) {
1859 result = null;
1860 }
1861 }
1862
1863 if (result == null) {
1864 StringBundler query = new StringBundler(2);
1865
1866 query.append(_SQL_SELECT_USER_WHERE);
1867
1868 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
1869
1870 String sql = query.toString();
1871
1872 Session session = null;
1873
1874 try {
1875 session = openSession();
1876
1877 Query q = session.createQuery(sql);
1878
1879 QueryPos qPos = QueryPos.getInstance(q);
1880
1881 qPos.add(contactId);
1882
1883 List<User> list = q.list();
1884
1885 result = list;
1886
1887 User user = null;
1888
1889 if (list.isEmpty()) {
1890 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1891 finderArgs, list);
1892 }
1893 else {
1894 user = list.get(0);
1895
1896 cacheResult(user);
1897
1898 if ((user.getContactId() != contactId)) {
1899 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1900 finderArgs, user);
1901 }
1902 }
1903
1904 return user;
1905 }
1906 catch (Exception e) {
1907 throw processException(e);
1908 }
1909 finally {
1910 if (result == null) {
1911 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
1912 finderArgs);
1913 }
1914
1915 closeSession(session);
1916 }
1917 }
1918 else {
1919 if (result instanceof List<?>) {
1920 return null;
1921 }
1922 else {
1923 return (User)result;
1924 }
1925 }
1926 }
1927
1928
1935 public List<User> findByEmailAddress(String emailAddress)
1936 throws SystemException {
1937 return findByEmailAddress(emailAddress, QueryUtil.ALL_POS,
1938 QueryUtil.ALL_POS, null);
1939 }
1940
1941
1954 public List<User> findByEmailAddress(String emailAddress, int start, int end)
1955 throws SystemException {
1956 return findByEmailAddress(emailAddress, start, end, null);
1957 }
1958
1959
1973 public List<User> findByEmailAddress(String emailAddress, int start,
1974 int end, OrderByComparator orderByComparator) throws SystemException {
1975 FinderPath finderPath = null;
1976 Object[] finderArgs = null;
1977
1978 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1979 (orderByComparator == null)) {
1980 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS;
1981 finderArgs = new Object[] { emailAddress };
1982 }
1983 else {
1984 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EMAILADDRESS;
1985 finderArgs = new Object[] {
1986 emailAddress,
1987
1988 start, end, orderByComparator
1989 };
1990 }
1991
1992 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1993 finderArgs, this);
1994
1995 if ((list != null) && !list.isEmpty()) {
1996 for (User user : list) {
1997 if (!Validator.equals(emailAddress, user.getEmailAddress())) {
1998 list = null;
1999
2000 break;
2001 }
2002 }
2003 }
2004
2005 if (list == null) {
2006 StringBundler query = null;
2007
2008 if (orderByComparator != null) {
2009 query = new StringBundler(3 +
2010 (orderByComparator.getOrderByFields().length * 3));
2011 }
2012 else {
2013 query = new StringBundler(2);
2014 }
2015
2016 query.append(_SQL_SELECT_USER_WHERE);
2017
2018 if (emailAddress == null) {
2019 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2020 }
2021 else {
2022 if (emailAddress.equals(StringPool.BLANK)) {
2023 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2024 }
2025 else {
2026 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2027 }
2028 }
2029
2030 if (orderByComparator != null) {
2031 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2032 orderByComparator);
2033 }
2034
2035 String sql = query.toString();
2036
2037 Session session = null;
2038
2039 try {
2040 session = openSession();
2041
2042 Query q = session.createQuery(sql);
2043
2044 QueryPos qPos = QueryPos.getInstance(q);
2045
2046 if (emailAddress != null) {
2047 qPos.add(emailAddress);
2048 }
2049
2050 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
2051 }
2052 catch (Exception e) {
2053 throw processException(e);
2054 }
2055 finally {
2056 if (list == null) {
2057 FinderCacheUtil.removeResult(finderPath, finderArgs);
2058 }
2059 else {
2060 cacheResult(list);
2061
2062 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2063 }
2064
2065 closeSession(session);
2066 }
2067 }
2068
2069 return list;
2070 }
2071
2072
2081 public User findByEmailAddress_First(String emailAddress,
2082 OrderByComparator orderByComparator)
2083 throws NoSuchUserException, SystemException {
2084 User user = fetchByEmailAddress_First(emailAddress, orderByComparator);
2085
2086 if (user != null) {
2087 return user;
2088 }
2089
2090 StringBundler msg = new StringBundler(4);
2091
2092 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2093
2094 msg.append("emailAddress=");
2095 msg.append(emailAddress);
2096
2097 msg.append(StringPool.CLOSE_CURLY_BRACE);
2098
2099 throw new NoSuchUserException(msg.toString());
2100 }
2101
2102
2110 public User fetchByEmailAddress_First(String emailAddress,
2111 OrderByComparator orderByComparator) throws SystemException {
2112 List<User> list = findByEmailAddress(emailAddress, 0, 1,
2113 orderByComparator);
2114
2115 if (!list.isEmpty()) {
2116 return list.get(0);
2117 }
2118
2119 return null;
2120 }
2121
2122
2131 public User findByEmailAddress_Last(String emailAddress,
2132 OrderByComparator orderByComparator)
2133 throws NoSuchUserException, SystemException {
2134 User user = fetchByEmailAddress_Last(emailAddress, orderByComparator);
2135
2136 if (user != null) {
2137 return user;
2138 }
2139
2140 StringBundler msg = new StringBundler(4);
2141
2142 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2143
2144 msg.append("emailAddress=");
2145 msg.append(emailAddress);
2146
2147 msg.append(StringPool.CLOSE_CURLY_BRACE);
2148
2149 throw new NoSuchUserException(msg.toString());
2150 }
2151
2152
2160 public User fetchByEmailAddress_Last(String emailAddress,
2161 OrderByComparator orderByComparator) throws SystemException {
2162 int count = countByEmailAddress(emailAddress);
2163
2164 List<User> list = findByEmailAddress(emailAddress, count - 1, count,
2165 orderByComparator);
2166
2167 if (!list.isEmpty()) {
2168 return list.get(0);
2169 }
2170
2171 return null;
2172 }
2173
2174
2184 public User[] findByEmailAddress_PrevAndNext(long userId,
2185 String emailAddress, OrderByComparator orderByComparator)
2186 throws NoSuchUserException, SystemException {
2187 User user = findByPrimaryKey(userId);
2188
2189 Session session = null;
2190
2191 try {
2192 session = openSession();
2193
2194 User[] array = new UserImpl[3];
2195
2196 array[0] = getByEmailAddress_PrevAndNext(session, user,
2197 emailAddress, orderByComparator, true);
2198
2199 array[1] = user;
2200
2201 array[2] = getByEmailAddress_PrevAndNext(session, user,
2202 emailAddress, orderByComparator, false);
2203
2204 return array;
2205 }
2206 catch (Exception e) {
2207 throw processException(e);
2208 }
2209 finally {
2210 closeSession(session);
2211 }
2212 }
2213
2214 protected User getByEmailAddress_PrevAndNext(Session session, User user,
2215 String emailAddress, OrderByComparator orderByComparator,
2216 boolean previous) {
2217 StringBundler query = null;
2218
2219 if (orderByComparator != null) {
2220 query = new StringBundler(6 +
2221 (orderByComparator.getOrderByFields().length * 6));
2222 }
2223 else {
2224 query = new StringBundler(3);
2225 }
2226
2227 query.append(_SQL_SELECT_USER_WHERE);
2228
2229 if (emailAddress == null) {
2230 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2231 }
2232 else {
2233 if (emailAddress.equals(StringPool.BLANK)) {
2234 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2235 }
2236 else {
2237 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2238 }
2239 }
2240
2241 if (orderByComparator != null) {
2242 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2243
2244 if (orderByConditionFields.length > 0) {
2245 query.append(WHERE_AND);
2246 }
2247
2248 for (int i = 0; i < orderByConditionFields.length; i++) {
2249 query.append(_ORDER_BY_ENTITY_ALIAS);
2250 query.append(orderByConditionFields[i]);
2251
2252 if ((i + 1) < orderByConditionFields.length) {
2253 if (orderByComparator.isAscending() ^ previous) {
2254 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2255 }
2256 else {
2257 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2258 }
2259 }
2260 else {
2261 if (orderByComparator.isAscending() ^ previous) {
2262 query.append(WHERE_GREATER_THAN);
2263 }
2264 else {
2265 query.append(WHERE_LESSER_THAN);
2266 }
2267 }
2268 }
2269
2270 query.append(ORDER_BY_CLAUSE);
2271
2272 String[] orderByFields = orderByComparator.getOrderByFields();
2273
2274 for (int i = 0; i < orderByFields.length; i++) {
2275 query.append(_ORDER_BY_ENTITY_ALIAS);
2276 query.append(orderByFields[i]);
2277
2278 if ((i + 1) < orderByFields.length) {
2279 if (orderByComparator.isAscending() ^ previous) {
2280 query.append(ORDER_BY_ASC_HAS_NEXT);
2281 }
2282 else {
2283 query.append(ORDER_BY_DESC_HAS_NEXT);
2284 }
2285 }
2286 else {
2287 if (orderByComparator.isAscending() ^ previous) {
2288 query.append(ORDER_BY_ASC);
2289 }
2290 else {
2291 query.append(ORDER_BY_DESC);
2292 }
2293 }
2294 }
2295 }
2296
2297 String sql = query.toString();
2298
2299 Query q = session.createQuery(sql);
2300
2301 q.setFirstResult(0);
2302 q.setMaxResults(2);
2303
2304 QueryPos qPos = QueryPos.getInstance(q);
2305
2306 if (emailAddress != null) {
2307 qPos.add(emailAddress);
2308 }
2309
2310 if (orderByComparator != null) {
2311 Object[] values = orderByComparator.getOrderByConditionValues(user);
2312
2313 for (Object value : values) {
2314 qPos.add(value);
2315 }
2316 }
2317
2318 List<User> list = q.list();
2319
2320 if (list.size() == 2) {
2321 return list.get(1);
2322 }
2323 else {
2324 return null;
2325 }
2326 }
2327
2328
2336 public User findByPortraitId(long portraitId)
2337 throws NoSuchUserException, SystemException {
2338 User user = fetchByPortraitId(portraitId);
2339
2340 if (user == null) {
2341 StringBundler msg = new StringBundler(4);
2342
2343 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2344
2345 msg.append("portraitId=");
2346 msg.append(portraitId);
2347
2348 msg.append(StringPool.CLOSE_CURLY_BRACE);
2349
2350 if (_log.isWarnEnabled()) {
2351 _log.warn(msg.toString());
2352 }
2353
2354 throw new NoSuchUserException(msg.toString());
2355 }
2356
2357 return user;
2358 }
2359
2360
2367 public User fetchByPortraitId(long portraitId) throws SystemException {
2368 return fetchByPortraitId(portraitId, true);
2369 }
2370
2371
2379 public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
2380 throws SystemException {
2381 Object[] finderArgs = new Object[] { portraitId };
2382
2383 Object result = null;
2384
2385 if (retrieveFromCache) {
2386 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2387 finderArgs, this);
2388 }
2389
2390 if (result instanceof User) {
2391 User user = (User)result;
2392
2393 if ((portraitId != user.getPortraitId())) {
2394 result = null;
2395 }
2396 }
2397
2398 if (result == null) {
2399 StringBundler query = new StringBundler(2);
2400
2401 query.append(_SQL_SELECT_USER_WHERE);
2402
2403 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
2404
2405 String sql = query.toString();
2406
2407 Session session = null;
2408
2409 try {
2410 session = openSession();
2411
2412 Query q = session.createQuery(sql);
2413
2414 QueryPos qPos = QueryPos.getInstance(q);
2415
2416 qPos.add(portraitId);
2417
2418 List<User> list = q.list();
2419
2420 result = list;
2421
2422 User user = null;
2423
2424 if (list.isEmpty()) {
2425 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2426 finderArgs, list);
2427 }
2428 else {
2429 user = list.get(0);
2430
2431 cacheResult(user);
2432
2433 if ((user.getPortraitId() != portraitId)) {
2434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2435 finderArgs, user);
2436 }
2437 }
2438
2439 return user;
2440 }
2441 catch (Exception e) {
2442 throw processException(e);
2443 }
2444 finally {
2445 if (result == null) {
2446 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2447 finderArgs);
2448 }
2449
2450 closeSession(session);
2451 }
2452 }
2453 else {
2454 if (result instanceof List<?>) {
2455 return null;
2456 }
2457 else {
2458 return (User)result;
2459 }
2460 }
2461 }
2462
2463
2472 public User findByC_U(long companyId, long userId)
2473 throws NoSuchUserException, SystemException {
2474 User user = fetchByC_U(companyId, userId);
2475
2476 if (user == null) {
2477 StringBundler msg = new StringBundler(6);
2478
2479 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2480
2481 msg.append("companyId=");
2482 msg.append(companyId);
2483
2484 msg.append(", userId=");
2485 msg.append(userId);
2486
2487 msg.append(StringPool.CLOSE_CURLY_BRACE);
2488
2489 if (_log.isWarnEnabled()) {
2490 _log.warn(msg.toString());
2491 }
2492
2493 throw new NoSuchUserException(msg.toString());
2494 }
2495
2496 return user;
2497 }
2498
2499
2507 public User fetchByC_U(long companyId, long userId)
2508 throws SystemException {
2509 return fetchByC_U(companyId, userId, true);
2510 }
2511
2512
2521 public User fetchByC_U(long companyId, long userId,
2522 boolean retrieveFromCache) throws SystemException {
2523 Object[] finderArgs = new Object[] { companyId, userId };
2524
2525 Object result = null;
2526
2527 if (retrieveFromCache) {
2528 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
2529 finderArgs, this);
2530 }
2531
2532 if (result instanceof User) {
2533 User user = (User)result;
2534
2535 if ((companyId != user.getCompanyId()) ||
2536 (userId != user.getUserId())) {
2537 result = null;
2538 }
2539 }
2540
2541 if (result == null) {
2542 StringBundler query = new StringBundler(3);
2543
2544 query.append(_SQL_SELECT_USER_WHERE);
2545
2546 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2547
2548 query.append(_FINDER_COLUMN_C_U_USERID_2);
2549
2550 String sql = query.toString();
2551
2552 Session session = null;
2553
2554 try {
2555 session = openSession();
2556
2557 Query q = session.createQuery(sql);
2558
2559 QueryPos qPos = QueryPos.getInstance(q);
2560
2561 qPos.add(companyId);
2562
2563 qPos.add(userId);
2564
2565 List<User> list = q.list();
2566
2567 result = list;
2568
2569 User user = null;
2570
2571 if (list.isEmpty()) {
2572 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2573 finderArgs, list);
2574 }
2575 else {
2576 user = list.get(0);
2577
2578 cacheResult(user);
2579
2580 if ((user.getCompanyId() != companyId) ||
2581 (user.getUserId() != userId)) {
2582 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2583 finderArgs, user);
2584 }
2585 }
2586
2587 return user;
2588 }
2589 catch (Exception e) {
2590 throw processException(e);
2591 }
2592 finally {
2593 if (result == null) {
2594 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
2595 finderArgs);
2596 }
2597
2598 closeSession(session);
2599 }
2600 }
2601 else {
2602 if (result instanceof List<?>) {
2603 return null;
2604 }
2605 else {
2606 return (User)result;
2607 }
2608 }
2609 }
2610
2611
2620 public User findByC_DU(long companyId, boolean defaultUser)
2621 throws NoSuchUserException, SystemException {
2622 User user = fetchByC_DU(companyId, defaultUser);
2623
2624 if (user == null) {
2625 StringBundler msg = new StringBundler(6);
2626
2627 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2628
2629 msg.append("companyId=");
2630 msg.append(companyId);
2631
2632 msg.append(", defaultUser=");
2633 msg.append(defaultUser);
2634
2635 msg.append(StringPool.CLOSE_CURLY_BRACE);
2636
2637 if (_log.isWarnEnabled()) {
2638 _log.warn(msg.toString());
2639 }
2640
2641 throw new NoSuchUserException(msg.toString());
2642 }
2643
2644 return user;
2645 }
2646
2647
2655 public User fetchByC_DU(long companyId, boolean defaultUser)
2656 throws SystemException {
2657 return fetchByC_DU(companyId, defaultUser, true);
2658 }
2659
2660
2669 public User fetchByC_DU(long companyId, boolean defaultUser,
2670 boolean retrieveFromCache) throws SystemException {
2671 Object[] finderArgs = new Object[] { companyId, defaultUser };
2672
2673 Object result = null;
2674
2675 if (retrieveFromCache) {
2676 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
2677 finderArgs, this);
2678 }
2679
2680 if (result instanceof User) {
2681 User user = (User)result;
2682
2683 if ((companyId != user.getCompanyId()) ||
2684 (defaultUser != user.getDefaultUser())) {
2685 result = null;
2686 }
2687 }
2688
2689 if (result == null) {
2690 StringBundler query = new StringBundler(3);
2691
2692 query.append(_SQL_SELECT_USER_WHERE);
2693
2694 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
2695
2696 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
2697
2698 String sql = query.toString();
2699
2700 Session session = null;
2701
2702 try {
2703 session = openSession();
2704
2705 Query q = session.createQuery(sql);
2706
2707 QueryPos qPos = QueryPos.getInstance(q);
2708
2709 qPos.add(companyId);
2710
2711 qPos.add(defaultUser);
2712
2713 List<User> list = q.list();
2714
2715 result = list;
2716
2717 User user = null;
2718
2719 if (list.isEmpty()) {
2720 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
2721 finderArgs, list);
2722 }
2723 else {
2724 user = list.get(0);
2725
2726 cacheResult(user);
2727
2728 if ((user.getCompanyId() != companyId) ||
2729 (user.getDefaultUser() != defaultUser)) {
2730 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
2731 finderArgs, user);
2732 }
2733 }
2734
2735 return user;
2736 }
2737 catch (Exception e) {
2738 throw processException(e);
2739 }
2740 finally {
2741 if (result == null) {
2742 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
2743 finderArgs);
2744 }
2745
2746 closeSession(session);
2747 }
2748 }
2749 else {
2750 if (result instanceof List<?>) {
2751 return null;
2752 }
2753 else {
2754 return (User)result;
2755 }
2756 }
2757 }
2758
2759
2768 public User findByC_SN(long companyId, String screenName)
2769 throws NoSuchUserException, SystemException {
2770 User user = fetchByC_SN(companyId, screenName);
2771
2772 if (user == null) {
2773 StringBundler msg = new StringBundler(6);
2774
2775 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2776
2777 msg.append("companyId=");
2778 msg.append(companyId);
2779
2780 msg.append(", screenName=");
2781 msg.append(screenName);
2782
2783 msg.append(StringPool.CLOSE_CURLY_BRACE);
2784
2785 if (_log.isWarnEnabled()) {
2786 _log.warn(msg.toString());
2787 }
2788
2789 throw new NoSuchUserException(msg.toString());
2790 }
2791
2792 return user;
2793 }
2794
2795
2803 public User fetchByC_SN(long companyId, String screenName)
2804 throws SystemException {
2805 return fetchByC_SN(companyId, screenName, true);
2806 }
2807
2808
2817 public User fetchByC_SN(long companyId, String screenName,
2818 boolean retrieveFromCache) throws SystemException {
2819 Object[] finderArgs = new Object[] { companyId, screenName };
2820
2821 Object result = null;
2822
2823 if (retrieveFromCache) {
2824 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
2825 finderArgs, this);
2826 }
2827
2828 if (result instanceof User) {
2829 User user = (User)result;
2830
2831 if ((companyId != user.getCompanyId()) ||
2832 !Validator.equals(screenName, user.getScreenName())) {
2833 result = null;
2834 }
2835 }
2836
2837 if (result == null) {
2838 StringBundler query = new StringBundler(3);
2839
2840 query.append(_SQL_SELECT_USER_WHERE);
2841
2842 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
2843
2844 if (screenName == null) {
2845 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
2846 }
2847 else {
2848 if (screenName.equals(StringPool.BLANK)) {
2849 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
2850 }
2851 else {
2852 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
2853 }
2854 }
2855
2856 String sql = query.toString();
2857
2858 Session session = null;
2859
2860 try {
2861 session = openSession();
2862
2863 Query q = session.createQuery(sql);
2864
2865 QueryPos qPos = QueryPos.getInstance(q);
2866
2867 qPos.add(companyId);
2868
2869 if (screenName != null) {
2870 qPos.add(screenName);
2871 }
2872
2873 List<User> list = q.list();
2874
2875 result = list;
2876
2877 User user = null;
2878
2879 if (list.isEmpty()) {
2880 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2881 finderArgs, list);
2882 }
2883 else {
2884 user = list.get(0);
2885
2886 cacheResult(user);
2887
2888 if ((user.getCompanyId() != companyId) ||
2889 (user.getScreenName() == null) ||
2890 !user.getScreenName().equals(screenName)) {
2891 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2892 finderArgs, user);
2893 }
2894 }
2895
2896 return user;
2897 }
2898 catch (Exception e) {
2899 throw processException(e);
2900 }
2901 finally {
2902 if (result == null) {
2903 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
2904 finderArgs);
2905 }
2906
2907 closeSession(session);
2908 }
2909 }
2910 else {
2911 if (result instanceof List<?>) {
2912 return null;
2913 }
2914 else {
2915 return (User)result;
2916 }
2917 }
2918 }
2919
2920
2929 public User findByC_EA(long companyId, String emailAddress)
2930 throws NoSuchUserException, SystemException {
2931 User user = fetchByC_EA(companyId, emailAddress);
2932
2933 if (user == null) {
2934 StringBundler msg = new StringBundler(6);
2935
2936 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2937
2938 msg.append("companyId=");
2939 msg.append(companyId);
2940
2941 msg.append(", emailAddress=");
2942 msg.append(emailAddress);
2943
2944 msg.append(StringPool.CLOSE_CURLY_BRACE);
2945
2946 if (_log.isWarnEnabled()) {
2947 _log.warn(msg.toString());
2948 }
2949
2950 throw new NoSuchUserException(msg.toString());
2951 }
2952
2953 return user;
2954 }
2955
2956
2964 public User fetchByC_EA(long companyId, String emailAddress)
2965 throws SystemException {
2966 return fetchByC_EA(companyId, emailAddress, true);
2967 }
2968
2969
2978 public User fetchByC_EA(long companyId, String emailAddress,
2979 boolean retrieveFromCache) throws SystemException {
2980 Object[] finderArgs = new Object[] { companyId, emailAddress };
2981
2982 Object result = null;
2983
2984 if (retrieveFromCache) {
2985 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
2986 finderArgs, this);
2987 }
2988
2989 if (result instanceof User) {
2990 User user = (User)result;
2991
2992 if ((companyId != user.getCompanyId()) ||
2993 !Validator.equals(emailAddress, user.getEmailAddress())) {
2994 result = null;
2995 }
2996 }
2997
2998 if (result == null) {
2999 StringBundler query = new StringBundler(3);
3000
3001 query.append(_SQL_SELECT_USER_WHERE);
3002
3003 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
3004
3005 if (emailAddress == null) {
3006 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
3007 }
3008 else {
3009 if (emailAddress.equals(StringPool.BLANK)) {
3010 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
3011 }
3012 else {
3013 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
3014 }
3015 }
3016
3017 String sql = query.toString();
3018
3019 Session session = null;
3020
3021 try {
3022 session = openSession();
3023
3024 Query q = session.createQuery(sql);
3025
3026 QueryPos qPos = QueryPos.getInstance(q);
3027
3028 qPos.add(companyId);
3029
3030 if (emailAddress != null) {
3031 qPos.add(emailAddress);
3032 }
3033
3034 List<User> list = q.list();
3035
3036 result = list;
3037
3038 User user = null;
3039
3040 if (list.isEmpty()) {
3041 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
3042 finderArgs, list);
3043 }
3044 else {
3045 user = list.get(0);
3046
3047 cacheResult(user);
3048
3049 if ((user.getCompanyId() != companyId) ||
3050 (user.getEmailAddress() == null) ||
3051 !user.getEmailAddress().equals(emailAddress)) {
3052 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
3053 finderArgs, user);
3054 }
3055 }
3056
3057 return user;
3058 }
3059 catch (Exception e) {
3060 throw processException(e);
3061 }
3062 finally {
3063 if (result == null) {
3064 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
3065 finderArgs);
3066 }
3067
3068 closeSession(session);
3069 }
3070 }
3071 else {
3072 if (result instanceof List<?>) {
3073 return null;
3074 }
3075 else {
3076 return (User)result;
3077 }
3078 }
3079 }
3080
3081
3090 public User findByC_FID(long companyId, long facebookId)
3091 throws NoSuchUserException, SystemException {
3092 User user = fetchByC_FID(companyId, facebookId);
3093
3094 if (user == null) {
3095 StringBundler msg = new StringBundler(6);
3096
3097 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3098
3099 msg.append("companyId=");
3100 msg.append(companyId);
3101
3102 msg.append(", facebookId=");
3103 msg.append(facebookId);
3104
3105 msg.append(StringPool.CLOSE_CURLY_BRACE);
3106
3107 if (_log.isWarnEnabled()) {
3108 _log.warn(msg.toString());
3109 }
3110
3111 throw new NoSuchUserException(msg.toString());
3112 }
3113
3114 return user;
3115 }
3116
3117
3125 public User fetchByC_FID(long companyId, long facebookId)
3126 throws SystemException {
3127 return fetchByC_FID(companyId, facebookId, true);
3128 }
3129
3130
3139 public User fetchByC_FID(long companyId, long facebookId,
3140 boolean retrieveFromCache) throws SystemException {
3141 Object[] finderArgs = new Object[] { companyId, facebookId };
3142
3143 Object result = null;
3144
3145 if (retrieveFromCache) {
3146 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_FID,
3147 finderArgs, this);
3148 }
3149
3150 if (result instanceof User) {
3151 User user = (User)result;
3152
3153 if ((companyId != user.getCompanyId()) ||
3154 (facebookId != user.getFacebookId())) {
3155 result = null;
3156 }
3157 }
3158
3159 if (result == null) {
3160 StringBundler query = new StringBundler(3);
3161
3162 query.append(_SQL_SELECT_USER_WHERE);
3163
3164 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
3165
3166 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
3167
3168 String sql = query.toString();
3169
3170 Session session = null;
3171
3172 try {
3173 session = openSession();
3174
3175 Query q = session.createQuery(sql);
3176
3177 QueryPos qPos = QueryPos.getInstance(q);
3178
3179 qPos.add(companyId);
3180
3181 qPos.add(facebookId);
3182
3183 List<User> list = q.list();
3184
3185 result = list;
3186
3187 User user = null;
3188
3189 if (list.isEmpty()) {
3190 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
3191 finderArgs, list);
3192 }
3193 else {
3194 user = list.get(0);
3195
3196 cacheResult(user);
3197
3198 if ((user.getCompanyId() != companyId) ||
3199 (user.getFacebookId() != facebookId)) {
3200 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
3201 finderArgs, user);
3202 }
3203 }
3204
3205 return user;
3206 }
3207 catch (Exception e) {
3208 throw processException(e);
3209 }
3210 finally {
3211 if (result == null) {
3212 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID,
3213 finderArgs);
3214 }
3215
3216 closeSession(session);
3217 }
3218 }
3219 else {
3220 if (result instanceof List<?>) {
3221 return null;
3222 }
3223 else {
3224 return (User)result;
3225 }
3226 }
3227 }
3228
3229
3238 public User findByC_O(long companyId, String openId)
3239 throws NoSuchUserException, SystemException {
3240 User user = fetchByC_O(companyId, openId);
3241
3242 if (user == null) {
3243 StringBundler msg = new StringBundler(6);
3244
3245 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3246
3247 msg.append("companyId=");
3248 msg.append(companyId);
3249
3250 msg.append(", openId=");
3251 msg.append(openId);
3252
3253 msg.append(StringPool.CLOSE_CURLY_BRACE);
3254
3255 if (_log.isWarnEnabled()) {
3256 _log.warn(msg.toString());
3257 }
3258
3259 throw new NoSuchUserException(msg.toString());
3260 }
3261
3262 return user;
3263 }
3264
3265
3273 public User fetchByC_O(long companyId, String openId)
3274 throws SystemException {
3275 return fetchByC_O(companyId, openId, true);
3276 }
3277
3278
3287 public User fetchByC_O(long companyId, String openId,
3288 boolean retrieveFromCache) throws SystemException {
3289 Object[] finderArgs = new Object[] { companyId, openId };
3290
3291 Object result = null;
3292
3293 if (retrieveFromCache) {
3294 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_O,
3295 finderArgs, this);
3296 }
3297
3298 if (result instanceof User) {
3299 User user = (User)result;
3300
3301 if ((companyId != user.getCompanyId()) ||
3302 !Validator.equals(openId, user.getOpenId())) {
3303 result = null;
3304 }
3305 }
3306
3307 if (result == null) {
3308 StringBundler query = new StringBundler(3);
3309
3310 query.append(_SQL_SELECT_USER_WHERE);
3311
3312 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
3313
3314 if (openId == null) {
3315 query.append(_FINDER_COLUMN_C_O_OPENID_1);
3316 }
3317 else {
3318 if (openId.equals(StringPool.BLANK)) {
3319 query.append(_FINDER_COLUMN_C_O_OPENID_3);
3320 }
3321 else {
3322 query.append(_FINDER_COLUMN_C_O_OPENID_2);
3323 }
3324 }
3325
3326 String sql = query.toString();
3327
3328 Session session = null;
3329
3330 try {
3331 session = openSession();
3332
3333 Query q = session.createQuery(sql);
3334
3335 QueryPos qPos = QueryPos.getInstance(q);
3336
3337 qPos.add(companyId);
3338
3339 if (openId != null) {
3340 qPos.add(openId);
3341 }
3342
3343 List<User> list = q.list();
3344
3345 result = list;
3346
3347 User user = null;
3348
3349 if (list.isEmpty()) {
3350 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
3351 finderArgs, list);
3352 }
3353 else {
3354 user = list.get(0);
3355
3356 cacheResult(user);
3357
3358 if ((user.getCompanyId() != companyId) ||
3359 (user.getOpenId() == null) ||
3360 !user.getOpenId().equals(openId)) {
3361 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
3362 finderArgs, user);
3363 }
3364 }
3365
3366 return user;
3367 }
3368 catch (Exception e) {
3369 throw processException(e);
3370 }
3371 finally {
3372 if (result == null) {
3373 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O,
3374 finderArgs);
3375 }
3376
3377 closeSession(session);
3378 }
3379 }
3380 else {
3381 if (result instanceof List<?>) {
3382 return null;
3383 }
3384 else {
3385 return (User)result;
3386 }
3387 }
3388 }
3389
3390
3398 public List<User> findByC_S(long companyId, int status)
3399 throws SystemException {
3400 return findByC_S(companyId, status, QueryUtil.ALL_POS,
3401 QueryUtil.ALL_POS, null);
3402 }
3403
3404
3418 public List<User> findByC_S(long companyId, int status, int start, int end)
3419 throws SystemException {
3420 return findByC_S(companyId, status, start, end, null);
3421 }
3422
3423
3438 public List<User> findByC_S(long companyId, int status, int start, int end,
3439 OrderByComparator orderByComparator) throws SystemException {
3440 FinderPath finderPath = null;
3441 Object[] finderArgs = null;
3442
3443 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3444 (orderByComparator == null)) {
3445 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3446 finderArgs = new Object[] { companyId, status };
3447 }
3448 else {
3449 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3450 finderArgs = new Object[] {
3451 companyId, status,
3452
3453 start, end, orderByComparator
3454 };
3455 }
3456
3457 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
3458 finderArgs, this);
3459
3460 if ((list != null) && !list.isEmpty()) {
3461 for (User user : list) {
3462 if ((companyId != user.getCompanyId()) ||
3463 (status != user.getStatus())) {
3464 list = null;
3465
3466 break;
3467 }
3468 }
3469 }
3470
3471 if (list == null) {
3472 StringBundler query = null;
3473
3474 if (orderByComparator != null) {
3475 query = new StringBundler(4 +
3476 (orderByComparator.getOrderByFields().length * 3));
3477 }
3478 else {
3479 query = new StringBundler(3);
3480 }
3481
3482 query.append(_SQL_SELECT_USER_WHERE);
3483
3484 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3485
3486 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3487
3488 if (orderByComparator != null) {
3489 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3490 orderByComparator);
3491 }
3492
3493 String sql = query.toString();
3494
3495 Session session = null;
3496
3497 try {
3498 session = openSession();
3499
3500 Query q = session.createQuery(sql);
3501
3502 QueryPos qPos = QueryPos.getInstance(q);
3503
3504 qPos.add(companyId);
3505
3506 qPos.add(status);
3507
3508 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
3509 }
3510 catch (Exception e) {
3511 throw processException(e);
3512 }
3513 finally {
3514 if (list == null) {
3515 FinderCacheUtil.removeResult(finderPath, finderArgs);
3516 }
3517 else {
3518 cacheResult(list);
3519
3520 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3521 }
3522
3523 closeSession(session);
3524 }
3525 }
3526
3527 return list;
3528 }
3529
3530
3540 public User findByC_S_First(long companyId, int status,
3541 OrderByComparator orderByComparator)
3542 throws NoSuchUserException, SystemException {
3543 User user = fetchByC_S_First(companyId, status, orderByComparator);
3544
3545 if (user != null) {
3546 return user;
3547 }
3548
3549 StringBundler msg = new StringBundler(6);
3550
3551 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3552
3553 msg.append("companyId=");
3554 msg.append(companyId);
3555
3556 msg.append(", status=");
3557 msg.append(status);
3558
3559 msg.append(StringPool.CLOSE_CURLY_BRACE);
3560
3561 throw new NoSuchUserException(msg.toString());
3562 }
3563
3564
3573 public User fetchByC_S_First(long companyId, int status,
3574 OrderByComparator orderByComparator) throws SystemException {
3575 List<User> list = findByC_S(companyId, status, 0, 1, orderByComparator);
3576
3577 if (!list.isEmpty()) {
3578 return list.get(0);
3579 }
3580
3581 return null;
3582 }
3583
3584
3594 public User findByC_S_Last(long companyId, int status,
3595 OrderByComparator orderByComparator)
3596 throws NoSuchUserException, SystemException {
3597 User user = fetchByC_S_Last(companyId, status, orderByComparator);
3598
3599 if (user != null) {
3600 return user;
3601 }
3602
3603 StringBundler msg = new StringBundler(6);
3604
3605 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3606
3607 msg.append("companyId=");
3608 msg.append(companyId);
3609
3610 msg.append(", status=");
3611 msg.append(status);
3612
3613 msg.append(StringPool.CLOSE_CURLY_BRACE);
3614
3615 throw new NoSuchUserException(msg.toString());
3616 }
3617
3618
3627 public User fetchByC_S_Last(long companyId, int status,
3628 OrderByComparator orderByComparator) throws SystemException {
3629 int count = countByC_S(companyId, status);
3630
3631 List<User> list = findByC_S(companyId, status, count - 1, count,
3632 orderByComparator);
3633
3634 if (!list.isEmpty()) {
3635 return list.get(0);
3636 }
3637
3638 return null;
3639 }
3640
3641
3652 public User[] findByC_S_PrevAndNext(long userId, long companyId,
3653 int status, OrderByComparator orderByComparator)
3654 throws NoSuchUserException, SystemException {
3655 User user = findByPrimaryKey(userId);
3656
3657 Session session = null;
3658
3659 try {
3660 session = openSession();
3661
3662 User[] array = new UserImpl[3];
3663
3664 array[0] = getByC_S_PrevAndNext(session, user, companyId, status,
3665 orderByComparator, true);
3666
3667 array[1] = user;
3668
3669 array[2] = getByC_S_PrevAndNext(session, user, companyId, status,
3670 orderByComparator, false);
3671
3672 return array;
3673 }
3674 catch (Exception e) {
3675 throw processException(e);
3676 }
3677 finally {
3678 closeSession(session);
3679 }
3680 }
3681
3682 protected User getByC_S_PrevAndNext(Session session, User user,
3683 long companyId, int status, OrderByComparator orderByComparator,
3684 boolean previous) {
3685 StringBundler query = null;
3686
3687 if (orderByComparator != null) {
3688 query = new StringBundler(6 +
3689 (orderByComparator.getOrderByFields().length * 6));
3690 }
3691 else {
3692 query = new StringBundler(3);
3693 }
3694
3695 query.append(_SQL_SELECT_USER_WHERE);
3696
3697 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3698
3699 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3700
3701 if (orderByComparator != null) {
3702 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3703
3704 if (orderByConditionFields.length > 0) {
3705 query.append(WHERE_AND);
3706 }
3707
3708 for (int i = 0; i < orderByConditionFields.length; i++) {
3709 query.append(_ORDER_BY_ENTITY_ALIAS);
3710 query.append(orderByConditionFields[i]);
3711
3712 if ((i + 1) < orderByConditionFields.length) {
3713 if (orderByComparator.isAscending() ^ previous) {
3714 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3715 }
3716 else {
3717 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3718 }
3719 }
3720 else {
3721 if (orderByComparator.isAscending() ^ previous) {
3722 query.append(WHERE_GREATER_THAN);
3723 }
3724 else {
3725 query.append(WHERE_LESSER_THAN);
3726 }
3727 }
3728 }
3729
3730 query.append(ORDER_BY_CLAUSE);
3731
3732 String[] orderByFields = orderByComparator.getOrderByFields();
3733
3734 for (int i = 0; i < orderByFields.length; i++) {
3735 query.append(_ORDER_BY_ENTITY_ALIAS);
3736 query.append(orderByFields[i]);
3737
3738 if ((i + 1) < orderByFields.length) {
3739 if (orderByComparator.isAscending() ^ previous) {
3740 query.append(ORDER_BY_ASC_HAS_NEXT);
3741 }
3742 else {
3743 query.append(ORDER_BY_DESC_HAS_NEXT);
3744 }
3745 }
3746 else {
3747 if (orderByComparator.isAscending() ^ previous) {
3748 query.append(ORDER_BY_ASC);
3749 }
3750 else {
3751 query.append(ORDER_BY_DESC);
3752 }
3753 }
3754 }
3755 }
3756
3757 String sql = query.toString();
3758
3759 Query q = session.createQuery(sql);
3760
3761 q.setFirstResult(0);
3762 q.setMaxResults(2);
3763
3764 QueryPos qPos = QueryPos.getInstance(q);
3765
3766 qPos.add(companyId);
3767
3768 qPos.add(status);
3769
3770 if (orderByComparator != null) {
3771 Object[] values = orderByComparator.getOrderByConditionValues(user);
3772
3773 for (Object value : values) {
3774 qPos.add(value);
3775 }
3776 }
3777
3778 List<User> list = q.list();
3779
3780 if (list.size() == 2) {
3781 return list.get(1);
3782 }
3783 else {
3784 return null;
3785 }
3786 }
3787
3788
3794 public List<User> findAll() throws SystemException {
3795 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3796 }
3797
3798
3810 public List<User> findAll(int start, int end) throws SystemException {
3811 return findAll(start, end, null);
3812 }
3813
3814
3827 public List<User> findAll(int start, int end,
3828 OrderByComparator orderByComparator) throws SystemException {
3829 FinderPath finderPath = null;
3830 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3831
3832 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3833 (orderByComparator == null)) {
3834 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3835 finderArgs = FINDER_ARGS_EMPTY;
3836 }
3837 else {
3838 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3839 finderArgs = new Object[] { start, end, orderByComparator };
3840 }
3841
3842 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
3843 finderArgs, this);
3844
3845 if (list == null) {
3846 StringBundler query = null;
3847 String sql = null;
3848
3849 if (orderByComparator != null) {
3850 query = new StringBundler(2 +
3851 (orderByComparator.getOrderByFields().length * 3));
3852
3853 query.append(_SQL_SELECT_USER);
3854
3855 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3856 orderByComparator);
3857
3858 sql = query.toString();
3859 }
3860 else {
3861 sql = _SQL_SELECT_USER;
3862 }
3863
3864 Session session = null;
3865
3866 try {
3867 session = openSession();
3868
3869 Query q = session.createQuery(sql);
3870
3871 if (orderByComparator == null) {
3872 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3873 end, false);
3874
3875 Collections.sort(list);
3876 }
3877 else {
3878 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3879 end);
3880 }
3881 }
3882 catch (Exception e) {
3883 throw processException(e);
3884 }
3885 finally {
3886 if (list == null) {
3887 FinderCacheUtil.removeResult(finderPath, finderArgs);
3888 }
3889 else {
3890 cacheResult(list);
3891
3892 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3893 }
3894
3895 closeSession(session);
3896 }
3897 }
3898
3899 return list;
3900 }
3901
3902
3908 public void removeByUuid(String uuid) throws SystemException {
3909 for (User user : findByUuid(uuid)) {
3910 remove(user);
3911 }
3912 }
3913
3914
3920 public void removeByCompanyId(long companyId) throws SystemException {
3921 for (User user : findByCompanyId(companyId)) {
3922 remove(user);
3923 }
3924 }
3925
3926
3933 public User removeByContactId(long contactId)
3934 throws NoSuchUserException, SystemException {
3935 User user = findByContactId(contactId);
3936
3937 return remove(user);
3938 }
3939
3940
3946 public void removeByEmailAddress(String emailAddress)
3947 throws SystemException {
3948 for (User user : findByEmailAddress(emailAddress)) {
3949 remove(user);
3950 }
3951 }
3952
3953
3960 public User removeByPortraitId(long portraitId)
3961 throws NoSuchUserException, SystemException {
3962 User user = findByPortraitId(portraitId);
3963
3964 return remove(user);
3965 }
3966
3967
3975 public User removeByC_U(long companyId, long userId)
3976 throws NoSuchUserException, SystemException {
3977 User user = findByC_U(companyId, userId);
3978
3979 return remove(user);
3980 }
3981
3982
3990 public User removeByC_DU(long companyId, boolean defaultUser)
3991 throws NoSuchUserException, SystemException {
3992 User user = findByC_DU(companyId, defaultUser);
3993
3994 return remove(user);
3995 }
3996
3997
4005 public User removeByC_SN(long companyId, String screenName)
4006 throws NoSuchUserException, SystemException {
4007 User user = findByC_SN(companyId, screenName);
4008
4009 return remove(user);
4010 }
4011
4012
4020 public User removeByC_EA(long companyId, String emailAddress)
4021 throws NoSuchUserException, SystemException {
4022 User user = findByC_EA(companyId, emailAddress);
4023
4024 return remove(user);
4025 }
4026
4027
4035 public User removeByC_FID(long companyId, long facebookId)
4036 throws NoSuchUserException, SystemException {
4037 User user = findByC_FID(companyId, facebookId);
4038
4039 return remove(user);
4040 }
4041
4042
4050 public User removeByC_O(long companyId, String openId)
4051 throws NoSuchUserException, SystemException {
4052 User user = findByC_O(companyId, openId);
4053
4054 return remove(user);
4055 }
4056
4057
4064 public void removeByC_S(long companyId, int status)
4065 throws SystemException {
4066 for (User user : findByC_S(companyId, status)) {
4067 remove(user);
4068 }
4069 }
4070
4071
4076 public void removeAll() throws SystemException {
4077 for (User user : findAll()) {
4078 remove(user);
4079 }
4080 }
4081
4082
4089 public int countByUuid(String uuid) throws SystemException {
4090 Object[] finderArgs = new Object[] { uuid };
4091
4092 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4093 finderArgs, this);
4094
4095 if (count == null) {
4096 StringBundler query = new StringBundler(2);
4097
4098 query.append(_SQL_COUNT_USER_WHERE);
4099
4100 if (uuid == null) {
4101 query.append(_FINDER_COLUMN_UUID_UUID_1);
4102 }
4103 else {
4104 if (uuid.equals(StringPool.BLANK)) {
4105 query.append(_FINDER_COLUMN_UUID_UUID_3);
4106 }
4107 else {
4108 query.append(_FINDER_COLUMN_UUID_UUID_2);
4109 }
4110 }
4111
4112 String sql = query.toString();
4113
4114 Session session = null;
4115
4116 try {
4117 session = openSession();
4118
4119 Query q = session.createQuery(sql);
4120
4121 QueryPos qPos = QueryPos.getInstance(q);
4122
4123 if (uuid != null) {
4124 qPos.add(uuid);
4125 }
4126
4127 count = (Long)q.uniqueResult();
4128 }
4129 catch (Exception e) {
4130 throw processException(e);
4131 }
4132 finally {
4133 if (count == null) {
4134 count = Long.valueOf(0);
4135 }
4136
4137 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4138 finderArgs, count);
4139
4140 closeSession(session);
4141 }
4142 }
4143
4144 return count.intValue();
4145 }
4146
4147
4154 public int countByCompanyId(long companyId) throws SystemException {
4155 Object[] finderArgs = new Object[] { companyId };
4156
4157 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
4158 finderArgs, this);
4159
4160 if (count == null) {
4161 StringBundler query = new StringBundler(2);
4162
4163 query.append(_SQL_COUNT_USER_WHERE);
4164
4165 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
4166
4167 String sql = query.toString();
4168
4169 Session session = null;
4170
4171 try {
4172 session = openSession();
4173
4174 Query q = session.createQuery(sql);
4175
4176 QueryPos qPos = QueryPos.getInstance(q);
4177
4178 qPos.add(companyId);
4179
4180 count = (Long)q.uniqueResult();
4181 }
4182 catch (Exception e) {
4183 throw processException(e);
4184 }
4185 finally {
4186 if (count == null) {
4187 count = Long.valueOf(0);
4188 }
4189
4190 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
4191 finderArgs, count);
4192
4193 closeSession(session);
4194 }
4195 }
4196
4197 return count.intValue();
4198 }
4199
4200
4207 public int countByContactId(long contactId) throws SystemException {
4208 Object[] finderArgs = new Object[] { contactId };
4209
4210 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CONTACTID,
4211 finderArgs, this);
4212
4213 if (count == null) {
4214 StringBundler query = new StringBundler(2);
4215
4216 query.append(_SQL_COUNT_USER_WHERE);
4217
4218 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
4219
4220 String sql = query.toString();
4221
4222 Session session = null;
4223
4224 try {
4225 session = openSession();
4226
4227 Query q = session.createQuery(sql);
4228
4229 QueryPos qPos = QueryPos.getInstance(q);
4230
4231 qPos.add(contactId);
4232
4233 count = (Long)q.uniqueResult();
4234 }
4235 catch (Exception e) {
4236 throw processException(e);
4237 }
4238 finally {
4239 if (count == null) {
4240 count = Long.valueOf(0);
4241 }
4242
4243 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID,
4244 finderArgs, count);
4245
4246 closeSession(session);
4247 }
4248 }
4249
4250 return count.intValue();
4251 }
4252
4253
4260 public int countByEmailAddress(String emailAddress)
4261 throws SystemException {
4262 Object[] finderArgs = new Object[] { emailAddress };
4263
4264 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
4265 finderArgs, this);
4266
4267 if (count == null) {
4268 StringBundler query = new StringBundler(2);
4269
4270 query.append(_SQL_COUNT_USER_WHERE);
4271
4272 if (emailAddress == null) {
4273 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
4274 }
4275 else {
4276 if (emailAddress.equals(StringPool.BLANK)) {
4277 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
4278 }
4279 else {
4280 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
4281 }
4282 }
4283
4284 String sql = query.toString();
4285
4286 Session session = null;
4287
4288 try {
4289 session = openSession();
4290
4291 Query q = session.createQuery(sql);
4292
4293 QueryPos qPos = QueryPos.getInstance(q);
4294
4295 if (emailAddress != null) {
4296 qPos.add(emailAddress);
4297 }
4298
4299 count = (Long)q.uniqueResult();
4300 }
4301 catch (Exception e) {
4302 throw processException(e);
4303 }
4304 finally {
4305 if (count == null) {
4306 count = Long.valueOf(0);
4307 }
4308
4309 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
4310 finderArgs, count);
4311
4312 closeSession(session);
4313 }
4314 }
4315
4316 return count.intValue();
4317 }
4318
4319
4326 public int countByPortraitId(long portraitId) throws SystemException {
4327 Object[] finderArgs = new Object[] { portraitId };
4328
4329 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTRAITID,
4330 finderArgs, this);
4331
4332 if (count == null) {
4333 StringBundler query = new StringBundler(2);
4334
4335 query.append(_SQL_COUNT_USER_WHERE);
4336
4337 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
4338
4339 String sql = query.toString();
4340
4341 Session session = null;
4342
4343 try {
4344 session = openSession();
4345
4346 Query q = session.createQuery(sql);
4347
4348 QueryPos qPos = QueryPos.getInstance(q);
4349
4350 qPos.add(portraitId);
4351
4352 count = (Long)q.uniqueResult();
4353 }
4354 catch (Exception e) {
4355 throw processException(e);
4356 }
4357 finally {
4358 if (count == null) {
4359 count = Long.valueOf(0);
4360 }
4361
4362 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_PORTRAITID,
4363 finderArgs, count);
4364
4365 closeSession(session);
4366 }
4367 }
4368
4369 return count.intValue();
4370 }
4371
4372
4380 public int countByC_U(long companyId, long userId)
4381 throws SystemException {
4382 Object[] finderArgs = new Object[] { companyId, userId };
4383
4384 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
4385 finderArgs, this);
4386
4387 if (count == null) {
4388 StringBundler query = new StringBundler(3);
4389
4390 query.append(_SQL_COUNT_USER_WHERE);
4391
4392 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
4393
4394 query.append(_FINDER_COLUMN_C_U_USERID_2);
4395
4396 String sql = query.toString();
4397
4398 Session session = null;
4399
4400 try {
4401 session = openSession();
4402
4403 Query q = session.createQuery(sql);
4404
4405 QueryPos qPos = QueryPos.getInstance(q);
4406
4407 qPos.add(companyId);
4408
4409 qPos.add(userId);
4410
4411 count = (Long)q.uniqueResult();
4412 }
4413 catch (Exception e) {
4414 throw processException(e);
4415 }
4416 finally {
4417 if (count == null) {
4418 count = Long.valueOf(0);
4419 }
4420
4421 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
4422 count);
4423
4424 closeSession(session);
4425 }
4426 }
4427
4428 return count.intValue();
4429 }
4430
4431
4439 public int countByC_DU(long companyId, boolean defaultUser)
4440 throws SystemException {
4441 Object[] finderArgs = new Object[] { companyId, defaultUser };
4442
4443 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DU,
4444 finderArgs, this);
4445
4446 if (count == null) {
4447 StringBundler query = new StringBundler(3);
4448
4449 query.append(_SQL_COUNT_USER_WHERE);
4450
4451 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
4452
4453 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
4454
4455 String sql = query.toString();
4456
4457 Session session = null;
4458
4459 try {
4460 session = openSession();
4461
4462 Query q = session.createQuery(sql);
4463
4464 QueryPos qPos = QueryPos.getInstance(q);
4465
4466 qPos.add(companyId);
4467
4468 qPos.add(defaultUser);
4469
4470 count = (Long)q.uniqueResult();
4471 }
4472 catch (Exception e) {
4473 throw processException(e);
4474 }
4475 finally {
4476 if (count == null) {
4477 count = Long.valueOf(0);
4478 }
4479
4480 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU,
4481 finderArgs, count);
4482
4483 closeSession(session);
4484 }
4485 }
4486
4487 return count.intValue();
4488 }
4489
4490
4498 public int countByC_SN(long companyId, String screenName)
4499 throws SystemException {
4500 Object[] finderArgs = new Object[] { companyId, screenName };
4501
4502 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_SN,
4503 finderArgs, this);
4504
4505 if (count == null) {
4506 StringBundler query = new StringBundler(3);
4507
4508 query.append(_SQL_COUNT_USER_WHERE);
4509
4510 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
4511
4512 if (screenName == null) {
4513 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
4514 }
4515 else {
4516 if (screenName.equals(StringPool.BLANK)) {
4517 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
4518 }
4519 else {
4520 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
4521 }
4522 }
4523
4524 String sql = query.toString();
4525
4526 Session session = null;
4527
4528 try {
4529 session = openSession();
4530
4531 Query q = session.createQuery(sql);
4532
4533 QueryPos qPos = QueryPos.getInstance(q);
4534
4535 qPos.add(companyId);
4536
4537 if (screenName != null) {
4538 qPos.add(screenName);
4539 }
4540
4541 count = (Long)q.uniqueResult();
4542 }
4543 catch (Exception e) {
4544 throw processException(e);
4545 }
4546 finally {
4547 if (count == null) {
4548 count = Long.valueOf(0);
4549 }
4550
4551 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN,
4552 finderArgs, count);
4553
4554 closeSession(session);
4555 }
4556 }
4557
4558 return count.intValue();
4559 }
4560
4561
4569 public int countByC_EA(long companyId, String emailAddress)
4570 throws SystemException {
4571 Object[] finderArgs = new Object[] { companyId, emailAddress };
4572
4573 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_EA,
4574 finderArgs, this);
4575
4576 if (count == null) {
4577 StringBundler query = new StringBundler(3);
4578
4579 query.append(_SQL_COUNT_USER_WHERE);
4580
4581 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
4582
4583 if (emailAddress == null) {
4584 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
4585 }
4586 else {
4587 if (emailAddress.equals(StringPool.BLANK)) {
4588 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
4589 }
4590 else {
4591 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
4592 }
4593 }
4594
4595 String sql = query.toString();
4596
4597 Session session = null;
4598
4599 try {
4600 session = openSession();
4601
4602 Query q = session.createQuery(sql);
4603
4604 QueryPos qPos = QueryPos.getInstance(q);
4605
4606 qPos.add(companyId);
4607
4608 if (emailAddress != null) {
4609 qPos.add(emailAddress);
4610 }
4611
4612 count = (Long)q.uniqueResult();
4613 }
4614 catch (Exception e) {
4615 throw processException(e);
4616 }
4617 finally {
4618 if (count == null) {
4619 count = Long.valueOf(0);
4620 }
4621
4622 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA,
4623 finderArgs, count);
4624
4625 closeSession(session);
4626 }
4627 }
4628
4629 return count.intValue();
4630 }
4631
4632
4640 public int countByC_FID(long companyId, long facebookId)
4641 throws SystemException {
4642 Object[] finderArgs = new Object[] { companyId, facebookId };
4643
4644 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_FID,
4645 finderArgs, this);
4646
4647 if (count == null) {
4648 StringBundler query = new StringBundler(3);
4649
4650 query.append(_SQL_COUNT_USER_WHERE);
4651
4652 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
4653
4654 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
4655
4656 String sql = query.toString();
4657
4658 Session session = null;
4659
4660 try {
4661 session = openSession();
4662
4663 Query q = session.createQuery(sql);
4664
4665 QueryPos qPos = QueryPos.getInstance(q);
4666
4667 qPos.add(companyId);
4668
4669 qPos.add(facebookId);
4670
4671 count = (Long)q.uniqueResult();
4672 }
4673 catch (Exception e) {
4674 throw processException(e);
4675 }
4676 finally {
4677 if (count == null) {
4678 count = Long.valueOf(0);
4679 }
4680
4681 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_FID,
4682 finderArgs, count);
4683
4684 closeSession(session);
4685 }
4686 }
4687
4688 return count.intValue();
4689 }
4690
4691
4699 public int countByC_O(long companyId, String openId)
4700 throws SystemException {
4701 Object[] finderArgs = new Object[] { companyId, openId };
4702
4703 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_O,
4704 finderArgs, this);
4705
4706 if (count == null) {
4707 StringBundler query = new StringBundler(3);
4708
4709 query.append(_SQL_COUNT_USER_WHERE);
4710
4711 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
4712
4713 if (openId == null) {
4714 query.append(_FINDER_COLUMN_C_O_OPENID_1);
4715 }
4716 else {
4717 if (openId.equals(StringPool.BLANK)) {
4718 query.append(_FINDER_COLUMN_C_O_OPENID_3);
4719 }
4720 else {
4721 query.append(_FINDER_COLUMN_C_O_OPENID_2);
4722 }
4723 }
4724
4725 String sql = query.toString();
4726
4727 Session session = null;
4728
4729 try {
4730 session = openSession();
4731
4732 Query q = session.createQuery(sql);
4733
4734 QueryPos qPos = QueryPos.getInstance(q);
4735
4736 qPos.add(companyId);
4737
4738 if (openId != null) {
4739 qPos.add(openId);
4740 }
4741
4742 count = (Long)q.uniqueResult();
4743 }
4744 catch (Exception e) {
4745 throw processException(e);
4746 }
4747 finally {
4748 if (count == null) {
4749 count = Long.valueOf(0);
4750 }
4751
4752 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_O, finderArgs,
4753 count);
4754
4755 closeSession(session);
4756 }
4757 }
4758
4759 return count.intValue();
4760 }
4761
4762
4770 public int countByC_S(long companyId, int status) throws SystemException {
4771 Object[] finderArgs = new Object[] { companyId, status };
4772
4773 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
4774 finderArgs, this);
4775
4776 if (count == null) {
4777 StringBundler query = new StringBundler(3);
4778
4779 query.append(_SQL_COUNT_USER_WHERE);
4780
4781 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4782
4783 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4784
4785 String sql = query.toString();
4786
4787 Session session = null;
4788
4789 try {
4790 session = openSession();
4791
4792 Query q = session.createQuery(sql);
4793
4794 QueryPos qPos = QueryPos.getInstance(q);
4795
4796 qPos.add(companyId);
4797
4798 qPos.add(status);
4799
4800 count = (Long)q.uniqueResult();
4801 }
4802 catch (Exception e) {
4803 throw processException(e);
4804 }
4805 finally {
4806 if (count == null) {
4807 count = Long.valueOf(0);
4808 }
4809
4810 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
4811 count);
4812
4813 closeSession(session);
4814 }
4815 }
4816
4817 return count.intValue();
4818 }
4819
4820
4826 public int countAll() throws SystemException {
4827 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4828 FINDER_ARGS_EMPTY, this);
4829
4830 if (count == null) {
4831 Session session = null;
4832
4833 try {
4834 session = openSession();
4835
4836 Query q = session.createQuery(_SQL_COUNT_USER);
4837
4838 count = (Long)q.uniqueResult();
4839 }
4840 catch (Exception e) {
4841 throw processException(e);
4842 }
4843 finally {
4844 if (count == null) {
4845 count = Long.valueOf(0);
4846 }
4847
4848 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4849 FINDER_ARGS_EMPTY, count);
4850
4851 closeSession(session);
4852 }
4853 }
4854
4855 return count.intValue();
4856 }
4857
4858
4865 public List<com.liferay.portal.model.Group> getGroups(long pk)
4866 throws SystemException {
4867 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4868 }
4869
4870
4883 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4884 int end) throws SystemException {
4885 return getGroups(pk, start, end, null);
4886 }
4887
4888 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4889 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
4890 com.liferay.portal.model.impl.GroupImpl.class,
4891 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroups",
4892 new String[] {
4893 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4894 "com.liferay.portal.kernel.util.OrderByComparator"
4895 });
4896
4897 static {
4898 FINDER_PATH_GET_GROUPS.setCacheKeyGeneratorCacheName(null);
4899 }
4900
4901
4915 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4916 int end, OrderByComparator orderByComparator) throws SystemException {
4917 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4918
4919 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4920 finderArgs, this);
4921
4922 if (list == null) {
4923 Session session = null;
4924
4925 try {
4926 session = openSession();
4927
4928 String sql = null;
4929
4930 if (orderByComparator != null) {
4931 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4932 .concat(orderByComparator.getOrderBy());
4933 }
4934 else {
4935 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4936 }
4937
4938 SQLQuery q = session.createSQLQuery(sql);
4939
4940 q.addEntity("Group_",
4941 com.liferay.portal.model.impl.GroupImpl.class);
4942
4943 QueryPos qPos = QueryPos.getInstance(q);
4944
4945 qPos.add(pk);
4946
4947 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4948 getDialect(), start, end);
4949 }
4950 catch (Exception e) {
4951 throw processException(e);
4952 }
4953 finally {
4954 if (list == null) {
4955 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4956 finderArgs);
4957 }
4958 else {
4959 groupPersistence.cacheResult(list);
4960
4961 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4962 finderArgs, list);
4963 }
4964
4965 closeSession(session);
4966 }
4967 }
4968
4969 return list;
4970 }
4971
4972 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4973 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
4974 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroupsSize",
4975 new String[] { Long.class.getName() });
4976
4977 static {
4978 FINDER_PATH_GET_GROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
4979 }
4980
4981
4988 public int getGroupsSize(long pk) throws SystemException {
4989 Object[] finderArgs = new Object[] { pk };
4990
4991 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4992 finderArgs, this);
4993
4994 if (count == null) {
4995 Session session = null;
4996
4997 try {
4998 session = openSession();
4999
5000 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
5001
5002 q.addScalar(COUNT_COLUMN_NAME,
5003 com.liferay.portal.kernel.dao.orm.Type.LONG);
5004
5005 QueryPos qPos = QueryPos.getInstance(q);
5006
5007 qPos.add(pk);
5008
5009 count = (Long)q.uniqueResult();
5010 }
5011 catch (Exception e) {
5012 throw processException(e);
5013 }
5014 finally {
5015 if (count == null) {
5016 count = Long.valueOf(0);
5017 }
5018
5019 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
5020 finderArgs, count);
5021
5022 closeSession(session);
5023 }
5024 }
5025
5026 return count.intValue();
5027 }
5028
5029 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
5030 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
5031 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsGroup",
5032 new String[] { Long.class.getName(), Long.class.getName() });
5033
5034
5042 public boolean containsGroup(long pk, long groupPK)
5043 throws SystemException {
5044 Object[] finderArgs = new Object[] { pk, groupPK };
5045
5046 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
5047 finderArgs, this);
5048
5049 if (value == null) {
5050 try {
5051 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
5052 }
5053 catch (Exception e) {
5054 throw processException(e);
5055 }
5056 finally {
5057 if (value == null) {
5058 value = Boolean.FALSE;
5059 }
5060
5061 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
5062 finderArgs, value);
5063 }
5064 }
5065
5066 return value.booleanValue();
5067 }
5068
5069
5076 public boolean containsGroups(long pk) throws SystemException {
5077 if (getGroupsSize(pk) > 0) {
5078 return true;
5079 }
5080 else {
5081 return false;
5082 }
5083 }
5084
5085
5092 public void addGroup(long pk, long groupPK) throws SystemException {
5093 try {
5094 addGroup.add(pk, groupPK);
5095 }
5096 catch (Exception e) {
5097 throw processException(e);
5098 }
5099 finally {
5100 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5101 }
5102 }
5103
5104
5111 public void addGroup(long pk, com.liferay.portal.model.Group group)
5112 throws SystemException {
5113 try {
5114 addGroup.add(pk, group.getPrimaryKey());
5115 }
5116 catch (Exception e) {
5117 throw processException(e);
5118 }
5119 finally {
5120 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5121 }
5122 }
5123
5124
5131 public void addGroups(long pk, long[] groupPKs) throws SystemException {
5132 try {
5133 for (long groupPK : groupPKs) {
5134 addGroup.add(pk, groupPK);
5135 }
5136 }
5137 catch (Exception e) {
5138 throw processException(e);
5139 }
5140 finally {
5141 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5142 }
5143 }
5144
5145
5152 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
5153 throws SystemException {
5154 try {
5155 for (com.liferay.portal.model.Group group : groups) {
5156 addGroup.add(pk, group.getPrimaryKey());
5157 }
5158 }
5159 catch (Exception e) {
5160 throw processException(e);
5161 }
5162 finally {
5163 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5164 }
5165 }
5166
5167
5173 public void clearGroups(long pk) throws SystemException {
5174 try {
5175 clearGroups.clear(pk);
5176 }
5177 catch (Exception e) {
5178 throw processException(e);
5179 }
5180 finally {
5181 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5182 }
5183 }
5184
5185
5192 public void removeGroup(long pk, long groupPK) throws SystemException {
5193 try {
5194 removeGroup.remove(pk, groupPK);
5195 }
5196 catch (Exception e) {
5197 throw processException(e);
5198 }
5199 finally {
5200 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5201 }
5202 }
5203
5204
5211 public void removeGroup(long pk, com.liferay.portal.model.Group group)
5212 throws SystemException {
5213 try {
5214 removeGroup.remove(pk, group.getPrimaryKey());
5215 }
5216 catch (Exception e) {
5217 throw processException(e);
5218 }
5219 finally {
5220 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5221 }
5222 }
5223
5224
5231 public void removeGroups(long pk, long[] groupPKs)
5232 throws SystemException {
5233 try {
5234 for (long groupPK : groupPKs) {
5235 removeGroup.remove(pk, groupPK);
5236 }
5237 }
5238 catch (Exception e) {
5239 throw processException(e);
5240 }
5241 finally {
5242 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5243 }
5244 }
5245
5246
5253 public void removeGroups(long pk,
5254 List<com.liferay.portal.model.Group> groups) throws SystemException {
5255 try {
5256 for (com.liferay.portal.model.Group group : groups) {
5257 removeGroup.remove(pk, group.getPrimaryKey());
5258 }
5259 }
5260 catch (Exception e) {
5261 throw processException(e);
5262 }
5263 finally {
5264 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5265 }
5266 }
5267
5268
5275 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5276 try {
5277 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5278
5279 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5280
5281 for (com.liferay.portal.model.Group group : groups) {
5282 if (!groupPKSet.remove(group.getPrimaryKey())) {
5283 removeGroup.remove(pk, group.getPrimaryKey());
5284 }
5285 }
5286
5287 for (Long groupPK : groupPKSet) {
5288 addGroup.add(pk, groupPK);
5289 }
5290 }
5291 catch (Exception e) {
5292 throw processException(e);
5293 }
5294 finally {
5295 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5296 }
5297 }
5298
5299
5306 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5307 throws SystemException {
5308 try {
5309 long[] groupPKs = new long[groups.size()];
5310
5311 for (int i = 0; i < groups.size(); i++) {
5312 com.liferay.portal.model.Group group = groups.get(i);
5313
5314 groupPKs[i] = group.getPrimaryKey();
5315 }
5316
5317 setGroups(pk, groupPKs);
5318 }
5319 catch (Exception e) {
5320 throw processException(e);
5321 }
5322 finally {
5323 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5324 }
5325 }
5326
5327
5334 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
5335 throws SystemException {
5336 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5337 }
5338
5339
5352 public List<com.liferay.portal.model.Organization> getOrganizations(
5353 long pk, int start, int end) throws SystemException {
5354 return getOrganizations(pk, start, end, null);
5355 }
5356
5357 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5358 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
5359 com.liferay.portal.model.impl.OrganizationImpl.class,
5360 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getOrganizations",
5361 new String[] {
5362 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5363 "com.liferay.portal.kernel.util.OrderByComparator"
5364 });
5365
5366 static {
5367 FINDER_PATH_GET_ORGANIZATIONS.setCacheKeyGeneratorCacheName(null);
5368 }
5369
5370
5384 public List<com.liferay.portal.model.Organization> getOrganizations(
5385 long pk, int start, int end, OrderByComparator orderByComparator)
5386 throws SystemException {
5387 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5388
5389 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
5390 finderArgs, this);
5391
5392 if (list == null) {
5393 Session session = null;
5394
5395 try {
5396 session = openSession();
5397
5398 String sql = null;
5399
5400 if (orderByComparator != null) {
5401 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
5402 .concat(orderByComparator.getOrderBy());
5403 }
5404 else {
5405 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
5406 }
5407
5408 SQLQuery q = session.createSQLQuery(sql);
5409
5410 q.addEntity("Organization_",
5411 com.liferay.portal.model.impl.OrganizationImpl.class);
5412
5413 QueryPos qPos = QueryPos.getInstance(q);
5414
5415 qPos.add(pk);
5416
5417 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
5418 getDialect(), start, end);
5419 }
5420 catch (Exception e) {
5421 throw processException(e);
5422 }
5423 finally {
5424 if (list == null) {
5425 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
5426 finderArgs);
5427 }
5428 else {
5429 organizationPersistence.cacheResult(list);
5430
5431 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
5432 finderArgs, list);
5433 }
5434
5435 closeSession(session);
5436 }
5437 }
5438
5439 return list;
5440 }
5441
5442 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5443 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Long.class,
5444 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
5445 "getOrganizationsSize", new String[] { Long.class.getName() });
5446
5447 static {
5448 FINDER_PATH_GET_ORGANIZATIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5449 }
5450
5451
5458 public int getOrganizationsSize(long pk) throws SystemException {
5459 Object[] finderArgs = new Object[] { pk };
5460
5461 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5462 finderArgs, this);
5463
5464 if (count == null) {
5465 Session session = null;
5466
5467 try {
5468 session = openSession();
5469
5470 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
5471
5472 q.addScalar(COUNT_COLUMN_NAME,
5473 com.liferay.portal.kernel.dao.orm.Type.LONG);
5474
5475 QueryPos qPos = QueryPos.getInstance(q);
5476
5477 qPos.add(pk);
5478
5479 count = (Long)q.uniqueResult();
5480 }
5481 catch (Exception e) {
5482 throw processException(e);
5483 }
5484 finally {
5485 if (count == null) {
5486 count = Long.valueOf(0);
5487 }
5488
5489 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5490 finderArgs, count);
5491
5492 closeSession(session);
5493 }
5494 }
5495
5496 return count.intValue();
5497 }
5498
5499 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5500 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Boolean.class,
5501 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
5502 "containsOrganization",
5503 new String[] { Long.class.getName(), Long.class.getName() });
5504
5505
5513 public boolean containsOrganization(long pk, long organizationPK)
5514 throws SystemException {
5515 Object[] finderArgs = new Object[] { pk, organizationPK };
5516
5517 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5518 finderArgs, this);
5519
5520 if (value == null) {
5521 try {
5522 value = Boolean.valueOf(containsOrganization.contains(pk,
5523 organizationPK));
5524 }
5525 catch (Exception e) {
5526 throw processException(e);
5527 }
5528 finally {
5529 if (value == null) {
5530 value = Boolean.FALSE;
5531 }
5532
5533 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5534 finderArgs, value);
5535 }
5536 }
5537
5538 return value.booleanValue();
5539 }
5540
5541
5548 public boolean containsOrganizations(long pk) throws SystemException {
5549 if (getOrganizationsSize(pk) > 0) {
5550 return true;
5551 }
5552 else {
5553 return false;
5554 }
5555 }
5556
5557
5564 public void addOrganization(long pk, long organizationPK)
5565 throws SystemException {
5566 try {
5567 addOrganization.add(pk, organizationPK);
5568 }
5569 catch (Exception e) {
5570 throw processException(e);
5571 }
5572 finally {
5573 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5574 }
5575 }
5576
5577
5584 public void addOrganization(long pk,
5585 com.liferay.portal.model.Organization organization)
5586 throws SystemException {
5587 try {
5588 addOrganization.add(pk, organization.getPrimaryKey());
5589 }
5590 catch (Exception e) {
5591 throw processException(e);
5592 }
5593 finally {
5594 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5595 }
5596 }
5597
5598
5605 public void addOrganizations(long pk, long[] organizationPKs)
5606 throws SystemException {
5607 try {
5608 for (long organizationPK : organizationPKs) {
5609 addOrganization.add(pk, organizationPK);
5610 }
5611 }
5612 catch (Exception e) {
5613 throw processException(e);
5614 }
5615 finally {
5616 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5617 }
5618 }
5619
5620
5627 public void addOrganizations(long pk,
5628 List<com.liferay.portal.model.Organization> organizations)
5629 throws SystemException {
5630 try {
5631 for (com.liferay.portal.model.Organization organization : organizations) {
5632 addOrganization.add(pk, organization.getPrimaryKey());
5633 }
5634 }
5635 catch (Exception e) {
5636 throw processException(e);
5637 }
5638 finally {
5639 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5640 }
5641 }
5642
5643
5649 public void clearOrganizations(long pk) throws SystemException {
5650 try {
5651 clearOrganizations.clear(pk);
5652 }
5653 catch (Exception e) {
5654 throw processException(e);
5655 }
5656 finally {
5657 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5658 }
5659 }
5660
5661
5668 public void removeOrganization(long pk, long organizationPK)
5669 throws SystemException {
5670 try {
5671 removeOrganization.remove(pk, organizationPK);
5672 }
5673 catch (Exception e) {
5674 throw processException(e);
5675 }
5676 finally {
5677 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5678 }
5679 }
5680
5681
5688 public void removeOrganization(long pk,
5689 com.liferay.portal.model.Organization organization)
5690 throws SystemException {
5691 try {
5692 removeOrganization.remove(pk, organization.getPrimaryKey());
5693 }
5694 catch (Exception e) {
5695 throw processException(e);
5696 }
5697 finally {
5698 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5699 }
5700 }
5701
5702
5709 public void removeOrganizations(long pk, long[] organizationPKs)
5710 throws SystemException {
5711 try {
5712 for (long organizationPK : organizationPKs) {
5713 removeOrganization.remove(pk, organizationPK);
5714 }
5715 }
5716 catch (Exception e) {
5717 throw processException(e);
5718 }
5719 finally {
5720 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5721 }
5722 }
5723
5724
5731 public void removeOrganizations(long pk,
5732 List<com.liferay.portal.model.Organization> organizations)
5733 throws SystemException {
5734 try {
5735 for (com.liferay.portal.model.Organization organization : organizations) {
5736 removeOrganization.remove(pk, organization.getPrimaryKey());
5737 }
5738 }
5739 catch (Exception e) {
5740 throw processException(e);
5741 }
5742 finally {
5743 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5744 }
5745 }
5746
5747
5754 public void setOrganizations(long pk, long[] organizationPKs)
5755 throws SystemException {
5756 try {
5757 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
5758
5759 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
5760
5761 for (com.liferay.portal.model.Organization organization : organizations) {
5762 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
5763 removeOrganization.remove(pk, organization.getPrimaryKey());
5764 }
5765 }
5766
5767 for (Long organizationPK : organizationPKSet) {
5768 addOrganization.add(pk, organizationPK);
5769 }
5770 }
5771 catch (Exception e) {
5772 throw processException(e);
5773 }
5774 finally {
5775 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5776 }
5777 }
5778
5779
5786 public void setOrganizations(long pk,
5787 List<com.liferay.portal.model.Organization> organizations)
5788 throws SystemException {
5789 try {
5790 long[] organizationPKs = new long[organizations.size()];
5791
5792 for (int i = 0; i < organizations.size(); i++) {
5793 com.liferay.portal.model.Organization organization = organizations.get(i);
5794
5795 organizationPKs[i] = organization.getPrimaryKey();
5796 }
5797
5798 setOrganizations(pk, organizationPKs);
5799 }
5800 catch (Exception e) {
5801 throw processException(e);
5802 }
5803 finally {
5804 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5805 }
5806 }
5807
5808
5815 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5816 throws SystemException {
5817 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5818 }
5819
5820
5833 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5834 int start, int end) throws SystemException {
5835 return getPermissions(pk, start, end, null);
5836 }
5837
5838 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5839 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
5840 com.liferay.portal.model.impl.PermissionImpl.class,
5841 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5842 "getPermissions",
5843 new String[] {
5844 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5845 "com.liferay.portal.kernel.util.OrderByComparator"
5846 });
5847
5848 static {
5849 FINDER_PATH_GET_PERMISSIONS.setCacheKeyGeneratorCacheName(null);
5850 }
5851
5852
5866 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5867 int start, int end, OrderByComparator orderByComparator)
5868 throws SystemException {
5869 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5870
5871 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5872 finderArgs, this);
5873
5874 if (list == null) {
5875 Session session = null;
5876
5877 try {
5878 session = openSession();
5879
5880 String sql = null;
5881
5882 if (orderByComparator != null) {
5883 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5884 .concat(orderByComparator.getOrderBy());
5885 }
5886 else {
5887 sql = _SQL_GETPERMISSIONS;
5888 }
5889
5890 SQLQuery q = session.createSQLQuery(sql);
5891
5892 q.addEntity("Permission_",
5893 com.liferay.portal.model.impl.PermissionImpl.class);
5894
5895 QueryPos qPos = QueryPos.getInstance(q);
5896
5897 qPos.add(pk);
5898
5899 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5900 getDialect(), start, end);
5901 }
5902 catch (Exception e) {
5903 throw processException(e);
5904 }
5905 finally {
5906 if (list == null) {
5907 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5908 finderArgs);
5909 }
5910 else {
5911 permissionPersistence.cacheResult(list);
5912
5913 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5914 finderArgs, list);
5915 }
5916
5917 closeSession(session);
5918 }
5919 }
5920
5921 return list;
5922 }
5923
5924 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5925 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS, Long.class,
5926 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5927 "getPermissionsSize", new String[] { Long.class.getName() });
5928
5929 static {
5930 FINDER_PATH_GET_PERMISSIONS_SIZE.setCacheKeyGeneratorCacheName(null);
5931 }
5932
5933
5940 public int getPermissionsSize(long pk) throws SystemException {
5941 Object[] finderArgs = new Object[] { pk };
5942
5943 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5944 finderArgs, this);
5945
5946 if (count == null) {
5947 Session session = null;
5948
5949 try {
5950 session = openSession();
5951
5952 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5953
5954 q.addScalar(COUNT_COLUMN_NAME,
5955 com.liferay.portal.kernel.dao.orm.Type.LONG);
5956
5957 QueryPos qPos = QueryPos.getInstance(q);
5958
5959 qPos.add(pk);
5960
5961 count = (Long)q.uniqueResult();
5962 }
5963 catch (Exception e) {
5964 throw processException(e);
5965 }
5966 finally {
5967 if (count == null) {
5968 count = Long.valueOf(0);
5969 }
5970
5971 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5972 finderArgs, count);
5973
5974 closeSession(session);
5975 }
5976 }
5977
5978 return count.intValue();
5979 }
5980
5981 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5982 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
5983 Boolean.class, UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5984 "containsPermission",
5985 new String[] { Long.class.getName(), Long.class.getName() });
5986
5987
5995 public boolean containsPermission(long pk, long permissionPK)
5996 throws SystemException {
5997 Object[] finderArgs = new Object[] { pk, permissionPK };
5998
5999 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
6000 finderArgs, this);
6001
6002 if (value == null) {
6003 try {
6004 value = Boolean.valueOf(containsPermission.contains(pk,
6005 permissionPK));
6006 }
6007 catch (Exception e) {
6008 throw processException(e);
6009 }
6010 finally {
6011 if (value == null) {
6012 value = Boolean.FALSE;
6013 }
6014
6015 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
6016 finderArgs, value);
6017 }
6018 }
6019
6020 return value.booleanValue();
6021 }
6022
6023
6030 public boolean containsPermissions(long pk) throws SystemException {
6031 if (getPermissionsSize(pk) > 0) {
6032 return true;
6033 }
6034 else {
6035 return false;
6036 }
6037 }
6038
6039
6046 public void addPermission(long pk, long permissionPK)
6047 throws SystemException {
6048 try {
6049 addPermission.add(pk, permissionPK);
6050 }
6051 catch (Exception e) {
6052 throw processException(e);
6053 }
6054 finally {
6055 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6056 }
6057 }
6058
6059
6066 public void addPermission(long pk,
6067 com.liferay.portal.model.Permission permission)
6068 throws SystemException {
6069 try {
6070 addPermission.add(pk, permission.getPrimaryKey());
6071 }
6072 catch (Exception e) {
6073 throw processException(e);
6074 }
6075 finally {
6076 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6077 }
6078 }
6079
6080
6087 public void addPermissions(long pk, long[] permissionPKs)
6088 throws SystemException {
6089 try {
6090 for (long permissionPK : permissionPKs) {
6091 addPermission.add(pk, permissionPK);
6092 }
6093 }
6094 catch (Exception e) {
6095 throw processException(e);
6096 }
6097 finally {
6098 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6099 }
6100 }
6101
6102
6109 public void addPermissions(long pk,
6110 List<com.liferay.portal.model.Permission> permissions)
6111 throws SystemException {
6112 try {
6113 for (com.liferay.portal.model.Permission permission : permissions) {
6114 addPermission.add(pk, permission.getPrimaryKey());
6115 }
6116 }
6117 catch (Exception e) {
6118 throw processException(e);
6119 }
6120 finally {
6121 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6122 }
6123 }
6124
6125
6131 public void clearPermissions(long pk) throws SystemException {
6132 try {
6133 clearPermissions.clear(pk);
6134 }
6135 catch (Exception e) {
6136 throw processException(e);
6137 }
6138 finally {
6139 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6140 }
6141 }
6142
6143
6150 public void removePermission(long pk, long permissionPK)
6151 throws SystemException {
6152 try {
6153 removePermission.remove(pk, permissionPK);
6154 }
6155 catch (Exception e) {
6156 throw processException(e);
6157 }
6158 finally {
6159 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6160 }
6161 }
6162
6163
6170 public void removePermission(long pk,
6171 com.liferay.portal.model.Permission permission)
6172 throws SystemException {
6173 try {
6174 removePermission.remove(pk, permission.getPrimaryKey());
6175 }
6176 catch (Exception e) {
6177 throw processException(e);
6178 }
6179 finally {
6180 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6181 }
6182 }
6183
6184
6191 public void removePermissions(long pk, long[] permissionPKs)
6192 throws SystemException {
6193 try {
6194 for (long permissionPK : permissionPKs) {
6195 removePermission.remove(pk, permissionPK);
6196 }
6197 }
6198 catch (Exception e) {
6199 throw processException(e);
6200 }
6201 finally {
6202 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6203 }
6204 }
6205
6206
6213 public void removePermissions(long pk,
6214 List<com.liferay.portal.model.Permission> permissions)
6215 throws SystemException {
6216 try {
6217 for (com.liferay.portal.model.Permission permission : permissions) {
6218 removePermission.remove(pk, permission.getPrimaryKey());
6219 }
6220 }
6221 catch (Exception e) {
6222 throw processException(e);
6223 }
6224 finally {
6225 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6226 }
6227 }
6228
6229
6236 public void setPermissions(long pk, long[] permissionPKs)
6237 throws SystemException {
6238 try {
6239 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
6240
6241 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
6242
6243 for (com.liferay.portal.model.Permission permission : permissions) {
6244 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
6245 removePermission.remove(pk, permission.getPrimaryKey());
6246 }
6247 }
6248
6249 for (Long permissionPK : permissionPKSet) {
6250 addPermission.add(pk, permissionPK);
6251 }
6252 }
6253 catch (Exception e) {
6254 throw processException(e);
6255 }
6256 finally {
6257 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6258 }
6259 }
6260
6261
6268 public void setPermissions(long pk,
6269 List<com.liferay.portal.model.Permission> permissions)
6270 throws SystemException {
6271 try {
6272 long[] permissionPKs = new long[permissions.size()];
6273
6274 for (int i = 0; i < permissions.size(); i++) {
6275 com.liferay.portal.model.Permission permission = permissions.get(i);
6276
6277 permissionPKs[i] = permission.getPrimaryKey();
6278 }
6279
6280 setPermissions(pk, permissionPKs);
6281 }
6282 catch (Exception e) {
6283 throw processException(e);
6284 }
6285 finally {
6286 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6287 }
6288 }
6289
6290
6297 public List<com.liferay.portal.model.Role> getRoles(long pk)
6298 throws SystemException {
6299 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6300 }
6301
6302
6315 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6316 int end) throws SystemException {
6317 return getRoles(pk, start, end, null);
6318 }
6319
6320 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6321 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
6322 com.liferay.portal.model.impl.RoleImpl.class,
6323 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRoles",
6324 new String[] {
6325 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6326 "com.liferay.portal.kernel.util.OrderByComparator"
6327 });
6328
6329 static {
6330 FINDER_PATH_GET_ROLES.setCacheKeyGeneratorCacheName(null);
6331 }
6332
6333
6347 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6348 int end, OrderByComparator orderByComparator) throws SystemException {
6349 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6350
6351 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
6352 finderArgs, this);
6353
6354 if (list == null) {
6355 Session session = null;
6356
6357 try {
6358 session = openSession();
6359
6360 String sql = null;
6361
6362 if (orderByComparator != null) {
6363 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
6364 .concat(orderByComparator.getOrderBy());
6365 }
6366 else {
6367 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
6368 }
6369
6370 SQLQuery q = session.createSQLQuery(sql);
6371
6372 q.addEntity("Role_",
6373 com.liferay.portal.model.impl.RoleImpl.class);
6374
6375 QueryPos qPos = QueryPos.getInstance(q);
6376
6377 qPos.add(pk);
6378
6379 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
6380 getDialect(), start, end);
6381 }
6382 catch (Exception e) {
6383 throw processException(e);
6384 }
6385 finally {
6386 if (list == null) {
6387 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
6388 finderArgs);
6389 }
6390 else {
6391 rolePersistence.cacheResult(list);
6392
6393 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
6394 finderArgs, list);
6395 }
6396
6397 closeSession(session);
6398 }
6399 }
6400
6401 return list;
6402 }
6403
6404 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6405 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
6406 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRolesSize",
6407 new String[] { Long.class.getName() });
6408
6409 static {
6410 FINDER_PATH_GET_ROLES_SIZE.setCacheKeyGeneratorCacheName(null);
6411 }
6412
6413
6420 public int getRolesSize(long pk) throws SystemException {
6421 Object[] finderArgs = new Object[] { pk };
6422
6423 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
6424 finderArgs, this);
6425
6426 if (count == null) {
6427 Session session = null;
6428
6429 try {
6430 session = openSession();
6431
6432 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
6433
6434 q.addScalar(COUNT_COLUMN_NAME,
6435 com.liferay.portal.kernel.dao.orm.Type.LONG);
6436
6437 QueryPos qPos = QueryPos.getInstance(q);
6438
6439 qPos.add(pk);
6440
6441 count = (Long)q.uniqueResult();
6442 }
6443 catch (Exception e) {
6444 throw processException(e);
6445 }
6446 finally {
6447 if (count == null) {
6448 count = Long.valueOf(0);
6449 }
6450
6451 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
6452 finderArgs, count);
6453
6454 closeSession(session);
6455 }
6456 }
6457
6458 return count.intValue();
6459 }
6460
6461 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6462 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
6463 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsRole",
6464 new String[] { Long.class.getName(), Long.class.getName() });
6465
6466
6474 public boolean containsRole(long pk, long rolePK) throws SystemException {
6475 Object[] finderArgs = new Object[] { pk, rolePK };
6476
6477 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
6478 finderArgs, this);
6479
6480 if (value == null) {
6481 try {
6482 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
6483 }
6484 catch (Exception e) {
6485 throw processException(e);
6486 }
6487 finally {
6488 if (value == null) {
6489 value = Boolean.FALSE;
6490 }
6491
6492 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
6493 finderArgs, value);
6494 }
6495 }
6496
6497 return value.booleanValue();
6498 }
6499
6500
6507 public boolean containsRoles(long pk) throws SystemException {
6508 if (getRolesSize(pk) > 0) {
6509 return true;
6510 }
6511 else {
6512 return false;
6513 }
6514 }
6515
6516
6523 public void addRole(long pk, long rolePK) throws SystemException {
6524 try {
6525 addRole.add(pk, rolePK);
6526 }
6527 catch (Exception e) {
6528 throw processException(e);
6529 }
6530 finally {
6531 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6532 }
6533 }
6534
6535
6542 public void addRole(long pk, com.liferay.portal.model.Role role)
6543 throws SystemException {
6544 try {
6545 addRole.add(pk, role.getPrimaryKey());
6546 }
6547 catch (Exception e) {
6548 throw processException(e);
6549 }
6550 finally {
6551 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6552 }
6553 }
6554
6555
6562 public void addRoles(long pk, long[] rolePKs) throws SystemException {
6563 try {
6564 for (long rolePK : rolePKs) {
6565 addRole.add(pk, rolePK);
6566 }
6567 }
6568 catch (Exception e) {
6569 throw processException(e);
6570 }
6571 finally {
6572 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6573 }
6574 }
6575
6576
6583 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
6584 throws SystemException {
6585 try {
6586 for (com.liferay.portal.model.Role role : roles) {
6587 addRole.add(pk, role.getPrimaryKey());
6588 }
6589 }
6590 catch (Exception e) {
6591 throw processException(e);
6592 }
6593 finally {
6594 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6595 }
6596 }
6597
6598
6604 public void clearRoles(long pk) throws SystemException {
6605 try {
6606 clearRoles.clear(pk);
6607 }
6608 catch (Exception e) {
6609 throw processException(e);
6610 }
6611 finally {
6612 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6613 }
6614 }
6615
6616
6623 public void removeRole(long pk, long rolePK) throws SystemException {
6624 try {
6625 removeRole.remove(pk, rolePK);
6626 }
6627 catch (Exception e) {
6628 throw processException(e);
6629 }
6630 finally {
6631 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6632 }
6633 }
6634
6635
6642 public void removeRole(long pk, com.liferay.portal.model.Role role)
6643 throws SystemException {
6644 try {
6645 removeRole.remove(pk, role.getPrimaryKey());
6646 }
6647 catch (Exception e) {
6648 throw processException(e);
6649 }
6650 finally {
6651 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6652 }
6653 }
6654
6655
6662 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
6663 try {
6664 for (long rolePK : rolePKs) {
6665 removeRole.remove(pk, rolePK);
6666 }
6667 }
6668 catch (Exception e) {
6669 throw processException(e);
6670 }
6671 finally {
6672 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6673 }
6674 }
6675
6676
6683 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
6684 throws SystemException {
6685 try {
6686 for (com.liferay.portal.model.Role role : roles) {
6687 removeRole.remove(pk, role.getPrimaryKey());
6688 }
6689 }
6690 catch (Exception e) {
6691 throw processException(e);
6692 }
6693 finally {
6694 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6695 }
6696 }
6697
6698
6705 public void setRoles(long pk, long[] rolePKs) throws SystemException {
6706 try {
6707 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
6708
6709 List<com.liferay.portal.model.Role> roles = getRoles(pk);
6710
6711 for (com.liferay.portal.model.Role role : roles) {
6712 if (!rolePKSet.remove(role.getPrimaryKey())) {
6713 removeRole.remove(pk, role.getPrimaryKey());
6714 }
6715 }
6716
6717 for (Long rolePK : rolePKSet) {
6718 addRole.add(pk, rolePK);
6719 }
6720 }
6721 catch (Exception e) {
6722 throw processException(e);
6723 }
6724 finally {
6725 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6726 }
6727 }
6728
6729
6736 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
6737 throws SystemException {
6738 try {
6739 long[] rolePKs = new long[roles.size()];
6740
6741 for (int i = 0; i < roles.size(); i++) {
6742 com.liferay.portal.model.Role role = roles.get(i);
6743
6744 rolePKs[i] = role.getPrimaryKey();
6745 }
6746
6747 setRoles(pk, rolePKs);
6748 }
6749 catch (Exception e) {
6750 throw processException(e);
6751 }
6752 finally {
6753 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6754 }
6755 }
6756
6757
6764 public List<com.liferay.portal.model.Team> getTeams(long pk)
6765 throws SystemException {
6766 return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6767 }
6768
6769
6782 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
6783 int end) throws SystemException {
6784 return getTeams(pk, start, end, null);
6785 }
6786
6787 public static final FinderPath FINDER_PATH_GET_TEAMS = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6788 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
6789 com.liferay.portal.model.impl.TeamImpl.class,
6790 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeams",
6791 new String[] {
6792 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6793 "com.liferay.portal.kernel.util.OrderByComparator"
6794 });
6795
6796 static {
6797 FINDER_PATH_GET_TEAMS.setCacheKeyGeneratorCacheName(null);
6798 }
6799
6800
6814 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
6815 int end, OrderByComparator orderByComparator) throws SystemException {
6816 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6817
6818 List<com.liferay.portal.model.Team> list = (List<com.liferay.portal.model.Team>)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS,
6819 finderArgs, this);
6820
6821 if (list == null) {
6822 Session session = null;
6823
6824 try {
6825 session = openSession();
6826
6827 String sql = null;
6828
6829 if (orderByComparator != null) {
6830 sql = _SQL_GETTEAMS.concat(ORDER_BY_CLAUSE)
6831 .concat(orderByComparator.getOrderBy());
6832 }
6833 else {
6834 sql = _SQL_GETTEAMS.concat(com.liferay.portal.model.impl.TeamModelImpl.ORDER_BY_SQL);
6835 }
6836
6837 SQLQuery q = session.createSQLQuery(sql);
6838
6839 q.addEntity("Team", com.liferay.portal.model.impl.TeamImpl.class);
6840
6841 QueryPos qPos = QueryPos.getInstance(q);
6842
6843 qPos.add(pk);
6844
6845 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
6846 getDialect(), start, end);
6847 }
6848 catch (Exception e) {
6849 throw processException(e);
6850 }
6851 finally {
6852 if (list == null) {
6853 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS,
6854 finderArgs);
6855 }
6856 else {
6857 teamPersistence.cacheResult(list);
6858
6859 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS,
6860 finderArgs, list);
6861 }
6862
6863 closeSession(session);
6864 }
6865 }
6866
6867 return list;
6868 }
6869
6870 public static final FinderPath FINDER_PATH_GET_TEAMS_SIZE = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6871 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
6872 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeamsSize",
6873 new String[] { Long.class.getName() });
6874
6875 static {
6876 FINDER_PATH_GET_TEAMS_SIZE.setCacheKeyGeneratorCacheName(null);
6877 }
6878
6879
6886 public int getTeamsSize(long pk) throws SystemException {
6887 Object[] finderArgs = new Object[] { pk };
6888
6889 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS_SIZE,
6890 finderArgs, this);
6891
6892 if (count == null) {
6893 Session session = null;
6894
6895 try {
6896 session = openSession();
6897
6898 SQLQuery q = session.createSQLQuery(_SQL_GETTEAMSSIZE);
6899
6900 q.addScalar(COUNT_COLUMN_NAME,
6901 com.liferay.portal.kernel.dao.orm.Type.LONG);
6902
6903 QueryPos qPos = QueryPos.getInstance(q);
6904
6905 qPos.add(pk);
6906
6907 count = (Long)q.uniqueResult();
6908 }
6909 catch (Exception e) {
6910 throw processException(e);
6911 }
6912 finally {
6913 if (count == null) {
6914 count = Long.valueOf(0);
6915 }
6916
6917 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS_SIZE,
6918 finderArgs, count);
6919
6920 closeSession(session);
6921 }
6922 }
6923
6924 return count.intValue();
6925 }
6926
6927 public static final FinderPath FINDER_PATH_CONTAINS_TEAM = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6928 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
6929 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsTeam",
6930 new String[] { Long.class.getName(), Long.class.getName() });
6931
6932
6940 public boolean containsTeam(long pk, long teamPK) throws SystemException {
6941 Object[] finderArgs = new Object[] { pk, teamPK };
6942
6943 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TEAM,
6944 finderArgs, this);
6945
6946 if (value == null) {
6947 try {
6948 value = Boolean.valueOf(containsTeam.contains(pk, teamPK));
6949 }
6950 catch (Exception e) {
6951 throw processException(e);
6952 }
6953 finally {
6954 if (value == null) {
6955 value = Boolean.FALSE;
6956 }
6957
6958 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TEAM,
6959 finderArgs, value);
6960 }
6961 }
6962
6963 return value.booleanValue();
6964 }
6965
6966
6973 public boolean containsTeams(long pk) throws SystemException {
6974 if (getTeamsSize(pk) > 0) {
6975 return true;
6976 }
6977 else {
6978 return false;
6979 }
6980 }
6981
6982
6989 public void addTeam(long pk, long teamPK) throws SystemException {
6990 try {
6991 addTeam.add(pk, teamPK);
6992 }
6993 catch (Exception e) {
6994 throw processException(e);
6995 }
6996 finally {
6997 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6998 }
6999 }
7000
7001
7008 public void addTeam(long pk, com.liferay.portal.model.Team team)
7009 throws SystemException {
7010 try {
7011 addTeam.add(pk, team.getPrimaryKey());
7012 }
7013 catch (Exception e) {
7014 throw processException(e);
7015 }
7016 finally {
7017 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7018 }
7019 }
7020
7021
7028 public void addTeams(long pk, long[] teamPKs) throws SystemException {
7029 try {
7030 for (long teamPK : teamPKs) {
7031 addTeam.add(pk, teamPK);
7032 }
7033 }
7034 catch (Exception e) {
7035 throw processException(e);
7036 }
7037 finally {
7038 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7039 }
7040 }
7041
7042
7049 public void addTeams(long pk, List<com.liferay.portal.model.Team> teams)
7050 throws SystemException {
7051 try {
7052 for (com.liferay.portal.model.Team team : teams) {
7053 addTeam.add(pk, team.getPrimaryKey());
7054 }
7055 }
7056 catch (Exception e) {
7057 throw processException(e);
7058 }
7059 finally {
7060 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7061 }
7062 }
7063
7064
7070 public void clearTeams(long pk) throws SystemException {
7071 try {
7072 clearTeams.clear(pk);
7073 }
7074 catch (Exception e) {
7075 throw processException(e);
7076 }
7077 finally {
7078 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7079 }
7080 }
7081
7082
7089 public void removeTeam(long pk, long teamPK) throws SystemException {
7090 try {
7091 removeTeam.remove(pk, teamPK);
7092 }
7093 catch (Exception e) {
7094 throw processException(e);
7095 }
7096 finally {
7097 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7098 }
7099 }
7100
7101
7108 public void removeTeam(long pk, com.liferay.portal.model.Team team)
7109 throws SystemException {
7110 try {
7111 removeTeam.remove(pk, team.getPrimaryKey());
7112 }
7113 catch (Exception e) {
7114 throw processException(e);
7115 }
7116 finally {
7117 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7118 }
7119 }
7120
7121
7128 public void removeTeams(long pk, long[] teamPKs) throws SystemException {
7129 try {
7130 for (long teamPK : teamPKs) {
7131 removeTeam.remove(pk, teamPK);
7132 }
7133 }
7134 catch (Exception e) {
7135 throw processException(e);
7136 }
7137 finally {
7138 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7139 }
7140 }
7141
7142
7149 public void removeTeams(long pk, List<com.liferay.portal.model.Team> teams)
7150 throws SystemException {
7151 try {
7152 for (com.liferay.portal.model.Team team : teams) {
7153 removeTeam.remove(pk, team.getPrimaryKey());
7154 }
7155 }
7156 catch (Exception e) {
7157 throw processException(e);
7158 }
7159 finally {
7160 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7161 }
7162 }
7163
7164
7171 public void setTeams(long pk, long[] teamPKs) throws SystemException {
7172 try {
7173 Set<Long> teamPKSet = SetUtil.fromArray(teamPKs);
7174
7175 List<com.liferay.portal.model.Team> teams = getTeams(pk);
7176
7177 for (com.liferay.portal.model.Team team : teams) {
7178 if (!teamPKSet.remove(team.getPrimaryKey())) {
7179 removeTeam.remove(pk, team.getPrimaryKey());
7180 }
7181 }
7182
7183 for (Long teamPK : teamPKSet) {
7184 addTeam.add(pk, teamPK);
7185 }
7186 }
7187 catch (Exception e) {
7188 throw processException(e);
7189 }
7190 finally {
7191 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7192 }
7193 }
7194
7195
7202 public void setTeams(long pk, List<com.liferay.portal.model.Team> teams)
7203 throws SystemException {
7204 try {
7205 long[] teamPKs = new long[teams.size()];
7206
7207 for (int i = 0; i < teams.size(); i++) {
7208 com.liferay.portal.model.Team team = teams.get(i);
7209
7210 teamPKs[i] = team.getPrimaryKey();
7211 }
7212
7213 setTeams(pk, teamPKs);
7214 }
7215 catch (Exception e) {
7216 throw processException(e);
7217 }
7218 finally {
7219 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
7220 }
7221 }
7222
7223
7230 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
7231 throws SystemException {
7232 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
7233 }
7234
7235
7248 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
7249 int start, int end) throws SystemException {
7250 return getUserGroups(pk, start, end, null);
7251 }
7252
7253 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
7254 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
7255 com.liferay.portal.model.impl.UserGroupImpl.class,
7256 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUserGroups",
7257 new String[] {
7258 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
7259 "com.liferay.portal.kernel.util.OrderByComparator"
7260 });
7261
7262 static {
7263 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
7264 }
7265
7266
7280 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
7281 int start, int end, OrderByComparator orderByComparator)
7282 throws SystemException {
7283 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
7284
7285 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
7286 finderArgs, this);
7287
7288 if (list == null) {
7289 Session session = null;
7290
7291 try {
7292 session = openSession();
7293
7294 String sql = null;
7295
7296 if (orderByComparator != null) {
7297 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
7298 .concat(orderByComparator.getOrderBy());
7299 }
7300 else {
7301 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
7302 }
7303
7304 SQLQuery q = session.createSQLQuery(sql);
7305
7306 q.addEntity("UserGroup",
7307 com.liferay.portal.model.impl.UserGroupImpl.class);
7308
7309 QueryPos qPos = QueryPos.getInstance(q);
7310
7311 qPos.add(pk);
7312
7313 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
7314 getDialect(), start, end);
7315 }
7316 catch (Exception e) {
7317 throw processException(e);
7318 }
7319 finally {
7320 if (list == null) {
7321 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
7322 finderArgs);
7323 }
7324 else {
7325 userGroupPersistence.cacheResult(list);
7326
7327 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
7328 finderArgs, list);
7329 }
7330
7331 closeSession(session);
7332 }
7333 }
7334
7335 return list;
7336 }
7337
7338 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
7339 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Long.class,
7340 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
7341 "getUserGroupsSize", new String[] { Long.class.getName() });
7342
7343 static {
7344 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
7345 }
7346
7347
7354 public int getUserGroupsSize(long pk) throws SystemException {
7355 Object[] finderArgs = new Object[] { pk };
7356
7357 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
7358 finderArgs, this);
7359
7360 if (count == null) {
7361 Session session = null;
7362
7363 try {
7364 session = openSession();
7365
7366 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
7367
7368 q.addScalar(COUNT_COLUMN_NAME,
7369 com.liferay.portal.kernel.dao.orm.Type.LONG);
7370
7371 QueryPos qPos = QueryPos.getInstance(q);
7372
7373 qPos.add(pk);
7374
7375 count = (Long)q.uniqueResult();
7376 }
7377 catch (Exception e) {
7378 throw processException(e);
7379 }
7380 finally {
7381 if (count == null) {
7382 count = Long.valueOf(0);
7383 }
7384
7385 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
7386 finderArgs, count);
7387
7388 closeSession(session);
7389 }
7390 }
7391
7392 return count.intValue();
7393 }
7394
7395 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
7396 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Boolean.class,
7397 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
7398 "containsUserGroup",
7399 new String[] { Long.class.getName(), Long.class.getName() });
7400
7401
7409 public boolean containsUserGroup(long pk, long userGroupPK)
7410 throws SystemException {
7411 Object[] finderArgs = new Object[] { pk, userGroupPK };
7412
7413 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
7414 finderArgs, this);
7415
7416 if (value == null) {
7417 try {
7418 value = Boolean.valueOf(containsUserGroup.contains(pk,
7419 userGroupPK));
7420 }
7421 catch (Exception e) {
7422 throw processException(e);
7423 }
7424 finally {
7425 if (value == null) {
7426 value = Boolean.FALSE;
7427 }
7428
7429 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
7430 finderArgs, value);
7431 }
7432 }
7433
7434 return value.booleanValue();
7435 }
7436
7437
7444 public boolean containsUserGroups(long pk) throws SystemException {
7445 if (getUserGroupsSize(pk) > 0) {
7446 return true;
7447 }
7448 else {
7449 return false;
7450 }
7451 }
7452
7453
7460 public void addUserGroup(long pk, long userGroupPK)
7461 throws SystemException {
7462 try {
7463 addUserGroup.add(pk, userGroupPK);
7464 }
7465 catch (Exception e) {
7466 throw processException(e);
7467 }
7468 finally {
7469 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7470 }
7471 }
7472
7473
7480 public void addUserGroup(long pk,
7481 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
7482 try {
7483 addUserGroup.add(pk, userGroup.getPrimaryKey());
7484 }
7485 catch (Exception e) {
7486 throw processException(e);
7487 }
7488 finally {
7489 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7490 }
7491 }
7492
7493
7500 public void addUserGroups(long pk, long[] userGroupPKs)
7501 throws SystemException {
7502 try {
7503 for (long userGroupPK : userGroupPKs) {
7504 addUserGroup.add(pk, userGroupPK);
7505 }
7506 }
7507 catch (Exception e) {
7508 throw processException(e);
7509 }
7510 finally {
7511 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7512 }
7513 }
7514
7515
7522 public void addUserGroups(long pk,
7523 List<com.liferay.portal.model.UserGroup> userGroups)
7524 throws SystemException {
7525 try {
7526 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7527 addUserGroup.add(pk, userGroup.getPrimaryKey());
7528 }
7529 }
7530 catch (Exception e) {
7531 throw processException(e);
7532 }
7533 finally {
7534 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7535 }
7536 }
7537
7538
7544 public void clearUserGroups(long pk) throws SystemException {
7545 try {
7546 clearUserGroups.clear(pk);
7547 }
7548 catch (Exception e) {
7549 throw processException(e);
7550 }
7551 finally {
7552 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7553 }
7554 }
7555
7556
7563 public void removeUserGroup(long pk, long userGroupPK)
7564 throws SystemException {
7565 try {
7566 removeUserGroup.remove(pk, userGroupPK);
7567 }
7568 catch (Exception e) {
7569 throw processException(e);
7570 }
7571 finally {
7572 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7573 }
7574 }
7575
7576
7583 public void removeUserGroup(long pk,
7584 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
7585 try {
7586 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7587 }
7588 catch (Exception e) {
7589 throw processException(e);
7590 }
7591 finally {
7592 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7593 }
7594 }
7595
7596
7603 public void removeUserGroups(long pk, long[] userGroupPKs)
7604 throws SystemException {
7605 try {
7606 for (long userGroupPK : userGroupPKs) {
7607 removeUserGroup.remove(pk, userGroupPK);
7608 }
7609 }
7610 catch (Exception e) {
7611 throw processException(e);
7612 }
7613 finally {
7614 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7615 }
7616 }
7617
7618
7625 public void removeUserGroups(long pk,
7626 List<com.liferay.portal.model.UserGroup> userGroups)
7627 throws SystemException {
7628 try {
7629 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7630 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7631 }
7632 }
7633 catch (Exception e) {
7634 throw processException(e);
7635 }
7636 finally {
7637 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7638 }
7639 }
7640
7641
7648 public void setUserGroups(long pk, long[] userGroupPKs)
7649 throws SystemException {
7650 try {
7651 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
7652
7653 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
7654
7655 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7656 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
7657 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7658 }
7659 }
7660
7661 for (Long userGroupPK : userGroupPKSet) {
7662 addUserGroup.add(pk, userGroupPK);
7663 }
7664 }
7665 catch (Exception e) {
7666 throw processException(e);
7667 }
7668 finally {
7669 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7670 }
7671 }
7672
7673
7680 public void setUserGroups(long pk,
7681 List<com.liferay.portal.model.UserGroup> userGroups)
7682 throws SystemException {
7683 try {
7684 long[] userGroupPKs = new long[userGroups.size()];
7685
7686 for (int i = 0; i < userGroups.size(); i++) {
7687 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
7688
7689 userGroupPKs[i] = userGroup.getPrimaryKey();
7690 }
7691
7692 setUserGroups(pk, userGroupPKs);
7693 }
7694 catch (Exception e) {
7695 throw processException(e);
7696 }
7697 finally {
7698 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7699 }
7700 }
7701
7702
7705 public void afterPropertiesSet() {
7706 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
7707 com.liferay.portal.util.PropsUtil.get(
7708 "value.object.listener.com.liferay.portal.model.User")));
7709
7710 if (listenerClassNames.length > 0) {
7711 try {
7712 List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
7713
7714 for (String listenerClassName : listenerClassNames) {
7715 listenersList.add((ModelListener<User>)InstanceFactory.newInstance(
7716 listenerClassName));
7717 }
7718
7719 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
7720 }
7721 catch (Exception e) {
7722 _log.error(e);
7723 }
7724 }
7725
7726 containsGroup = new ContainsGroup();
7727
7728 addGroup = new AddGroup();
7729 clearGroups = new ClearGroups();
7730 removeGroup = new RemoveGroup();
7731
7732 containsOrganization = new ContainsOrganization();
7733
7734 addOrganization = new AddOrganization();
7735 clearOrganizations = new ClearOrganizations();
7736 removeOrganization = new RemoveOrganization();
7737
7738 containsPermission = new ContainsPermission();
7739
7740 addPermission = new AddPermission();
7741 clearPermissions = new ClearPermissions();
7742 removePermission = new RemovePermission();
7743
7744 containsRole = new ContainsRole();
7745
7746 addRole = new AddRole();
7747 clearRoles = new ClearRoles();
7748 removeRole = new RemoveRole();
7749
7750 containsTeam = new ContainsTeam();
7751
7752 addTeam = new AddTeam();
7753 clearTeams = new ClearTeams();
7754 removeTeam = new RemoveTeam();
7755
7756 containsUserGroup = new ContainsUserGroup();
7757
7758 addUserGroup = new AddUserGroup();
7759 clearUserGroups = new ClearUserGroups();
7760 removeUserGroup = new RemoveUserGroup();
7761 }
7762
7763 public void destroy() {
7764 EntityCacheUtil.removeCache(UserImpl.class.getName());
7765 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
7766 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7767 }
7768
7769 @BeanReference(type = AccountPersistence.class)
7770 protected AccountPersistence accountPersistence;
7771 @BeanReference(type = AddressPersistence.class)
7772 protected AddressPersistence addressPersistence;
7773 @BeanReference(type = BrowserTrackerPersistence.class)
7774 protected BrowserTrackerPersistence browserTrackerPersistence;
7775 @BeanReference(type = ClassNamePersistence.class)
7776 protected ClassNamePersistence classNamePersistence;
7777 @BeanReference(type = ClusterGroupPersistence.class)
7778 protected ClusterGroupPersistence clusterGroupPersistence;
7779 @BeanReference(type = CompanyPersistence.class)
7780 protected CompanyPersistence companyPersistence;
7781 @BeanReference(type = ContactPersistence.class)
7782 protected ContactPersistence contactPersistence;
7783 @BeanReference(type = CountryPersistence.class)
7784 protected CountryPersistence countryPersistence;
7785 @BeanReference(type = EmailAddressPersistence.class)
7786 protected EmailAddressPersistence emailAddressPersistence;
7787 @BeanReference(type = GroupPersistence.class)
7788 protected GroupPersistence groupPersistence;
7789 @BeanReference(type = ImagePersistence.class)
7790 protected ImagePersistence imagePersistence;
7791 @BeanReference(type = LayoutPersistence.class)
7792 protected LayoutPersistence layoutPersistence;
7793 @BeanReference(type = LayoutBranchPersistence.class)
7794 protected LayoutBranchPersistence layoutBranchPersistence;
7795 @BeanReference(type = LayoutPrototypePersistence.class)
7796 protected LayoutPrototypePersistence layoutPrototypePersistence;
7797 @BeanReference(type = LayoutRevisionPersistence.class)
7798 protected LayoutRevisionPersistence layoutRevisionPersistence;
7799 @BeanReference(type = LayoutSetPersistence.class)
7800 protected LayoutSetPersistence layoutSetPersistence;
7801 @BeanReference(type = LayoutSetBranchPersistence.class)
7802 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
7803 @BeanReference(type = LayoutSetPrototypePersistence.class)
7804 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
7805 @BeanReference(type = ListTypePersistence.class)
7806 protected ListTypePersistence listTypePersistence;
7807 @BeanReference(type = LockPersistence.class)
7808 protected LockPersistence lockPersistence;
7809 @BeanReference(type = MembershipRequestPersistence.class)
7810 protected MembershipRequestPersistence membershipRequestPersistence;
7811 @BeanReference(type = OrganizationPersistence.class)
7812 protected OrganizationPersistence organizationPersistence;
7813 @BeanReference(type = OrgGroupPermissionPersistence.class)
7814 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
7815 @BeanReference(type = OrgGroupRolePersistence.class)
7816 protected OrgGroupRolePersistence orgGroupRolePersistence;
7817 @BeanReference(type = OrgLaborPersistence.class)
7818 protected OrgLaborPersistence orgLaborPersistence;
7819 @BeanReference(type = PasswordPolicyPersistence.class)
7820 protected PasswordPolicyPersistence passwordPolicyPersistence;
7821 @BeanReference(type = PasswordPolicyRelPersistence.class)
7822 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
7823 @BeanReference(type = PasswordTrackerPersistence.class)
7824 protected PasswordTrackerPersistence passwordTrackerPersistence;
7825 @BeanReference(type = PermissionPersistence.class)
7826 protected PermissionPersistence permissionPersistence;
7827 @BeanReference(type = PhonePersistence.class)
7828 protected PhonePersistence phonePersistence;
7829 @BeanReference(type = PluginSettingPersistence.class)
7830 protected PluginSettingPersistence pluginSettingPersistence;
7831 @BeanReference(type = PortalPreferencesPersistence.class)
7832 protected PortalPreferencesPersistence portalPreferencesPersistence;
7833 @BeanReference(type = PortletPersistence.class)
7834 protected PortletPersistence portletPersistence;
7835 @BeanReference(type = PortletItemPersistence.class)
7836 protected PortletItemPersistence portletItemPersistence;
7837 @BeanReference(type = PortletPreferencesPersistence.class)
7838 protected PortletPreferencesPersistence portletPreferencesPersistence;
7839 @BeanReference(type = RegionPersistence.class)
7840 protected RegionPersistence regionPersistence;
7841 @BeanReference(type = ReleasePersistence.class)
7842 protected ReleasePersistence releasePersistence;
7843 @BeanReference(type = RepositoryPersistence.class)
7844 protected RepositoryPersistence repositoryPersistence;
7845 @BeanReference(type = RepositoryEntryPersistence.class)
7846 protected RepositoryEntryPersistence repositoryEntryPersistence;
7847 @BeanReference(type = ResourcePersistence.class)
7848 protected ResourcePersistence resourcePersistence;
7849 @BeanReference(type = ResourceActionPersistence.class)
7850 protected ResourceActionPersistence resourceActionPersistence;
7851 @BeanReference(type = ResourceBlockPersistence.class)
7852 protected ResourceBlockPersistence resourceBlockPersistence;
7853 @BeanReference(type = ResourceBlockPermissionPersistence.class)
7854 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
7855 @BeanReference(type = ResourceCodePersistence.class)
7856 protected ResourceCodePersistence resourceCodePersistence;
7857 @BeanReference(type = ResourcePermissionPersistence.class)
7858 protected ResourcePermissionPersistence resourcePermissionPersistence;
7859 @BeanReference(type = ResourceTypePermissionPersistence.class)
7860 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
7861 @BeanReference(type = RolePersistence.class)
7862 protected RolePersistence rolePersistence;
7863 @BeanReference(type = ServiceComponentPersistence.class)
7864 protected ServiceComponentPersistence serviceComponentPersistence;
7865 @BeanReference(type = ShardPersistence.class)
7866 protected ShardPersistence shardPersistence;
7867 @BeanReference(type = SubscriptionPersistence.class)
7868 protected SubscriptionPersistence subscriptionPersistence;
7869 @BeanReference(type = TeamPersistence.class)
7870 protected TeamPersistence teamPersistence;
7871 @BeanReference(type = TicketPersistence.class)
7872 protected TicketPersistence ticketPersistence;
7873 @BeanReference(type = UserPersistence.class)
7874 protected UserPersistence userPersistence;
7875 @BeanReference(type = UserGroupPersistence.class)
7876 protected UserGroupPersistence userGroupPersistence;
7877 @BeanReference(type = UserGroupGroupRolePersistence.class)
7878 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
7879 @BeanReference(type = UserGroupRolePersistence.class)
7880 protected UserGroupRolePersistence userGroupRolePersistence;
7881 @BeanReference(type = UserIdMapperPersistence.class)
7882 protected UserIdMapperPersistence userIdMapperPersistence;
7883 @BeanReference(type = UserNotificationEventPersistence.class)
7884 protected UserNotificationEventPersistence userNotificationEventPersistence;
7885 @BeanReference(type = UserTrackerPersistence.class)
7886 protected UserTrackerPersistence userTrackerPersistence;
7887 @BeanReference(type = UserTrackerPathPersistence.class)
7888 protected UserTrackerPathPersistence userTrackerPathPersistence;
7889 @BeanReference(type = VirtualHostPersistence.class)
7890 protected VirtualHostPersistence virtualHostPersistence;
7891 @BeanReference(type = WebDAVPropsPersistence.class)
7892 protected WebDAVPropsPersistence webDAVPropsPersistence;
7893 @BeanReference(type = WebsitePersistence.class)
7894 protected WebsitePersistence websitePersistence;
7895 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
7896 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
7897 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
7898 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
7899 @BeanReference(type = AnnouncementsDeliveryPersistence.class)
7900 protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
7901 @BeanReference(type = AssetEntryPersistence.class)
7902 protected AssetEntryPersistence assetEntryPersistence;
7903 @BeanReference(type = BlogsStatsUserPersistence.class)
7904 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
7905 @BeanReference(type = DLFileRankPersistence.class)
7906 protected DLFileRankPersistence dlFileRankPersistence;
7907 @BeanReference(type = ExpandoValuePersistence.class)
7908 protected ExpandoValuePersistence expandoValuePersistence;
7909 @BeanReference(type = MBBanPersistence.class)
7910 protected MBBanPersistence mbBanPersistence;
7911 @BeanReference(type = MBMessagePersistence.class)
7912 protected MBMessagePersistence mbMessagePersistence;
7913 @BeanReference(type = MBStatsUserPersistence.class)
7914 protected MBStatsUserPersistence mbStatsUserPersistence;
7915 @BeanReference(type = MBThreadFlagPersistence.class)
7916 protected MBThreadFlagPersistence mbThreadFlagPersistence;
7917 @BeanReference(type = ShoppingCartPersistence.class)
7918 protected ShoppingCartPersistence shoppingCartPersistence;
7919 @BeanReference(type = SocialActivityPersistence.class)
7920 protected SocialActivityPersistence socialActivityPersistence;
7921 @BeanReference(type = SocialRequestPersistence.class)
7922 protected SocialRequestPersistence socialRequestPersistence;
7923 protected ContainsGroup containsGroup;
7924 protected AddGroup addGroup;
7925 protected ClearGroups clearGroups;
7926 protected RemoveGroup removeGroup;
7927 protected ContainsOrganization containsOrganization;
7928 protected AddOrganization addOrganization;
7929 protected ClearOrganizations clearOrganizations;
7930 protected RemoveOrganization removeOrganization;
7931 protected ContainsPermission containsPermission;
7932 protected AddPermission addPermission;
7933 protected ClearPermissions clearPermissions;
7934 protected RemovePermission removePermission;
7935 protected ContainsRole containsRole;
7936 protected AddRole addRole;
7937 protected ClearRoles clearRoles;
7938 protected RemoveRole removeRole;
7939 protected ContainsTeam containsTeam;
7940 protected AddTeam addTeam;
7941 protected ClearTeams clearTeams;
7942 protected RemoveTeam removeTeam;
7943 protected ContainsUserGroup containsUserGroup;
7944 protected AddUserGroup addUserGroup;
7945 protected ClearUserGroups clearUserGroups;
7946 protected RemoveUserGroup removeUserGroup;
7947
7948 protected class ContainsGroup {
7949 protected ContainsGroup() {
7950 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7951 _SQL_CONTAINSGROUP,
7952 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7953 RowMapper.COUNT);
7954 }
7955
7956 protected boolean contains(long userId, long groupId) {
7957 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7958 new Long(userId), new Long(groupId)
7959 });
7960
7961 if (results.size() > 0) {
7962 Integer count = results.get(0);
7963
7964 if (count.intValue() > 0) {
7965 return true;
7966 }
7967 }
7968
7969 return false;
7970 }
7971
7972 private MappingSqlQuery<Integer> _mappingSqlQuery;
7973 }
7974
7975 protected class AddGroup {
7976 protected AddGroup() {
7977 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7978 "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
7979 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7980 }
7981
7982 protected void add(long userId, long groupId) throws SystemException {
7983 if (!containsGroup.contains(userId, groupId)) {
7984 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
7985
7986 for (ModelListener<User> listener : listeners) {
7987 listener.onBeforeAddAssociation(userId,
7988 com.liferay.portal.model.Group.class.getName(), groupId);
7989 }
7990
7991 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7992 listener.onBeforeAddAssociation(groupId,
7993 User.class.getName(), userId);
7994 }
7995
7996 _sqlUpdate.update(new Object[] {
7997 new Long(userId), new Long(groupId)
7998 });
7999
8000 for (ModelListener<User> listener : listeners) {
8001 listener.onAfterAddAssociation(userId,
8002 com.liferay.portal.model.Group.class.getName(), groupId);
8003 }
8004
8005 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
8006 listener.onAfterAddAssociation(groupId,
8007 User.class.getName(), userId);
8008 }
8009 }
8010 }
8011
8012 private SqlUpdate _sqlUpdate;
8013 }
8014
8015 protected class ClearGroups {
8016 protected ClearGroups() {
8017 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8018 "DELETE FROM Users_Groups WHERE userId = ?",
8019 new int[] { java.sql.Types.BIGINT });
8020 }
8021
8022 protected void clear(long userId) throws SystemException {
8023 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
8024
8025 List<com.liferay.portal.model.Group> groups = null;
8026
8027 if ((listeners.length > 0) || (groupListeners.length > 0)) {
8028 groups = getGroups(userId);
8029
8030 for (com.liferay.portal.model.Group group : groups) {
8031 for (ModelListener<User> listener : listeners) {
8032 listener.onBeforeRemoveAssociation(userId,
8033 com.liferay.portal.model.Group.class.getName(),
8034 group.getPrimaryKey());
8035 }
8036
8037 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
8038 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
8039 User.class.getName(), userId);
8040 }
8041 }
8042 }
8043
8044 _sqlUpdate.update(new Object[] { new Long(userId) });
8045
8046 if ((listeners.length > 0) || (groupListeners.length > 0)) {
8047 for (com.liferay.portal.model.Group group : groups) {
8048 for (ModelListener<User> listener : listeners) {
8049 listener.onAfterRemoveAssociation(userId,
8050 com.liferay.portal.model.Group.class.getName(),
8051 group.getPrimaryKey());
8052 }
8053
8054 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
8055 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
8056 User.class.getName(), userId);
8057 }
8058 }
8059 }
8060 }
8061
8062 private SqlUpdate _sqlUpdate;
8063 }
8064
8065 protected class RemoveGroup {
8066 protected RemoveGroup() {
8067 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8068 "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
8069 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8070 }
8071
8072 protected void remove(long userId, long groupId)
8073 throws SystemException {
8074 if (containsGroup.contains(userId, groupId)) {
8075 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
8076
8077 for (ModelListener<User> listener : listeners) {
8078 listener.onBeforeRemoveAssociation(userId,
8079 com.liferay.portal.model.Group.class.getName(), groupId);
8080 }
8081
8082 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
8083 listener.onBeforeRemoveAssociation(groupId,
8084 User.class.getName(), userId);
8085 }
8086
8087 _sqlUpdate.update(new Object[] {
8088 new Long(userId), new Long(groupId)
8089 });
8090
8091 for (ModelListener<User> listener : listeners) {
8092 listener.onAfterRemoveAssociation(userId,
8093 com.liferay.portal.model.Group.class.getName(), groupId);
8094 }
8095
8096 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
8097 listener.onAfterRemoveAssociation(groupId,
8098 User.class.getName(), userId);
8099 }
8100 }
8101 }
8102
8103 private SqlUpdate _sqlUpdate;
8104 }
8105
8106 protected class ContainsOrganization {
8107 protected ContainsOrganization() {
8108 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8109 _SQL_CONTAINSORGANIZATION,
8110 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8111 RowMapper.COUNT);
8112 }
8113
8114 protected boolean contains(long userId, long organizationId) {
8115 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8116 new Long(userId), new Long(organizationId)
8117 });
8118
8119 if (results.size() > 0) {
8120 Integer count = results.get(0);
8121
8122 if (count.intValue() > 0) {
8123 return true;
8124 }
8125 }
8126
8127 return false;
8128 }
8129
8130 private MappingSqlQuery<Integer> _mappingSqlQuery;
8131 }
8132
8133 protected class AddOrganization {
8134 protected AddOrganization() {
8135 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8136 "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
8137 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8138 }
8139
8140 protected void add(long userId, long organizationId)
8141 throws SystemException {
8142 if (!containsOrganization.contains(userId, organizationId)) {
8143 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
8144 organizationPersistence.getListeners();
8145
8146 for (ModelListener<User> listener : listeners) {
8147 listener.onBeforeAddAssociation(userId,
8148 com.liferay.portal.model.Organization.class.getName(),
8149 organizationId);
8150 }
8151
8152 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8153 listener.onBeforeAddAssociation(organizationId,
8154 User.class.getName(), userId);
8155 }
8156
8157 _sqlUpdate.update(new Object[] {
8158 new Long(userId), new Long(organizationId)
8159 });
8160
8161 for (ModelListener<User> listener : listeners) {
8162 listener.onAfterAddAssociation(userId,
8163 com.liferay.portal.model.Organization.class.getName(),
8164 organizationId);
8165 }
8166
8167 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8168 listener.onAfterAddAssociation(organizationId,
8169 User.class.getName(), userId);
8170 }
8171 }
8172 }
8173
8174 private SqlUpdate _sqlUpdate;
8175 }
8176
8177 protected class ClearOrganizations {
8178 protected ClearOrganizations() {
8179 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8180 "DELETE FROM Users_Orgs WHERE userId = ?",
8181 new int[] { java.sql.Types.BIGINT });
8182 }
8183
8184 protected void clear(long userId) throws SystemException {
8185 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
8186 organizationPersistence.getListeners();
8187
8188 List<com.liferay.portal.model.Organization> organizations = null;
8189
8190 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
8191 organizations = getOrganizations(userId);
8192
8193 for (com.liferay.portal.model.Organization organization : organizations) {
8194 for (ModelListener<User> listener : listeners) {
8195 listener.onBeforeRemoveAssociation(userId,
8196 com.liferay.portal.model.Organization.class.getName(),
8197 organization.getPrimaryKey());
8198 }
8199
8200 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8201 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
8202 User.class.getName(), userId);
8203 }
8204 }
8205 }
8206
8207 _sqlUpdate.update(new Object[] { new Long(userId) });
8208
8209 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
8210 for (com.liferay.portal.model.Organization organization : organizations) {
8211 for (ModelListener<User> listener : listeners) {
8212 listener.onAfterRemoveAssociation(userId,
8213 com.liferay.portal.model.Organization.class.getName(),
8214 organization.getPrimaryKey());
8215 }
8216
8217 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8218 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
8219 User.class.getName(), userId);
8220 }
8221 }
8222 }
8223 }
8224
8225 private SqlUpdate _sqlUpdate;
8226 }
8227
8228 protected class RemoveOrganization {
8229 protected RemoveOrganization() {
8230 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8231 "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
8232 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8233 }
8234
8235 protected void remove(long userId, long organizationId)
8236 throws SystemException {
8237 if (containsOrganization.contains(userId, organizationId)) {
8238 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
8239 organizationPersistence.getListeners();
8240
8241 for (ModelListener<User> listener : listeners) {
8242 listener.onBeforeRemoveAssociation(userId,
8243 com.liferay.portal.model.Organization.class.getName(),
8244 organizationId);
8245 }
8246
8247 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8248 listener.onBeforeRemoveAssociation(organizationId,
8249 User.class.getName(), userId);
8250 }
8251
8252 _sqlUpdate.update(new Object[] {
8253 new Long(userId), new Long(organizationId)
8254 });
8255
8256 for (ModelListener<User> listener : listeners) {
8257 listener.onAfterRemoveAssociation(userId,
8258 com.liferay.portal.model.Organization.class.getName(),
8259 organizationId);
8260 }
8261
8262 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
8263 listener.onAfterRemoveAssociation(organizationId,
8264 User.class.getName(), userId);
8265 }
8266 }
8267 }
8268
8269 private SqlUpdate _sqlUpdate;
8270 }
8271
8272 protected class ContainsPermission {
8273 protected ContainsPermission() {
8274 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8275 _SQL_CONTAINSPERMISSION,
8276 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8277 RowMapper.COUNT);
8278 }
8279
8280 protected boolean contains(long userId, long permissionId) {
8281 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8282 new Long(userId), new Long(permissionId)
8283 });
8284
8285 if (results.size() > 0) {
8286 Integer count = results.get(0);
8287
8288 if (count.intValue() > 0) {
8289 return true;
8290 }
8291 }
8292
8293 return false;
8294 }
8295
8296 private MappingSqlQuery<Integer> _mappingSqlQuery;
8297 }
8298
8299 protected class AddPermission {
8300 protected AddPermission() {
8301 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8302 "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)",
8303 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8304 }
8305
8306 protected void add(long userId, long permissionId)
8307 throws SystemException {
8308 if (!containsPermission.contains(userId, permissionId)) {
8309 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8310 permissionPersistence.getListeners();
8311
8312 for (ModelListener<User> listener : listeners) {
8313 listener.onBeforeAddAssociation(userId,
8314 com.liferay.portal.model.Permission.class.getName(),
8315 permissionId);
8316 }
8317
8318 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8319 listener.onBeforeAddAssociation(permissionId,
8320 User.class.getName(), userId);
8321 }
8322
8323 _sqlUpdate.update(new Object[] {
8324 new Long(userId), new Long(permissionId)
8325 });
8326
8327 for (ModelListener<User> listener : listeners) {
8328 listener.onAfterAddAssociation(userId,
8329 com.liferay.portal.model.Permission.class.getName(),
8330 permissionId);
8331 }
8332
8333 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8334 listener.onAfterAddAssociation(permissionId,
8335 User.class.getName(), userId);
8336 }
8337 }
8338 }
8339
8340 private SqlUpdate _sqlUpdate;
8341 }
8342
8343 protected class ClearPermissions {
8344 protected ClearPermissions() {
8345 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8346 "DELETE FROM Users_Permissions WHERE userId = ?",
8347 new int[] { java.sql.Types.BIGINT });
8348 }
8349
8350 protected void clear(long userId) throws SystemException {
8351 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8352 permissionPersistence.getListeners();
8353
8354 List<com.liferay.portal.model.Permission> permissions = null;
8355
8356 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
8357 permissions = getPermissions(userId);
8358
8359 for (com.liferay.portal.model.Permission permission : permissions) {
8360 for (ModelListener<User> listener : listeners) {
8361 listener.onBeforeRemoveAssociation(userId,
8362 com.liferay.portal.model.Permission.class.getName(),
8363 permission.getPrimaryKey());
8364 }
8365
8366 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8367 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
8368 User.class.getName(), userId);
8369 }
8370 }
8371 }
8372
8373 _sqlUpdate.update(new Object[] { new Long(userId) });
8374
8375 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
8376 for (com.liferay.portal.model.Permission permission : permissions) {
8377 for (ModelListener<User> listener : listeners) {
8378 listener.onAfterRemoveAssociation(userId,
8379 com.liferay.portal.model.Permission.class.getName(),
8380 permission.getPrimaryKey());
8381 }
8382
8383 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8384 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
8385 User.class.getName(), userId);
8386 }
8387 }
8388 }
8389 }
8390
8391 private SqlUpdate _sqlUpdate;
8392 }
8393
8394 protected class RemovePermission {
8395 protected RemovePermission() {
8396 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8397 "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?",
8398 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8399 }
8400
8401 protected void remove(long userId, long permissionId)
8402 throws SystemException {
8403 if (containsPermission.contains(userId, permissionId)) {
8404 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8405 permissionPersistence.getListeners();
8406
8407 for (ModelListener<User> listener : listeners) {
8408 listener.onBeforeRemoveAssociation(userId,
8409 com.liferay.portal.model.Permission.class.getName(),
8410 permissionId);
8411 }
8412
8413 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8414 listener.onBeforeRemoveAssociation(permissionId,
8415 User.class.getName(), userId);
8416 }
8417
8418 _sqlUpdate.update(new Object[] {
8419 new Long(userId), new Long(permissionId)
8420 });
8421
8422 for (ModelListener<User> listener : listeners) {
8423 listener.onAfterRemoveAssociation(userId,
8424 com.liferay.portal.model.Permission.class.getName(),
8425 permissionId);
8426 }
8427
8428 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8429 listener.onAfterRemoveAssociation(permissionId,
8430 User.class.getName(), userId);
8431 }
8432 }
8433 }
8434
8435 private SqlUpdate _sqlUpdate;
8436 }
8437
8438 protected class ContainsRole {
8439 protected ContainsRole() {
8440 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8441 _SQL_CONTAINSROLE,
8442 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8443 RowMapper.COUNT);
8444 }
8445
8446 protected boolean contains(long userId, long roleId) {
8447 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8448 new Long(userId), new Long(roleId)
8449 });
8450
8451 if (results.size() > 0) {
8452 Integer count = results.get(0);
8453
8454 if (count.intValue() > 0) {
8455 return true;
8456 }
8457 }
8458
8459 return false;
8460 }
8461
8462 private MappingSqlQuery<Integer> _mappingSqlQuery;
8463 }
8464
8465 protected class AddRole {
8466 protected AddRole() {
8467 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8468 "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
8469 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8470 }
8471
8472 protected void add(long userId, long roleId) throws SystemException {
8473 if (!containsRole.contains(userId, roleId)) {
8474 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8475
8476 for (ModelListener<User> listener : listeners) {
8477 listener.onBeforeAddAssociation(userId,
8478 com.liferay.portal.model.Role.class.getName(), roleId);
8479 }
8480
8481 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8482 listener.onBeforeAddAssociation(roleId,
8483 User.class.getName(), userId);
8484 }
8485
8486 _sqlUpdate.update(new Object[] {
8487 new Long(userId), new Long(roleId)
8488 });
8489
8490 for (ModelListener<User> listener : listeners) {
8491 listener.onAfterAddAssociation(userId,
8492 com.liferay.portal.model.Role.class.getName(), roleId);
8493 }
8494
8495 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8496 listener.onAfterAddAssociation(roleId,
8497 User.class.getName(), userId);
8498 }
8499 }
8500 }
8501
8502 private SqlUpdate _sqlUpdate;
8503 }
8504
8505 protected class ClearRoles {
8506 protected ClearRoles() {
8507 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8508 "DELETE FROM Users_Roles WHERE userId = ?",
8509 new int[] { java.sql.Types.BIGINT });
8510 }
8511
8512 protected void clear(long userId) throws SystemException {
8513 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8514
8515 List<com.liferay.portal.model.Role> roles = null;
8516
8517 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8518 roles = getRoles(userId);
8519
8520 for (com.liferay.portal.model.Role role : roles) {
8521 for (ModelListener<User> listener : listeners) {
8522 listener.onBeforeRemoveAssociation(userId,
8523 com.liferay.portal.model.Role.class.getName(),
8524 role.getPrimaryKey());
8525 }
8526
8527 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8528 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
8529 User.class.getName(), userId);
8530 }
8531 }
8532 }
8533
8534 _sqlUpdate.update(new Object[] { new Long(userId) });
8535
8536 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8537 for (com.liferay.portal.model.Role role : roles) {
8538 for (ModelListener<User> listener : listeners) {
8539 listener.onAfterRemoveAssociation(userId,
8540 com.liferay.portal.model.Role.class.getName(),
8541 role.getPrimaryKey());
8542 }
8543
8544 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8545 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
8546 User.class.getName(), userId);
8547 }
8548 }
8549 }
8550 }
8551
8552 private SqlUpdate _sqlUpdate;
8553 }
8554
8555 protected class RemoveRole {
8556 protected RemoveRole() {
8557 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8558 "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
8559 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8560 }
8561
8562 protected void remove(long userId, long roleId)
8563 throws SystemException {
8564 if (containsRole.contains(userId, roleId)) {
8565 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8566
8567 for (ModelListener<User> listener : listeners) {
8568 listener.onBeforeRemoveAssociation(userId,
8569 com.liferay.portal.model.Role.class.getName(), roleId);
8570 }
8571
8572 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8573 listener.onBeforeRemoveAssociation(roleId,
8574 User.class.getName(), userId);
8575 }
8576
8577 _sqlUpdate.update(new Object[] {
8578 new Long(userId), new Long(roleId)
8579 });
8580
8581 for (ModelListener<User> listener : listeners) {
8582 listener.onAfterRemoveAssociation(userId,
8583 com.liferay.portal.model.Role.class.getName(), roleId);
8584 }
8585
8586 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8587 listener.onAfterRemoveAssociation(roleId,
8588 User.class.getName(), userId);
8589 }
8590 }
8591 }
8592
8593 private SqlUpdate _sqlUpdate;
8594 }
8595
8596 protected class ContainsTeam {
8597 protected ContainsTeam() {
8598 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8599 _SQL_CONTAINSTEAM,
8600 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8601 RowMapper.COUNT);
8602 }
8603
8604 protected boolean contains(long userId, long teamId) {
8605 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8606 new Long(userId), new Long(teamId)
8607 });
8608
8609 if (results.size() > 0) {
8610 Integer count = results.get(0);
8611
8612 if (count.intValue() > 0) {
8613 return true;
8614 }
8615 }
8616
8617 return false;
8618 }
8619
8620 private MappingSqlQuery<Integer> _mappingSqlQuery;
8621 }
8622
8623 protected class AddTeam {
8624 protected AddTeam() {
8625 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8626 "INSERT INTO Users_Teams (userId, teamId) VALUES (?, ?)",
8627 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8628 }
8629
8630 protected void add(long userId, long teamId) throws SystemException {
8631 if (!containsTeam.contains(userId, teamId)) {
8632 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8633
8634 for (ModelListener<User> listener : listeners) {
8635 listener.onBeforeAddAssociation(userId,
8636 com.liferay.portal.model.Team.class.getName(), teamId);
8637 }
8638
8639 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8640 listener.onBeforeAddAssociation(teamId,
8641 User.class.getName(), userId);
8642 }
8643
8644 _sqlUpdate.update(new Object[] {
8645 new Long(userId), new Long(teamId)
8646 });
8647
8648 for (ModelListener<User> listener : listeners) {
8649 listener.onAfterAddAssociation(userId,
8650 com.liferay.portal.model.Team.class.getName(), teamId);
8651 }
8652
8653 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8654 listener.onAfterAddAssociation(teamId,
8655 User.class.getName(), userId);
8656 }
8657 }
8658 }
8659
8660 private SqlUpdate _sqlUpdate;
8661 }
8662
8663 protected class ClearTeams {
8664 protected ClearTeams() {
8665 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8666 "DELETE FROM Users_Teams WHERE userId = ?",
8667 new int[] { java.sql.Types.BIGINT });
8668 }
8669
8670 protected void clear(long userId) throws SystemException {
8671 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8672
8673 List<com.liferay.portal.model.Team> teams = null;
8674
8675 if ((listeners.length > 0) || (teamListeners.length > 0)) {
8676 teams = getTeams(userId);
8677
8678 for (com.liferay.portal.model.Team team : teams) {
8679 for (ModelListener<User> listener : listeners) {
8680 listener.onBeforeRemoveAssociation(userId,
8681 com.liferay.portal.model.Team.class.getName(),
8682 team.getPrimaryKey());
8683 }
8684
8685 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8686 listener.onBeforeRemoveAssociation(team.getPrimaryKey(),
8687 User.class.getName(), userId);
8688 }
8689 }
8690 }
8691
8692 _sqlUpdate.update(new Object[] { new Long(userId) });
8693
8694 if ((listeners.length > 0) || (teamListeners.length > 0)) {
8695 for (com.liferay.portal.model.Team team : teams) {
8696 for (ModelListener<User> listener : listeners) {
8697 listener.onAfterRemoveAssociation(userId,
8698 com.liferay.portal.model.Team.class.getName(),
8699 team.getPrimaryKey());
8700 }
8701
8702 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8703 listener.onAfterRemoveAssociation(team.getPrimaryKey(),
8704 User.class.getName(), userId);
8705 }
8706 }
8707 }
8708 }
8709
8710 private SqlUpdate _sqlUpdate;
8711 }
8712
8713 protected class RemoveTeam {
8714 protected RemoveTeam() {
8715 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8716 "DELETE FROM Users_Teams WHERE userId = ? AND teamId = ?",
8717 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8718 }
8719
8720 protected void remove(long userId, long teamId)
8721 throws SystemException {
8722 if (containsTeam.contains(userId, teamId)) {
8723 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8724
8725 for (ModelListener<User> listener : listeners) {
8726 listener.onBeforeRemoveAssociation(userId,
8727 com.liferay.portal.model.Team.class.getName(), teamId);
8728 }
8729
8730 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8731 listener.onBeforeRemoveAssociation(teamId,
8732 User.class.getName(), userId);
8733 }
8734
8735 _sqlUpdate.update(new Object[] {
8736 new Long(userId), new Long(teamId)
8737 });
8738
8739 for (ModelListener<User> listener : listeners) {
8740 listener.onAfterRemoveAssociation(userId,
8741 com.liferay.portal.model.Team.class.getName(), teamId);
8742 }
8743
8744 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8745 listener.onAfterRemoveAssociation(teamId,
8746 User.class.getName(), userId);
8747 }
8748 }
8749 }
8750
8751 private SqlUpdate _sqlUpdate;
8752 }
8753
8754 protected class ContainsUserGroup {
8755 protected ContainsUserGroup() {
8756 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8757 _SQL_CONTAINSUSERGROUP,
8758 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8759 RowMapper.COUNT);
8760 }
8761
8762 protected boolean contains(long userId, long userGroupId) {
8763 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8764 new Long(userId), new Long(userGroupId)
8765 });
8766
8767 if (results.size() > 0) {
8768 Integer count = results.get(0);
8769
8770 if (count.intValue() > 0) {
8771 return true;
8772 }
8773 }
8774
8775 return false;
8776 }
8777
8778 private MappingSqlQuery<Integer> _mappingSqlQuery;
8779 }
8780
8781 protected class AddUserGroup {
8782 protected AddUserGroup() {
8783 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8784 "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
8785 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8786 }
8787
8788 protected void add(long userId, long userGroupId)
8789 throws SystemException {
8790 if (!containsUserGroup.contains(userId, userGroupId)) {
8791 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8792 userGroupPersistence.getListeners();
8793
8794 for (ModelListener<User> listener : listeners) {
8795 listener.onBeforeAddAssociation(userId,
8796 com.liferay.portal.model.UserGroup.class.getName(),
8797 userGroupId);
8798 }
8799
8800 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8801 listener.onBeforeAddAssociation(userGroupId,
8802 User.class.getName(), userId);
8803 }
8804
8805 _sqlUpdate.update(new Object[] {
8806 new Long(userId), new Long(userGroupId)
8807 });
8808
8809 for (ModelListener<User> listener : listeners) {
8810 listener.onAfterAddAssociation(userId,
8811 com.liferay.portal.model.UserGroup.class.getName(),
8812 userGroupId);
8813 }
8814
8815 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8816 listener.onAfterAddAssociation(userGroupId,
8817 User.class.getName(), userId);
8818 }
8819 }
8820 }
8821
8822 private SqlUpdate _sqlUpdate;
8823 }
8824
8825 protected class ClearUserGroups {
8826 protected ClearUserGroups() {
8827 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8828 "DELETE FROM Users_UserGroups WHERE userId = ?",
8829 new int[] { java.sql.Types.BIGINT });
8830 }
8831
8832 protected void clear(long userId) throws SystemException {
8833 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8834 userGroupPersistence.getListeners();
8835
8836 List<com.liferay.portal.model.UserGroup> userGroups = null;
8837
8838 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8839 userGroups = getUserGroups(userId);
8840
8841 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8842 for (ModelListener<User> listener : listeners) {
8843 listener.onBeforeRemoveAssociation(userId,
8844 com.liferay.portal.model.UserGroup.class.getName(),
8845 userGroup.getPrimaryKey());
8846 }
8847
8848 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8849 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
8850 User.class.getName(), userId);
8851 }
8852 }
8853 }
8854
8855 _sqlUpdate.update(new Object[] { new Long(userId) });
8856
8857 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8858 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8859 for (ModelListener<User> listener : listeners) {
8860 listener.onAfterRemoveAssociation(userId,
8861 com.liferay.portal.model.UserGroup.class.getName(),
8862 userGroup.getPrimaryKey());
8863 }
8864
8865 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8866 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
8867 User.class.getName(), userId);
8868 }
8869 }
8870 }
8871 }
8872
8873 private SqlUpdate _sqlUpdate;
8874 }
8875
8876 protected class RemoveUserGroup {
8877 protected RemoveUserGroup() {
8878 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8879 "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
8880 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8881 }
8882
8883 protected void remove(long userId, long userGroupId)
8884 throws SystemException {
8885 if (containsUserGroup.contains(userId, userGroupId)) {
8886 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8887 userGroupPersistence.getListeners();
8888
8889 for (ModelListener<User> listener : listeners) {
8890 listener.onBeforeRemoveAssociation(userId,
8891 com.liferay.portal.model.UserGroup.class.getName(),
8892 userGroupId);
8893 }
8894
8895 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8896 listener.onBeforeRemoveAssociation(userGroupId,
8897 User.class.getName(), userId);
8898 }
8899
8900 _sqlUpdate.update(new Object[] {
8901 new Long(userId), new Long(userGroupId)
8902 });
8903
8904 for (ModelListener<User> listener : listeners) {
8905 listener.onAfterRemoveAssociation(userId,
8906 com.liferay.portal.model.UserGroup.class.getName(),
8907 userGroupId);
8908 }
8909
8910 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8911 listener.onAfterRemoveAssociation(userGroupId,
8912 User.class.getName(), userId);
8913 }
8914 }
8915 }
8916
8917 private SqlUpdate _sqlUpdate;
8918 }
8919
8920 private static final String _SQL_SELECT_USER = "SELECT user FROM User user";
8921 private static final String _SQL_SELECT_USER_WHERE = "SELECT user FROM User user WHERE ";
8922 private static final String _SQL_COUNT_USER = "SELECT COUNT(user) FROM User user";
8923 private static final String _SQL_COUNT_USER_WHERE = "SELECT COUNT(user) FROM User user WHERE ";
8924 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
8925 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
8926 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
8927 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
8928 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
8929 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
8930 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
8931 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
8932 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
8933 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
8934 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
8935 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
8936 private static final String _SQL_GETTEAMS = "SELECT {Team.*} FROM Team INNER JOIN Users_Teams ON (Users_Teams.teamId = Team.teamId) WHERE (Users_Teams.userId = ?)";
8937 private static final String _SQL_GETTEAMSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ?";
8938 private static final String _SQL_CONTAINSTEAM = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ? AND teamId = ?";
8939 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
8940 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
8941 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
8942 private static final String _FINDER_COLUMN_UUID_UUID_1 = "user.uuid IS NULL";
8943 private static final String _FINDER_COLUMN_UUID_UUID_2 = "user.uuid = ?";
8944 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(user.uuid IS NULL OR user.uuid = ?)";
8945 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "user.companyId = ?";
8946 private static final String _FINDER_COLUMN_CONTACTID_CONTACTID_2 = "user.contactId = ?";
8947 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1 = "user.emailAddress IS NULL";
8948 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2 = "user.emailAddress = ?";
8949 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
8950 private static final String _FINDER_COLUMN_PORTRAITID_PORTRAITID_2 = "user.portraitId = ?";
8951 private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "user.companyId = ? AND ";
8952 private static final String _FINDER_COLUMN_C_U_USERID_2 = "user.userId = ?";
8953 private static final String _FINDER_COLUMN_C_DU_COMPANYID_2 = "user.companyId = ? AND ";
8954 private static final String _FINDER_COLUMN_C_DU_DEFAULTUSER_2 = "user.defaultUser = ?";
8955 private static final String _FINDER_COLUMN_C_SN_COMPANYID_2 = "user.companyId = ? AND ";
8956 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_1 = "user.screenName IS NULL";
8957 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_2 = "user.screenName = ?";
8958 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_3 = "(user.screenName IS NULL OR user.screenName = ?)";
8959 private static final String _FINDER_COLUMN_C_EA_COMPANYID_2 = "user.companyId = ? AND ";
8960 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_1 = "user.emailAddress IS NULL";
8961 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_2 = "user.emailAddress = ?";
8962 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
8963 private static final String _FINDER_COLUMN_C_FID_COMPANYID_2 = "user.companyId = ? AND ";
8964 private static final String _FINDER_COLUMN_C_FID_FACEBOOKID_2 = "user.facebookId = ?";
8965 private static final String _FINDER_COLUMN_C_O_COMPANYID_2 = "user.companyId = ? AND ";
8966 private static final String _FINDER_COLUMN_C_O_OPENID_1 = "user.openId IS NULL";
8967 private static final String _FINDER_COLUMN_C_O_OPENID_2 = "user.openId = ?";
8968 private static final String _FINDER_COLUMN_C_O_OPENID_3 = "(user.openId IS NULL OR user.openId = ?)";
8969 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "user.companyId = ? AND ";
8970 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "user.status = ?";
8971 private static final String _ORDER_BY_ENTITY_ALIAS = "user.";
8972 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No User exists with the primary key ";
8973 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No User exists with the key {";
8974 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8975 private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
8976 private static User _nullUser = new UserImpl() {
8977 @Override
8978 public Object clone() {
8979 return this;
8980 }
8981
8982 @Override
8983 public CacheModel<User> toCacheModel() {
8984 return _nullUserCacheModel;
8985 }
8986 };
8987
8988 private static CacheModel<User> _nullUserCacheModel = new CacheModel<User>() {
8989 public User toEntityModel() {
8990 return _nullUser;
8991 }
8992 };
8993 }