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_WITHOUT_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_WITH_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 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
743 args);
744
745 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
746 new Object[] { Long.valueOf(user.getContactId()) }, user);
747 }
748
749 if ((userModelImpl.getColumnBitmask() &
750 FINDER_PATH_FETCH_BY_PORTRAITID.getColumnBitmask()) != 0) {
751 Object[] args = new Object[] {
752 Long.valueOf(userModelImpl.getOriginalPortraitId())
753 };
754
755 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_PORTRAITID,
756 args);
757 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
758 args);
759
760 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
761 new Object[] { Long.valueOf(user.getPortraitId()) }, user);
762 }
763
764 if ((userModelImpl.getColumnBitmask() &
765 FINDER_PATH_FETCH_BY_C_U.getColumnBitmask()) != 0) {
766 Object[] args = new Object[] {
767 Long.valueOf(userModelImpl.getOriginalCompanyId()),
768 Long.valueOf(userModelImpl.getOriginalUserId())
769 };
770
771 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U, args);
772 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U, args);
773
774 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
775 new Object[] {
776 Long.valueOf(user.getCompanyId()),
777 Long.valueOf(user.getUserId())
778 }, user);
779 }
780
781 if ((userModelImpl.getColumnBitmask() &
782 FINDER_PATH_FETCH_BY_C_DU.getColumnBitmask()) != 0) {
783 Object[] args = new Object[] {
784 Long.valueOf(userModelImpl.getOriginalCompanyId()),
785 Boolean.valueOf(userModelImpl.getOriginalDefaultUser())
786 };
787
788 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_DU, args);
789 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU, args);
790
791 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
792 new Object[] {
793 Long.valueOf(user.getCompanyId()),
794 Boolean.valueOf(user.getDefaultUser())
795 }, user);
796 }
797
798 if ((userModelImpl.getColumnBitmask() &
799 FINDER_PATH_FETCH_BY_C_SN.getColumnBitmask()) != 0) {
800 Object[] args = new Object[] {
801 Long.valueOf(userModelImpl.getOriginalCompanyId()),
802
803 userModelImpl.getOriginalScreenName()
804 };
805
806 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_SN, args);
807 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN, args);
808
809 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
810 new Object[] {
811 Long.valueOf(user.getCompanyId()),
812
813 user.getScreenName()
814 }, user);
815 }
816
817 if ((userModelImpl.getColumnBitmask() &
818 FINDER_PATH_FETCH_BY_C_EA.getColumnBitmask()) != 0) {
819 Object[] args = new Object[] {
820 Long.valueOf(userModelImpl.getOriginalCompanyId()),
821
822 userModelImpl.getOriginalEmailAddress()
823 };
824
825 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_EA, args);
826 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA, args);
827
828 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
829 new Object[] {
830 Long.valueOf(user.getCompanyId()),
831
832 user.getEmailAddress()
833 }, user);
834 }
835
836 if ((userModelImpl.getColumnBitmask() &
837 FINDER_PATH_FETCH_BY_C_FID.getColumnBitmask()) != 0) {
838 Object[] args = new Object[] {
839 Long.valueOf(userModelImpl.getOriginalCompanyId()),
840 Long.valueOf(userModelImpl.getOriginalFacebookId())
841 };
842
843 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_FID, args);
844 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID, args);
845
846 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
847 new Object[] {
848 Long.valueOf(user.getCompanyId()),
849 Long.valueOf(user.getFacebookId())
850 }, user);
851 }
852
853 if ((userModelImpl.getColumnBitmask() &
854 FINDER_PATH_FETCH_BY_C_O.getColumnBitmask()) != 0) {
855 Object[] args = new Object[] {
856 Long.valueOf(userModelImpl.getOriginalCompanyId()),
857
858 userModelImpl.getOriginalOpenId()
859 };
860
861 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_O, args);
862 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O, args);
863
864 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
865 new Object[] {
866 Long.valueOf(user.getCompanyId()),
867
868 user.getOpenId()
869 }, user);
870 }
871 }
872
873 return user;
874 }
875
876 protected User toUnwrappedModel(User user) {
877 if (user instanceof UserImpl) {
878 return user;
879 }
880
881 UserImpl userImpl = new UserImpl();
882
883 userImpl.setNew(user.isNew());
884 userImpl.setPrimaryKey(user.getPrimaryKey());
885
886 userImpl.setUuid(user.getUuid());
887 userImpl.setUserId(user.getUserId());
888 userImpl.setCompanyId(user.getCompanyId());
889 userImpl.setCreateDate(user.getCreateDate());
890 userImpl.setModifiedDate(user.getModifiedDate());
891 userImpl.setDefaultUser(user.isDefaultUser());
892 userImpl.setContactId(user.getContactId());
893 userImpl.setPassword(user.getPassword());
894 userImpl.setPasswordEncrypted(user.isPasswordEncrypted());
895 userImpl.setPasswordReset(user.isPasswordReset());
896 userImpl.setPasswordModifiedDate(user.getPasswordModifiedDate());
897 userImpl.setDigest(user.getDigest());
898 userImpl.setReminderQueryQuestion(user.getReminderQueryQuestion());
899 userImpl.setReminderQueryAnswer(user.getReminderQueryAnswer());
900 userImpl.setGraceLoginCount(user.getGraceLoginCount());
901 userImpl.setScreenName(user.getScreenName());
902 userImpl.setEmailAddress(user.getEmailAddress());
903 userImpl.setFacebookId(user.getFacebookId());
904 userImpl.setOpenId(user.getOpenId());
905 userImpl.setPortraitId(user.getPortraitId());
906 userImpl.setLanguageId(user.getLanguageId());
907 userImpl.setTimeZoneId(user.getTimeZoneId());
908 userImpl.setGreeting(user.getGreeting());
909 userImpl.setComments(user.getComments());
910 userImpl.setFirstName(user.getFirstName());
911 userImpl.setMiddleName(user.getMiddleName());
912 userImpl.setLastName(user.getLastName());
913 userImpl.setJobTitle(user.getJobTitle());
914 userImpl.setLoginDate(user.getLoginDate());
915 userImpl.setLoginIP(user.getLoginIP());
916 userImpl.setLastLoginDate(user.getLastLoginDate());
917 userImpl.setLastLoginIP(user.getLastLoginIP());
918 userImpl.setLastFailedLoginDate(user.getLastFailedLoginDate());
919 userImpl.setFailedLoginAttempts(user.getFailedLoginAttempts());
920 userImpl.setLockout(user.isLockout());
921 userImpl.setLockoutDate(user.getLockoutDate());
922 userImpl.setAgreedToTermsOfUse(user.isAgreedToTermsOfUse());
923 userImpl.setEmailAddressVerified(user.isEmailAddressVerified());
924 userImpl.setStatus(user.getStatus());
925
926 return userImpl;
927 }
928
929
937 @Override
938 public User findByPrimaryKey(Serializable primaryKey)
939 throws NoSuchModelException, SystemException {
940 return findByPrimaryKey(((Long)primaryKey).longValue());
941 }
942
943
951 public User findByPrimaryKey(long userId)
952 throws NoSuchUserException, SystemException {
953 User user = fetchByPrimaryKey(userId);
954
955 if (user == null) {
956 if (_log.isWarnEnabled()) {
957 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + userId);
958 }
959
960 throw new NoSuchUserException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
961 userId);
962 }
963
964 return user;
965 }
966
967
974 @Override
975 public User fetchByPrimaryKey(Serializable primaryKey)
976 throws SystemException {
977 return fetchByPrimaryKey(((Long)primaryKey).longValue());
978 }
979
980
987 public User fetchByPrimaryKey(long userId) throws SystemException {
988 User user = (User)EntityCacheUtil.getResult(UserModelImpl.ENTITY_CACHE_ENABLED,
989 UserImpl.class, userId);
990
991 if (user == _nullUser) {
992 return null;
993 }
994
995 if (user == null) {
996 Session session = null;
997
998 boolean hasException = false;
999
1000 try {
1001 session = openSession();
1002
1003 user = (User)session.get(UserImpl.class, Long.valueOf(userId));
1004 }
1005 catch (Exception e) {
1006 hasException = true;
1007
1008 throw processException(e);
1009 }
1010 finally {
1011 if (user != null) {
1012 cacheResult(user);
1013 }
1014 else if (!hasException) {
1015 EntityCacheUtil.putResult(UserModelImpl.ENTITY_CACHE_ENABLED,
1016 UserImpl.class, userId, _nullUser);
1017 }
1018
1019 closeSession(session);
1020 }
1021 }
1022
1023 return user;
1024 }
1025
1026
1033 public List<User> findByUuid(String uuid) throws SystemException {
1034 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1035 }
1036
1037
1050 public List<User> findByUuid(String uuid, int start, int end)
1051 throws SystemException {
1052 return findByUuid(uuid, start, end, null);
1053 }
1054
1055
1069 public List<User> findByUuid(String uuid, int start, int end,
1070 OrderByComparator orderByComparator) throws SystemException {
1071 FinderPath finderPath = null;
1072 Object[] finderArgs = null;
1073
1074 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1075 (orderByComparator == null)) {
1076 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
1077 finderArgs = new Object[] { uuid };
1078 }
1079 else {
1080 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
1081 finderArgs = new Object[] { uuid, start, end, orderByComparator };
1082 }
1083
1084 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1085 finderArgs, this);
1086
1087 if (list == null) {
1088 StringBundler query = null;
1089
1090 if (orderByComparator != null) {
1091 query = new StringBundler(3 +
1092 (orderByComparator.getOrderByFields().length * 3));
1093 }
1094 else {
1095 query = new StringBundler(2);
1096 }
1097
1098 query.append(_SQL_SELECT_USER_WHERE);
1099
1100 if (uuid == null) {
1101 query.append(_FINDER_COLUMN_UUID_UUID_1);
1102 }
1103 else {
1104 if (uuid.equals(StringPool.BLANK)) {
1105 query.append(_FINDER_COLUMN_UUID_UUID_3);
1106 }
1107 else {
1108 query.append(_FINDER_COLUMN_UUID_UUID_2);
1109 }
1110 }
1111
1112 if (orderByComparator != null) {
1113 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1114 orderByComparator);
1115 }
1116
1117 String sql = query.toString();
1118
1119 Session session = null;
1120
1121 try {
1122 session = openSession();
1123
1124 Query q = session.createQuery(sql);
1125
1126 QueryPos qPos = QueryPos.getInstance(q);
1127
1128 if (uuid != null) {
1129 qPos.add(uuid);
1130 }
1131
1132 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1133 }
1134 catch (Exception e) {
1135 throw processException(e);
1136 }
1137 finally {
1138 if (list == null) {
1139 FinderCacheUtil.removeResult(finderPath, finderArgs);
1140 }
1141 else {
1142 cacheResult(list);
1143
1144 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1145 }
1146
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154
1167 public User findByUuid_First(String uuid,
1168 OrderByComparator orderByComparator)
1169 throws NoSuchUserException, SystemException {
1170 List<User> list = findByUuid(uuid, 0, 1, orderByComparator);
1171
1172 if (list.isEmpty()) {
1173 StringBundler msg = new StringBundler(4);
1174
1175 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1176
1177 msg.append("uuid=");
1178 msg.append(uuid);
1179
1180 msg.append(StringPool.CLOSE_CURLY_BRACE);
1181
1182 throw new NoSuchUserException(msg.toString());
1183 }
1184 else {
1185 return list.get(0);
1186 }
1187 }
1188
1189
1202 public User findByUuid_Last(String uuid, OrderByComparator orderByComparator)
1203 throws NoSuchUserException, SystemException {
1204 int count = countByUuid(uuid);
1205
1206 List<User> list = findByUuid(uuid, count - 1, count, orderByComparator);
1207
1208 if (list.isEmpty()) {
1209 StringBundler msg = new StringBundler(4);
1210
1211 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1212
1213 msg.append("uuid=");
1214 msg.append(uuid);
1215
1216 msg.append(StringPool.CLOSE_CURLY_BRACE);
1217
1218 throw new NoSuchUserException(msg.toString());
1219 }
1220 else {
1221 return list.get(0);
1222 }
1223 }
1224
1225
1239 public User[] findByUuid_PrevAndNext(long userId, String uuid,
1240 OrderByComparator orderByComparator)
1241 throws NoSuchUserException, SystemException {
1242 User user = findByPrimaryKey(userId);
1243
1244 Session session = null;
1245
1246 try {
1247 session = openSession();
1248
1249 User[] array = new UserImpl[3];
1250
1251 array[0] = getByUuid_PrevAndNext(session, user, uuid,
1252 orderByComparator, true);
1253
1254 array[1] = user;
1255
1256 array[2] = getByUuid_PrevAndNext(session, user, uuid,
1257 orderByComparator, false);
1258
1259 return array;
1260 }
1261 catch (Exception e) {
1262 throw processException(e);
1263 }
1264 finally {
1265 closeSession(session);
1266 }
1267 }
1268
1269 protected User getByUuid_PrevAndNext(Session session, User user,
1270 String uuid, OrderByComparator orderByComparator, boolean previous) {
1271 StringBundler query = null;
1272
1273 if (orderByComparator != null) {
1274 query = new StringBundler(6 +
1275 (orderByComparator.getOrderByFields().length * 6));
1276 }
1277 else {
1278 query = new StringBundler(3);
1279 }
1280
1281 query.append(_SQL_SELECT_USER_WHERE);
1282
1283 if (uuid == null) {
1284 query.append(_FINDER_COLUMN_UUID_UUID_1);
1285 }
1286 else {
1287 if (uuid.equals(StringPool.BLANK)) {
1288 query.append(_FINDER_COLUMN_UUID_UUID_3);
1289 }
1290 else {
1291 query.append(_FINDER_COLUMN_UUID_UUID_2);
1292 }
1293 }
1294
1295 if (orderByComparator != null) {
1296 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1297
1298 if (orderByConditionFields.length > 0) {
1299 query.append(WHERE_AND);
1300 }
1301
1302 for (int i = 0; i < orderByConditionFields.length; i++) {
1303 query.append(_ORDER_BY_ENTITY_ALIAS);
1304 query.append(orderByConditionFields[i]);
1305
1306 if ((i + 1) < orderByConditionFields.length) {
1307 if (orderByComparator.isAscending() ^ previous) {
1308 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1309 }
1310 else {
1311 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1312 }
1313 }
1314 else {
1315 if (orderByComparator.isAscending() ^ previous) {
1316 query.append(WHERE_GREATER_THAN);
1317 }
1318 else {
1319 query.append(WHERE_LESSER_THAN);
1320 }
1321 }
1322 }
1323
1324 query.append(ORDER_BY_CLAUSE);
1325
1326 String[] orderByFields = orderByComparator.getOrderByFields();
1327
1328 for (int i = 0; i < orderByFields.length; i++) {
1329 query.append(_ORDER_BY_ENTITY_ALIAS);
1330 query.append(orderByFields[i]);
1331
1332 if ((i + 1) < orderByFields.length) {
1333 if (orderByComparator.isAscending() ^ previous) {
1334 query.append(ORDER_BY_ASC_HAS_NEXT);
1335 }
1336 else {
1337 query.append(ORDER_BY_DESC_HAS_NEXT);
1338 }
1339 }
1340 else {
1341 if (orderByComparator.isAscending() ^ previous) {
1342 query.append(ORDER_BY_ASC);
1343 }
1344 else {
1345 query.append(ORDER_BY_DESC);
1346 }
1347 }
1348 }
1349 }
1350
1351 String sql = query.toString();
1352
1353 Query q = session.createQuery(sql);
1354
1355 q.setFirstResult(0);
1356 q.setMaxResults(2);
1357
1358 QueryPos qPos = QueryPos.getInstance(q);
1359
1360 if (uuid != null) {
1361 qPos.add(uuid);
1362 }
1363
1364 if (orderByComparator != null) {
1365 Object[] values = orderByComparator.getOrderByConditionValues(user);
1366
1367 for (Object value : values) {
1368 qPos.add(value);
1369 }
1370 }
1371
1372 List<User> list = q.list();
1373
1374 if (list.size() == 2) {
1375 return list.get(1);
1376 }
1377 else {
1378 return null;
1379 }
1380 }
1381
1382
1389 public List<User> findByCompanyId(long companyId) throws SystemException {
1390 return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1391 null);
1392 }
1393
1394
1407 public List<User> findByCompanyId(long companyId, int start, int end)
1408 throws SystemException {
1409 return findByCompanyId(companyId, start, end, null);
1410 }
1411
1412
1426 public List<User> findByCompanyId(long companyId, int start, int end,
1427 OrderByComparator orderByComparator) throws SystemException {
1428 FinderPath finderPath = null;
1429 Object[] finderArgs = null;
1430
1431 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1432 (orderByComparator == null)) {
1433 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
1434 finderArgs = new Object[] { companyId };
1435 }
1436 else {
1437 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
1438 finderArgs = new Object[] { companyId, start, end, orderByComparator };
1439 }
1440
1441 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1442 finderArgs, this);
1443
1444 if (list == null) {
1445 StringBundler query = null;
1446
1447 if (orderByComparator != null) {
1448 query = new StringBundler(3 +
1449 (orderByComparator.getOrderByFields().length * 3));
1450 }
1451 else {
1452 query = new StringBundler(2);
1453 }
1454
1455 query.append(_SQL_SELECT_USER_WHERE);
1456
1457 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1458
1459 if (orderByComparator != null) {
1460 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1461 orderByComparator);
1462 }
1463
1464 String sql = query.toString();
1465
1466 Session session = null;
1467
1468 try {
1469 session = openSession();
1470
1471 Query q = session.createQuery(sql);
1472
1473 QueryPos qPos = QueryPos.getInstance(q);
1474
1475 qPos.add(companyId);
1476
1477 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1478 }
1479 catch (Exception e) {
1480 throw processException(e);
1481 }
1482 finally {
1483 if (list == null) {
1484 FinderCacheUtil.removeResult(finderPath, finderArgs);
1485 }
1486 else {
1487 cacheResult(list);
1488
1489 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1490 }
1491
1492 closeSession(session);
1493 }
1494 }
1495
1496 return list;
1497 }
1498
1499
1512 public User findByCompanyId_First(long companyId,
1513 OrderByComparator orderByComparator)
1514 throws NoSuchUserException, SystemException {
1515 List<User> list = findByCompanyId(companyId, 0, 1, orderByComparator);
1516
1517 if (list.isEmpty()) {
1518 StringBundler msg = new StringBundler(4);
1519
1520 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1521
1522 msg.append("companyId=");
1523 msg.append(companyId);
1524
1525 msg.append(StringPool.CLOSE_CURLY_BRACE);
1526
1527 throw new NoSuchUserException(msg.toString());
1528 }
1529 else {
1530 return list.get(0);
1531 }
1532 }
1533
1534
1547 public User findByCompanyId_Last(long companyId,
1548 OrderByComparator orderByComparator)
1549 throws NoSuchUserException, SystemException {
1550 int count = countByCompanyId(companyId);
1551
1552 List<User> list = findByCompanyId(companyId, count - 1, count,
1553 orderByComparator);
1554
1555 if (list.isEmpty()) {
1556 StringBundler msg = new StringBundler(4);
1557
1558 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1559
1560 msg.append("companyId=");
1561 msg.append(companyId);
1562
1563 msg.append(StringPool.CLOSE_CURLY_BRACE);
1564
1565 throw new NoSuchUserException(msg.toString());
1566 }
1567 else {
1568 return list.get(0);
1569 }
1570 }
1571
1572
1586 public User[] findByCompanyId_PrevAndNext(long userId, long companyId,
1587 OrderByComparator orderByComparator)
1588 throws NoSuchUserException, SystemException {
1589 User user = findByPrimaryKey(userId);
1590
1591 Session session = null;
1592
1593 try {
1594 session = openSession();
1595
1596 User[] array = new UserImpl[3];
1597
1598 array[0] = getByCompanyId_PrevAndNext(session, user, companyId,
1599 orderByComparator, true);
1600
1601 array[1] = user;
1602
1603 array[2] = getByCompanyId_PrevAndNext(session, user, companyId,
1604 orderByComparator, false);
1605
1606 return array;
1607 }
1608 catch (Exception e) {
1609 throw processException(e);
1610 }
1611 finally {
1612 closeSession(session);
1613 }
1614 }
1615
1616 protected User getByCompanyId_PrevAndNext(Session session, User user,
1617 long companyId, OrderByComparator orderByComparator, boolean previous) {
1618 StringBundler query = null;
1619
1620 if (orderByComparator != null) {
1621 query = new StringBundler(6 +
1622 (orderByComparator.getOrderByFields().length * 6));
1623 }
1624 else {
1625 query = new StringBundler(3);
1626 }
1627
1628 query.append(_SQL_SELECT_USER_WHERE);
1629
1630 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1631
1632 if (orderByComparator != null) {
1633 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1634
1635 if (orderByConditionFields.length > 0) {
1636 query.append(WHERE_AND);
1637 }
1638
1639 for (int i = 0; i < orderByConditionFields.length; i++) {
1640 query.append(_ORDER_BY_ENTITY_ALIAS);
1641 query.append(orderByConditionFields[i]);
1642
1643 if ((i + 1) < orderByConditionFields.length) {
1644 if (orderByComparator.isAscending() ^ previous) {
1645 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1646 }
1647 else {
1648 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1649 }
1650 }
1651 else {
1652 if (orderByComparator.isAscending() ^ previous) {
1653 query.append(WHERE_GREATER_THAN);
1654 }
1655 else {
1656 query.append(WHERE_LESSER_THAN);
1657 }
1658 }
1659 }
1660
1661 query.append(ORDER_BY_CLAUSE);
1662
1663 String[] orderByFields = orderByComparator.getOrderByFields();
1664
1665 for (int i = 0; i < orderByFields.length; i++) {
1666 query.append(_ORDER_BY_ENTITY_ALIAS);
1667 query.append(orderByFields[i]);
1668
1669 if ((i + 1) < orderByFields.length) {
1670 if (orderByComparator.isAscending() ^ previous) {
1671 query.append(ORDER_BY_ASC_HAS_NEXT);
1672 }
1673 else {
1674 query.append(ORDER_BY_DESC_HAS_NEXT);
1675 }
1676 }
1677 else {
1678 if (orderByComparator.isAscending() ^ previous) {
1679 query.append(ORDER_BY_ASC);
1680 }
1681 else {
1682 query.append(ORDER_BY_DESC);
1683 }
1684 }
1685 }
1686 }
1687
1688 String sql = query.toString();
1689
1690 Query q = session.createQuery(sql);
1691
1692 q.setFirstResult(0);
1693 q.setMaxResults(2);
1694
1695 QueryPos qPos = QueryPos.getInstance(q);
1696
1697 qPos.add(companyId);
1698
1699 if (orderByComparator != null) {
1700 Object[] values = orderByComparator.getOrderByConditionValues(user);
1701
1702 for (Object value : values) {
1703 qPos.add(value);
1704 }
1705 }
1706
1707 List<User> list = q.list();
1708
1709 if (list.size() == 2) {
1710 return list.get(1);
1711 }
1712 else {
1713 return null;
1714 }
1715 }
1716
1717
1725 public User findByContactId(long contactId)
1726 throws NoSuchUserException, SystemException {
1727 User user = fetchByContactId(contactId);
1728
1729 if (user == null) {
1730 StringBundler msg = new StringBundler(4);
1731
1732 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1733
1734 msg.append("contactId=");
1735 msg.append(contactId);
1736
1737 msg.append(StringPool.CLOSE_CURLY_BRACE);
1738
1739 if (_log.isWarnEnabled()) {
1740 _log.warn(msg.toString());
1741 }
1742
1743 throw new NoSuchUserException(msg.toString());
1744 }
1745
1746 return user;
1747 }
1748
1749
1756 public User fetchByContactId(long contactId) throws SystemException {
1757 return fetchByContactId(contactId, true);
1758 }
1759
1760
1768 public User fetchByContactId(long contactId, boolean retrieveFromCache)
1769 throws SystemException {
1770 Object[] finderArgs = new Object[] { contactId };
1771
1772 Object result = null;
1773
1774 if (retrieveFromCache) {
1775 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_CONTACTID,
1776 finderArgs, this);
1777 }
1778
1779 if (result == null) {
1780 StringBundler query = new StringBundler(2);
1781
1782 query.append(_SQL_SELECT_USER_WHERE);
1783
1784 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
1785
1786 String sql = query.toString();
1787
1788 Session session = null;
1789
1790 try {
1791 session = openSession();
1792
1793 Query q = session.createQuery(sql);
1794
1795 QueryPos qPos = QueryPos.getInstance(q);
1796
1797 qPos.add(contactId);
1798
1799 List<User> list = q.list();
1800
1801 result = list;
1802
1803 User user = null;
1804
1805 if (list.isEmpty()) {
1806 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1807 finderArgs, list);
1808 }
1809 else {
1810 user = list.get(0);
1811
1812 cacheResult(user);
1813
1814 if ((user.getContactId() != contactId)) {
1815 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_CONTACTID,
1816 finderArgs, user);
1817 }
1818 }
1819
1820 return user;
1821 }
1822 catch (Exception e) {
1823 throw processException(e);
1824 }
1825 finally {
1826 if (result == null) {
1827 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_CONTACTID,
1828 finderArgs);
1829 }
1830
1831 closeSession(session);
1832 }
1833 }
1834 else {
1835 if (result instanceof List<?>) {
1836 return null;
1837 }
1838 else {
1839 return (User)result;
1840 }
1841 }
1842 }
1843
1844
1851 public List<User> findByEmailAddress(String emailAddress)
1852 throws SystemException {
1853 return findByEmailAddress(emailAddress, QueryUtil.ALL_POS,
1854 QueryUtil.ALL_POS, null);
1855 }
1856
1857
1870 public List<User> findByEmailAddress(String emailAddress, int start, int end)
1871 throws SystemException {
1872 return findByEmailAddress(emailAddress, start, end, null);
1873 }
1874
1875
1889 public List<User> findByEmailAddress(String emailAddress, int start,
1890 int end, OrderByComparator orderByComparator) throws SystemException {
1891 FinderPath finderPath = null;
1892 Object[] finderArgs = null;
1893
1894 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1895 (orderByComparator == null)) {
1896 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_EMAILADDRESS;
1897 finderArgs = new Object[] { emailAddress };
1898 }
1899 else {
1900 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_EMAILADDRESS;
1901 finderArgs = new Object[] {
1902 emailAddress,
1903
1904 start, end, orderByComparator
1905 };
1906 }
1907
1908 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
1909 finderArgs, this);
1910
1911 if (list == null) {
1912 StringBundler query = null;
1913
1914 if (orderByComparator != null) {
1915 query = new StringBundler(3 +
1916 (orderByComparator.getOrderByFields().length * 3));
1917 }
1918 else {
1919 query = new StringBundler(2);
1920 }
1921
1922 query.append(_SQL_SELECT_USER_WHERE);
1923
1924 if (emailAddress == null) {
1925 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
1926 }
1927 else {
1928 if (emailAddress.equals(StringPool.BLANK)) {
1929 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
1930 }
1931 else {
1932 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
1933 }
1934 }
1935
1936 if (orderByComparator != null) {
1937 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1938 orderByComparator);
1939 }
1940
1941 String sql = query.toString();
1942
1943 Session session = null;
1944
1945 try {
1946 session = openSession();
1947
1948 Query q = session.createQuery(sql);
1949
1950 QueryPos qPos = QueryPos.getInstance(q);
1951
1952 if (emailAddress != null) {
1953 qPos.add(emailAddress);
1954 }
1955
1956 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
1957 }
1958 catch (Exception e) {
1959 throw processException(e);
1960 }
1961 finally {
1962 if (list == null) {
1963 FinderCacheUtil.removeResult(finderPath, finderArgs);
1964 }
1965 else {
1966 cacheResult(list);
1967
1968 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1969 }
1970
1971 closeSession(session);
1972 }
1973 }
1974
1975 return list;
1976 }
1977
1978
1991 public User findByEmailAddress_First(String emailAddress,
1992 OrderByComparator orderByComparator)
1993 throws NoSuchUserException, SystemException {
1994 List<User> list = findByEmailAddress(emailAddress, 0, 1,
1995 orderByComparator);
1996
1997 if (list.isEmpty()) {
1998 StringBundler msg = new StringBundler(4);
1999
2000 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2001
2002 msg.append("emailAddress=");
2003 msg.append(emailAddress);
2004
2005 msg.append(StringPool.CLOSE_CURLY_BRACE);
2006
2007 throw new NoSuchUserException(msg.toString());
2008 }
2009 else {
2010 return list.get(0);
2011 }
2012 }
2013
2014
2027 public User findByEmailAddress_Last(String emailAddress,
2028 OrderByComparator orderByComparator)
2029 throws NoSuchUserException, SystemException {
2030 int count = countByEmailAddress(emailAddress);
2031
2032 List<User> list = findByEmailAddress(emailAddress, count - 1, count,
2033 orderByComparator);
2034
2035 if (list.isEmpty()) {
2036 StringBundler msg = new StringBundler(4);
2037
2038 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2039
2040 msg.append("emailAddress=");
2041 msg.append(emailAddress);
2042
2043 msg.append(StringPool.CLOSE_CURLY_BRACE);
2044
2045 throw new NoSuchUserException(msg.toString());
2046 }
2047 else {
2048 return list.get(0);
2049 }
2050 }
2051
2052
2066 public User[] findByEmailAddress_PrevAndNext(long userId,
2067 String emailAddress, OrderByComparator orderByComparator)
2068 throws NoSuchUserException, SystemException {
2069 User user = findByPrimaryKey(userId);
2070
2071 Session session = null;
2072
2073 try {
2074 session = openSession();
2075
2076 User[] array = new UserImpl[3];
2077
2078 array[0] = getByEmailAddress_PrevAndNext(session, user,
2079 emailAddress, orderByComparator, true);
2080
2081 array[1] = user;
2082
2083 array[2] = getByEmailAddress_PrevAndNext(session, user,
2084 emailAddress, orderByComparator, false);
2085
2086 return array;
2087 }
2088 catch (Exception e) {
2089 throw processException(e);
2090 }
2091 finally {
2092 closeSession(session);
2093 }
2094 }
2095
2096 protected User getByEmailAddress_PrevAndNext(Session session, User user,
2097 String emailAddress, OrderByComparator orderByComparator,
2098 boolean previous) {
2099 StringBundler query = null;
2100
2101 if (orderByComparator != null) {
2102 query = new StringBundler(6 +
2103 (orderByComparator.getOrderByFields().length * 6));
2104 }
2105 else {
2106 query = new StringBundler(3);
2107 }
2108
2109 query.append(_SQL_SELECT_USER_WHERE);
2110
2111 if (emailAddress == null) {
2112 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
2113 }
2114 else {
2115 if (emailAddress.equals(StringPool.BLANK)) {
2116 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
2117 }
2118 else {
2119 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
2120 }
2121 }
2122
2123 if (orderByComparator != null) {
2124 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2125
2126 if (orderByConditionFields.length > 0) {
2127 query.append(WHERE_AND);
2128 }
2129
2130 for (int i = 0; i < orderByConditionFields.length; i++) {
2131 query.append(_ORDER_BY_ENTITY_ALIAS);
2132 query.append(orderByConditionFields[i]);
2133
2134 if ((i + 1) < orderByConditionFields.length) {
2135 if (orderByComparator.isAscending() ^ previous) {
2136 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2137 }
2138 else {
2139 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2140 }
2141 }
2142 else {
2143 if (orderByComparator.isAscending() ^ previous) {
2144 query.append(WHERE_GREATER_THAN);
2145 }
2146 else {
2147 query.append(WHERE_LESSER_THAN);
2148 }
2149 }
2150 }
2151
2152 query.append(ORDER_BY_CLAUSE);
2153
2154 String[] orderByFields = orderByComparator.getOrderByFields();
2155
2156 for (int i = 0; i < orderByFields.length; i++) {
2157 query.append(_ORDER_BY_ENTITY_ALIAS);
2158 query.append(orderByFields[i]);
2159
2160 if ((i + 1) < orderByFields.length) {
2161 if (orderByComparator.isAscending() ^ previous) {
2162 query.append(ORDER_BY_ASC_HAS_NEXT);
2163 }
2164 else {
2165 query.append(ORDER_BY_DESC_HAS_NEXT);
2166 }
2167 }
2168 else {
2169 if (orderByComparator.isAscending() ^ previous) {
2170 query.append(ORDER_BY_ASC);
2171 }
2172 else {
2173 query.append(ORDER_BY_DESC);
2174 }
2175 }
2176 }
2177 }
2178
2179 String sql = query.toString();
2180
2181 Query q = session.createQuery(sql);
2182
2183 q.setFirstResult(0);
2184 q.setMaxResults(2);
2185
2186 QueryPos qPos = QueryPos.getInstance(q);
2187
2188 if (emailAddress != null) {
2189 qPos.add(emailAddress);
2190 }
2191
2192 if (orderByComparator != null) {
2193 Object[] values = orderByComparator.getOrderByConditionValues(user);
2194
2195 for (Object value : values) {
2196 qPos.add(value);
2197 }
2198 }
2199
2200 List<User> list = q.list();
2201
2202 if (list.size() == 2) {
2203 return list.get(1);
2204 }
2205 else {
2206 return null;
2207 }
2208 }
2209
2210
2218 public User findByPortraitId(long portraitId)
2219 throws NoSuchUserException, SystemException {
2220 User user = fetchByPortraitId(portraitId);
2221
2222 if (user == null) {
2223 StringBundler msg = new StringBundler(4);
2224
2225 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2226
2227 msg.append("portraitId=");
2228 msg.append(portraitId);
2229
2230 msg.append(StringPool.CLOSE_CURLY_BRACE);
2231
2232 if (_log.isWarnEnabled()) {
2233 _log.warn(msg.toString());
2234 }
2235
2236 throw new NoSuchUserException(msg.toString());
2237 }
2238
2239 return user;
2240 }
2241
2242
2249 public User fetchByPortraitId(long portraitId) throws SystemException {
2250 return fetchByPortraitId(portraitId, true);
2251 }
2252
2253
2261 public User fetchByPortraitId(long portraitId, boolean retrieveFromCache)
2262 throws SystemException {
2263 Object[] finderArgs = new Object[] { portraitId };
2264
2265 Object result = null;
2266
2267 if (retrieveFromCache) {
2268 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2269 finderArgs, this);
2270 }
2271
2272 if (result == null) {
2273 StringBundler query = new StringBundler(2);
2274
2275 query.append(_SQL_SELECT_USER_WHERE);
2276
2277 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
2278
2279 String sql = query.toString();
2280
2281 Session session = null;
2282
2283 try {
2284 session = openSession();
2285
2286 Query q = session.createQuery(sql);
2287
2288 QueryPos qPos = QueryPos.getInstance(q);
2289
2290 qPos.add(portraitId);
2291
2292 List<User> list = q.list();
2293
2294 result = list;
2295
2296 User user = null;
2297
2298 if (list.isEmpty()) {
2299 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2300 finderArgs, list);
2301 }
2302 else {
2303 user = list.get(0);
2304
2305 cacheResult(user);
2306
2307 if ((user.getPortraitId() != portraitId)) {
2308 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2309 finderArgs, user);
2310 }
2311 }
2312
2313 return user;
2314 }
2315 catch (Exception e) {
2316 throw processException(e);
2317 }
2318 finally {
2319 if (result == null) {
2320 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_PORTRAITID,
2321 finderArgs);
2322 }
2323
2324 closeSession(session);
2325 }
2326 }
2327 else {
2328 if (result instanceof List<?>) {
2329 return null;
2330 }
2331 else {
2332 return (User)result;
2333 }
2334 }
2335 }
2336
2337
2346 public User findByC_U(long companyId, long userId)
2347 throws NoSuchUserException, SystemException {
2348 User user = fetchByC_U(companyId, userId);
2349
2350 if (user == null) {
2351 StringBundler msg = new StringBundler(6);
2352
2353 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2354
2355 msg.append("companyId=");
2356 msg.append(companyId);
2357
2358 msg.append(", userId=");
2359 msg.append(userId);
2360
2361 msg.append(StringPool.CLOSE_CURLY_BRACE);
2362
2363 if (_log.isWarnEnabled()) {
2364 _log.warn(msg.toString());
2365 }
2366
2367 throw new NoSuchUserException(msg.toString());
2368 }
2369
2370 return user;
2371 }
2372
2373
2381 public User fetchByC_U(long companyId, long userId)
2382 throws SystemException {
2383 return fetchByC_U(companyId, userId, true);
2384 }
2385
2386
2395 public User fetchByC_U(long companyId, long userId,
2396 boolean retrieveFromCache) throws SystemException {
2397 Object[] finderArgs = new Object[] { companyId, userId };
2398
2399 Object result = null;
2400
2401 if (retrieveFromCache) {
2402 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U,
2403 finderArgs, this);
2404 }
2405
2406 if (result == null) {
2407 StringBundler query = new StringBundler(3);
2408
2409 query.append(_SQL_SELECT_USER_WHERE);
2410
2411 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
2412
2413 query.append(_FINDER_COLUMN_C_U_USERID_2);
2414
2415 String sql = query.toString();
2416
2417 Session session = null;
2418
2419 try {
2420 session = openSession();
2421
2422 Query q = session.createQuery(sql);
2423
2424 QueryPos qPos = QueryPos.getInstance(q);
2425
2426 qPos.add(companyId);
2427
2428 qPos.add(userId);
2429
2430 List<User> list = q.list();
2431
2432 result = list;
2433
2434 User user = null;
2435
2436 if (list.isEmpty()) {
2437 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2438 finderArgs, list);
2439 }
2440 else {
2441 user = list.get(0);
2442
2443 cacheResult(user);
2444
2445 if ((user.getCompanyId() != companyId) ||
2446 (user.getUserId() != userId)) {
2447 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U,
2448 finderArgs, user);
2449 }
2450 }
2451
2452 return user;
2453 }
2454 catch (Exception e) {
2455 throw processException(e);
2456 }
2457 finally {
2458 if (result == null) {
2459 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U,
2460 finderArgs);
2461 }
2462
2463 closeSession(session);
2464 }
2465 }
2466 else {
2467 if (result instanceof List<?>) {
2468 return null;
2469 }
2470 else {
2471 return (User)result;
2472 }
2473 }
2474 }
2475
2476
2485 public User findByC_DU(long companyId, boolean defaultUser)
2486 throws NoSuchUserException, SystemException {
2487 User user = fetchByC_DU(companyId, defaultUser);
2488
2489 if (user == null) {
2490 StringBundler msg = new StringBundler(6);
2491
2492 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2493
2494 msg.append("companyId=");
2495 msg.append(companyId);
2496
2497 msg.append(", defaultUser=");
2498 msg.append(defaultUser);
2499
2500 msg.append(StringPool.CLOSE_CURLY_BRACE);
2501
2502 if (_log.isWarnEnabled()) {
2503 _log.warn(msg.toString());
2504 }
2505
2506 throw new NoSuchUserException(msg.toString());
2507 }
2508
2509 return user;
2510 }
2511
2512
2520 public User fetchByC_DU(long companyId, boolean defaultUser)
2521 throws SystemException {
2522 return fetchByC_DU(companyId, defaultUser, true);
2523 }
2524
2525
2534 public User fetchByC_DU(long companyId, boolean defaultUser,
2535 boolean retrieveFromCache) throws SystemException {
2536 Object[] finderArgs = new Object[] { companyId, defaultUser };
2537
2538 Object result = null;
2539
2540 if (retrieveFromCache) {
2541 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_DU,
2542 finderArgs, this);
2543 }
2544
2545 if (result == null) {
2546 StringBundler query = new StringBundler(3);
2547
2548 query.append(_SQL_SELECT_USER_WHERE);
2549
2550 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
2551
2552 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
2553
2554 String sql = query.toString();
2555
2556 Session session = null;
2557
2558 try {
2559 session = openSession();
2560
2561 Query q = session.createQuery(sql);
2562
2563 QueryPos qPos = QueryPos.getInstance(q);
2564
2565 qPos.add(companyId);
2566
2567 qPos.add(defaultUser);
2568
2569 List<User> list = q.list();
2570
2571 result = list;
2572
2573 User user = null;
2574
2575 if (list.isEmpty()) {
2576 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
2577 finderArgs, list);
2578 }
2579 else {
2580 user = list.get(0);
2581
2582 cacheResult(user);
2583
2584 if ((user.getCompanyId() != companyId) ||
2585 (user.getDefaultUser() != defaultUser)) {
2586 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_DU,
2587 finderArgs, user);
2588 }
2589 }
2590
2591 return user;
2592 }
2593 catch (Exception e) {
2594 throw processException(e);
2595 }
2596 finally {
2597 if (result == null) {
2598 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_DU,
2599 finderArgs);
2600 }
2601
2602 closeSession(session);
2603 }
2604 }
2605 else {
2606 if (result instanceof List<?>) {
2607 return null;
2608 }
2609 else {
2610 return (User)result;
2611 }
2612 }
2613 }
2614
2615
2624 public User findByC_SN(long companyId, String screenName)
2625 throws NoSuchUserException, SystemException {
2626 User user = fetchByC_SN(companyId, screenName);
2627
2628 if (user == null) {
2629 StringBundler msg = new StringBundler(6);
2630
2631 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2632
2633 msg.append("companyId=");
2634 msg.append(companyId);
2635
2636 msg.append(", screenName=");
2637 msg.append(screenName);
2638
2639 msg.append(StringPool.CLOSE_CURLY_BRACE);
2640
2641 if (_log.isWarnEnabled()) {
2642 _log.warn(msg.toString());
2643 }
2644
2645 throw new NoSuchUserException(msg.toString());
2646 }
2647
2648 return user;
2649 }
2650
2651
2659 public User fetchByC_SN(long companyId, String screenName)
2660 throws SystemException {
2661 return fetchByC_SN(companyId, screenName, true);
2662 }
2663
2664
2673 public User fetchByC_SN(long companyId, String screenName,
2674 boolean retrieveFromCache) throws SystemException {
2675 Object[] finderArgs = new Object[] { companyId, screenName };
2676
2677 Object result = null;
2678
2679 if (retrieveFromCache) {
2680 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_SN,
2681 finderArgs, this);
2682 }
2683
2684 if (result == null) {
2685 StringBundler query = new StringBundler(3);
2686
2687 query.append(_SQL_SELECT_USER_WHERE);
2688
2689 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
2690
2691 if (screenName == null) {
2692 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
2693 }
2694 else {
2695 if (screenName.equals(StringPool.BLANK)) {
2696 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
2697 }
2698 else {
2699 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
2700 }
2701 }
2702
2703 String sql = query.toString();
2704
2705 Session session = null;
2706
2707 try {
2708 session = openSession();
2709
2710 Query q = session.createQuery(sql);
2711
2712 QueryPos qPos = QueryPos.getInstance(q);
2713
2714 qPos.add(companyId);
2715
2716 if (screenName != null) {
2717 qPos.add(screenName);
2718 }
2719
2720 List<User> list = q.list();
2721
2722 result = list;
2723
2724 User user = null;
2725
2726 if (list.isEmpty()) {
2727 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2728 finderArgs, list);
2729 }
2730 else {
2731 user = list.get(0);
2732
2733 cacheResult(user);
2734
2735 if ((user.getCompanyId() != companyId) ||
2736 (user.getScreenName() == null) ||
2737 !user.getScreenName().equals(screenName)) {
2738 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_SN,
2739 finderArgs, user);
2740 }
2741 }
2742
2743 return user;
2744 }
2745 catch (Exception e) {
2746 throw processException(e);
2747 }
2748 finally {
2749 if (result == null) {
2750 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_SN,
2751 finderArgs);
2752 }
2753
2754 closeSession(session);
2755 }
2756 }
2757 else {
2758 if (result instanceof List<?>) {
2759 return null;
2760 }
2761 else {
2762 return (User)result;
2763 }
2764 }
2765 }
2766
2767
2776 public User findByC_EA(long companyId, String emailAddress)
2777 throws NoSuchUserException, SystemException {
2778 User user = fetchByC_EA(companyId, emailAddress);
2779
2780 if (user == null) {
2781 StringBundler msg = new StringBundler(6);
2782
2783 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2784
2785 msg.append("companyId=");
2786 msg.append(companyId);
2787
2788 msg.append(", emailAddress=");
2789 msg.append(emailAddress);
2790
2791 msg.append(StringPool.CLOSE_CURLY_BRACE);
2792
2793 if (_log.isWarnEnabled()) {
2794 _log.warn(msg.toString());
2795 }
2796
2797 throw new NoSuchUserException(msg.toString());
2798 }
2799
2800 return user;
2801 }
2802
2803
2811 public User fetchByC_EA(long companyId, String emailAddress)
2812 throws SystemException {
2813 return fetchByC_EA(companyId, emailAddress, true);
2814 }
2815
2816
2825 public User fetchByC_EA(long companyId, String emailAddress,
2826 boolean retrieveFromCache) throws SystemException {
2827 Object[] finderArgs = new Object[] { companyId, emailAddress };
2828
2829 Object result = null;
2830
2831 if (retrieveFromCache) {
2832 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_EA,
2833 finderArgs, this);
2834 }
2835
2836 if (result == null) {
2837 StringBundler query = new StringBundler(3);
2838
2839 query.append(_SQL_SELECT_USER_WHERE);
2840
2841 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
2842
2843 if (emailAddress == null) {
2844 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
2845 }
2846 else {
2847 if (emailAddress.equals(StringPool.BLANK)) {
2848 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
2849 }
2850 else {
2851 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
2852 }
2853 }
2854
2855 String sql = query.toString();
2856
2857 Session session = null;
2858
2859 try {
2860 session = openSession();
2861
2862 Query q = session.createQuery(sql);
2863
2864 QueryPos qPos = QueryPos.getInstance(q);
2865
2866 qPos.add(companyId);
2867
2868 if (emailAddress != null) {
2869 qPos.add(emailAddress);
2870 }
2871
2872 List<User> list = q.list();
2873
2874 result = list;
2875
2876 User user = null;
2877
2878 if (list.isEmpty()) {
2879 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2880 finderArgs, list);
2881 }
2882 else {
2883 user = list.get(0);
2884
2885 cacheResult(user);
2886
2887 if ((user.getCompanyId() != companyId) ||
2888 (user.getEmailAddress() == null) ||
2889 !user.getEmailAddress().equals(emailAddress)) {
2890 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_EA,
2891 finderArgs, user);
2892 }
2893 }
2894
2895 return user;
2896 }
2897 catch (Exception e) {
2898 throw processException(e);
2899 }
2900 finally {
2901 if (result == null) {
2902 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_EA,
2903 finderArgs);
2904 }
2905
2906 closeSession(session);
2907 }
2908 }
2909 else {
2910 if (result instanceof List<?>) {
2911 return null;
2912 }
2913 else {
2914 return (User)result;
2915 }
2916 }
2917 }
2918
2919
2928 public User findByC_FID(long companyId, long facebookId)
2929 throws NoSuchUserException, SystemException {
2930 User user = fetchByC_FID(companyId, facebookId);
2931
2932 if (user == null) {
2933 StringBundler msg = new StringBundler(6);
2934
2935 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2936
2937 msg.append("companyId=");
2938 msg.append(companyId);
2939
2940 msg.append(", facebookId=");
2941 msg.append(facebookId);
2942
2943 msg.append(StringPool.CLOSE_CURLY_BRACE);
2944
2945 if (_log.isWarnEnabled()) {
2946 _log.warn(msg.toString());
2947 }
2948
2949 throw new NoSuchUserException(msg.toString());
2950 }
2951
2952 return user;
2953 }
2954
2955
2963 public User fetchByC_FID(long companyId, long facebookId)
2964 throws SystemException {
2965 return fetchByC_FID(companyId, facebookId, true);
2966 }
2967
2968
2977 public User fetchByC_FID(long companyId, long facebookId,
2978 boolean retrieveFromCache) throws SystemException {
2979 Object[] finderArgs = new Object[] { companyId, facebookId };
2980
2981 Object result = null;
2982
2983 if (retrieveFromCache) {
2984 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_FID,
2985 finderArgs, this);
2986 }
2987
2988 if (result == null) {
2989 StringBundler query = new StringBundler(3);
2990
2991 query.append(_SQL_SELECT_USER_WHERE);
2992
2993 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
2994
2995 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
2996
2997 String sql = query.toString();
2998
2999 Session session = null;
3000
3001 try {
3002 session = openSession();
3003
3004 Query q = session.createQuery(sql);
3005
3006 QueryPos qPos = QueryPos.getInstance(q);
3007
3008 qPos.add(companyId);
3009
3010 qPos.add(facebookId);
3011
3012 List<User> list = q.list();
3013
3014 result = list;
3015
3016 User user = null;
3017
3018 if (list.isEmpty()) {
3019 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
3020 finderArgs, list);
3021 }
3022 else {
3023 user = list.get(0);
3024
3025 cacheResult(user);
3026
3027 if ((user.getCompanyId() != companyId) ||
3028 (user.getFacebookId() != facebookId)) {
3029 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_FID,
3030 finderArgs, user);
3031 }
3032 }
3033
3034 return user;
3035 }
3036 catch (Exception e) {
3037 throw processException(e);
3038 }
3039 finally {
3040 if (result == null) {
3041 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_FID,
3042 finderArgs);
3043 }
3044
3045 closeSession(session);
3046 }
3047 }
3048 else {
3049 if (result instanceof List<?>) {
3050 return null;
3051 }
3052 else {
3053 return (User)result;
3054 }
3055 }
3056 }
3057
3058
3067 public User findByC_O(long companyId, String openId)
3068 throws NoSuchUserException, SystemException {
3069 User user = fetchByC_O(companyId, openId);
3070
3071 if (user == null) {
3072 StringBundler msg = new StringBundler(6);
3073
3074 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3075
3076 msg.append("companyId=");
3077 msg.append(companyId);
3078
3079 msg.append(", openId=");
3080 msg.append(openId);
3081
3082 msg.append(StringPool.CLOSE_CURLY_BRACE);
3083
3084 if (_log.isWarnEnabled()) {
3085 _log.warn(msg.toString());
3086 }
3087
3088 throw new NoSuchUserException(msg.toString());
3089 }
3090
3091 return user;
3092 }
3093
3094
3102 public User fetchByC_O(long companyId, String openId)
3103 throws SystemException {
3104 return fetchByC_O(companyId, openId, true);
3105 }
3106
3107
3116 public User fetchByC_O(long companyId, String openId,
3117 boolean retrieveFromCache) throws SystemException {
3118 Object[] finderArgs = new Object[] { companyId, openId };
3119
3120 Object result = null;
3121
3122 if (retrieveFromCache) {
3123 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_O,
3124 finderArgs, this);
3125 }
3126
3127 if (result == null) {
3128 StringBundler query = new StringBundler(3);
3129
3130 query.append(_SQL_SELECT_USER_WHERE);
3131
3132 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
3133
3134 if (openId == null) {
3135 query.append(_FINDER_COLUMN_C_O_OPENID_1);
3136 }
3137 else {
3138 if (openId.equals(StringPool.BLANK)) {
3139 query.append(_FINDER_COLUMN_C_O_OPENID_3);
3140 }
3141 else {
3142 query.append(_FINDER_COLUMN_C_O_OPENID_2);
3143 }
3144 }
3145
3146 String sql = query.toString();
3147
3148 Session session = null;
3149
3150 try {
3151 session = openSession();
3152
3153 Query q = session.createQuery(sql);
3154
3155 QueryPos qPos = QueryPos.getInstance(q);
3156
3157 qPos.add(companyId);
3158
3159 if (openId != null) {
3160 qPos.add(openId);
3161 }
3162
3163 List<User> list = q.list();
3164
3165 result = list;
3166
3167 User user = null;
3168
3169 if (list.isEmpty()) {
3170 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
3171 finderArgs, list);
3172 }
3173 else {
3174 user = list.get(0);
3175
3176 cacheResult(user);
3177
3178 if ((user.getCompanyId() != companyId) ||
3179 (user.getOpenId() == null) ||
3180 !user.getOpenId().equals(openId)) {
3181 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_O,
3182 finderArgs, user);
3183 }
3184 }
3185
3186 return user;
3187 }
3188 catch (Exception e) {
3189 throw processException(e);
3190 }
3191 finally {
3192 if (result == null) {
3193 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_O,
3194 finderArgs);
3195 }
3196
3197 closeSession(session);
3198 }
3199 }
3200 else {
3201 if (result instanceof List<?>) {
3202 return null;
3203 }
3204 else {
3205 return (User)result;
3206 }
3207 }
3208 }
3209
3210
3218 public List<User> findByC_S(long companyId, int status)
3219 throws SystemException {
3220 return findByC_S(companyId, status, QueryUtil.ALL_POS,
3221 QueryUtil.ALL_POS, null);
3222 }
3223
3224
3238 public List<User> findByC_S(long companyId, int status, int start, int end)
3239 throws SystemException {
3240 return findByC_S(companyId, status, start, end, null);
3241 }
3242
3243
3258 public List<User> findByC_S(long companyId, int status, int start, int end,
3259 OrderByComparator orderByComparator) throws SystemException {
3260 FinderPath finderPath = null;
3261 Object[] finderArgs = null;
3262
3263 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3264 (orderByComparator == null)) {
3265 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_S;
3266 finderArgs = new Object[] { companyId, status };
3267 }
3268 else {
3269 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_S;
3270 finderArgs = new Object[] {
3271 companyId, status,
3272
3273 start, end, orderByComparator
3274 };
3275 }
3276
3277 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
3278 finderArgs, this);
3279
3280 if (list == null) {
3281 StringBundler query = null;
3282
3283 if (orderByComparator != null) {
3284 query = new StringBundler(4 +
3285 (orderByComparator.getOrderByFields().length * 3));
3286 }
3287 else {
3288 query = new StringBundler(3);
3289 }
3290
3291 query.append(_SQL_SELECT_USER_WHERE);
3292
3293 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3294
3295 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3296
3297 if (orderByComparator != null) {
3298 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3299 orderByComparator);
3300 }
3301
3302 String sql = query.toString();
3303
3304 Session session = null;
3305
3306 try {
3307 session = openSession();
3308
3309 Query q = session.createQuery(sql);
3310
3311 QueryPos qPos = QueryPos.getInstance(q);
3312
3313 qPos.add(companyId);
3314
3315 qPos.add(status);
3316
3317 list = (List<User>)QueryUtil.list(q, getDialect(), start, end);
3318 }
3319 catch (Exception e) {
3320 throw processException(e);
3321 }
3322 finally {
3323 if (list == null) {
3324 FinderCacheUtil.removeResult(finderPath, finderArgs);
3325 }
3326 else {
3327 cacheResult(list);
3328
3329 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3330 }
3331
3332 closeSession(session);
3333 }
3334 }
3335
3336 return list;
3337 }
3338
3339
3353 public User findByC_S_First(long companyId, int status,
3354 OrderByComparator orderByComparator)
3355 throws NoSuchUserException, SystemException {
3356 List<User> list = findByC_S(companyId, status, 0, 1, orderByComparator);
3357
3358 if (list.isEmpty()) {
3359 StringBundler msg = new StringBundler(6);
3360
3361 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3362
3363 msg.append("companyId=");
3364 msg.append(companyId);
3365
3366 msg.append(", status=");
3367 msg.append(status);
3368
3369 msg.append(StringPool.CLOSE_CURLY_BRACE);
3370
3371 throw new NoSuchUserException(msg.toString());
3372 }
3373 else {
3374 return list.get(0);
3375 }
3376 }
3377
3378
3392 public User findByC_S_Last(long companyId, int status,
3393 OrderByComparator orderByComparator)
3394 throws NoSuchUserException, SystemException {
3395 int count = countByC_S(companyId, status);
3396
3397 List<User> list = findByC_S(companyId, status, count - 1, count,
3398 orderByComparator);
3399
3400 if (list.isEmpty()) {
3401 StringBundler msg = new StringBundler(6);
3402
3403 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3404
3405 msg.append("companyId=");
3406 msg.append(companyId);
3407
3408 msg.append(", status=");
3409 msg.append(status);
3410
3411 msg.append(StringPool.CLOSE_CURLY_BRACE);
3412
3413 throw new NoSuchUserException(msg.toString());
3414 }
3415 else {
3416 return list.get(0);
3417 }
3418 }
3419
3420
3435 public User[] findByC_S_PrevAndNext(long userId, long companyId,
3436 int status, OrderByComparator orderByComparator)
3437 throws NoSuchUserException, SystemException {
3438 User user = findByPrimaryKey(userId);
3439
3440 Session session = null;
3441
3442 try {
3443 session = openSession();
3444
3445 User[] array = new UserImpl[3];
3446
3447 array[0] = getByC_S_PrevAndNext(session, user, companyId, status,
3448 orderByComparator, true);
3449
3450 array[1] = user;
3451
3452 array[2] = getByC_S_PrevAndNext(session, user, companyId, status,
3453 orderByComparator, false);
3454
3455 return array;
3456 }
3457 catch (Exception e) {
3458 throw processException(e);
3459 }
3460 finally {
3461 closeSession(session);
3462 }
3463 }
3464
3465 protected User getByC_S_PrevAndNext(Session session, User user,
3466 long companyId, int status, OrderByComparator orderByComparator,
3467 boolean previous) {
3468 StringBundler query = null;
3469
3470 if (orderByComparator != null) {
3471 query = new StringBundler(6 +
3472 (orderByComparator.getOrderByFields().length * 6));
3473 }
3474 else {
3475 query = new StringBundler(3);
3476 }
3477
3478 query.append(_SQL_SELECT_USER_WHERE);
3479
3480 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
3481
3482 query.append(_FINDER_COLUMN_C_S_STATUS_2);
3483
3484 if (orderByComparator != null) {
3485 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3486
3487 if (orderByConditionFields.length > 0) {
3488 query.append(WHERE_AND);
3489 }
3490
3491 for (int i = 0; i < orderByConditionFields.length; i++) {
3492 query.append(_ORDER_BY_ENTITY_ALIAS);
3493 query.append(orderByConditionFields[i]);
3494
3495 if ((i + 1) < orderByConditionFields.length) {
3496 if (orderByComparator.isAscending() ^ previous) {
3497 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3498 }
3499 else {
3500 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3501 }
3502 }
3503 else {
3504 if (orderByComparator.isAscending() ^ previous) {
3505 query.append(WHERE_GREATER_THAN);
3506 }
3507 else {
3508 query.append(WHERE_LESSER_THAN);
3509 }
3510 }
3511 }
3512
3513 query.append(ORDER_BY_CLAUSE);
3514
3515 String[] orderByFields = orderByComparator.getOrderByFields();
3516
3517 for (int i = 0; i < orderByFields.length; i++) {
3518 query.append(_ORDER_BY_ENTITY_ALIAS);
3519 query.append(orderByFields[i]);
3520
3521 if ((i + 1) < orderByFields.length) {
3522 if (orderByComparator.isAscending() ^ previous) {
3523 query.append(ORDER_BY_ASC_HAS_NEXT);
3524 }
3525 else {
3526 query.append(ORDER_BY_DESC_HAS_NEXT);
3527 }
3528 }
3529 else {
3530 if (orderByComparator.isAscending() ^ previous) {
3531 query.append(ORDER_BY_ASC);
3532 }
3533 else {
3534 query.append(ORDER_BY_DESC);
3535 }
3536 }
3537 }
3538 }
3539
3540 String sql = query.toString();
3541
3542 Query q = session.createQuery(sql);
3543
3544 q.setFirstResult(0);
3545 q.setMaxResults(2);
3546
3547 QueryPos qPos = QueryPos.getInstance(q);
3548
3549 qPos.add(companyId);
3550
3551 qPos.add(status);
3552
3553 if (orderByComparator != null) {
3554 Object[] values = orderByComparator.getOrderByConditionValues(user);
3555
3556 for (Object value : values) {
3557 qPos.add(value);
3558 }
3559 }
3560
3561 List<User> list = q.list();
3562
3563 if (list.size() == 2) {
3564 return list.get(1);
3565 }
3566 else {
3567 return null;
3568 }
3569 }
3570
3571
3577 public List<User> findAll() throws SystemException {
3578 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3579 }
3580
3581
3593 public List<User> findAll(int start, int end) throws SystemException {
3594 return findAll(start, end, null);
3595 }
3596
3597
3610 public List<User> findAll(int start, int end,
3611 OrderByComparator orderByComparator) throws SystemException {
3612 FinderPath finderPath = null;
3613 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3614
3615 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3616 (orderByComparator == null)) {
3617 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3618 finderArgs = FINDER_ARGS_EMPTY;
3619 }
3620 else {
3621 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3622 finderArgs = new Object[] { start, end, orderByComparator };
3623 }
3624
3625 List<User> list = (List<User>)FinderCacheUtil.getResult(finderPath,
3626 finderArgs, this);
3627
3628 if (list == null) {
3629 StringBundler query = null;
3630 String sql = null;
3631
3632 if (orderByComparator != null) {
3633 query = new StringBundler(2 +
3634 (orderByComparator.getOrderByFields().length * 3));
3635
3636 query.append(_SQL_SELECT_USER);
3637
3638 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3639 orderByComparator);
3640
3641 sql = query.toString();
3642 }
3643 else {
3644 sql = _SQL_SELECT_USER;
3645 }
3646
3647 Session session = null;
3648
3649 try {
3650 session = openSession();
3651
3652 Query q = session.createQuery(sql);
3653
3654 if (orderByComparator == null) {
3655 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3656 end, false);
3657
3658 Collections.sort(list);
3659 }
3660 else {
3661 list = (List<User>)QueryUtil.list(q, getDialect(), start,
3662 end);
3663 }
3664 }
3665 catch (Exception e) {
3666 throw processException(e);
3667 }
3668 finally {
3669 if (list == null) {
3670 FinderCacheUtil.removeResult(finderPath, finderArgs);
3671 }
3672 else {
3673 cacheResult(list);
3674
3675 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3676 }
3677
3678 closeSession(session);
3679 }
3680 }
3681
3682 return list;
3683 }
3684
3685
3691 public void removeByUuid(String uuid) throws SystemException {
3692 for (User user : findByUuid(uuid)) {
3693 remove(user);
3694 }
3695 }
3696
3697
3703 public void removeByCompanyId(long companyId) throws SystemException {
3704 for (User user : findByCompanyId(companyId)) {
3705 remove(user);
3706 }
3707 }
3708
3709
3715 public void removeByContactId(long contactId)
3716 throws NoSuchUserException, SystemException {
3717 User user = findByContactId(contactId);
3718
3719 remove(user);
3720 }
3721
3722
3728 public void removeByEmailAddress(String emailAddress)
3729 throws SystemException {
3730 for (User user : findByEmailAddress(emailAddress)) {
3731 remove(user);
3732 }
3733 }
3734
3735
3741 public void removeByPortraitId(long portraitId)
3742 throws NoSuchUserException, SystemException {
3743 User user = findByPortraitId(portraitId);
3744
3745 remove(user);
3746 }
3747
3748
3755 public void removeByC_U(long companyId, long userId)
3756 throws NoSuchUserException, SystemException {
3757 User user = findByC_U(companyId, userId);
3758
3759 remove(user);
3760 }
3761
3762
3769 public void removeByC_DU(long companyId, boolean defaultUser)
3770 throws NoSuchUserException, SystemException {
3771 User user = findByC_DU(companyId, defaultUser);
3772
3773 remove(user);
3774 }
3775
3776
3783 public void removeByC_SN(long companyId, String screenName)
3784 throws NoSuchUserException, SystemException {
3785 User user = findByC_SN(companyId, screenName);
3786
3787 remove(user);
3788 }
3789
3790
3797 public void removeByC_EA(long companyId, String emailAddress)
3798 throws NoSuchUserException, SystemException {
3799 User user = findByC_EA(companyId, emailAddress);
3800
3801 remove(user);
3802 }
3803
3804
3811 public void removeByC_FID(long companyId, long facebookId)
3812 throws NoSuchUserException, SystemException {
3813 User user = findByC_FID(companyId, facebookId);
3814
3815 remove(user);
3816 }
3817
3818
3825 public void removeByC_O(long companyId, String openId)
3826 throws NoSuchUserException, SystemException {
3827 User user = findByC_O(companyId, openId);
3828
3829 remove(user);
3830 }
3831
3832
3839 public void removeByC_S(long companyId, int status)
3840 throws SystemException {
3841 for (User user : findByC_S(companyId, status)) {
3842 remove(user);
3843 }
3844 }
3845
3846
3851 public void removeAll() throws SystemException {
3852 for (User user : findAll()) {
3853 remove(user);
3854 }
3855 }
3856
3857
3864 public int countByUuid(String uuid) throws SystemException {
3865 Object[] finderArgs = new Object[] { uuid };
3866
3867 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
3868 finderArgs, this);
3869
3870 if (count == null) {
3871 StringBundler query = new StringBundler(2);
3872
3873 query.append(_SQL_COUNT_USER_WHERE);
3874
3875 if (uuid == null) {
3876 query.append(_FINDER_COLUMN_UUID_UUID_1);
3877 }
3878 else {
3879 if (uuid.equals(StringPool.BLANK)) {
3880 query.append(_FINDER_COLUMN_UUID_UUID_3);
3881 }
3882 else {
3883 query.append(_FINDER_COLUMN_UUID_UUID_2);
3884 }
3885 }
3886
3887 String sql = query.toString();
3888
3889 Session session = null;
3890
3891 try {
3892 session = openSession();
3893
3894 Query q = session.createQuery(sql);
3895
3896 QueryPos qPos = QueryPos.getInstance(q);
3897
3898 if (uuid != null) {
3899 qPos.add(uuid);
3900 }
3901
3902 count = (Long)q.uniqueResult();
3903 }
3904 catch (Exception e) {
3905 throw processException(e);
3906 }
3907 finally {
3908 if (count == null) {
3909 count = Long.valueOf(0);
3910 }
3911
3912 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
3913 finderArgs, count);
3914
3915 closeSession(session);
3916 }
3917 }
3918
3919 return count.intValue();
3920 }
3921
3922
3929 public int countByCompanyId(long companyId) throws SystemException {
3930 Object[] finderArgs = new Object[] { companyId };
3931
3932 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
3933 finderArgs, this);
3934
3935 if (count == null) {
3936 StringBundler query = new StringBundler(2);
3937
3938 query.append(_SQL_COUNT_USER_WHERE);
3939
3940 query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
3941
3942 String sql = query.toString();
3943
3944 Session session = null;
3945
3946 try {
3947 session = openSession();
3948
3949 Query q = session.createQuery(sql);
3950
3951 QueryPos qPos = QueryPos.getInstance(q);
3952
3953 qPos.add(companyId);
3954
3955 count = (Long)q.uniqueResult();
3956 }
3957 catch (Exception e) {
3958 throw processException(e);
3959 }
3960 finally {
3961 if (count == null) {
3962 count = Long.valueOf(0);
3963 }
3964
3965 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
3966 finderArgs, count);
3967
3968 closeSession(session);
3969 }
3970 }
3971
3972 return count.intValue();
3973 }
3974
3975
3982 public int countByContactId(long contactId) throws SystemException {
3983 Object[] finderArgs = new Object[] { contactId };
3984
3985 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CONTACTID,
3986 finderArgs, this);
3987
3988 if (count == null) {
3989 StringBundler query = new StringBundler(2);
3990
3991 query.append(_SQL_COUNT_USER_WHERE);
3992
3993 query.append(_FINDER_COLUMN_CONTACTID_CONTACTID_2);
3994
3995 String sql = query.toString();
3996
3997 Session session = null;
3998
3999 try {
4000 session = openSession();
4001
4002 Query q = session.createQuery(sql);
4003
4004 QueryPos qPos = QueryPos.getInstance(q);
4005
4006 qPos.add(contactId);
4007
4008 count = (Long)q.uniqueResult();
4009 }
4010 catch (Exception e) {
4011 throw processException(e);
4012 }
4013 finally {
4014 if (count == null) {
4015 count = Long.valueOf(0);
4016 }
4017
4018 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CONTACTID,
4019 finderArgs, count);
4020
4021 closeSession(session);
4022 }
4023 }
4024
4025 return count.intValue();
4026 }
4027
4028
4035 public int countByEmailAddress(String emailAddress)
4036 throws SystemException {
4037 Object[] finderArgs = new Object[] { emailAddress };
4038
4039 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
4040 finderArgs, this);
4041
4042 if (count == null) {
4043 StringBundler query = new StringBundler(2);
4044
4045 query.append(_SQL_COUNT_USER_WHERE);
4046
4047 if (emailAddress == null) {
4048 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1);
4049 }
4050 else {
4051 if (emailAddress.equals(StringPool.BLANK)) {
4052 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3);
4053 }
4054 else {
4055 query.append(_FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2);
4056 }
4057 }
4058
4059 String sql = query.toString();
4060
4061 Session session = null;
4062
4063 try {
4064 session = openSession();
4065
4066 Query q = session.createQuery(sql);
4067
4068 QueryPos qPos = QueryPos.getInstance(q);
4069
4070 if (emailAddress != null) {
4071 qPos.add(emailAddress);
4072 }
4073
4074 count = (Long)q.uniqueResult();
4075 }
4076 catch (Exception e) {
4077 throw processException(e);
4078 }
4079 finally {
4080 if (count == null) {
4081 count = Long.valueOf(0);
4082 }
4083
4084 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_EMAILADDRESS,
4085 finderArgs, count);
4086
4087 closeSession(session);
4088 }
4089 }
4090
4091 return count.intValue();
4092 }
4093
4094
4101 public int countByPortraitId(long portraitId) throws SystemException {
4102 Object[] finderArgs = new Object[] { portraitId };
4103
4104 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_PORTRAITID,
4105 finderArgs, this);
4106
4107 if (count == null) {
4108 StringBundler query = new StringBundler(2);
4109
4110 query.append(_SQL_COUNT_USER_WHERE);
4111
4112 query.append(_FINDER_COLUMN_PORTRAITID_PORTRAITID_2);
4113
4114 String sql = query.toString();
4115
4116 Session session = null;
4117
4118 try {
4119 session = openSession();
4120
4121 Query q = session.createQuery(sql);
4122
4123 QueryPos qPos = QueryPos.getInstance(q);
4124
4125 qPos.add(portraitId);
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_PORTRAITID,
4138 finderArgs, count);
4139
4140 closeSession(session);
4141 }
4142 }
4143
4144 return count.intValue();
4145 }
4146
4147
4155 public int countByC_U(long companyId, long userId)
4156 throws SystemException {
4157 Object[] finderArgs = new Object[] { companyId, userId };
4158
4159 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U,
4160 finderArgs, this);
4161
4162 if (count == null) {
4163 StringBundler query = new StringBundler(3);
4164
4165 query.append(_SQL_COUNT_USER_WHERE);
4166
4167 query.append(_FINDER_COLUMN_C_U_COMPANYID_2);
4168
4169 query.append(_FINDER_COLUMN_C_U_USERID_2);
4170
4171 String sql = query.toString();
4172
4173 Session session = null;
4174
4175 try {
4176 session = openSession();
4177
4178 Query q = session.createQuery(sql);
4179
4180 QueryPos qPos = QueryPos.getInstance(q);
4181
4182 qPos.add(companyId);
4183
4184 qPos.add(userId);
4185
4186 count = (Long)q.uniqueResult();
4187 }
4188 catch (Exception e) {
4189 throw processException(e);
4190 }
4191 finally {
4192 if (count == null) {
4193 count = Long.valueOf(0);
4194 }
4195
4196 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U, finderArgs,
4197 count);
4198
4199 closeSession(session);
4200 }
4201 }
4202
4203 return count.intValue();
4204 }
4205
4206
4214 public int countByC_DU(long companyId, boolean defaultUser)
4215 throws SystemException {
4216 Object[] finderArgs = new Object[] { companyId, defaultUser };
4217
4218 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_DU,
4219 finderArgs, this);
4220
4221 if (count == null) {
4222 StringBundler query = new StringBundler(3);
4223
4224 query.append(_SQL_COUNT_USER_WHERE);
4225
4226 query.append(_FINDER_COLUMN_C_DU_COMPANYID_2);
4227
4228 query.append(_FINDER_COLUMN_C_DU_DEFAULTUSER_2);
4229
4230 String sql = query.toString();
4231
4232 Session session = null;
4233
4234 try {
4235 session = openSession();
4236
4237 Query q = session.createQuery(sql);
4238
4239 QueryPos qPos = QueryPos.getInstance(q);
4240
4241 qPos.add(companyId);
4242
4243 qPos.add(defaultUser);
4244
4245 count = (Long)q.uniqueResult();
4246 }
4247 catch (Exception e) {
4248 throw processException(e);
4249 }
4250 finally {
4251 if (count == null) {
4252 count = Long.valueOf(0);
4253 }
4254
4255 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_DU,
4256 finderArgs, count);
4257
4258 closeSession(session);
4259 }
4260 }
4261
4262 return count.intValue();
4263 }
4264
4265
4273 public int countByC_SN(long companyId, String screenName)
4274 throws SystemException {
4275 Object[] finderArgs = new Object[] { companyId, screenName };
4276
4277 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_SN,
4278 finderArgs, this);
4279
4280 if (count == null) {
4281 StringBundler query = new StringBundler(3);
4282
4283 query.append(_SQL_COUNT_USER_WHERE);
4284
4285 query.append(_FINDER_COLUMN_C_SN_COMPANYID_2);
4286
4287 if (screenName == null) {
4288 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_1);
4289 }
4290 else {
4291 if (screenName.equals(StringPool.BLANK)) {
4292 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_3);
4293 }
4294 else {
4295 query.append(_FINDER_COLUMN_C_SN_SCREENNAME_2);
4296 }
4297 }
4298
4299 String sql = query.toString();
4300
4301 Session session = null;
4302
4303 try {
4304 session = openSession();
4305
4306 Query q = session.createQuery(sql);
4307
4308 QueryPos qPos = QueryPos.getInstance(q);
4309
4310 qPos.add(companyId);
4311
4312 if (screenName != null) {
4313 qPos.add(screenName);
4314 }
4315
4316 count = (Long)q.uniqueResult();
4317 }
4318 catch (Exception e) {
4319 throw processException(e);
4320 }
4321 finally {
4322 if (count == null) {
4323 count = Long.valueOf(0);
4324 }
4325
4326 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_SN,
4327 finderArgs, count);
4328
4329 closeSession(session);
4330 }
4331 }
4332
4333 return count.intValue();
4334 }
4335
4336
4344 public int countByC_EA(long companyId, String emailAddress)
4345 throws SystemException {
4346 Object[] finderArgs = new Object[] { companyId, emailAddress };
4347
4348 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_EA,
4349 finderArgs, this);
4350
4351 if (count == null) {
4352 StringBundler query = new StringBundler(3);
4353
4354 query.append(_SQL_COUNT_USER_WHERE);
4355
4356 query.append(_FINDER_COLUMN_C_EA_COMPANYID_2);
4357
4358 if (emailAddress == null) {
4359 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_1);
4360 }
4361 else {
4362 if (emailAddress.equals(StringPool.BLANK)) {
4363 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_3);
4364 }
4365 else {
4366 query.append(_FINDER_COLUMN_C_EA_EMAILADDRESS_2);
4367 }
4368 }
4369
4370 String sql = query.toString();
4371
4372 Session session = null;
4373
4374 try {
4375 session = openSession();
4376
4377 Query q = session.createQuery(sql);
4378
4379 QueryPos qPos = QueryPos.getInstance(q);
4380
4381 qPos.add(companyId);
4382
4383 if (emailAddress != null) {
4384 qPos.add(emailAddress);
4385 }
4386
4387 count = (Long)q.uniqueResult();
4388 }
4389 catch (Exception e) {
4390 throw processException(e);
4391 }
4392 finally {
4393 if (count == null) {
4394 count = Long.valueOf(0);
4395 }
4396
4397 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_EA,
4398 finderArgs, count);
4399
4400 closeSession(session);
4401 }
4402 }
4403
4404 return count.intValue();
4405 }
4406
4407
4415 public int countByC_FID(long companyId, long facebookId)
4416 throws SystemException {
4417 Object[] finderArgs = new Object[] { companyId, facebookId };
4418
4419 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_FID,
4420 finderArgs, this);
4421
4422 if (count == null) {
4423 StringBundler query = new StringBundler(3);
4424
4425 query.append(_SQL_COUNT_USER_WHERE);
4426
4427 query.append(_FINDER_COLUMN_C_FID_COMPANYID_2);
4428
4429 query.append(_FINDER_COLUMN_C_FID_FACEBOOKID_2);
4430
4431 String sql = query.toString();
4432
4433 Session session = null;
4434
4435 try {
4436 session = openSession();
4437
4438 Query q = session.createQuery(sql);
4439
4440 QueryPos qPos = QueryPos.getInstance(q);
4441
4442 qPos.add(companyId);
4443
4444 qPos.add(facebookId);
4445
4446 count = (Long)q.uniqueResult();
4447 }
4448 catch (Exception e) {
4449 throw processException(e);
4450 }
4451 finally {
4452 if (count == null) {
4453 count = Long.valueOf(0);
4454 }
4455
4456 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_FID,
4457 finderArgs, count);
4458
4459 closeSession(session);
4460 }
4461 }
4462
4463 return count.intValue();
4464 }
4465
4466
4474 public int countByC_O(long companyId, String openId)
4475 throws SystemException {
4476 Object[] finderArgs = new Object[] { companyId, openId };
4477
4478 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_O,
4479 finderArgs, this);
4480
4481 if (count == null) {
4482 StringBundler query = new StringBundler(3);
4483
4484 query.append(_SQL_COUNT_USER_WHERE);
4485
4486 query.append(_FINDER_COLUMN_C_O_COMPANYID_2);
4487
4488 if (openId == null) {
4489 query.append(_FINDER_COLUMN_C_O_OPENID_1);
4490 }
4491 else {
4492 if (openId.equals(StringPool.BLANK)) {
4493 query.append(_FINDER_COLUMN_C_O_OPENID_3);
4494 }
4495 else {
4496 query.append(_FINDER_COLUMN_C_O_OPENID_2);
4497 }
4498 }
4499
4500 String sql = query.toString();
4501
4502 Session session = null;
4503
4504 try {
4505 session = openSession();
4506
4507 Query q = session.createQuery(sql);
4508
4509 QueryPos qPos = QueryPos.getInstance(q);
4510
4511 qPos.add(companyId);
4512
4513 if (openId != null) {
4514 qPos.add(openId);
4515 }
4516
4517 count = (Long)q.uniqueResult();
4518 }
4519 catch (Exception e) {
4520 throw processException(e);
4521 }
4522 finally {
4523 if (count == null) {
4524 count = Long.valueOf(0);
4525 }
4526
4527 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_O, finderArgs,
4528 count);
4529
4530 closeSession(session);
4531 }
4532 }
4533
4534 return count.intValue();
4535 }
4536
4537
4545 public int countByC_S(long companyId, int status) throws SystemException {
4546 Object[] finderArgs = new Object[] { companyId, status };
4547
4548 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_S,
4549 finderArgs, this);
4550
4551 if (count == null) {
4552 StringBundler query = new StringBundler(3);
4553
4554 query.append(_SQL_COUNT_USER_WHERE);
4555
4556 query.append(_FINDER_COLUMN_C_S_COMPANYID_2);
4557
4558 query.append(_FINDER_COLUMN_C_S_STATUS_2);
4559
4560 String sql = query.toString();
4561
4562 Session session = null;
4563
4564 try {
4565 session = openSession();
4566
4567 Query q = session.createQuery(sql);
4568
4569 QueryPos qPos = QueryPos.getInstance(q);
4570
4571 qPos.add(companyId);
4572
4573 qPos.add(status);
4574
4575 count = (Long)q.uniqueResult();
4576 }
4577 catch (Exception e) {
4578 throw processException(e);
4579 }
4580 finally {
4581 if (count == null) {
4582 count = Long.valueOf(0);
4583 }
4584
4585 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_S, finderArgs,
4586 count);
4587
4588 closeSession(session);
4589 }
4590 }
4591
4592 return count.intValue();
4593 }
4594
4595
4601 public int countAll() throws SystemException {
4602 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4603 FINDER_ARGS_EMPTY, this);
4604
4605 if (count == null) {
4606 Session session = null;
4607
4608 try {
4609 session = openSession();
4610
4611 Query q = session.createQuery(_SQL_COUNT_USER);
4612
4613 count = (Long)q.uniqueResult();
4614 }
4615 catch (Exception e) {
4616 throw processException(e);
4617 }
4618 finally {
4619 if (count == null) {
4620 count = Long.valueOf(0);
4621 }
4622
4623 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4624 FINDER_ARGS_EMPTY, count);
4625
4626 closeSession(session);
4627 }
4628 }
4629
4630 return count.intValue();
4631 }
4632
4633
4640 public List<com.liferay.portal.model.Group> getGroups(long pk)
4641 throws SystemException {
4642 return getGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4643 }
4644
4645
4658 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4659 int end) throws SystemException {
4660 return getGroups(pk, start, end, null);
4661 }
4662
4663 public static final FinderPath FINDER_PATH_GET_GROUPS = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4664 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS,
4665 com.liferay.portal.model.impl.GroupImpl.class,
4666 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroups",
4667 new String[] {
4668 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4669 "com.liferay.portal.kernel.util.OrderByComparator"
4670 });
4671
4672
4686 public List<com.liferay.portal.model.Group> getGroups(long pk, int start,
4687 int end, OrderByComparator orderByComparator) throws SystemException {
4688 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4689
4690 List<com.liferay.portal.model.Group> list = (List<com.liferay.portal.model.Group>)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS,
4691 finderArgs, this);
4692
4693 if (list == null) {
4694 Session session = null;
4695
4696 try {
4697 session = openSession();
4698
4699 String sql = null;
4700
4701 if (orderByComparator != null) {
4702 sql = _SQL_GETGROUPS.concat(ORDER_BY_CLAUSE)
4703 .concat(orderByComparator.getOrderBy());
4704 }
4705 else {
4706 sql = _SQL_GETGROUPS.concat(com.liferay.portal.model.impl.GroupModelImpl.ORDER_BY_SQL);
4707 }
4708
4709 SQLQuery q = session.createSQLQuery(sql);
4710
4711 q.addEntity("Group_",
4712 com.liferay.portal.model.impl.GroupImpl.class);
4713
4714 QueryPos qPos = QueryPos.getInstance(q);
4715
4716 qPos.add(pk);
4717
4718 list = (List<com.liferay.portal.model.Group>)QueryUtil.list(q,
4719 getDialect(), start, end);
4720 }
4721 catch (Exception e) {
4722 throw processException(e);
4723 }
4724 finally {
4725 if (list == null) {
4726 FinderCacheUtil.removeResult(FINDER_PATH_GET_GROUPS,
4727 finderArgs);
4728 }
4729 else {
4730 groupPersistence.cacheResult(list);
4731
4732 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS,
4733 finderArgs, list);
4734 }
4735
4736 closeSession(session);
4737 }
4738 }
4739
4740 return list;
4741 }
4742
4743 public static final FinderPath FINDER_PATH_GET_GROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4744 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Long.class,
4745 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "getGroupsSize",
4746 new String[] { Long.class.getName() });
4747
4748
4755 public int getGroupsSize(long pk) throws SystemException {
4756 Object[] finderArgs = new Object[] { pk };
4757
4758 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_GROUPS_SIZE,
4759 finderArgs, this);
4760
4761 if (count == null) {
4762 Session session = null;
4763
4764 try {
4765 session = openSession();
4766
4767 SQLQuery q = session.createSQLQuery(_SQL_GETGROUPSSIZE);
4768
4769 q.addScalar(COUNT_COLUMN_NAME,
4770 com.liferay.portal.kernel.dao.orm.Type.LONG);
4771
4772 QueryPos qPos = QueryPos.getInstance(q);
4773
4774 qPos.add(pk);
4775
4776 count = (Long)q.uniqueResult();
4777 }
4778 catch (Exception e) {
4779 throw processException(e);
4780 }
4781 finally {
4782 if (count == null) {
4783 count = Long.valueOf(0);
4784 }
4785
4786 FinderCacheUtil.putResult(FINDER_PATH_GET_GROUPS_SIZE,
4787 finderArgs, count);
4788
4789 closeSession(session);
4790 }
4791 }
4792
4793 return count.intValue();
4794 }
4795
4796 public static final FinderPath FINDER_PATH_CONTAINS_GROUP = new FinderPath(com.liferay.portal.model.impl.GroupModelImpl.ENTITY_CACHE_ENABLED,
4797 UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS, Boolean.class,
4798 UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME, "containsGroup",
4799 new String[] { Long.class.getName(), Long.class.getName() });
4800
4801
4809 public boolean containsGroup(long pk, long groupPK)
4810 throws SystemException {
4811 Object[] finderArgs = new Object[] { pk, groupPK };
4812
4813 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_GROUP,
4814 finderArgs, this);
4815
4816 if (value == null) {
4817 try {
4818 value = Boolean.valueOf(containsGroup.contains(pk, groupPK));
4819 }
4820 catch (Exception e) {
4821 throw processException(e);
4822 }
4823 finally {
4824 if (value == null) {
4825 value = Boolean.FALSE;
4826 }
4827
4828 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_GROUP,
4829 finderArgs, value);
4830 }
4831 }
4832
4833 return value.booleanValue();
4834 }
4835
4836
4843 public boolean containsGroups(long pk) throws SystemException {
4844 if (getGroupsSize(pk) > 0) {
4845 return true;
4846 }
4847 else {
4848 return false;
4849 }
4850 }
4851
4852
4859 public void addGroup(long pk, long groupPK) throws SystemException {
4860 try {
4861 addGroup.add(pk, groupPK);
4862 }
4863 catch (Exception e) {
4864 throw processException(e);
4865 }
4866 finally {
4867 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4868 }
4869 }
4870
4871
4878 public void addGroup(long pk, com.liferay.portal.model.Group group)
4879 throws SystemException {
4880 try {
4881 addGroup.add(pk, group.getPrimaryKey());
4882 }
4883 catch (Exception e) {
4884 throw processException(e);
4885 }
4886 finally {
4887 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4888 }
4889 }
4890
4891
4898 public void addGroups(long pk, long[] groupPKs) throws SystemException {
4899 try {
4900 for (long groupPK : groupPKs) {
4901 addGroup.add(pk, groupPK);
4902 }
4903 }
4904 catch (Exception e) {
4905 throw processException(e);
4906 }
4907 finally {
4908 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4909 }
4910 }
4911
4912
4919 public void addGroups(long pk, List<com.liferay.portal.model.Group> groups)
4920 throws SystemException {
4921 try {
4922 for (com.liferay.portal.model.Group group : groups) {
4923 addGroup.add(pk, group.getPrimaryKey());
4924 }
4925 }
4926 catch (Exception e) {
4927 throw processException(e);
4928 }
4929 finally {
4930 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4931 }
4932 }
4933
4934
4940 public void clearGroups(long pk) throws SystemException {
4941 try {
4942 clearGroups.clear(pk);
4943 }
4944 catch (Exception e) {
4945 throw processException(e);
4946 }
4947 finally {
4948 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4949 }
4950 }
4951
4952
4959 public void removeGroup(long pk, long groupPK) throws SystemException {
4960 try {
4961 removeGroup.remove(pk, groupPK);
4962 }
4963 catch (Exception e) {
4964 throw processException(e);
4965 }
4966 finally {
4967 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4968 }
4969 }
4970
4971
4978 public void removeGroup(long pk, com.liferay.portal.model.Group group)
4979 throws SystemException {
4980 try {
4981 removeGroup.remove(pk, group.getPrimaryKey());
4982 }
4983 catch (Exception e) {
4984 throw processException(e);
4985 }
4986 finally {
4987 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
4988 }
4989 }
4990
4991
4998 public void removeGroups(long pk, long[] groupPKs)
4999 throws SystemException {
5000 try {
5001 for (long groupPK : groupPKs) {
5002 removeGroup.remove(pk, groupPK);
5003 }
5004 }
5005 catch (Exception e) {
5006 throw processException(e);
5007 }
5008 finally {
5009 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5010 }
5011 }
5012
5013
5020 public void removeGroups(long pk,
5021 List<com.liferay.portal.model.Group> groups) throws SystemException {
5022 try {
5023 for (com.liferay.portal.model.Group group : groups) {
5024 removeGroup.remove(pk, group.getPrimaryKey());
5025 }
5026 }
5027 catch (Exception e) {
5028 throw processException(e);
5029 }
5030 finally {
5031 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5032 }
5033 }
5034
5035
5042 public void setGroups(long pk, long[] groupPKs) throws SystemException {
5043 try {
5044 Set<Long> groupPKSet = SetUtil.fromArray(groupPKs);
5045
5046 List<com.liferay.portal.model.Group> groups = getGroups(pk);
5047
5048 for (com.liferay.portal.model.Group group : groups) {
5049 if (!groupPKSet.remove(group.getPrimaryKey())) {
5050 removeGroup.remove(pk, group.getPrimaryKey());
5051 }
5052 }
5053
5054 for (Long groupPK : groupPKSet) {
5055 addGroup.add(pk, groupPK);
5056 }
5057 }
5058 catch (Exception e) {
5059 throw processException(e);
5060 }
5061 finally {
5062 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5063 }
5064 }
5065
5066
5073 public void setGroups(long pk, List<com.liferay.portal.model.Group> groups)
5074 throws SystemException {
5075 try {
5076 long[] groupPKs = new long[groups.size()];
5077
5078 for (int i = 0; i < groups.size(); i++) {
5079 com.liferay.portal.model.Group group = groups.get(i);
5080
5081 groupPKs[i] = group.getPrimaryKey();
5082 }
5083
5084 setGroups(pk, groupPKs);
5085 }
5086 catch (Exception e) {
5087 throw processException(e);
5088 }
5089 finally {
5090 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME);
5091 }
5092 }
5093
5094
5101 public List<com.liferay.portal.model.Organization> getOrganizations(long pk)
5102 throws SystemException {
5103 return getOrganizations(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5104 }
5105
5106
5119 public List<com.liferay.portal.model.Organization> getOrganizations(
5120 long pk, int start, int end) throws SystemException {
5121 return getOrganizations(pk, start, end, null);
5122 }
5123
5124 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5125 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS,
5126 com.liferay.portal.model.impl.OrganizationImpl.class,
5127 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME, "getOrganizations",
5128 new String[] {
5129 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5130 "com.liferay.portal.kernel.util.OrderByComparator"
5131 });
5132
5133
5147 public List<com.liferay.portal.model.Organization> getOrganizations(
5148 long pk, int start, int end, OrderByComparator orderByComparator)
5149 throws SystemException {
5150 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5151
5152 List<com.liferay.portal.model.Organization> list = (List<com.liferay.portal.model.Organization>)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS,
5153 finderArgs, this);
5154
5155 if (list == null) {
5156 Session session = null;
5157
5158 try {
5159 session = openSession();
5160
5161 String sql = null;
5162
5163 if (orderByComparator != null) {
5164 sql = _SQL_GETORGANIZATIONS.concat(ORDER_BY_CLAUSE)
5165 .concat(orderByComparator.getOrderBy());
5166 }
5167 else {
5168 sql = _SQL_GETORGANIZATIONS.concat(com.liferay.portal.model.impl.OrganizationModelImpl.ORDER_BY_SQL);
5169 }
5170
5171 SQLQuery q = session.createSQLQuery(sql);
5172
5173 q.addEntity("Organization_",
5174 com.liferay.portal.model.impl.OrganizationImpl.class);
5175
5176 QueryPos qPos = QueryPos.getInstance(q);
5177
5178 qPos.add(pk);
5179
5180 list = (List<com.liferay.portal.model.Organization>)QueryUtil.list(q,
5181 getDialect(), start, end);
5182 }
5183 catch (Exception e) {
5184 throw processException(e);
5185 }
5186 finally {
5187 if (list == null) {
5188 FinderCacheUtil.removeResult(FINDER_PATH_GET_ORGANIZATIONS,
5189 finderArgs);
5190 }
5191 else {
5192 organizationPersistence.cacheResult(list);
5193
5194 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS,
5195 finderArgs, list);
5196 }
5197
5198 closeSession(session);
5199 }
5200 }
5201
5202 return list;
5203 }
5204
5205 public static final FinderPath FINDER_PATH_GET_ORGANIZATIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5206 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Long.class,
5207 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
5208 "getOrganizationsSize", new String[] { Long.class.getName() });
5209
5210
5217 public int getOrganizationsSize(long pk) throws SystemException {
5218 Object[] finderArgs = new Object[] { pk };
5219
5220 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5221 finderArgs, this);
5222
5223 if (count == null) {
5224 Session session = null;
5225
5226 try {
5227 session = openSession();
5228
5229 SQLQuery q = session.createSQLQuery(_SQL_GETORGANIZATIONSSIZE);
5230
5231 q.addScalar(COUNT_COLUMN_NAME,
5232 com.liferay.portal.kernel.dao.orm.Type.LONG);
5233
5234 QueryPos qPos = QueryPos.getInstance(q);
5235
5236 qPos.add(pk);
5237
5238 count = (Long)q.uniqueResult();
5239 }
5240 catch (Exception e) {
5241 throw processException(e);
5242 }
5243 finally {
5244 if (count == null) {
5245 count = Long.valueOf(0);
5246 }
5247
5248 FinderCacheUtil.putResult(FINDER_PATH_GET_ORGANIZATIONS_SIZE,
5249 finderArgs, count);
5250
5251 closeSession(session);
5252 }
5253 }
5254
5255 return count.intValue();
5256 }
5257
5258 public static final FinderPath FINDER_PATH_CONTAINS_ORGANIZATION = new FinderPath(com.liferay.portal.model.impl.OrganizationModelImpl.ENTITY_CACHE_ENABLED,
5259 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ORGS, Boolean.class,
5260 UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME,
5261 "containsOrganization",
5262 new String[] { Long.class.getName(), Long.class.getName() });
5263
5264
5272 public boolean containsOrganization(long pk, long organizationPK)
5273 throws SystemException {
5274 Object[] finderArgs = new Object[] { pk, organizationPK };
5275
5276 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5277 finderArgs, this);
5278
5279 if (value == null) {
5280 try {
5281 value = Boolean.valueOf(containsOrganization.contains(pk,
5282 organizationPK));
5283 }
5284 catch (Exception e) {
5285 throw processException(e);
5286 }
5287 finally {
5288 if (value == null) {
5289 value = Boolean.FALSE;
5290 }
5291
5292 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ORGANIZATION,
5293 finderArgs, value);
5294 }
5295 }
5296
5297 return value.booleanValue();
5298 }
5299
5300
5307 public boolean containsOrganizations(long pk) throws SystemException {
5308 if (getOrganizationsSize(pk) > 0) {
5309 return true;
5310 }
5311 else {
5312 return false;
5313 }
5314 }
5315
5316
5323 public void addOrganization(long pk, long organizationPK)
5324 throws SystemException {
5325 try {
5326 addOrganization.add(pk, organizationPK);
5327 }
5328 catch (Exception e) {
5329 throw processException(e);
5330 }
5331 finally {
5332 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5333 }
5334 }
5335
5336
5343 public void addOrganization(long pk,
5344 com.liferay.portal.model.Organization organization)
5345 throws SystemException {
5346 try {
5347 addOrganization.add(pk, organization.getPrimaryKey());
5348 }
5349 catch (Exception e) {
5350 throw processException(e);
5351 }
5352 finally {
5353 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5354 }
5355 }
5356
5357
5364 public void addOrganizations(long pk, long[] organizationPKs)
5365 throws SystemException {
5366 try {
5367 for (long organizationPK : organizationPKs) {
5368 addOrganization.add(pk, organizationPK);
5369 }
5370 }
5371 catch (Exception e) {
5372 throw processException(e);
5373 }
5374 finally {
5375 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5376 }
5377 }
5378
5379
5386 public void addOrganizations(long pk,
5387 List<com.liferay.portal.model.Organization> organizations)
5388 throws SystemException {
5389 try {
5390 for (com.liferay.portal.model.Organization organization : organizations) {
5391 addOrganization.add(pk, organization.getPrimaryKey());
5392 }
5393 }
5394 catch (Exception e) {
5395 throw processException(e);
5396 }
5397 finally {
5398 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5399 }
5400 }
5401
5402
5408 public void clearOrganizations(long pk) throws SystemException {
5409 try {
5410 clearOrganizations.clear(pk);
5411 }
5412 catch (Exception e) {
5413 throw processException(e);
5414 }
5415 finally {
5416 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5417 }
5418 }
5419
5420
5427 public void removeOrganization(long pk, long organizationPK)
5428 throws SystemException {
5429 try {
5430 removeOrganization.remove(pk, organizationPK);
5431 }
5432 catch (Exception e) {
5433 throw processException(e);
5434 }
5435 finally {
5436 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5437 }
5438 }
5439
5440
5447 public void removeOrganization(long pk,
5448 com.liferay.portal.model.Organization organization)
5449 throws SystemException {
5450 try {
5451 removeOrganization.remove(pk, organization.getPrimaryKey());
5452 }
5453 catch (Exception e) {
5454 throw processException(e);
5455 }
5456 finally {
5457 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5458 }
5459 }
5460
5461
5468 public void removeOrganizations(long pk, long[] organizationPKs)
5469 throws SystemException {
5470 try {
5471 for (long organizationPK : organizationPKs) {
5472 removeOrganization.remove(pk, organizationPK);
5473 }
5474 }
5475 catch (Exception e) {
5476 throw processException(e);
5477 }
5478 finally {
5479 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5480 }
5481 }
5482
5483
5490 public void removeOrganizations(long pk,
5491 List<com.liferay.portal.model.Organization> organizations)
5492 throws SystemException {
5493 try {
5494 for (com.liferay.portal.model.Organization organization : organizations) {
5495 removeOrganization.remove(pk, organization.getPrimaryKey());
5496 }
5497 }
5498 catch (Exception e) {
5499 throw processException(e);
5500 }
5501 finally {
5502 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5503 }
5504 }
5505
5506
5513 public void setOrganizations(long pk, long[] organizationPKs)
5514 throws SystemException {
5515 try {
5516 Set<Long> organizationPKSet = SetUtil.fromArray(organizationPKs);
5517
5518 List<com.liferay.portal.model.Organization> organizations = getOrganizations(pk);
5519
5520 for (com.liferay.portal.model.Organization organization : organizations) {
5521 if (!organizationPKSet.remove(organization.getPrimaryKey())) {
5522 removeOrganization.remove(pk, organization.getPrimaryKey());
5523 }
5524 }
5525
5526 for (Long organizationPK : organizationPKSet) {
5527 addOrganization.add(pk, organizationPK);
5528 }
5529 }
5530 catch (Exception e) {
5531 throw processException(e);
5532 }
5533 finally {
5534 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5535 }
5536 }
5537
5538
5545 public void setOrganizations(long pk,
5546 List<com.liferay.portal.model.Organization> organizations)
5547 throws SystemException {
5548 try {
5549 long[] organizationPKs = new long[organizations.size()];
5550
5551 for (int i = 0; i < organizations.size(); i++) {
5552 com.liferay.portal.model.Organization organization = organizations.get(i);
5553
5554 organizationPKs[i] = organization.getPrimaryKey();
5555 }
5556
5557 setOrganizations(pk, organizationPKs);
5558 }
5559 catch (Exception e) {
5560 throw processException(e);
5561 }
5562 finally {
5563 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ORGS_NAME);
5564 }
5565 }
5566
5567
5574 public List<com.liferay.portal.model.Permission> getPermissions(long pk)
5575 throws SystemException {
5576 return getPermissions(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
5577 }
5578
5579
5592 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5593 int start, int end) throws SystemException {
5594 return getPermissions(pk, start, end, null);
5595 }
5596
5597 public static final FinderPath FINDER_PATH_GET_PERMISSIONS = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5598 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
5599 com.liferay.portal.model.impl.PermissionImpl.class,
5600 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5601 "getPermissions",
5602 new String[] {
5603 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
5604 "com.liferay.portal.kernel.util.OrderByComparator"
5605 });
5606
5607
5621 public List<com.liferay.portal.model.Permission> getPermissions(long pk,
5622 int start, int end, OrderByComparator orderByComparator)
5623 throws SystemException {
5624 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
5625
5626 List<com.liferay.portal.model.Permission> list = (List<com.liferay.portal.model.Permission>)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS,
5627 finderArgs, this);
5628
5629 if (list == null) {
5630 Session session = null;
5631
5632 try {
5633 session = openSession();
5634
5635 String sql = null;
5636
5637 if (orderByComparator != null) {
5638 sql = _SQL_GETPERMISSIONS.concat(ORDER_BY_CLAUSE)
5639 .concat(orderByComparator.getOrderBy());
5640 }
5641 else {
5642 sql = _SQL_GETPERMISSIONS;
5643 }
5644
5645 SQLQuery q = session.createSQLQuery(sql);
5646
5647 q.addEntity("Permission_",
5648 com.liferay.portal.model.impl.PermissionImpl.class);
5649
5650 QueryPos qPos = QueryPos.getInstance(q);
5651
5652 qPos.add(pk);
5653
5654 list = (List<com.liferay.portal.model.Permission>)QueryUtil.list(q,
5655 getDialect(), start, end);
5656 }
5657 catch (Exception e) {
5658 throw processException(e);
5659 }
5660 finally {
5661 if (list == null) {
5662 FinderCacheUtil.removeResult(FINDER_PATH_GET_PERMISSIONS,
5663 finderArgs);
5664 }
5665 else {
5666 permissionPersistence.cacheResult(list);
5667
5668 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS,
5669 finderArgs, list);
5670 }
5671
5672 closeSession(session);
5673 }
5674 }
5675
5676 return list;
5677 }
5678
5679 public static final FinderPath FINDER_PATH_GET_PERMISSIONS_SIZE = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5680 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS, Long.class,
5681 UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5682 "getPermissionsSize", new String[] { Long.class.getName() });
5683
5684
5691 public int getPermissionsSize(long pk) throws SystemException {
5692 Object[] finderArgs = new Object[] { pk };
5693
5694 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5695 finderArgs, this);
5696
5697 if (count == null) {
5698 Session session = null;
5699
5700 try {
5701 session = openSession();
5702
5703 SQLQuery q = session.createSQLQuery(_SQL_GETPERMISSIONSSIZE);
5704
5705 q.addScalar(COUNT_COLUMN_NAME,
5706 com.liferay.portal.kernel.dao.orm.Type.LONG);
5707
5708 QueryPos qPos = QueryPos.getInstance(q);
5709
5710 qPos.add(pk);
5711
5712 count = (Long)q.uniqueResult();
5713 }
5714 catch (Exception e) {
5715 throw processException(e);
5716 }
5717 finally {
5718 if (count == null) {
5719 count = Long.valueOf(0);
5720 }
5721
5722 FinderCacheUtil.putResult(FINDER_PATH_GET_PERMISSIONS_SIZE,
5723 finderArgs, count);
5724
5725 closeSession(session);
5726 }
5727 }
5728
5729 return count.intValue();
5730 }
5731
5732 public static final FinderPath FINDER_PATH_CONTAINS_PERMISSION = new FinderPath(com.liferay.portal.model.impl.PermissionModelImpl.ENTITY_CACHE_ENABLED,
5733 UserModelImpl.FINDER_CACHE_ENABLED_USERS_PERMISSIONS,
5734 Boolean.class, UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME,
5735 "containsPermission",
5736 new String[] { Long.class.getName(), Long.class.getName() });
5737
5738
5746 public boolean containsPermission(long pk, long permissionPK)
5747 throws SystemException {
5748 Object[] finderArgs = new Object[] { pk, permissionPK };
5749
5750 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_PERMISSION,
5751 finderArgs, this);
5752
5753 if (value == null) {
5754 try {
5755 value = Boolean.valueOf(containsPermission.contains(pk,
5756 permissionPK));
5757 }
5758 catch (Exception e) {
5759 throw processException(e);
5760 }
5761 finally {
5762 if (value == null) {
5763 value = Boolean.FALSE;
5764 }
5765
5766 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_PERMISSION,
5767 finderArgs, value);
5768 }
5769 }
5770
5771 return value.booleanValue();
5772 }
5773
5774
5781 public boolean containsPermissions(long pk) throws SystemException {
5782 if (getPermissionsSize(pk) > 0) {
5783 return true;
5784 }
5785 else {
5786 return false;
5787 }
5788 }
5789
5790
5797 public void addPermission(long pk, long permissionPK)
5798 throws SystemException {
5799 try {
5800 addPermission.add(pk, permissionPK);
5801 }
5802 catch (Exception e) {
5803 throw processException(e);
5804 }
5805 finally {
5806 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5807 }
5808 }
5809
5810
5817 public void addPermission(long pk,
5818 com.liferay.portal.model.Permission permission)
5819 throws SystemException {
5820 try {
5821 addPermission.add(pk, permission.getPrimaryKey());
5822 }
5823 catch (Exception e) {
5824 throw processException(e);
5825 }
5826 finally {
5827 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5828 }
5829 }
5830
5831
5838 public void addPermissions(long pk, long[] permissionPKs)
5839 throws SystemException {
5840 try {
5841 for (long permissionPK : permissionPKs) {
5842 addPermission.add(pk, permissionPK);
5843 }
5844 }
5845 catch (Exception e) {
5846 throw processException(e);
5847 }
5848 finally {
5849 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5850 }
5851 }
5852
5853
5860 public void addPermissions(long pk,
5861 List<com.liferay.portal.model.Permission> permissions)
5862 throws SystemException {
5863 try {
5864 for (com.liferay.portal.model.Permission permission : permissions) {
5865 addPermission.add(pk, permission.getPrimaryKey());
5866 }
5867 }
5868 catch (Exception e) {
5869 throw processException(e);
5870 }
5871 finally {
5872 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5873 }
5874 }
5875
5876
5882 public void clearPermissions(long pk) throws SystemException {
5883 try {
5884 clearPermissions.clear(pk);
5885 }
5886 catch (Exception e) {
5887 throw processException(e);
5888 }
5889 finally {
5890 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5891 }
5892 }
5893
5894
5901 public void removePermission(long pk, long permissionPK)
5902 throws SystemException {
5903 try {
5904 removePermission.remove(pk, permissionPK);
5905 }
5906 catch (Exception e) {
5907 throw processException(e);
5908 }
5909 finally {
5910 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5911 }
5912 }
5913
5914
5921 public void removePermission(long pk,
5922 com.liferay.portal.model.Permission permission)
5923 throws SystemException {
5924 try {
5925 removePermission.remove(pk, permission.getPrimaryKey());
5926 }
5927 catch (Exception e) {
5928 throw processException(e);
5929 }
5930 finally {
5931 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5932 }
5933 }
5934
5935
5942 public void removePermissions(long pk, long[] permissionPKs)
5943 throws SystemException {
5944 try {
5945 for (long permissionPK : permissionPKs) {
5946 removePermission.remove(pk, permissionPK);
5947 }
5948 }
5949 catch (Exception e) {
5950 throw processException(e);
5951 }
5952 finally {
5953 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5954 }
5955 }
5956
5957
5964 public void removePermissions(long pk,
5965 List<com.liferay.portal.model.Permission> permissions)
5966 throws SystemException {
5967 try {
5968 for (com.liferay.portal.model.Permission permission : permissions) {
5969 removePermission.remove(pk, permission.getPrimaryKey());
5970 }
5971 }
5972 catch (Exception e) {
5973 throw processException(e);
5974 }
5975 finally {
5976 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
5977 }
5978 }
5979
5980
5987 public void setPermissions(long pk, long[] permissionPKs)
5988 throws SystemException {
5989 try {
5990 Set<Long> permissionPKSet = SetUtil.fromArray(permissionPKs);
5991
5992 List<com.liferay.portal.model.Permission> permissions = getPermissions(pk);
5993
5994 for (com.liferay.portal.model.Permission permission : permissions) {
5995 if (!permissionPKSet.remove(permission.getPrimaryKey())) {
5996 removePermission.remove(pk, permission.getPrimaryKey());
5997 }
5998 }
5999
6000 for (Long permissionPK : permissionPKSet) {
6001 addPermission.add(pk, permissionPK);
6002 }
6003 }
6004 catch (Exception e) {
6005 throw processException(e);
6006 }
6007 finally {
6008 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6009 }
6010 }
6011
6012
6019 public void setPermissions(long pk,
6020 List<com.liferay.portal.model.Permission> permissions)
6021 throws SystemException {
6022 try {
6023 long[] permissionPKs = new long[permissions.size()];
6024
6025 for (int i = 0; i < permissions.size(); i++) {
6026 com.liferay.portal.model.Permission permission = permissions.get(i);
6027
6028 permissionPKs[i] = permission.getPrimaryKey();
6029 }
6030
6031 setPermissions(pk, permissionPKs);
6032 }
6033 catch (Exception e) {
6034 throw processException(e);
6035 }
6036 finally {
6037 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_PERMISSIONS_NAME);
6038 }
6039 }
6040
6041
6048 public List<com.liferay.portal.model.Role> getRoles(long pk)
6049 throws SystemException {
6050 return getRoles(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6051 }
6052
6053
6066 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6067 int end) throws SystemException {
6068 return getRoles(pk, start, end, null);
6069 }
6070
6071 public static final FinderPath FINDER_PATH_GET_ROLES = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6072 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES,
6073 com.liferay.portal.model.impl.RoleImpl.class,
6074 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRoles",
6075 new String[] {
6076 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6077 "com.liferay.portal.kernel.util.OrderByComparator"
6078 });
6079
6080
6094 public List<com.liferay.portal.model.Role> getRoles(long pk, int start,
6095 int end, OrderByComparator orderByComparator) throws SystemException {
6096 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6097
6098 List<com.liferay.portal.model.Role> list = (List<com.liferay.portal.model.Role>)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES,
6099 finderArgs, this);
6100
6101 if (list == null) {
6102 Session session = null;
6103
6104 try {
6105 session = openSession();
6106
6107 String sql = null;
6108
6109 if (orderByComparator != null) {
6110 sql = _SQL_GETROLES.concat(ORDER_BY_CLAUSE)
6111 .concat(orderByComparator.getOrderBy());
6112 }
6113 else {
6114 sql = _SQL_GETROLES.concat(com.liferay.portal.model.impl.RoleModelImpl.ORDER_BY_SQL);
6115 }
6116
6117 SQLQuery q = session.createSQLQuery(sql);
6118
6119 q.addEntity("Role_",
6120 com.liferay.portal.model.impl.RoleImpl.class);
6121
6122 QueryPos qPos = QueryPos.getInstance(q);
6123
6124 qPos.add(pk);
6125
6126 list = (List<com.liferay.portal.model.Role>)QueryUtil.list(q,
6127 getDialect(), start, end);
6128 }
6129 catch (Exception e) {
6130 throw processException(e);
6131 }
6132 finally {
6133 if (list == null) {
6134 FinderCacheUtil.removeResult(FINDER_PATH_GET_ROLES,
6135 finderArgs);
6136 }
6137 else {
6138 rolePersistence.cacheResult(list);
6139
6140 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES,
6141 finderArgs, list);
6142 }
6143
6144 closeSession(session);
6145 }
6146 }
6147
6148 return list;
6149 }
6150
6151 public static final FinderPath FINDER_PATH_GET_ROLES_SIZE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6152 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Long.class,
6153 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "getRolesSize",
6154 new String[] { Long.class.getName() });
6155
6156
6163 public int getRolesSize(long pk) throws SystemException {
6164 Object[] finderArgs = new Object[] { pk };
6165
6166 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_ROLES_SIZE,
6167 finderArgs, this);
6168
6169 if (count == null) {
6170 Session session = null;
6171
6172 try {
6173 session = openSession();
6174
6175 SQLQuery q = session.createSQLQuery(_SQL_GETROLESSIZE);
6176
6177 q.addScalar(COUNT_COLUMN_NAME,
6178 com.liferay.portal.kernel.dao.orm.Type.LONG);
6179
6180 QueryPos qPos = QueryPos.getInstance(q);
6181
6182 qPos.add(pk);
6183
6184 count = (Long)q.uniqueResult();
6185 }
6186 catch (Exception e) {
6187 throw processException(e);
6188 }
6189 finally {
6190 if (count == null) {
6191 count = Long.valueOf(0);
6192 }
6193
6194 FinderCacheUtil.putResult(FINDER_PATH_GET_ROLES_SIZE,
6195 finderArgs, count);
6196
6197 closeSession(session);
6198 }
6199 }
6200
6201 return count.intValue();
6202 }
6203
6204 public static final FinderPath FINDER_PATH_CONTAINS_ROLE = new FinderPath(com.liferay.portal.model.impl.RoleModelImpl.ENTITY_CACHE_ENABLED,
6205 UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES, Boolean.class,
6206 UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME, "containsRole",
6207 new String[] { Long.class.getName(), Long.class.getName() });
6208
6209
6217 public boolean containsRole(long pk, long rolePK) throws SystemException {
6218 Object[] finderArgs = new Object[] { pk, rolePK };
6219
6220 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_ROLE,
6221 finderArgs, this);
6222
6223 if (value == null) {
6224 try {
6225 value = Boolean.valueOf(containsRole.contains(pk, rolePK));
6226 }
6227 catch (Exception e) {
6228 throw processException(e);
6229 }
6230 finally {
6231 if (value == null) {
6232 value = Boolean.FALSE;
6233 }
6234
6235 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_ROLE,
6236 finderArgs, value);
6237 }
6238 }
6239
6240 return value.booleanValue();
6241 }
6242
6243
6250 public boolean containsRoles(long pk) throws SystemException {
6251 if (getRolesSize(pk) > 0) {
6252 return true;
6253 }
6254 else {
6255 return false;
6256 }
6257 }
6258
6259
6266 public void addRole(long pk, long rolePK) throws SystemException {
6267 try {
6268 addRole.add(pk, rolePK);
6269 }
6270 catch (Exception e) {
6271 throw processException(e);
6272 }
6273 finally {
6274 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6275 }
6276 }
6277
6278
6285 public void addRole(long pk, com.liferay.portal.model.Role role)
6286 throws SystemException {
6287 try {
6288 addRole.add(pk, role.getPrimaryKey());
6289 }
6290 catch (Exception e) {
6291 throw processException(e);
6292 }
6293 finally {
6294 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6295 }
6296 }
6297
6298
6305 public void addRoles(long pk, long[] rolePKs) throws SystemException {
6306 try {
6307 for (long rolePK : rolePKs) {
6308 addRole.add(pk, rolePK);
6309 }
6310 }
6311 catch (Exception e) {
6312 throw processException(e);
6313 }
6314 finally {
6315 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6316 }
6317 }
6318
6319
6326 public void addRoles(long pk, List<com.liferay.portal.model.Role> roles)
6327 throws SystemException {
6328 try {
6329 for (com.liferay.portal.model.Role role : roles) {
6330 addRole.add(pk, role.getPrimaryKey());
6331 }
6332 }
6333 catch (Exception e) {
6334 throw processException(e);
6335 }
6336 finally {
6337 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6338 }
6339 }
6340
6341
6347 public void clearRoles(long pk) throws SystemException {
6348 try {
6349 clearRoles.clear(pk);
6350 }
6351 catch (Exception e) {
6352 throw processException(e);
6353 }
6354 finally {
6355 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6356 }
6357 }
6358
6359
6366 public void removeRole(long pk, long rolePK) throws SystemException {
6367 try {
6368 removeRole.remove(pk, rolePK);
6369 }
6370 catch (Exception e) {
6371 throw processException(e);
6372 }
6373 finally {
6374 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6375 }
6376 }
6377
6378
6385 public void removeRole(long pk, com.liferay.portal.model.Role role)
6386 throws SystemException {
6387 try {
6388 removeRole.remove(pk, role.getPrimaryKey());
6389 }
6390 catch (Exception e) {
6391 throw processException(e);
6392 }
6393 finally {
6394 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6395 }
6396 }
6397
6398
6405 public void removeRoles(long pk, long[] rolePKs) throws SystemException {
6406 try {
6407 for (long rolePK : rolePKs) {
6408 removeRole.remove(pk, rolePK);
6409 }
6410 }
6411 catch (Exception e) {
6412 throw processException(e);
6413 }
6414 finally {
6415 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6416 }
6417 }
6418
6419
6426 public void removeRoles(long pk, List<com.liferay.portal.model.Role> roles)
6427 throws SystemException {
6428 try {
6429 for (com.liferay.portal.model.Role role : roles) {
6430 removeRole.remove(pk, role.getPrimaryKey());
6431 }
6432 }
6433 catch (Exception e) {
6434 throw processException(e);
6435 }
6436 finally {
6437 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6438 }
6439 }
6440
6441
6448 public void setRoles(long pk, long[] rolePKs) throws SystemException {
6449 try {
6450 Set<Long> rolePKSet = SetUtil.fromArray(rolePKs);
6451
6452 List<com.liferay.portal.model.Role> roles = getRoles(pk);
6453
6454 for (com.liferay.portal.model.Role role : roles) {
6455 if (!rolePKSet.remove(role.getPrimaryKey())) {
6456 removeRole.remove(pk, role.getPrimaryKey());
6457 }
6458 }
6459
6460 for (Long rolePK : rolePKSet) {
6461 addRole.add(pk, rolePK);
6462 }
6463 }
6464 catch (Exception e) {
6465 throw processException(e);
6466 }
6467 finally {
6468 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6469 }
6470 }
6471
6472
6479 public void setRoles(long pk, List<com.liferay.portal.model.Role> roles)
6480 throws SystemException {
6481 try {
6482 long[] rolePKs = new long[roles.size()];
6483
6484 for (int i = 0; i < roles.size(); i++) {
6485 com.liferay.portal.model.Role role = roles.get(i);
6486
6487 rolePKs[i] = role.getPrimaryKey();
6488 }
6489
6490 setRoles(pk, rolePKs);
6491 }
6492 catch (Exception e) {
6493 throw processException(e);
6494 }
6495 finally {
6496 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_ROLES_NAME);
6497 }
6498 }
6499
6500
6507 public List<com.liferay.portal.model.Team> getTeams(long pk)
6508 throws SystemException {
6509 return getTeams(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6510 }
6511
6512
6525 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
6526 int end) throws SystemException {
6527 return getTeams(pk, start, end, null);
6528 }
6529
6530 public static final FinderPath FINDER_PATH_GET_TEAMS = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6531 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
6532 com.liferay.portal.model.impl.TeamImpl.class,
6533 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeams",
6534 new String[] {
6535 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6536 "com.liferay.portal.kernel.util.OrderByComparator"
6537 });
6538
6539
6553 public List<com.liferay.portal.model.Team> getTeams(long pk, int start,
6554 int end, OrderByComparator orderByComparator) throws SystemException {
6555 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
6556
6557 List<com.liferay.portal.model.Team> list = (List<com.liferay.portal.model.Team>)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS,
6558 finderArgs, this);
6559
6560 if (list == null) {
6561 Session session = null;
6562
6563 try {
6564 session = openSession();
6565
6566 String sql = null;
6567
6568 if (orderByComparator != null) {
6569 sql = _SQL_GETTEAMS.concat(ORDER_BY_CLAUSE)
6570 .concat(orderByComparator.getOrderBy());
6571 }
6572 else {
6573 sql = _SQL_GETTEAMS.concat(com.liferay.portal.model.impl.TeamModelImpl.ORDER_BY_SQL);
6574 }
6575
6576 SQLQuery q = session.createSQLQuery(sql);
6577
6578 q.addEntity("Team", com.liferay.portal.model.impl.TeamImpl.class);
6579
6580 QueryPos qPos = QueryPos.getInstance(q);
6581
6582 qPos.add(pk);
6583
6584 list = (List<com.liferay.portal.model.Team>)QueryUtil.list(q,
6585 getDialect(), start, end);
6586 }
6587 catch (Exception e) {
6588 throw processException(e);
6589 }
6590 finally {
6591 if (list == null) {
6592 FinderCacheUtil.removeResult(FINDER_PATH_GET_TEAMS,
6593 finderArgs);
6594 }
6595 else {
6596 teamPersistence.cacheResult(list);
6597
6598 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS,
6599 finderArgs, list);
6600 }
6601
6602 closeSession(session);
6603 }
6604 }
6605
6606 return list;
6607 }
6608
6609 public static final FinderPath FINDER_PATH_GET_TEAMS_SIZE = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6610 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
6611 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getTeamsSize",
6612 new String[] { Long.class.getName() });
6613
6614
6621 public int getTeamsSize(long pk) throws SystemException {
6622 Object[] finderArgs = new Object[] { pk };
6623
6624 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_TEAMS_SIZE,
6625 finderArgs, this);
6626
6627 if (count == null) {
6628 Session session = null;
6629
6630 try {
6631 session = openSession();
6632
6633 SQLQuery q = session.createSQLQuery(_SQL_GETTEAMSSIZE);
6634
6635 q.addScalar(COUNT_COLUMN_NAME,
6636 com.liferay.portal.kernel.dao.orm.Type.LONG);
6637
6638 QueryPos qPos = QueryPos.getInstance(q);
6639
6640 qPos.add(pk);
6641
6642 count = (Long)q.uniqueResult();
6643 }
6644 catch (Exception e) {
6645 throw processException(e);
6646 }
6647 finally {
6648 if (count == null) {
6649 count = Long.valueOf(0);
6650 }
6651
6652 FinderCacheUtil.putResult(FINDER_PATH_GET_TEAMS_SIZE,
6653 finderArgs, count);
6654
6655 closeSession(session);
6656 }
6657 }
6658
6659 return count.intValue();
6660 }
6661
6662 public static final FinderPath FINDER_PATH_CONTAINS_TEAM = new FinderPath(com.liferay.portal.model.impl.TeamModelImpl.ENTITY_CACHE_ENABLED,
6663 UserModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
6664 UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsTeam",
6665 new String[] { Long.class.getName(), Long.class.getName() });
6666
6667
6675 public boolean containsTeam(long pk, long teamPK) throws SystemException {
6676 Object[] finderArgs = new Object[] { pk, teamPK };
6677
6678 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_TEAM,
6679 finderArgs, this);
6680
6681 if (value == null) {
6682 try {
6683 value = Boolean.valueOf(containsTeam.contains(pk, teamPK));
6684 }
6685 catch (Exception e) {
6686 throw processException(e);
6687 }
6688 finally {
6689 if (value == null) {
6690 value = Boolean.FALSE;
6691 }
6692
6693 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_TEAM,
6694 finderArgs, value);
6695 }
6696 }
6697
6698 return value.booleanValue();
6699 }
6700
6701
6708 public boolean containsTeams(long pk) throws SystemException {
6709 if (getTeamsSize(pk) > 0) {
6710 return true;
6711 }
6712 else {
6713 return false;
6714 }
6715 }
6716
6717
6724 public void addTeam(long pk, long teamPK) throws SystemException {
6725 try {
6726 addTeam.add(pk, teamPK);
6727 }
6728 catch (Exception e) {
6729 throw processException(e);
6730 }
6731 finally {
6732 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6733 }
6734 }
6735
6736
6743 public void addTeam(long pk, com.liferay.portal.model.Team team)
6744 throws SystemException {
6745 try {
6746 addTeam.add(pk, team.getPrimaryKey());
6747 }
6748 catch (Exception e) {
6749 throw processException(e);
6750 }
6751 finally {
6752 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6753 }
6754 }
6755
6756
6763 public void addTeams(long pk, long[] teamPKs) throws SystemException {
6764 try {
6765 for (long teamPK : teamPKs) {
6766 addTeam.add(pk, teamPK);
6767 }
6768 }
6769 catch (Exception e) {
6770 throw processException(e);
6771 }
6772 finally {
6773 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6774 }
6775 }
6776
6777
6784 public void addTeams(long pk, List<com.liferay.portal.model.Team> teams)
6785 throws SystemException {
6786 try {
6787 for (com.liferay.portal.model.Team team : teams) {
6788 addTeam.add(pk, team.getPrimaryKey());
6789 }
6790 }
6791 catch (Exception e) {
6792 throw processException(e);
6793 }
6794 finally {
6795 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6796 }
6797 }
6798
6799
6805 public void clearTeams(long pk) throws SystemException {
6806 try {
6807 clearTeams.clear(pk);
6808 }
6809 catch (Exception e) {
6810 throw processException(e);
6811 }
6812 finally {
6813 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6814 }
6815 }
6816
6817
6824 public void removeTeam(long pk, long teamPK) throws SystemException {
6825 try {
6826 removeTeam.remove(pk, teamPK);
6827 }
6828 catch (Exception e) {
6829 throw processException(e);
6830 }
6831 finally {
6832 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6833 }
6834 }
6835
6836
6843 public void removeTeam(long pk, com.liferay.portal.model.Team team)
6844 throws SystemException {
6845 try {
6846 removeTeam.remove(pk, team.getPrimaryKey());
6847 }
6848 catch (Exception e) {
6849 throw processException(e);
6850 }
6851 finally {
6852 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6853 }
6854 }
6855
6856
6863 public void removeTeams(long pk, long[] teamPKs) throws SystemException {
6864 try {
6865 for (long teamPK : teamPKs) {
6866 removeTeam.remove(pk, teamPK);
6867 }
6868 }
6869 catch (Exception e) {
6870 throw processException(e);
6871 }
6872 finally {
6873 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6874 }
6875 }
6876
6877
6884 public void removeTeams(long pk, List<com.liferay.portal.model.Team> teams)
6885 throws SystemException {
6886 try {
6887 for (com.liferay.portal.model.Team team : teams) {
6888 removeTeam.remove(pk, team.getPrimaryKey());
6889 }
6890 }
6891 catch (Exception e) {
6892 throw processException(e);
6893 }
6894 finally {
6895 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6896 }
6897 }
6898
6899
6906 public void setTeams(long pk, long[] teamPKs) throws SystemException {
6907 try {
6908 Set<Long> teamPKSet = SetUtil.fromArray(teamPKs);
6909
6910 List<com.liferay.portal.model.Team> teams = getTeams(pk);
6911
6912 for (com.liferay.portal.model.Team team : teams) {
6913 if (!teamPKSet.remove(team.getPrimaryKey())) {
6914 removeTeam.remove(pk, team.getPrimaryKey());
6915 }
6916 }
6917
6918 for (Long teamPK : teamPKSet) {
6919 addTeam.add(pk, teamPK);
6920 }
6921 }
6922 catch (Exception e) {
6923 throw processException(e);
6924 }
6925 finally {
6926 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6927 }
6928 }
6929
6930
6937 public void setTeams(long pk, List<com.liferay.portal.model.Team> teams)
6938 throws SystemException {
6939 try {
6940 long[] teamPKs = new long[teams.size()];
6941
6942 for (int i = 0; i < teams.size(); i++) {
6943 com.liferay.portal.model.Team team = teams.get(i);
6944
6945 teamPKs[i] = team.getPrimaryKey();
6946 }
6947
6948 setTeams(pk, teamPKs);
6949 }
6950 catch (Exception e) {
6951 throw processException(e);
6952 }
6953 finally {
6954 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
6955 }
6956 }
6957
6958
6965 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
6966 throws SystemException {
6967 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
6968 }
6969
6970
6983 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
6984 int start, int end) throws SystemException {
6985 return getUserGroups(pk, start, end, null);
6986 }
6987
6988 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
6989 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS,
6990 com.liferay.portal.model.impl.UserGroupImpl.class,
6991 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME, "getUserGroups",
6992 new String[] {
6993 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
6994 "com.liferay.portal.kernel.util.OrderByComparator"
6995 });
6996
6997
7011 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
7012 int start, int end, OrderByComparator orderByComparator)
7013 throws SystemException {
7014 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
7015
7016 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
7017 finderArgs, this);
7018
7019 if (list == null) {
7020 Session session = null;
7021
7022 try {
7023 session = openSession();
7024
7025 String sql = null;
7026
7027 if (orderByComparator != null) {
7028 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
7029 .concat(orderByComparator.getOrderBy());
7030 }
7031 else {
7032 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
7033 }
7034
7035 SQLQuery q = session.createSQLQuery(sql);
7036
7037 q.addEntity("UserGroup",
7038 com.liferay.portal.model.impl.UserGroupImpl.class);
7039
7040 QueryPos qPos = QueryPos.getInstance(q);
7041
7042 qPos.add(pk);
7043
7044 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
7045 getDialect(), start, end);
7046 }
7047 catch (Exception e) {
7048 throw processException(e);
7049 }
7050 finally {
7051 if (list == null) {
7052 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
7053 finderArgs);
7054 }
7055 else {
7056 userGroupPersistence.cacheResult(list);
7057
7058 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
7059 finderArgs, list);
7060 }
7061
7062 closeSession(session);
7063 }
7064 }
7065
7066 return list;
7067 }
7068
7069 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
7070 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Long.class,
7071 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
7072 "getUserGroupsSize", new String[] { Long.class.getName() });
7073
7074
7081 public int getUserGroupsSize(long pk) throws SystemException {
7082 Object[] finderArgs = new Object[] { pk };
7083
7084 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
7085 finderArgs, this);
7086
7087 if (count == null) {
7088 Session session = null;
7089
7090 try {
7091 session = openSession();
7092
7093 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
7094
7095 q.addScalar(COUNT_COLUMN_NAME,
7096 com.liferay.portal.kernel.dao.orm.Type.LONG);
7097
7098 QueryPos qPos = QueryPos.getInstance(q);
7099
7100 qPos.add(pk);
7101
7102 count = (Long)q.uniqueResult();
7103 }
7104 catch (Exception e) {
7105 throw processException(e);
7106 }
7107 finally {
7108 if (count == null) {
7109 count = Long.valueOf(0);
7110 }
7111
7112 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
7113 finderArgs, count);
7114
7115 closeSession(session);
7116 }
7117 }
7118
7119 return count.intValue();
7120 }
7121
7122 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
7123 UserModelImpl.FINDER_CACHE_ENABLED_USERS_USERGROUPS, Boolean.class,
7124 UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME,
7125 "containsUserGroup",
7126 new String[] { Long.class.getName(), Long.class.getName() });
7127
7128
7136 public boolean containsUserGroup(long pk, long userGroupPK)
7137 throws SystemException {
7138 Object[] finderArgs = new Object[] { pk, userGroupPK };
7139
7140 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
7141 finderArgs, this);
7142
7143 if (value == null) {
7144 try {
7145 value = Boolean.valueOf(containsUserGroup.contains(pk,
7146 userGroupPK));
7147 }
7148 catch (Exception e) {
7149 throw processException(e);
7150 }
7151 finally {
7152 if (value == null) {
7153 value = Boolean.FALSE;
7154 }
7155
7156 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
7157 finderArgs, value);
7158 }
7159 }
7160
7161 return value.booleanValue();
7162 }
7163
7164
7171 public boolean containsUserGroups(long pk) throws SystemException {
7172 if (getUserGroupsSize(pk) > 0) {
7173 return true;
7174 }
7175 else {
7176 return false;
7177 }
7178 }
7179
7180
7187 public void addUserGroup(long pk, long userGroupPK)
7188 throws SystemException {
7189 try {
7190 addUserGroup.add(pk, userGroupPK);
7191 }
7192 catch (Exception e) {
7193 throw processException(e);
7194 }
7195 finally {
7196 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7197 }
7198 }
7199
7200
7207 public void addUserGroup(long pk,
7208 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
7209 try {
7210 addUserGroup.add(pk, userGroup.getPrimaryKey());
7211 }
7212 catch (Exception e) {
7213 throw processException(e);
7214 }
7215 finally {
7216 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7217 }
7218 }
7219
7220
7227 public void addUserGroups(long pk, long[] userGroupPKs)
7228 throws SystemException {
7229 try {
7230 for (long userGroupPK : userGroupPKs) {
7231 addUserGroup.add(pk, userGroupPK);
7232 }
7233 }
7234 catch (Exception e) {
7235 throw processException(e);
7236 }
7237 finally {
7238 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7239 }
7240 }
7241
7242
7249 public void addUserGroups(long pk,
7250 List<com.liferay.portal.model.UserGroup> userGroups)
7251 throws SystemException {
7252 try {
7253 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7254 addUserGroup.add(pk, userGroup.getPrimaryKey());
7255 }
7256 }
7257 catch (Exception e) {
7258 throw processException(e);
7259 }
7260 finally {
7261 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7262 }
7263 }
7264
7265
7271 public void clearUserGroups(long pk) throws SystemException {
7272 try {
7273 clearUserGroups.clear(pk);
7274 }
7275 catch (Exception e) {
7276 throw processException(e);
7277 }
7278 finally {
7279 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7280 }
7281 }
7282
7283
7290 public void removeUserGroup(long pk, long userGroupPK)
7291 throws SystemException {
7292 try {
7293 removeUserGroup.remove(pk, userGroupPK);
7294 }
7295 catch (Exception e) {
7296 throw processException(e);
7297 }
7298 finally {
7299 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7300 }
7301 }
7302
7303
7310 public void removeUserGroup(long pk,
7311 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
7312 try {
7313 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7314 }
7315 catch (Exception e) {
7316 throw processException(e);
7317 }
7318 finally {
7319 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7320 }
7321 }
7322
7323
7330 public void removeUserGroups(long pk, long[] userGroupPKs)
7331 throws SystemException {
7332 try {
7333 for (long userGroupPK : userGroupPKs) {
7334 removeUserGroup.remove(pk, userGroupPK);
7335 }
7336 }
7337 catch (Exception e) {
7338 throw processException(e);
7339 }
7340 finally {
7341 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7342 }
7343 }
7344
7345
7352 public void removeUserGroups(long pk,
7353 List<com.liferay.portal.model.UserGroup> userGroups)
7354 throws SystemException {
7355 try {
7356 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7357 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7358 }
7359 }
7360 catch (Exception e) {
7361 throw processException(e);
7362 }
7363 finally {
7364 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7365 }
7366 }
7367
7368
7375 public void setUserGroups(long pk, long[] userGroupPKs)
7376 throws SystemException {
7377 try {
7378 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
7379
7380 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
7381
7382 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
7383 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
7384 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
7385 }
7386 }
7387
7388 for (Long userGroupPK : userGroupPKSet) {
7389 addUserGroup.add(pk, userGroupPK);
7390 }
7391 }
7392 catch (Exception e) {
7393 throw processException(e);
7394 }
7395 finally {
7396 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7397 }
7398 }
7399
7400
7407 public void setUserGroups(long pk,
7408 List<com.liferay.portal.model.UserGroup> userGroups)
7409 throws SystemException {
7410 try {
7411 long[] userGroupPKs = new long[userGroups.size()];
7412
7413 for (int i = 0; i < userGroups.size(); i++) {
7414 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
7415
7416 userGroupPKs[i] = userGroup.getPrimaryKey();
7417 }
7418
7419 setUserGroups(pk, userGroupPKs);
7420 }
7421 catch (Exception e) {
7422 throw processException(e);
7423 }
7424 finally {
7425 FinderCacheUtil.clearCache(UserModelImpl.MAPPING_TABLE_USERS_USERGROUPS_NAME);
7426 }
7427 }
7428
7429
7432 public void afterPropertiesSet() {
7433 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
7434 com.liferay.portal.util.PropsUtil.get(
7435 "value.object.listener.com.liferay.portal.model.User")));
7436
7437 if (listenerClassNames.length > 0) {
7438 try {
7439 List<ModelListener<User>> listenersList = new ArrayList<ModelListener<User>>();
7440
7441 for (String listenerClassName : listenerClassNames) {
7442 listenersList.add((ModelListener<User>)InstanceFactory.newInstance(
7443 listenerClassName));
7444 }
7445
7446 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
7447 }
7448 catch (Exception e) {
7449 _log.error(e);
7450 }
7451 }
7452
7453 containsGroup = new ContainsGroup();
7454
7455 addGroup = new AddGroup();
7456 clearGroups = new ClearGroups();
7457 removeGroup = new RemoveGroup();
7458
7459 containsOrganization = new ContainsOrganization();
7460
7461 addOrganization = new AddOrganization();
7462 clearOrganizations = new ClearOrganizations();
7463 removeOrganization = new RemoveOrganization();
7464
7465 containsPermission = new ContainsPermission();
7466
7467 addPermission = new AddPermission();
7468 clearPermissions = new ClearPermissions();
7469 removePermission = new RemovePermission();
7470
7471 containsRole = new ContainsRole();
7472
7473 addRole = new AddRole();
7474 clearRoles = new ClearRoles();
7475 removeRole = new RemoveRole();
7476
7477 containsTeam = new ContainsTeam();
7478
7479 addTeam = new AddTeam();
7480 clearTeams = new ClearTeams();
7481 removeTeam = new RemoveTeam();
7482
7483 containsUserGroup = new ContainsUserGroup();
7484
7485 addUserGroup = new AddUserGroup();
7486 clearUserGroups = new ClearUserGroups();
7487 removeUserGroup = new RemoveUserGroup();
7488 }
7489
7490 public void destroy() {
7491 EntityCacheUtil.removeCache(UserImpl.class.getName());
7492 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
7493 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
7494 }
7495
7496 @BeanReference(type = AccountPersistence.class)
7497 protected AccountPersistence accountPersistence;
7498 @BeanReference(type = AddressPersistence.class)
7499 protected AddressPersistence addressPersistence;
7500 @BeanReference(type = BrowserTrackerPersistence.class)
7501 protected BrowserTrackerPersistence browserTrackerPersistence;
7502 @BeanReference(type = ClassNamePersistence.class)
7503 protected ClassNamePersistence classNamePersistence;
7504 @BeanReference(type = ClusterGroupPersistence.class)
7505 protected ClusterGroupPersistence clusterGroupPersistence;
7506 @BeanReference(type = CompanyPersistence.class)
7507 protected CompanyPersistence companyPersistence;
7508 @BeanReference(type = ContactPersistence.class)
7509 protected ContactPersistence contactPersistence;
7510 @BeanReference(type = CountryPersistence.class)
7511 protected CountryPersistence countryPersistence;
7512 @BeanReference(type = EmailAddressPersistence.class)
7513 protected EmailAddressPersistence emailAddressPersistence;
7514 @BeanReference(type = GroupPersistence.class)
7515 protected GroupPersistence groupPersistence;
7516 @BeanReference(type = ImagePersistence.class)
7517 protected ImagePersistence imagePersistence;
7518 @BeanReference(type = LayoutPersistence.class)
7519 protected LayoutPersistence layoutPersistence;
7520 @BeanReference(type = LayoutBranchPersistence.class)
7521 protected LayoutBranchPersistence layoutBranchPersistence;
7522 @BeanReference(type = LayoutPrototypePersistence.class)
7523 protected LayoutPrototypePersistence layoutPrototypePersistence;
7524 @BeanReference(type = LayoutRevisionPersistence.class)
7525 protected LayoutRevisionPersistence layoutRevisionPersistence;
7526 @BeanReference(type = LayoutSetPersistence.class)
7527 protected LayoutSetPersistence layoutSetPersistence;
7528 @BeanReference(type = LayoutSetBranchPersistence.class)
7529 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
7530 @BeanReference(type = LayoutSetPrototypePersistence.class)
7531 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
7532 @BeanReference(type = ListTypePersistence.class)
7533 protected ListTypePersistence listTypePersistence;
7534 @BeanReference(type = LockPersistence.class)
7535 protected LockPersistence lockPersistence;
7536 @BeanReference(type = MembershipRequestPersistence.class)
7537 protected MembershipRequestPersistence membershipRequestPersistence;
7538 @BeanReference(type = OrganizationPersistence.class)
7539 protected OrganizationPersistence organizationPersistence;
7540 @BeanReference(type = OrgGroupPermissionPersistence.class)
7541 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
7542 @BeanReference(type = OrgGroupRolePersistence.class)
7543 protected OrgGroupRolePersistence orgGroupRolePersistence;
7544 @BeanReference(type = OrgLaborPersistence.class)
7545 protected OrgLaborPersistence orgLaborPersistence;
7546 @BeanReference(type = PasswordPolicyPersistence.class)
7547 protected PasswordPolicyPersistence passwordPolicyPersistence;
7548 @BeanReference(type = PasswordPolicyRelPersistence.class)
7549 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
7550 @BeanReference(type = PasswordTrackerPersistence.class)
7551 protected PasswordTrackerPersistence passwordTrackerPersistence;
7552 @BeanReference(type = PermissionPersistence.class)
7553 protected PermissionPersistence permissionPersistence;
7554 @BeanReference(type = PhonePersistence.class)
7555 protected PhonePersistence phonePersistence;
7556 @BeanReference(type = PluginSettingPersistence.class)
7557 protected PluginSettingPersistence pluginSettingPersistence;
7558 @BeanReference(type = PortalPreferencesPersistence.class)
7559 protected PortalPreferencesPersistence portalPreferencesPersistence;
7560 @BeanReference(type = PortletPersistence.class)
7561 protected PortletPersistence portletPersistence;
7562 @BeanReference(type = PortletItemPersistence.class)
7563 protected PortletItemPersistence portletItemPersistence;
7564 @BeanReference(type = PortletPreferencesPersistence.class)
7565 protected PortletPreferencesPersistence portletPreferencesPersistence;
7566 @BeanReference(type = RegionPersistence.class)
7567 protected RegionPersistence regionPersistence;
7568 @BeanReference(type = ReleasePersistence.class)
7569 protected ReleasePersistence releasePersistence;
7570 @BeanReference(type = RepositoryPersistence.class)
7571 protected RepositoryPersistence repositoryPersistence;
7572 @BeanReference(type = RepositoryEntryPersistence.class)
7573 protected RepositoryEntryPersistence repositoryEntryPersistence;
7574 @BeanReference(type = ResourcePersistence.class)
7575 protected ResourcePersistence resourcePersistence;
7576 @BeanReference(type = ResourceActionPersistence.class)
7577 protected ResourceActionPersistence resourceActionPersistence;
7578 @BeanReference(type = ResourceBlockPersistence.class)
7579 protected ResourceBlockPersistence resourceBlockPersistence;
7580 @BeanReference(type = ResourceBlockPermissionPersistence.class)
7581 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
7582 @BeanReference(type = ResourceCodePersistence.class)
7583 protected ResourceCodePersistence resourceCodePersistence;
7584 @BeanReference(type = ResourcePermissionPersistence.class)
7585 protected ResourcePermissionPersistence resourcePermissionPersistence;
7586 @BeanReference(type = ResourceTypePermissionPersistence.class)
7587 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
7588 @BeanReference(type = RolePersistence.class)
7589 protected RolePersistence rolePersistence;
7590 @BeanReference(type = ServiceComponentPersistence.class)
7591 protected ServiceComponentPersistence serviceComponentPersistence;
7592 @BeanReference(type = ShardPersistence.class)
7593 protected ShardPersistence shardPersistence;
7594 @BeanReference(type = SubscriptionPersistence.class)
7595 protected SubscriptionPersistence subscriptionPersistence;
7596 @BeanReference(type = TeamPersistence.class)
7597 protected TeamPersistence teamPersistence;
7598 @BeanReference(type = TicketPersistence.class)
7599 protected TicketPersistence ticketPersistence;
7600 @BeanReference(type = UserPersistence.class)
7601 protected UserPersistence userPersistence;
7602 @BeanReference(type = UserGroupPersistence.class)
7603 protected UserGroupPersistence userGroupPersistence;
7604 @BeanReference(type = UserGroupGroupRolePersistence.class)
7605 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
7606 @BeanReference(type = UserGroupRolePersistence.class)
7607 protected UserGroupRolePersistence userGroupRolePersistence;
7608 @BeanReference(type = UserIdMapperPersistence.class)
7609 protected UserIdMapperPersistence userIdMapperPersistence;
7610 @BeanReference(type = UserNotificationEventPersistence.class)
7611 protected UserNotificationEventPersistence userNotificationEventPersistence;
7612 @BeanReference(type = UserTrackerPersistence.class)
7613 protected UserTrackerPersistence userTrackerPersistence;
7614 @BeanReference(type = UserTrackerPathPersistence.class)
7615 protected UserTrackerPathPersistence userTrackerPathPersistence;
7616 @BeanReference(type = VirtualHostPersistence.class)
7617 protected VirtualHostPersistence virtualHostPersistence;
7618 @BeanReference(type = WebDAVPropsPersistence.class)
7619 protected WebDAVPropsPersistence webDAVPropsPersistence;
7620 @BeanReference(type = WebsitePersistence.class)
7621 protected WebsitePersistence websitePersistence;
7622 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
7623 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
7624 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
7625 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
7626 @BeanReference(type = AnnouncementsDeliveryPersistence.class)
7627 protected AnnouncementsDeliveryPersistence announcementsDeliveryPersistence;
7628 @BeanReference(type = AssetEntryPersistence.class)
7629 protected AssetEntryPersistence assetEntryPersistence;
7630 @BeanReference(type = BlogsStatsUserPersistence.class)
7631 protected BlogsStatsUserPersistence blogsStatsUserPersistence;
7632 @BeanReference(type = DLFileRankPersistence.class)
7633 protected DLFileRankPersistence dlFileRankPersistence;
7634 @BeanReference(type = ExpandoValuePersistence.class)
7635 protected ExpandoValuePersistence expandoValuePersistence;
7636 @BeanReference(type = MBBanPersistence.class)
7637 protected MBBanPersistence mbBanPersistence;
7638 @BeanReference(type = MBMessagePersistence.class)
7639 protected MBMessagePersistence mbMessagePersistence;
7640 @BeanReference(type = MBStatsUserPersistence.class)
7641 protected MBStatsUserPersistence mbStatsUserPersistence;
7642 @BeanReference(type = MBThreadFlagPersistence.class)
7643 protected MBThreadFlagPersistence mbThreadFlagPersistence;
7644 @BeanReference(type = ShoppingCartPersistence.class)
7645 protected ShoppingCartPersistence shoppingCartPersistence;
7646 @BeanReference(type = SocialActivityPersistence.class)
7647 protected SocialActivityPersistence socialActivityPersistence;
7648 @BeanReference(type = SocialRequestPersistence.class)
7649 protected SocialRequestPersistence socialRequestPersistence;
7650 protected ContainsGroup containsGroup;
7651 protected AddGroup addGroup;
7652 protected ClearGroups clearGroups;
7653 protected RemoveGroup removeGroup;
7654 protected ContainsOrganization containsOrganization;
7655 protected AddOrganization addOrganization;
7656 protected ClearOrganizations clearOrganizations;
7657 protected RemoveOrganization removeOrganization;
7658 protected ContainsPermission containsPermission;
7659 protected AddPermission addPermission;
7660 protected ClearPermissions clearPermissions;
7661 protected RemovePermission removePermission;
7662 protected ContainsRole containsRole;
7663 protected AddRole addRole;
7664 protected ClearRoles clearRoles;
7665 protected RemoveRole removeRole;
7666 protected ContainsTeam containsTeam;
7667 protected AddTeam addTeam;
7668 protected ClearTeams clearTeams;
7669 protected RemoveTeam removeTeam;
7670 protected ContainsUserGroup containsUserGroup;
7671 protected AddUserGroup addUserGroup;
7672 protected ClearUserGroups clearUserGroups;
7673 protected RemoveUserGroup removeUserGroup;
7674
7675 protected class ContainsGroup {
7676 protected ContainsGroup() {
7677 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7678 _SQL_CONTAINSGROUP,
7679 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7680 RowMapper.COUNT);
7681 }
7682
7683 protected boolean contains(long userId, long groupId) {
7684 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7685 new Long(userId), new Long(groupId)
7686 });
7687
7688 if (results.size() > 0) {
7689 Integer count = results.get(0);
7690
7691 if (count.intValue() > 0) {
7692 return true;
7693 }
7694 }
7695
7696 return false;
7697 }
7698
7699 private MappingSqlQuery<Integer> _mappingSqlQuery;
7700 }
7701
7702 protected class AddGroup {
7703 protected AddGroup() {
7704 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7705 "INSERT INTO Users_Groups (userId, groupId) VALUES (?, ?)",
7706 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7707 }
7708
7709 protected void add(long userId, long groupId) throws SystemException {
7710 if (!containsGroup.contains(userId, groupId)) {
7711 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
7712
7713 for (ModelListener<User> listener : listeners) {
7714 listener.onBeforeAddAssociation(userId,
7715 com.liferay.portal.model.Group.class.getName(), groupId);
7716 }
7717
7718 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7719 listener.onBeforeAddAssociation(groupId,
7720 User.class.getName(), userId);
7721 }
7722
7723 _sqlUpdate.update(new Object[] {
7724 new Long(userId), new Long(groupId)
7725 });
7726
7727 for (ModelListener<User> listener : listeners) {
7728 listener.onAfterAddAssociation(userId,
7729 com.liferay.portal.model.Group.class.getName(), groupId);
7730 }
7731
7732 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7733 listener.onAfterAddAssociation(groupId,
7734 User.class.getName(), userId);
7735 }
7736 }
7737 }
7738
7739 private SqlUpdate _sqlUpdate;
7740 }
7741
7742 protected class ClearGroups {
7743 protected ClearGroups() {
7744 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7745 "DELETE FROM Users_Groups WHERE userId = ?",
7746 new int[] { java.sql.Types.BIGINT });
7747 }
7748
7749 protected void clear(long userId) throws SystemException {
7750 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
7751
7752 List<com.liferay.portal.model.Group> groups = null;
7753
7754 if ((listeners.length > 0) || (groupListeners.length > 0)) {
7755 groups = getGroups(userId);
7756
7757 for (com.liferay.portal.model.Group group : groups) {
7758 for (ModelListener<User> listener : listeners) {
7759 listener.onBeforeRemoveAssociation(userId,
7760 com.liferay.portal.model.Group.class.getName(),
7761 group.getPrimaryKey());
7762 }
7763
7764 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7765 listener.onBeforeRemoveAssociation(group.getPrimaryKey(),
7766 User.class.getName(), userId);
7767 }
7768 }
7769 }
7770
7771 _sqlUpdate.update(new Object[] { new Long(userId) });
7772
7773 if ((listeners.length > 0) || (groupListeners.length > 0)) {
7774 for (com.liferay.portal.model.Group group : groups) {
7775 for (ModelListener<User> listener : listeners) {
7776 listener.onAfterRemoveAssociation(userId,
7777 com.liferay.portal.model.Group.class.getName(),
7778 group.getPrimaryKey());
7779 }
7780
7781 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7782 listener.onAfterRemoveAssociation(group.getPrimaryKey(),
7783 User.class.getName(), userId);
7784 }
7785 }
7786 }
7787 }
7788
7789 private SqlUpdate _sqlUpdate;
7790 }
7791
7792 protected class RemoveGroup {
7793 protected RemoveGroup() {
7794 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7795 "DELETE FROM Users_Groups WHERE userId = ? AND groupId = ?",
7796 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7797 }
7798
7799 protected void remove(long userId, long groupId)
7800 throws SystemException {
7801 if (containsGroup.contains(userId, groupId)) {
7802 ModelListener<com.liferay.portal.model.Group>[] groupListeners = groupPersistence.getListeners();
7803
7804 for (ModelListener<User> listener : listeners) {
7805 listener.onBeforeRemoveAssociation(userId,
7806 com.liferay.portal.model.Group.class.getName(), groupId);
7807 }
7808
7809 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7810 listener.onBeforeRemoveAssociation(groupId,
7811 User.class.getName(), userId);
7812 }
7813
7814 _sqlUpdate.update(new Object[] {
7815 new Long(userId), new Long(groupId)
7816 });
7817
7818 for (ModelListener<User> listener : listeners) {
7819 listener.onAfterRemoveAssociation(userId,
7820 com.liferay.portal.model.Group.class.getName(), groupId);
7821 }
7822
7823 for (ModelListener<com.liferay.portal.model.Group> listener : groupListeners) {
7824 listener.onAfterRemoveAssociation(groupId,
7825 User.class.getName(), userId);
7826 }
7827 }
7828 }
7829
7830 private SqlUpdate _sqlUpdate;
7831 }
7832
7833 protected class ContainsOrganization {
7834 protected ContainsOrganization() {
7835 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
7836 _SQL_CONTAINSORGANIZATION,
7837 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
7838 RowMapper.COUNT);
7839 }
7840
7841 protected boolean contains(long userId, long organizationId) {
7842 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
7843 new Long(userId), new Long(organizationId)
7844 });
7845
7846 if (results.size() > 0) {
7847 Integer count = results.get(0);
7848
7849 if (count.intValue() > 0) {
7850 return true;
7851 }
7852 }
7853
7854 return false;
7855 }
7856
7857 private MappingSqlQuery<Integer> _mappingSqlQuery;
7858 }
7859
7860 protected class AddOrganization {
7861 protected AddOrganization() {
7862 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7863 "INSERT INTO Users_Orgs (userId, organizationId) VALUES (?, ?)",
7864 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7865 }
7866
7867 protected void add(long userId, long organizationId)
7868 throws SystemException {
7869 if (!containsOrganization.contains(userId, organizationId)) {
7870 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7871 organizationPersistence.getListeners();
7872
7873 for (ModelListener<User> listener : listeners) {
7874 listener.onBeforeAddAssociation(userId,
7875 com.liferay.portal.model.Organization.class.getName(),
7876 organizationId);
7877 }
7878
7879 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7880 listener.onBeforeAddAssociation(organizationId,
7881 User.class.getName(), userId);
7882 }
7883
7884 _sqlUpdate.update(new Object[] {
7885 new Long(userId), new Long(organizationId)
7886 });
7887
7888 for (ModelListener<User> listener : listeners) {
7889 listener.onAfterAddAssociation(userId,
7890 com.liferay.portal.model.Organization.class.getName(),
7891 organizationId);
7892 }
7893
7894 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7895 listener.onAfterAddAssociation(organizationId,
7896 User.class.getName(), userId);
7897 }
7898 }
7899 }
7900
7901 private SqlUpdate _sqlUpdate;
7902 }
7903
7904 protected class ClearOrganizations {
7905 protected ClearOrganizations() {
7906 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7907 "DELETE FROM Users_Orgs WHERE userId = ?",
7908 new int[] { java.sql.Types.BIGINT });
7909 }
7910
7911 protected void clear(long userId) throws SystemException {
7912 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7913 organizationPersistence.getListeners();
7914
7915 List<com.liferay.portal.model.Organization> organizations = null;
7916
7917 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
7918 organizations = getOrganizations(userId);
7919
7920 for (com.liferay.portal.model.Organization organization : organizations) {
7921 for (ModelListener<User> listener : listeners) {
7922 listener.onBeforeRemoveAssociation(userId,
7923 com.liferay.portal.model.Organization.class.getName(),
7924 organization.getPrimaryKey());
7925 }
7926
7927 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7928 listener.onBeforeRemoveAssociation(organization.getPrimaryKey(),
7929 User.class.getName(), userId);
7930 }
7931 }
7932 }
7933
7934 _sqlUpdate.update(new Object[] { new Long(userId) });
7935
7936 if ((listeners.length > 0) || (organizationListeners.length > 0)) {
7937 for (com.liferay.portal.model.Organization organization : organizations) {
7938 for (ModelListener<User> listener : listeners) {
7939 listener.onAfterRemoveAssociation(userId,
7940 com.liferay.portal.model.Organization.class.getName(),
7941 organization.getPrimaryKey());
7942 }
7943
7944 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7945 listener.onAfterRemoveAssociation(organization.getPrimaryKey(),
7946 User.class.getName(), userId);
7947 }
7948 }
7949 }
7950 }
7951
7952 private SqlUpdate _sqlUpdate;
7953 }
7954
7955 protected class RemoveOrganization {
7956 protected RemoveOrganization() {
7957 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
7958 "DELETE FROM Users_Orgs WHERE userId = ? AND organizationId = ?",
7959 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
7960 }
7961
7962 protected void remove(long userId, long organizationId)
7963 throws SystemException {
7964 if (containsOrganization.contains(userId, organizationId)) {
7965 ModelListener<com.liferay.portal.model.Organization>[] organizationListeners =
7966 organizationPersistence.getListeners();
7967
7968 for (ModelListener<User> listener : listeners) {
7969 listener.onBeforeRemoveAssociation(userId,
7970 com.liferay.portal.model.Organization.class.getName(),
7971 organizationId);
7972 }
7973
7974 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7975 listener.onBeforeRemoveAssociation(organizationId,
7976 User.class.getName(), userId);
7977 }
7978
7979 _sqlUpdate.update(new Object[] {
7980 new Long(userId), new Long(organizationId)
7981 });
7982
7983 for (ModelListener<User> listener : listeners) {
7984 listener.onAfterRemoveAssociation(userId,
7985 com.liferay.portal.model.Organization.class.getName(),
7986 organizationId);
7987 }
7988
7989 for (ModelListener<com.liferay.portal.model.Organization> listener : organizationListeners) {
7990 listener.onAfterRemoveAssociation(organizationId,
7991 User.class.getName(), userId);
7992 }
7993 }
7994 }
7995
7996 private SqlUpdate _sqlUpdate;
7997 }
7998
7999 protected class ContainsPermission {
8000 protected ContainsPermission() {
8001 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8002 _SQL_CONTAINSPERMISSION,
8003 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8004 RowMapper.COUNT);
8005 }
8006
8007 protected boolean contains(long userId, long permissionId) {
8008 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8009 new Long(userId), new Long(permissionId)
8010 });
8011
8012 if (results.size() > 0) {
8013 Integer count = results.get(0);
8014
8015 if (count.intValue() > 0) {
8016 return true;
8017 }
8018 }
8019
8020 return false;
8021 }
8022
8023 private MappingSqlQuery<Integer> _mappingSqlQuery;
8024 }
8025
8026 protected class AddPermission {
8027 protected AddPermission() {
8028 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8029 "INSERT INTO Users_Permissions (userId, permissionId) VALUES (?, ?)",
8030 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8031 }
8032
8033 protected void add(long userId, long permissionId)
8034 throws SystemException {
8035 if (!containsPermission.contains(userId, permissionId)) {
8036 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8037 permissionPersistence.getListeners();
8038
8039 for (ModelListener<User> listener : listeners) {
8040 listener.onBeforeAddAssociation(userId,
8041 com.liferay.portal.model.Permission.class.getName(),
8042 permissionId);
8043 }
8044
8045 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8046 listener.onBeforeAddAssociation(permissionId,
8047 User.class.getName(), userId);
8048 }
8049
8050 _sqlUpdate.update(new Object[] {
8051 new Long(userId), new Long(permissionId)
8052 });
8053
8054 for (ModelListener<User> listener : listeners) {
8055 listener.onAfterAddAssociation(userId,
8056 com.liferay.portal.model.Permission.class.getName(),
8057 permissionId);
8058 }
8059
8060 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8061 listener.onAfterAddAssociation(permissionId,
8062 User.class.getName(), userId);
8063 }
8064 }
8065 }
8066
8067 private SqlUpdate _sqlUpdate;
8068 }
8069
8070 protected class ClearPermissions {
8071 protected ClearPermissions() {
8072 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8073 "DELETE FROM Users_Permissions WHERE userId = ?",
8074 new int[] { java.sql.Types.BIGINT });
8075 }
8076
8077 protected void clear(long userId) throws SystemException {
8078 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8079 permissionPersistence.getListeners();
8080
8081 List<com.liferay.portal.model.Permission> permissions = null;
8082
8083 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
8084 permissions = getPermissions(userId);
8085
8086 for (com.liferay.portal.model.Permission permission : permissions) {
8087 for (ModelListener<User> listener : listeners) {
8088 listener.onBeforeRemoveAssociation(userId,
8089 com.liferay.portal.model.Permission.class.getName(),
8090 permission.getPrimaryKey());
8091 }
8092
8093 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8094 listener.onBeforeRemoveAssociation(permission.getPrimaryKey(),
8095 User.class.getName(), userId);
8096 }
8097 }
8098 }
8099
8100 _sqlUpdate.update(new Object[] { new Long(userId) });
8101
8102 if ((listeners.length > 0) || (permissionListeners.length > 0)) {
8103 for (com.liferay.portal.model.Permission permission : permissions) {
8104 for (ModelListener<User> listener : listeners) {
8105 listener.onAfterRemoveAssociation(userId,
8106 com.liferay.portal.model.Permission.class.getName(),
8107 permission.getPrimaryKey());
8108 }
8109
8110 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8111 listener.onAfterRemoveAssociation(permission.getPrimaryKey(),
8112 User.class.getName(), userId);
8113 }
8114 }
8115 }
8116 }
8117
8118 private SqlUpdate _sqlUpdate;
8119 }
8120
8121 protected class RemovePermission {
8122 protected RemovePermission() {
8123 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8124 "DELETE FROM Users_Permissions WHERE userId = ? AND permissionId = ?",
8125 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8126 }
8127
8128 protected void remove(long userId, long permissionId)
8129 throws SystemException {
8130 if (containsPermission.contains(userId, permissionId)) {
8131 ModelListener<com.liferay.portal.model.Permission>[] permissionListeners =
8132 permissionPersistence.getListeners();
8133
8134 for (ModelListener<User> listener : listeners) {
8135 listener.onBeforeRemoveAssociation(userId,
8136 com.liferay.portal.model.Permission.class.getName(),
8137 permissionId);
8138 }
8139
8140 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8141 listener.onBeforeRemoveAssociation(permissionId,
8142 User.class.getName(), userId);
8143 }
8144
8145 _sqlUpdate.update(new Object[] {
8146 new Long(userId), new Long(permissionId)
8147 });
8148
8149 for (ModelListener<User> listener : listeners) {
8150 listener.onAfterRemoveAssociation(userId,
8151 com.liferay.portal.model.Permission.class.getName(),
8152 permissionId);
8153 }
8154
8155 for (ModelListener<com.liferay.portal.model.Permission> listener : permissionListeners) {
8156 listener.onAfterRemoveAssociation(permissionId,
8157 User.class.getName(), userId);
8158 }
8159 }
8160 }
8161
8162 private SqlUpdate _sqlUpdate;
8163 }
8164
8165 protected class ContainsRole {
8166 protected ContainsRole() {
8167 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8168 _SQL_CONTAINSROLE,
8169 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8170 RowMapper.COUNT);
8171 }
8172
8173 protected boolean contains(long userId, long roleId) {
8174 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8175 new Long(userId), new Long(roleId)
8176 });
8177
8178 if (results.size() > 0) {
8179 Integer count = results.get(0);
8180
8181 if (count.intValue() > 0) {
8182 return true;
8183 }
8184 }
8185
8186 return false;
8187 }
8188
8189 private MappingSqlQuery<Integer> _mappingSqlQuery;
8190 }
8191
8192 protected class AddRole {
8193 protected AddRole() {
8194 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8195 "INSERT INTO Users_Roles (userId, roleId) VALUES (?, ?)",
8196 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8197 }
8198
8199 protected void add(long userId, long roleId) throws SystemException {
8200 if (!containsRole.contains(userId, roleId)) {
8201 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8202
8203 for (ModelListener<User> listener : listeners) {
8204 listener.onBeforeAddAssociation(userId,
8205 com.liferay.portal.model.Role.class.getName(), roleId);
8206 }
8207
8208 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8209 listener.onBeforeAddAssociation(roleId,
8210 User.class.getName(), userId);
8211 }
8212
8213 _sqlUpdate.update(new Object[] {
8214 new Long(userId), new Long(roleId)
8215 });
8216
8217 for (ModelListener<User> listener : listeners) {
8218 listener.onAfterAddAssociation(userId,
8219 com.liferay.portal.model.Role.class.getName(), roleId);
8220 }
8221
8222 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8223 listener.onAfterAddAssociation(roleId,
8224 User.class.getName(), userId);
8225 }
8226 }
8227 }
8228
8229 private SqlUpdate _sqlUpdate;
8230 }
8231
8232 protected class ClearRoles {
8233 protected ClearRoles() {
8234 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8235 "DELETE FROM Users_Roles WHERE userId = ?",
8236 new int[] { java.sql.Types.BIGINT });
8237 }
8238
8239 protected void clear(long userId) throws SystemException {
8240 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8241
8242 List<com.liferay.portal.model.Role> roles = null;
8243
8244 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8245 roles = getRoles(userId);
8246
8247 for (com.liferay.portal.model.Role role : roles) {
8248 for (ModelListener<User> listener : listeners) {
8249 listener.onBeforeRemoveAssociation(userId,
8250 com.liferay.portal.model.Role.class.getName(),
8251 role.getPrimaryKey());
8252 }
8253
8254 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8255 listener.onBeforeRemoveAssociation(role.getPrimaryKey(),
8256 User.class.getName(), userId);
8257 }
8258 }
8259 }
8260
8261 _sqlUpdate.update(new Object[] { new Long(userId) });
8262
8263 if ((listeners.length > 0) || (roleListeners.length > 0)) {
8264 for (com.liferay.portal.model.Role role : roles) {
8265 for (ModelListener<User> listener : listeners) {
8266 listener.onAfterRemoveAssociation(userId,
8267 com.liferay.portal.model.Role.class.getName(),
8268 role.getPrimaryKey());
8269 }
8270
8271 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8272 listener.onAfterRemoveAssociation(role.getPrimaryKey(),
8273 User.class.getName(), userId);
8274 }
8275 }
8276 }
8277 }
8278
8279 private SqlUpdate _sqlUpdate;
8280 }
8281
8282 protected class RemoveRole {
8283 protected RemoveRole() {
8284 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8285 "DELETE FROM Users_Roles WHERE userId = ? AND roleId = ?",
8286 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8287 }
8288
8289 protected void remove(long userId, long roleId)
8290 throws SystemException {
8291 if (containsRole.contains(userId, roleId)) {
8292 ModelListener<com.liferay.portal.model.Role>[] roleListeners = rolePersistence.getListeners();
8293
8294 for (ModelListener<User> listener : listeners) {
8295 listener.onBeforeRemoveAssociation(userId,
8296 com.liferay.portal.model.Role.class.getName(), roleId);
8297 }
8298
8299 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8300 listener.onBeforeRemoveAssociation(roleId,
8301 User.class.getName(), userId);
8302 }
8303
8304 _sqlUpdate.update(new Object[] {
8305 new Long(userId), new Long(roleId)
8306 });
8307
8308 for (ModelListener<User> listener : listeners) {
8309 listener.onAfterRemoveAssociation(userId,
8310 com.liferay.portal.model.Role.class.getName(), roleId);
8311 }
8312
8313 for (ModelListener<com.liferay.portal.model.Role> listener : roleListeners) {
8314 listener.onAfterRemoveAssociation(roleId,
8315 User.class.getName(), userId);
8316 }
8317 }
8318 }
8319
8320 private SqlUpdate _sqlUpdate;
8321 }
8322
8323 protected class ContainsTeam {
8324 protected ContainsTeam() {
8325 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8326 _SQL_CONTAINSTEAM,
8327 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8328 RowMapper.COUNT);
8329 }
8330
8331 protected boolean contains(long userId, long teamId) {
8332 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8333 new Long(userId), new Long(teamId)
8334 });
8335
8336 if (results.size() > 0) {
8337 Integer count = results.get(0);
8338
8339 if (count.intValue() > 0) {
8340 return true;
8341 }
8342 }
8343
8344 return false;
8345 }
8346
8347 private MappingSqlQuery<Integer> _mappingSqlQuery;
8348 }
8349
8350 protected class AddTeam {
8351 protected AddTeam() {
8352 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8353 "INSERT INTO Users_Teams (userId, teamId) VALUES (?, ?)",
8354 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8355 }
8356
8357 protected void add(long userId, long teamId) throws SystemException {
8358 if (!containsTeam.contains(userId, teamId)) {
8359 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8360
8361 for (ModelListener<User> listener : listeners) {
8362 listener.onBeforeAddAssociation(userId,
8363 com.liferay.portal.model.Team.class.getName(), teamId);
8364 }
8365
8366 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8367 listener.onBeforeAddAssociation(teamId,
8368 User.class.getName(), userId);
8369 }
8370
8371 _sqlUpdate.update(new Object[] {
8372 new Long(userId), new Long(teamId)
8373 });
8374
8375 for (ModelListener<User> listener : listeners) {
8376 listener.onAfterAddAssociation(userId,
8377 com.liferay.portal.model.Team.class.getName(), teamId);
8378 }
8379
8380 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8381 listener.onAfterAddAssociation(teamId,
8382 User.class.getName(), userId);
8383 }
8384 }
8385 }
8386
8387 private SqlUpdate _sqlUpdate;
8388 }
8389
8390 protected class ClearTeams {
8391 protected ClearTeams() {
8392 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8393 "DELETE FROM Users_Teams WHERE userId = ?",
8394 new int[] { java.sql.Types.BIGINT });
8395 }
8396
8397 protected void clear(long userId) throws SystemException {
8398 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8399
8400 List<com.liferay.portal.model.Team> teams = null;
8401
8402 if ((listeners.length > 0) || (teamListeners.length > 0)) {
8403 teams = getTeams(userId);
8404
8405 for (com.liferay.portal.model.Team team : teams) {
8406 for (ModelListener<User> listener : listeners) {
8407 listener.onBeforeRemoveAssociation(userId,
8408 com.liferay.portal.model.Team.class.getName(),
8409 team.getPrimaryKey());
8410 }
8411
8412 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8413 listener.onBeforeRemoveAssociation(team.getPrimaryKey(),
8414 User.class.getName(), userId);
8415 }
8416 }
8417 }
8418
8419 _sqlUpdate.update(new Object[] { new Long(userId) });
8420
8421 if ((listeners.length > 0) || (teamListeners.length > 0)) {
8422 for (com.liferay.portal.model.Team team : teams) {
8423 for (ModelListener<User> listener : listeners) {
8424 listener.onAfterRemoveAssociation(userId,
8425 com.liferay.portal.model.Team.class.getName(),
8426 team.getPrimaryKey());
8427 }
8428
8429 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8430 listener.onAfterRemoveAssociation(team.getPrimaryKey(),
8431 User.class.getName(), userId);
8432 }
8433 }
8434 }
8435 }
8436
8437 private SqlUpdate _sqlUpdate;
8438 }
8439
8440 protected class RemoveTeam {
8441 protected RemoveTeam() {
8442 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8443 "DELETE FROM Users_Teams WHERE userId = ? AND teamId = ?",
8444 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8445 }
8446
8447 protected void remove(long userId, long teamId)
8448 throws SystemException {
8449 if (containsTeam.contains(userId, teamId)) {
8450 ModelListener<com.liferay.portal.model.Team>[] teamListeners = teamPersistence.getListeners();
8451
8452 for (ModelListener<User> listener : listeners) {
8453 listener.onBeforeRemoveAssociation(userId,
8454 com.liferay.portal.model.Team.class.getName(), teamId);
8455 }
8456
8457 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8458 listener.onBeforeRemoveAssociation(teamId,
8459 User.class.getName(), userId);
8460 }
8461
8462 _sqlUpdate.update(new Object[] {
8463 new Long(userId), new Long(teamId)
8464 });
8465
8466 for (ModelListener<User> listener : listeners) {
8467 listener.onAfterRemoveAssociation(userId,
8468 com.liferay.portal.model.Team.class.getName(), teamId);
8469 }
8470
8471 for (ModelListener<com.liferay.portal.model.Team> listener : teamListeners) {
8472 listener.onAfterRemoveAssociation(teamId,
8473 User.class.getName(), userId);
8474 }
8475 }
8476 }
8477
8478 private SqlUpdate _sqlUpdate;
8479 }
8480
8481 protected class ContainsUserGroup {
8482 protected ContainsUserGroup() {
8483 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
8484 _SQL_CONTAINSUSERGROUP,
8485 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
8486 RowMapper.COUNT);
8487 }
8488
8489 protected boolean contains(long userId, long userGroupId) {
8490 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
8491 new Long(userId), new Long(userGroupId)
8492 });
8493
8494 if (results.size() > 0) {
8495 Integer count = results.get(0);
8496
8497 if (count.intValue() > 0) {
8498 return true;
8499 }
8500 }
8501
8502 return false;
8503 }
8504
8505 private MappingSqlQuery<Integer> _mappingSqlQuery;
8506 }
8507
8508 protected class AddUserGroup {
8509 protected AddUserGroup() {
8510 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8511 "INSERT INTO Users_UserGroups (userId, userGroupId) VALUES (?, ?)",
8512 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8513 }
8514
8515 protected void add(long userId, long userGroupId)
8516 throws SystemException {
8517 if (!containsUserGroup.contains(userId, userGroupId)) {
8518 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8519 userGroupPersistence.getListeners();
8520
8521 for (ModelListener<User> listener : listeners) {
8522 listener.onBeforeAddAssociation(userId,
8523 com.liferay.portal.model.UserGroup.class.getName(),
8524 userGroupId);
8525 }
8526
8527 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8528 listener.onBeforeAddAssociation(userGroupId,
8529 User.class.getName(), userId);
8530 }
8531
8532 _sqlUpdate.update(new Object[] {
8533 new Long(userId), new Long(userGroupId)
8534 });
8535
8536 for (ModelListener<User> listener : listeners) {
8537 listener.onAfterAddAssociation(userId,
8538 com.liferay.portal.model.UserGroup.class.getName(),
8539 userGroupId);
8540 }
8541
8542 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8543 listener.onAfterAddAssociation(userGroupId,
8544 User.class.getName(), userId);
8545 }
8546 }
8547 }
8548
8549 private SqlUpdate _sqlUpdate;
8550 }
8551
8552 protected class ClearUserGroups {
8553 protected ClearUserGroups() {
8554 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8555 "DELETE FROM Users_UserGroups WHERE userId = ?",
8556 new int[] { java.sql.Types.BIGINT });
8557 }
8558
8559 protected void clear(long userId) throws SystemException {
8560 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8561 userGroupPersistence.getListeners();
8562
8563 List<com.liferay.portal.model.UserGroup> userGroups = null;
8564
8565 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8566 userGroups = getUserGroups(userId);
8567
8568 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8569 for (ModelListener<User> listener : listeners) {
8570 listener.onBeforeRemoveAssociation(userId,
8571 com.liferay.portal.model.UserGroup.class.getName(),
8572 userGroup.getPrimaryKey());
8573 }
8574
8575 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8576 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
8577 User.class.getName(), userId);
8578 }
8579 }
8580 }
8581
8582 _sqlUpdate.update(new Object[] { new Long(userId) });
8583
8584 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
8585 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
8586 for (ModelListener<User> listener : listeners) {
8587 listener.onAfterRemoveAssociation(userId,
8588 com.liferay.portal.model.UserGroup.class.getName(),
8589 userGroup.getPrimaryKey());
8590 }
8591
8592 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8593 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
8594 User.class.getName(), userId);
8595 }
8596 }
8597 }
8598 }
8599
8600 private SqlUpdate _sqlUpdate;
8601 }
8602
8603 protected class RemoveUserGroup {
8604 protected RemoveUserGroup() {
8605 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
8606 "DELETE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?",
8607 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
8608 }
8609
8610 protected void remove(long userId, long userGroupId)
8611 throws SystemException {
8612 if (containsUserGroup.contains(userId, userGroupId)) {
8613 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
8614 userGroupPersistence.getListeners();
8615
8616 for (ModelListener<User> listener : listeners) {
8617 listener.onBeforeRemoveAssociation(userId,
8618 com.liferay.portal.model.UserGroup.class.getName(),
8619 userGroupId);
8620 }
8621
8622 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8623 listener.onBeforeRemoveAssociation(userGroupId,
8624 User.class.getName(), userId);
8625 }
8626
8627 _sqlUpdate.update(new Object[] {
8628 new Long(userId), new Long(userGroupId)
8629 });
8630
8631 for (ModelListener<User> listener : listeners) {
8632 listener.onAfterRemoveAssociation(userId,
8633 com.liferay.portal.model.UserGroup.class.getName(),
8634 userGroupId);
8635 }
8636
8637 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
8638 listener.onAfterRemoveAssociation(userGroupId,
8639 User.class.getName(), userId);
8640 }
8641 }
8642 }
8643
8644 private SqlUpdate _sqlUpdate;
8645 }
8646
8647 private static final String _SQL_SELECT_USER = "SELECT user FROM User user";
8648 private static final String _SQL_SELECT_USER_WHERE = "SELECT user FROM User user WHERE ";
8649 private static final String _SQL_COUNT_USER = "SELECT COUNT(user) FROM User user";
8650 private static final String _SQL_COUNT_USER_WHERE = "SELECT COUNT(user) FROM User user WHERE ";
8651 private static final String _SQL_GETGROUPS = "SELECT {Group_.*} FROM Group_ INNER JOIN Users_Groups ON (Users_Groups.groupId = Group_.groupId) WHERE (Users_Groups.userId = ?)";
8652 private static final String _SQL_GETGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ?";
8653 private static final String _SQL_CONTAINSGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Groups WHERE userId = ? AND groupId = ?";
8654 private static final String _SQL_GETORGANIZATIONS = "SELECT {Organization_.*} FROM Organization_ INNER JOIN Users_Orgs ON (Users_Orgs.organizationId = Organization_.organizationId) WHERE (Users_Orgs.userId = ?)";
8655 private static final String _SQL_GETORGANIZATIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ?";
8656 private static final String _SQL_CONTAINSORGANIZATION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Orgs WHERE userId = ? AND organizationId = ?";
8657 private static final String _SQL_GETPERMISSIONS = "SELECT {Permission_.*} FROM Permission_ INNER JOIN Users_Permissions ON (Users_Permissions.permissionId = Permission_.permissionId) WHERE (Users_Permissions.userId = ?)";
8658 private static final String _SQL_GETPERMISSIONSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ?";
8659 private static final String _SQL_CONTAINSPERMISSION = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Permissions WHERE userId = ? AND permissionId = ?";
8660 private static final String _SQL_GETROLES = "SELECT {Role_.*} FROM Role_ INNER JOIN Users_Roles ON (Users_Roles.roleId = Role_.roleId) WHERE (Users_Roles.userId = ?)";
8661 private static final String _SQL_GETROLESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ?";
8662 private static final String _SQL_CONTAINSROLE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Roles WHERE userId = ? AND roleId = ?";
8663 private static final String _SQL_GETTEAMS = "SELECT {Team.*} FROM Team INNER JOIN Users_Teams ON (Users_Teams.teamId = Team.teamId) WHERE (Users_Teams.userId = ?)";
8664 private static final String _SQL_GETTEAMSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ?";
8665 private static final String _SQL_CONTAINSTEAM = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE userId = ? AND teamId = ?";
8666 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN Users_UserGroups ON (Users_UserGroups.userGroupId = UserGroup.userGroupId) WHERE (Users_UserGroups.userId = ?)";
8667 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ?";
8668 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_UserGroups WHERE userId = ? AND userGroupId = ?";
8669 private static final String _FINDER_COLUMN_UUID_UUID_1 = "user.uuid IS NULL";
8670 private static final String _FINDER_COLUMN_UUID_UUID_2 = "user.uuid = ?";
8671 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(user.uuid IS NULL OR user.uuid = ?)";
8672 private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "user.companyId = ?";
8673 private static final String _FINDER_COLUMN_CONTACTID_CONTACTID_2 = "user.contactId = ?";
8674 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_1 = "user.emailAddress IS NULL";
8675 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_2 = "user.emailAddress = ?";
8676 private static final String _FINDER_COLUMN_EMAILADDRESS_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
8677 private static final String _FINDER_COLUMN_PORTRAITID_PORTRAITID_2 = "user.portraitId = ?";
8678 private static final String _FINDER_COLUMN_C_U_COMPANYID_2 = "user.companyId = ? AND ";
8679 private static final String _FINDER_COLUMN_C_U_USERID_2 = "user.userId = ?";
8680 private static final String _FINDER_COLUMN_C_DU_COMPANYID_2 = "user.companyId = ? AND ";
8681 private static final String _FINDER_COLUMN_C_DU_DEFAULTUSER_2 = "user.defaultUser = ?";
8682 private static final String _FINDER_COLUMN_C_SN_COMPANYID_2 = "user.companyId = ? AND ";
8683 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_1 = "user.screenName IS NULL";
8684 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_2 = "user.screenName = ?";
8685 private static final String _FINDER_COLUMN_C_SN_SCREENNAME_3 = "(user.screenName IS NULL OR user.screenName = ?)";
8686 private static final String _FINDER_COLUMN_C_EA_COMPANYID_2 = "user.companyId = ? AND ";
8687 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_1 = "user.emailAddress IS NULL";
8688 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_2 = "user.emailAddress = ?";
8689 private static final String _FINDER_COLUMN_C_EA_EMAILADDRESS_3 = "(user.emailAddress IS NULL OR user.emailAddress = ?)";
8690 private static final String _FINDER_COLUMN_C_FID_COMPANYID_2 = "user.companyId = ? AND ";
8691 private static final String _FINDER_COLUMN_C_FID_FACEBOOKID_2 = "user.facebookId = ?";
8692 private static final String _FINDER_COLUMN_C_O_COMPANYID_2 = "user.companyId = ? AND ";
8693 private static final String _FINDER_COLUMN_C_O_OPENID_1 = "user.openId IS NULL";
8694 private static final String _FINDER_COLUMN_C_O_OPENID_2 = "user.openId = ?";
8695 private static final String _FINDER_COLUMN_C_O_OPENID_3 = "(user.openId IS NULL OR user.openId = ?)";
8696 private static final String _FINDER_COLUMN_C_S_COMPANYID_2 = "user.companyId = ? AND ";
8697 private static final String _FINDER_COLUMN_C_S_STATUS_2 = "user.status = ?";
8698 private static final String _ORDER_BY_ENTITY_ALIAS = "user.";
8699 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No User exists with the primary key ";
8700 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No User exists with the key {";
8701 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
8702 private static Log _log = LogFactoryUtil.getLog(UserPersistenceImpl.class);
8703 private static User _nullUser = new UserImpl() {
8704 @Override
8705 public Object clone() {
8706 return this;
8707 }
8708
8709 @Override
8710 public CacheModel<User> toCacheModel() {
8711 return _nullUserCacheModel;
8712 }
8713 };
8714
8715 private static CacheModel<User> _nullUserCacheModel = new CacheModel<User>() {
8716 public User toEntityModel() {
8717 return _nullUser;
8718 }
8719 };
8720 }