001
014
015 package com.liferay.portal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.NoSuchTeamException;
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.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.model.Team;
048 import com.liferay.portal.model.impl.TeamImpl;
049 import com.liferay.portal.model.impl.TeamModelImpl;
050 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058 import java.util.Set;
059
060
072 public class TeamPersistenceImpl extends BasePersistenceImpl<Team>
073 implements TeamPersistence {
074
079 public static final String FINDER_CLASS_NAME_ENTITY = TeamImpl.class.getName();
080 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
081 ".List1";
082 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
083 ".List2";
084 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
085 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
086 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
087 new String[] {
088 Long.class.getName(),
089
090 "java.lang.Integer", "java.lang.Integer",
091 "com.liferay.portal.kernel.util.OrderByComparator"
092 });
093 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
094 new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
095 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
096 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
097 new String[] { Long.class.getName() },
098 TeamModelImpl.GROUPID_COLUMN_BITMASK);
099 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
100 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
102 new String[] { Long.class.getName() });
103 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
104 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
105 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
106 new String[] { Long.class.getName(), String.class.getName() },
107 TeamModelImpl.GROUPID_COLUMN_BITMASK |
108 TeamModelImpl.NAME_COLUMN_BITMASK);
109 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
110 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
111 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
112 new String[] { Long.class.getName(), String.class.getName() });
113 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
114 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
115 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
116 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
117 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
118 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
119 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
120 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
121 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
122
123
128 public void cacheResult(Team team) {
129 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
130 TeamImpl.class, team.getPrimaryKey(), team);
131
132 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
133 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
134 team);
135
136 team.resetOriginalValues();
137 }
138
139
144 public void cacheResult(List<Team> teams) {
145 for (Team team : teams) {
146 if (EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
147 TeamImpl.class, team.getPrimaryKey()) == null) {
148 cacheResult(team);
149 }
150 else {
151 team.resetOriginalValues();
152 }
153 }
154 }
155
156
163 @Override
164 public void clearCache() {
165 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
166 CacheRegistryUtil.clear(TeamImpl.class.getName());
167 }
168
169 EntityCacheUtil.clearCache(TeamImpl.class.getName());
170
171 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
173 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
174 }
175
176
183 @Override
184 public void clearCache(Team team) {
185 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
186 TeamImpl.class, team.getPrimaryKey());
187
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
189 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
190
191 clearUniqueFindersCache(team);
192 }
193
194 @Override
195 public void clearCache(List<Team> teams) {
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
197 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
198
199 for (Team team : teams) {
200 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
201 TeamImpl.class, team.getPrimaryKey());
202
203 clearUniqueFindersCache(team);
204 }
205 }
206
207 protected void clearUniqueFindersCache(Team team) {
208 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
209 new Object[] { Long.valueOf(team.getGroupId()), team.getName() });
210 }
211
212
218 public Team create(long teamId) {
219 Team team = new TeamImpl();
220
221 team.setNew(true);
222 team.setPrimaryKey(teamId);
223
224 return team;
225 }
226
227
235 public Team remove(long teamId) throws NoSuchTeamException, SystemException {
236 return remove(Long.valueOf(teamId));
237 }
238
239
247 @Override
248 public Team remove(Serializable primaryKey)
249 throws NoSuchTeamException, SystemException {
250 Session session = null;
251
252 try {
253 session = openSession();
254
255 Team team = (Team)session.get(TeamImpl.class, primaryKey);
256
257 if (team == null) {
258 if (_log.isWarnEnabled()) {
259 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
260 }
261
262 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
263 primaryKey);
264 }
265
266 return remove(team);
267 }
268 catch (NoSuchTeamException nsee) {
269 throw nsee;
270 }
271 catch (Exception e) {
272 throw processException(e);
273 }
274 finally {
275 closeSession(session);
276 }
277 }
278
279 @Override
280 protected Team removeImpl(Team team) throws SystemException {
281 team = toUnwrappedModel(team);
282
283 try {
284 clearUsers.clear(team.getPrimaryKey());
285 }
286 catch (Exception e) {
287 throw processException(e);
288 }
289 finally {
290 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
291 }
292
293 try {
294 clearUserGroups.clear(team.getPrimaryKey());
295 }
296 catch (Exception e) {
297 throw processException(e);
298 }
299 finally {
300 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
301 }
302
303 Session session = null;
304
305 try {
306 session = openSession();
307
308 BatchSessionUtil.delete(session, team);
309 }
310 catch (Exception e) {
311 throw processException(e);
312 }
313 finally {
314 closeSession(session);
315 }
316
317 clearCache(team);
318
319 return team;
320 }
321
322 @Override
323 public Team updateImpl(com.liferay.portal.model.Team team, boolean merge)
324 throws SystemException {
325 team = toUnwrappedModel(team);
326
327 boolean isNew = team.isNew();
328
329 TeamModelImpl teamModelImpl = (TeamModelImpl)team;
330
331 Session session = null;
332
333 try {
334 session = openSession();
335
336 BatchSessionUtil.update(session, team, merge);
337
338 team.setNew(false);
339 }
340 catch (Exception e) {
341 throw processException(e);
342 }
343 finally {
344 closeSession(session);
345 }
346
347 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
348
349 if (isNew || !TeamModelImpl.COLUMN_BITMASK_ENABLED) {
350 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
351 }
352
353 else {
354 if ((teamModelImpl.getColumnBitmask() &
355 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
356 Object[] args = new Object[] {
357 Long.valueOf(teamModelImpl.getOriginalGroupId())
358 };
359
360 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
361 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
362 args);
363
364 args = new Object[] { Long.valueOf(teamModelImpl.getGroupId()) };
365
366 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
367 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
368 args);
369 }
370 }
371
372 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
373 TeamImpl.class, team.getPrimaryKey(), team);
374
375 if (isNew) {
376 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
377 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
378 team);
379 }
380 else {
381 if ((teamModelImpl.getColumnBitmask() &
382 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
383 Object[] args = new Object[] {
384 Long.valueOf(teamModelImpl.getOriginalGroupId()),
385
386 teamModelImpl.getOriginalName()
387 };
388
389 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
390
391 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
392
393 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
394 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
395 team);
396 }
397 }
398
399 return team;
400 }
401
402 protected Team toUnwrappedModel(Team team) {
403 if (team instanceof TeamImpl) {
404 return team;
405 }
406
407 TeamImpl teamImpl = new TeamImpl();
408
409 teamImpl.setNew(team.isNew());
410 teamImpl.setPrimaryKey(team.getPrimaryKey());
411
412 teamImpl.setTeamId(team.getTeamId());
413 teamImpl.setCompanyId(team.getCompanyId());
414 teamImpl.setUserId(team.getUserId());
415 teamImpl.setUserName(team.getUserName());
416 teamImpl.setCreateDate(team.getCreateDate());
417 teamImpl.setModifiedDate(team.getModifiedDate());
418 teamImpl.setGroupId(team.getGroupId());
419 teamImpl.setName(team.getName());
420 teamImpl.setDescription(team.getDescription());
421
422 return teamImpl;
423 }
424
425
433 @Override
434 public Team findByPrimaryKey(Serializable primaryKey)
435 throws NoSuchModelException, SystemException {
436 return findByPrimaryKey(((Long)primaryKey).longValue());
437 }
438
439
447 public Team findByPrimaryKey(long teamId)
448 throws NoSuchTeamException, SystemException {
449 Team team = fetchByPrimaryKey(teamId);
450
451 if (team == null) {
452 if (_log.isWarnEnabled()) {
453 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + teamId);
454 }
455
456 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
457 teamId);
458 }
459
460 return team;
461 }
462
463
470 @Override
471 public Team fetchByPrimaryKey(Serializable primaryKey)
472 throws SystemException {
473 return fetchByPrimaryKey(((Long)primaryKey).longValue());
474 }
475
476
483 public Team fetchByPrimaryKey(long teamId) throws SystemException {
484 Team team = (Team)EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
485 TeamImpl.class, teamId);
486
487 if (team == _nullTeam) {
488 return null;
489 }
490
491 if (team == null) {
492 Session session = null;
493
494 boolean hasException = false;
495
496 try {
497 session = openSession();
498
499 team = (Team)session.get(TeamImpl.class, Long.valueOf(teamId));
500 }
501 catch (Exception e) {
502 hasException = true;
503
504 throw processException(e);
505 }
506 finally {
507 if (team != null) {
508 cacheResult(team);
509 }
510 else if (!hasException) {
511 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
512 TeamImpl.class, teamId, _nullTeam);
513 }
514
515 closeSession(session);
516 }
517 }
518
519 return team;
520 }
521
522
529 public List<Team> findByGroupId(long groupId) throws SystemException {
530 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
531 }
532
533
546 public List<Team> findByGroupId(long groupId, int start, int end)
547 throws SystemException {
548 return findByGroupId(groupId, start, end, null);
549 }
550
551
565 public List<Team> findByGroupId(long groupId, int start, int end,
566 OrderByComparator orderByComparator) throws SystemException {
567 FinderPath finderPath = null;
568 Object[] finderArgs = null;
569
570 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
571 (orderByComparator == null)) {
572 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
573 finderArgs = new Object[] { groupId };
574 }
575 else {
576 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
577 finderArgs = new Object[] { groupId, start, end, orderByComparator };
578 }
579
580 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
581 finderArgs, this);
582
583 if ((list != null) && !list.isEmpty()) {
584 for (Team team : list) {
585 if ((groupId != team.getGroupId())) {
586 list = null;
587
588 break;
589 }
590 }
591 }
592
593 if (list == null) {
594 StringBundler query = null;
595
596 if (orderByComparator != null) {
597 query = new StringBundler(3 +
598 (orderByComparator.getOrderByFields().length * 3));
599 }
600 else {
601 query = new StringBundler(3);
602 }
603
604 query.append(_SQL_SELECT_TEAM_WHERE);
605
606 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
607
608 if (orderByComparator != null) {
609 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
610 orderByComparator);
611 }
612
613 else {
614 query.append(TeamModelImpl.ORDER_BY_JPQL);
615 }
616
617 String sql = query.toString();
618
619 Session session = null;
620
621 try {
622 session = openSession();
623
624 Query q = session.createQuery(sql);
625
626 QueryPos qPos = QueryPos.getInstance(q);
627
628 qPos.add(groupId);
629
630 list = (List<Team>)QueryUtil.list(q, getDialect(), start, end);
631 }
632 catch (Exception e) {
633 throw processException(e);
634 }
635 finally {
636 if (list == null) {
637 FinderCacheUtil.removeResult(finderPath, finderArgs);
638 }
639 else {
640 cacheResult(list);
641
642 FinderCacheUtil.putResult(finderPath, finderArgs, list);
643 }
644
645 closeSession(session);
646 }
647 }
648
649 return list;
650 }
651
652
661 public Team findByGroupId_First(long groupId,
662 OrderByComparator orderByComparator)
663 throws NoSuchTeamException, SystemException {
664 Team team = fetchByGroupId_First(groupId, orderByComparator);
665
666 if (team != null) {
667 return team;
668 }
669
670 StringBundler msg = new StringBundler(4);
671
672 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
673
674 msg.append("groupId=");
675 msg.append(groupId);
676
677 msg.append(StringPool.CLOSE_CURLY_BRACE);
678
679 throw new NoSuchTeamException(msg.toString());
680 }
681
682
690 public Team fetchByGroupId_First(long groupId,
691 OrderByComparator orderByComparator) throws SystemException {
692 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
693
694 if (!list.isEmpty()) {
695 return list.get(0);
696 }
697
698 return null;
699 }
700
701
710 public Team findByGroupId_Last(long groupId,
711 OrderByComparator orderByComparator)
712 throws NoSuchTeamException, SystemException {
713 Team team = fetchByGroupId_Last(groupId, orderByComparator);
714
715 if (team != null) {
716 return team;
717 }
718
719 StringBundler msg = new StringBundler(4);
720
721 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
722
723 msg.append("groupId=");
724 msg.append(groupId);
725
726 msg.append(StringPool.CLOSE_CURLY_BRACE);
727
728 throw new NoSuchTeamException(msg.toString());
729 }
730
731
739 public Team fetchByGroupId_Last(long groupId,
740 OrderByComparator orderByComparator) throws SystemException {
741 int count = countByGroupId(groupId);
742
743 List<Team> list = findByGroupId(groupId, count - 1, count,
744 orderByComparator);
745
746 if (!list.isEmpty()) {
747 return list.get(0);
748 }
749
750 return null;
751 }
752
753
763 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
764 OrderByComparator orderByComparator)
765 throws NoSuchTeamException, SystemException {
766 Team team = findByPrimaryKey(teamId);
767
768 Session session = null;
769
770 try {
771 session = openSession();
772
773 Team[] array = new TeamImpl[3];
774
775 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
776 orderByComparator, true);
777
778 array[1] = team;
779
780 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
781 orderByComparator, false);
782
783 return array;
784 }
785 catch (Exception e) {
786 throw processException(e);
787 }
788 finally {
789 closeSession(session);
790 }
791 }
792
793 protected Team getByGroupId_PrevAndNext(Session session, Team team,
794 long groupId, OrderByComparator orderByComparator, boolean previous) {
795 StringBundler query = null;
796
797 if (orderByComparator != null) {
798 query = new StringBundler(6 +
799 (orderByComparator.getOrderByFields().length * 6));
800 }
801 else {
802 query = new StringBundler(3);
803 }
804
805 query.append(_SQL_SELECT_TEAM_WHERE);
806
807 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
808
809 if (orderByComparator != null) {
810 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
811
812 if (orderByConditionFields.length > 0) {
813 query.append(WHERE_AND);
814 }
815
816 for (int i = 0; i < orderByConditionFields.length; i++) {
817 query.append(_ORDER_BY_ENTITY_ALIAS);
818 query.append(orderByConditionFields[i]);
819
820 if ((i + 1) < orderByConditionFields.length) {
821 if (orderByComparator.isAscending() ^ previous) {
822 query.append(WHERE_GREATER_THAN_HAS_NEXT);
823 }
824 else {
825 query.append(WHERE_LESSER_THAN_HAS_NEXT);
826 }
827 }
828 else {
829 if (orderByComparator.isAscending() ^ previous) {
830 query.append(WHERE_GREATER_THAN);
831 }
832 else {
833 query.append(WHERE_LESSER_THAN);
834 }
835 }
836 }
837
838 query.append(ORDER_BY_CLAUSE);
839
840 String[] orderByFields = orderByComparator.getOrderByFields();
841
842 for (int i = 0; i < orderByFields.length; i++) {
843 query.append(_ORDER_BY_ENTITY_ALIAS);
844 query.append(orderByFields[i]);
845
846 if ((i + 1) < orderByFields.length) {
847 if (orderByComparator.isAscending() ^ previous) {
848 query.append(ORDER_BY_ASC_HAS_NEXT);
849 }
850 else {
851 query.append(ORDER_BY_DESC_HAS_NEXT);
852 }
853 }
854 else {
855 if (orderByComparator.isAscending() ^ previous) {
856 query.append(ORDER_BY_ASC);
857 }
858 else {
859 query.append(ORDER_BY_DESC);
860 }
861 }
862 }
863 }
864
865 else {
866 query.append(TeamModelImpl.ORDER_BY_JPQL);
867 }
868
869 String sql = query.toString();
870
871 Query q = session.createQuery(sql);
872
873 q.setFirstResult(0);
874 q.setMaxResults(2);
875
876 QueryPos qPos = QueryPos.getInstance(q);
877
878 qPos.add(groupId);
879
880 if (orderByComparator != null) {
881 Object[] values = orderByComparator.getOrderByConditionValues(team);
882
883 for (Object value : values) {
884 qPos.add(value);
885 }
886 }
887
888 List<Team> list = q.list();
889
890 if (list.size() == 2) {
891 return list.get(1);
892 }
893 else {
894 return null;
895 }
896 }
897
898
905 public List<Team> filterFindByGroupId(long groupId)
906 throws SystemException {
907 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
908 QueryUtil.ALL_POS, null);
909 }
910
911
924 public List<Team> filterFindByGroupId(long groupId, int start, int end)
925 throws SystemException {
926 return filterFindByGroupId(groupId, start, end, null);
927 }
928
929
943 public List<Team> filterFindByGroupId(long groupId, int start, int end,
944 OrderByComparator orderByComparator) throws SystemException {
945 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
946 return findByGroupId(groupId, start, end, orderByComparator);
947 }
948
949 StringBundler query = null;
950
951 if (orderByComparator != null) {
952 query = new StringBundler(3 +
953 (orderByComparator.getOrderByFields().length * 3));
954 }
955 else {
956 query = new StringBundler(3);
957 }
958
959 if (getDB().isSupportsInlineDistinct()) {
960 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
961 }
962 else {
963 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
964 }
965
966 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
967
968 if (!getDB().isSupportsInlineDistinct()) {
969 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
970 }
971
972 if (orderByComparator != null) {
973 if (getDB().isSupportsInlineDistinct()) {
974 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
975 orderByComparator);
976 }
977 else {
978 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
979 orderByComparator);
980 }
981 }
982
983 else {
984 if (getDB().isSupportsInlineDistinct()) {
985 query.append(TeamModelImpl.ORDER_BY_JPQL);
986 }
987 else {
988 query.append(TeamModelImpl.ORDER_BY_SQL);
989 }
990 }
991
992 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
993 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
994 groupId);
995
996 Session session = null;
997
998 try {
999 session = openSession();
1000
1001 SQLQuery q = session.createSQLQuery(sql);
1002
1003 if (getDB().isSupportsInlineDistinct()) {
1004 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1005 }
1006 else {
1007 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1008 }
1009
1010 QueryPos qPos = QueryPos.getInstance(q);
1011
1012 qPos.add(groupId);
1013
1014 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
1015 }
1016 catch (Exception e) {
1017 throw processException(e);
1018 }
1019 finally {
1020 closeSession(session);
1021 }
1022 }
1023
1024
1034 public Team[] filterFindByGroupId_PrevAndNext(long teamId, long groupId,
1035 OrderByComparator orderByComparator)
1036 throws NoSuchTeamException, SystemException {
1037 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1038 return findByGroupId_PrevAndNext(teamId, groupId, orderByComparator);
1039 }
1040
1041 Team team = findByPrimaryKey(teamId);
1042
1043 Session session = null;
1044
1045 try {
1046 session = openSession();
1047
1048 Team[] array = new TeamImpl[3];
1049
1050 array[0] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1051 orderByComparator, true);
1052
1053 array[1] = team;
1054
1055 array[2] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1056 orderByComparator, false);
1057
1058 return array;
1059 }
1060 catch (Exception e) {
1061 throw processException(e);
1062 }
1063 finally {
1064 closeSession(session);
1065 }
1066 }
1067
1068 protected Team filterGetByGroupId_PrevAndNext(Session session, Team team,
1069 long groupId, OrderByComparator orderByComparator, boolean previous) {
1070 StringBundler query = null;
1071
1072 if (orderByComparator != null) {
1073 query = new StringBundler(6 +
1074 (orderByComparator.getOrderByFields().length * 6));
1075 }
1076 else {
1077 query = new StringBundler(3);
1078 }
1079
1080 if (getDB().isSupportsInlineDistinct()) {
1081 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
1082 }
1083 else {
1084 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
1085 }
1086
1087 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1088
1089 if (!getDB().isSupportsInlineDistinct()) {
1090 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
1091 }
1092
1093 if (orderByComparator != null) {
1094 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1095
1096 if (orderByConditionFields.length > 0) {
1097 query.append(WHERE_AND);
1098 }
1099
1100 for (int i = 0; i < orderByConditionFields.length; i++) {
1101 if (getDB().isSupportsInlineDistinct()) {
1102 query.append(_ORDER_BY_ENTITY_ALIAS);
1103 }
1104 else {
1105 query.append(_ORDER_BY_ENTITY_TABLE);
1106 }
1107
1108 query.append(orderByConditionFields[i]);
1109
1110 if ((i + 1) < orderByConditionFields.length) {
1111 if (orderByComparator.isAscending() ^ previous) {
1112 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1113 }
1114 else {
1115 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1116 }
1117 }
1118 else {
1119 if (orderByComparator.isAscending() ^ previous) {
1120 query.append(WHERE_GREATER_THAN);
1121 }
1122 else {
1123 query.append(WHERE_LESSER_THAN);
1124 }
1125 }
1126 }
1127
1128 query.append(ORDER_BY_CLAUSE);
1129
1130 String[] orderByFields = orderByComparator.getOrderByFields();
1131
1132 for (int i = 0; i < orderByFields.length; i++) {
1133 if (getDB().isSupportsInlineDistinct()) {
1134 query.append(_ORDER_BY_ENTITY_ALIAS);
1135 }
1136 else {
1137 query.append(_ORDER_BY_ENTITY_TABLE);
1138 }
1139
1140 query.append(orderByFields[i]);
1141
1142 if ((i + 1) < orderByFields.length) {
1143 if (orderByComparator.isAscending() ^ previous) {
1144 query.append(ORDER_BY_ASC_HAS_NEXT);
1145 }
1146 else {
1147 query.append(ORDER_BY_DESC_HAS_NEXT);
1148 }
1149 }
1150 else {
1151 if (orderByComparator.isAscending() ^ previous) {
1152 query.append(ORDER_BY_ASC);
1153 }
1154 else {
1155 query.append(ORDER_BY_DESC);
1156 }
1157 }
1158 }
1159 }
1160
1161 else {
1162 if (getDB().isSupportsInlineDistinct()) {
1163 query.append(TeamModelImpl.ORDER_BY_JPQL);
1164 }
1165 else {
1166 query.append(TeamModelImpl.ORDER_BY_SQL);
1167 }
1168 }
1169
1170 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1171 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1172 groupId);
1173
1174 SQLQuery q = session.createSQLQuery(sql);
1175
1176 q.setFirstResult(0);
1177 q.setMaxResults(2);
1178
1179 if (getDB().isSupportsInlineDistinct()) {
1180 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1181 }
1182 else {
1183 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1184 }
1185
1186 QueryPos qPos = QueryPos.getInstance(q);
1187
1188 qPos.add(groupId);
1189
1190 if (orderByComparator != null) {
1191 Object[] values = orderByComparator.getOrderByConditionValues(team);
1192
1193 for (Object value : values) {
1194 qPos.add(value);
1195 }
1196 }
1197
1198 List<Team> list = q.list();
1199
1200 if (list.size() == 2) {
1201 return list.get(1);
1202 }
1203 else {
1204 return null;
1205 }
1206 }
1207
1208
1217 public Team findByG_N(long groupId, String name)
1218 throws NoSuchTeamException, SystemException {
1219 Team team = fetchByG_N(groupId, name);
1220
1221 if (team == null) {
1222 StringBundler msg = new StringBundler(6);
1223
1224 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1225
1226 msg.append("groupId=");
1227 msg.append(groupId);
1228
1229 msg.append(", name=");
1230 msg.append(name);
1231
1232 msg.append(StringPool.CLOSE_CURLY_BRACE);
1233
1234 if (_log.isWarnEnabled()) {
1235 _log.warn(msg.toString());
1236 }
1237
1238 throw new NoSuchTeamException(msg.toString());
1239 }
1240
1241 return team;
1242 }
1243
1244
1252 public Team fetchByG_N(long groupId, String name) throws SystemException {
1253 return fetchByG_N(groupId, name, true);
1254 }
1255
1256
1265 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
1266 throws SystemException {
1267 Object[] finderArgs = new Object[] { groupId, name };
1268
1269 Object result = null;
1270
1271 if (retrieveFromCache) {
1272 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1273 finderArgs, this);
1274 }
1275
1276 if (result instanceof Team) {
1277 Team team = (Team)result;
1278
1279 if ((groupId != team.getGroupId()) ||
1280 !Validator.equals(name, team.getName())) {
1281 result = null;
1282 }
1283 }
1284
1285 if (result == null) {
1286 StringBundler query = new StringBundler(4);
1287
1288 query.append(_SQL_SELECT_TEAM_WHERE);
1289
1290 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1291
1292 if (name == null) {
1293 query.append(_FINDER_COLUMN_G_N_NAME_1);
1294 }
1295 else {
1296 if (name.equals(StringPool.BLANK)) {
1297 query.append(_FINDER_COLUMN_G_N_NAME_3);
1298 }
1299 else {
1300 query.append(_FINDER_COLUMN_G_N_NAME_2);
1301 }
1302 }
1303
1304 query.append(TeamModelImpl.ORDER_BY_JPQL);
1305
1306 String sql = query.toString();
1307
1308 Session session = null;
1309
1310 try {
1311 session = openSession();
1312
1313 Query q = session.createQuery(sql);
1314
1315 QueryPos qPos = QueryPos.getInstance(q);
1316
1317 qPos.add(groupId);
1318
1319 if (name != null) {
1320 qPos.add(name);
1321 }
1322
1323 List<Team> list = q.list();
1324
1325 result = list;
1326
1327 Team team = null;
1328
1329 if (list.isEmpty()) {
1330 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1331 finderArgs, list);
1332 }
1333 else {
1334 team = list.get(0);
1335
1336 cacheResult(team);
1337
1338 if ((team.getGroupId() != groupId) ||
1339 (team.getName() == null) ||
1340 !team.getName().equals(name)) {
1341 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1342 finderArgs, team);
1343 }
1344 }
1345
1346 return team;
1347 }
1348 catch (Exception e) {
1349 throw processException(e);
1350 }
1351 finally {
1352 if (result == null) {
1353 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1354 finderArgs);
1355 }
1356
1357 closeSession(session);
1358 }
1359 }
1360 else {
1361 if (result instanceof List<?>) {
1362 return null;
1363 }
1364 else {
1365 return (Team)result;
1366 }
1367 }
1368 }
1369
1370
1376 public List<Team> findAll() throws SystemException {
1377 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1378 }
1379
1380
1392 public List<Team> findAll(int start, int end) throws SystemException {
1393 return findAll(start, end, null);
1394 }
1395
1396
1409 public List<Team> findAll(int start, int end,
1410 OrderByComparator orderByComparator) throws SystemException {
1411 FinderPath finderPath = null;
1412 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1413
1414 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1415 (orderByComparator == null)) {
1416 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1417 finderArgs = FINDER_ARGS_EMPTY;
1418 }
1419 else {
1420 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1421 finderArgs = new Object[] { start, end, orderByComparator };
1422 }
1423
1424 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
1425 finderArgs, this);
1426
1427 if (list == null) {
1428 StringBundler query = null;
1429 String sql = null;
1430
1431 if (orderByComparator != null) {
1432 query = new StringBundler(2 +
1433 (orderByComparator.getOrderByFields().length * 3));
1434
1435 query.append(_SQL_SELECT_TEAM);
1436
1437 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1438 orderByComparator);
1439
1440 sql = query.toString();
1441 }
1442 else {
1443 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1444 }
1445
1446 Session session = null;
1447
1448 try {
1449 session = openSession();
1450
1451 Query q = session.createQuery(sql);
1452
1453 if (orderByComparator == null) {
1454 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1455 end, false);
1456
1457 Collections.sort(list);
1458 }
1459 else {
1460 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1461 end);
1462 }
1463 }
1464 catch (Exception e) {
1465 throw processException(e);
1466 }
1467 finally {
1468 if (list == null) {
1469 FinderCacheUtil.removeResult(finderPath, finderArgs);
1470 }
1471 else {
1472 cacheResult(list);
1473
1474 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1475 }
1476
1477 closeSession(session);
1478 }
1479 }
1480
1481 return list;
1482 }
1483
1484
1490 public void removeByGroupId(long groupId) throws SystemException {
1491 for (Team team : findByGroupId(groupId)) {
1492 remove(team);
1493 }
1494 }
1495
1496
1504 public Team removeByG_N(long groupId, String name)
1505 throws NoSuchTeamException, SystemException {
1506 Team team = findByG_N(groupId, name);
1507
1508 return remove(team);
1509 }
1510
1511
1516 public void removeAll() throws SystemException {
1517 for (Team team : findAll()) {
1518 remove(team);
1519 }
1520 }
1521
1522
1529 public int countByGroupId(long groupId) throws SystemException {
1530 Object[] finderArgs = new Object[] { groupId };
1531
1532 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1533 finderArgs, this);
1534
1535 if (count == null) {
1536 StringBundler query = new StringBundler(2);
1537
1538 query.append(_SQL_COUNT_TEAM_WHERE);
1539
1540 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1541
1542 String sql = query.toString();
1543
1544 Session session = null;
1545
1546 try {
1547 session = openSession();
1548
1549 Query q = session.createQuery(sql);
1550
1551 QueryPos qPos = QueryPos.getInstance(q);
1552
1553 qPos.add(groupId);
1554
1555 count = (Long)q.uniqueResult();
1556 }
1557 catch (Exception e) {
1558 throw processException(e);
1559 }
1560 finally {
1561 if (count == null) {
1562 count = Long.valueOf(0);
1563 }
1564
1565 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1566 finderArgs, count);
1567
1568 closeSession(session);
1569 }
1570 }
1571
1572 return count.intValue();
1573 }
1574
1575
1582 public int filterCountByGroupId(long groupId) throws SystemException {
1583 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1584 return countByGroupId(groupId);
1585 }
1586
1587 StringBundler query = new StringBundler(2);
1588
1589 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1590
1591 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1592
1593 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1594 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1595 groupId);
1596
1597 Session session = null;
1598
1599 try {
1600 session = openSession();
1601
1602 SQLQuery q = session.createSQLQuery(sql);
1603
1604 q.addScalar(COUNT_COLUMN_NAME,
1605 com.liferay.portal.kernel.dao.orm.Type.LONG);
1606
1607 QueryPos qPos = QueryPos.getInstance(q);
1608
1609 qPos.add(groupId);
1610
1611 Long count = (Long)q.uniqueResult();
1612
1613 return count.intValue();
1614 }
1615 catch (Exception e) {
1616 throw processException(e);
1617 }
1618 finally {
1619 closeSession(session);
1620 }
1621 }
1622
1623
1631 public int countByG_N(long groupId, String name) throws SystemException {
1632 Object[] finderArgs = new Object[] { groupId, name };
1633
1634 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1635 finderArgs, this);
1636
1637 if (count == null) {
1638 StringBundler query = new StringBundler(3);
1639
1640 query.append(_SQL_COUNT_TEAM_WHERE);
1641
1642 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1643
1644 if (name == null) {
1645 query.append(_FINDER_COLUMN_G_N_NAME_1);
1646 }
1647 else {
1648 if (name.equals(StringPool.BLANK)) {
1649 query.append(_FINDER_COLUMN_G_N_NAME_3);
1650 }
1651 else {
1652 query.append(_FINDER_COLUMN_G_N_NAME_2);
1653 }
1654 }
1655
1656 String sql = query.toString();
1657
1658 Session session = null;
1659
1660 try {
1661 session = openSession();
1662
1663 Query q = session.createQuery(sql);
1664
1665 QueryPos qPos = QueryPos.getInstance(q);
1666
1667 qPos.add(groupId);
1668
1669 if (name != null) {
1670 qPos.add(name);
1671 }
1672
1673 count = (Long)q.uniqueResult();
1674 }
1675 catch (Exception e) {
1676 throw processException(e);
1677 }
1678 finally {
1679 if (count == null) {
1680 count = Long.valueOf(0);
1681 }
1682
1683 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1684 count);
1685
1686 closeSession(session);
1687 }
1688 }
1689
1690 return count.intValue();
1691 }
1692
1693
1699 public int countAll() throws SystemException {
1700 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1701 FINDER_ARGS_EMPTY, this);
1702
1703 if (count == null) {
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 Query q = session.createQuery(_SQL_COUNT_TEAM);
1710
1711 count = (Long)q.uniqueResult();
1712 }
1713 catch (Exception e) {
1714 throw processException(e);
1715 }
1716 finally {
1717 if (count == null) {
1718 count = Long.valueOf(0);
1719 }
1720
1721 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1722 FINDER_ARGS_EMPTY, count);
1723
1724 closeSession(session);
1725 }
1726 }
1727
1728 return count.intValue();
1729 }
1730
1731
1738 public List<com.liferay.portal.model.User> getUsers(long pk)
1739 throws SystemException {
1740 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1741 }
1742
1743
1756 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1757 int end) throws SystemException {
1758 return getUsers(pk, start, end, null);
1759 }
1760
1761 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1762 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1763 com.liferay.portal.model.impl.UserImpl.class,
1764 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1765 new String[] {
1766 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1767 "com.liferay.portal.kernel.util.OrderByComparator"
1768 });
1769
1770 static {
1771 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
1772 }
1773
1774
1788 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1789 int end, OrderByComparator orderByComparator) throws SystemException {
1790 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1791
1792 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1793 finderArgs, this);
1794
1795 if (list == null) {
1796 Session session = null;
1797
1798 try {
1799 session = openSession();
1800
1801 String sql = null;
1802
1803 if (orderByComparator != null) {
1804 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1805 .concat(orderByComparator.getOrderBy());
1806 }
1807 else {
1808 sql = _SQL_GETUSERS;
1809 }
1810
1811 SQLQuery q = session.createSQLQuery(sql);
1812
1813 q.addEntity("User_",
1814 com.liferay.portal.model.impl.UserImpl.class);
1815
1816 QueryPos qPos = QueryPos.getInstance(q);
1817
1818 qPos.add(pk);
1819
1820 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1821 getDialect(), start, end);
1822 }
1823 catch (Exception e) {
1824 throw processException(e);
1825 }
1826 finally {
1827 if (list == null) {
1828 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
1829 finderArgs);
1830 }
1831 else {
1832 userPersistence.cacheResult(list);
1833
1834 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
1835 finderArgs, list);
1836 }
1837
1838 closeSession(session);
1839 }
1840 }
1841
1842 return list;
1843 }
1844
1845 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1846 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
1847 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1848 new String[] { Long.class.getName() });
1849
1850 static {
1851 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
1852 }
1853
1854
1861 public int getUsersSize(long pk) throws SystemException {
1862 Object[] finderArgs = new Object[] { pk };
1863
1864 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1865 finderArgs, this);
1866
1867 if (count == null) {
1868 Session session = null;
1869
1870 try {
1871 session = openSession();
1872
1873 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1874
1875 q.addScalar(COUNT_COLUMN_NAME,
1876 com.liferay.portal.kernel.dao.orm.Type.LONG);
1877
1878 QueryPos qPos = QueryPos.getInstance(q);
1879
1880 qPos.add(pk);
1881
1882 count = (Long)q.uniqueResult();
1883 }
1884 catch (Exception e) {
1885 throw processException(e);
1886 }
1887 finally {
1888 if (count == null) {
1889 count = Long.valueOf(0);
1890 }
1891
1892 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1893 finderArgs, count);
1894
1895 closeSession(session);
1896 }
1897 }
1898
1899 return count.intValue();
1900 }
1901
1902 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1903 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
1904 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1905 new String[] { Long.class.getName(), Long.class.getName() });
1906
1907
1915 public boolean containsUser(long pk, long userPK) throws SystemException {
1916 Object[] finderArgs = new Object[] { pk, userPK };
1917
1918 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1919 finderArgs, this);
1920
1921 if (value == null) {
1922 try {
1923 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1924 }
1925 catch (Exception e) {
1926 throw processException(e);
1927 }
1928 finally {
1929 if (value == null) {
1930 value = Boolean.FALSE;
1931 }
1932
1933 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1934 finderArgs, value);
1935 }
1936 }
1937
1938 return value.booleanValue();
1939 }
1940
1941
1948 public boolean containsUsers(long pk) throws SystemException {
1949 if (getUsersSize(pk) > 0) {
1950 return true;
1951 }
1952 else {
1953 return false;
1954 }
1955 }
1956
1957
1964 public void addUser(long pk, long userPK) throws SystemException {
1965 try {
1966 addUser.add(pk, userPK);
1967 }
1968 catch (Exception e) {
1969 throw processException(e);
1970 }
1971 finally {
1972 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1973 }
1974 }
1975
1976
1983 public void addUser(long pk, com.liferay.portal.model.User user)
1984 throws SystemException {
1985 try {
1986 addUser.add(pk, user.getPrimaryKey());
1987 }
1988 catch (Exception e) {
1989 throw processException(e);
1990 }
1991 finally {
1992 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1993 }
1994 }
1995
1996
2003 public void addUsers(long pk, long[] userPKs) throws SystemException {
2004 try {
2005 for (long userPK : userPKs) {
2006 addUser.add(pk, userPK);
2007 }
2008 }
2009 catch (Exception e) {
2010 throw processException(e);
2011 }
2012 finally {
2013 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2014 }
2015 }
2016
2017
2024 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2025 throws SystemException {
2026 try {
2027 for (com.liferay.portal.model.User user : users) {
2028 addUser.add(pk, user.getPrimaryKey());
2029 }
2030 }
2031 catch (Exception e) {
2032 throw processException(e);
2033 }
2034 finally {
2035 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2036 }
2037 }
2038
2039
2045 public void clearUsers(long pk) throws SystemException {
2046 try {
2047 clearUsers.clear(pk);
2048 }
2049 catch (Exception e) {
2050 throw processException(e);
2051 }
2052 finally {
2053 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2054 }
2055 }
2056
2057
2064 public void removeUser(long pk, long userPK) throws SystemException {
2065 try {
2066 removeUser.remove(pk, userPK);
2067 }
2068 catch (Exception e) {
2069 throw processException(e);
2070 }
2071 finally {
2072 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2073 }
2074 }
2075
2076
2083 public void removeUser(long pk, com.liferay.portal.model.User user)
2084 throws SystemException {
2085 try {
2086 removeUser.remove(pk, user.getPrimaryKey());
2087 }
2088 catch (Exception e) {
2089 throw processException(e);
2090 }
2091 finally {
2092 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2093 }
2094 }
2095
2096
2103 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2104 try {
2105 for (long userPK : userPKs) {
2106 removeUser.remove(pk, userPK);
2107 }
2108 }
2109 catch (Exception e) {
2110 throw processException(e);
2111 }
2112 finally {
2113 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2114 }
2115 }
2116
2117
2124 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2125 throws SystemException {
2126 try {
2127 for (com.liferay.portal.model.User user : users) {
2128 removeUser.remove(pk, user.getPrimaryKey());
2129 }
2130 }
2131 catch (Exception e) {
2132 throw processException(e);
2133 }
2134 finally {
2135 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2136 }
2137 }
2138
2139
2146 public void setUsers(long pk, long[] userPKs) throws SystemException {
2147 try {
2148 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2149
2150 List<com.liferay.portal.model.User> users = getUsers(pk);
2151
2152 for (com.liferay.portal.model.User user : users) {
2153 if (!userPKSet.remove(user.getPrimaryKey())) {
2154 removeUser.remove(pk, user.getPrimaryKey());
2155 }
2156 }
2157
2158 for (Long userPK : userPKSet) {
2159 addUser.add(pk, userPK);
2160 }
2161 }
2162 catch (Exception e) {
2163 throw processException(e);
2164 }
2165 finally {
2166 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2167 }
2168 }
2169
2170
2177 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2178 throws SystemException {
2179 try {
2180 long[] userPKs = new long[users.size()];
2181
2182 for (int i = 0; i < users.size(); i++) {
2183 com.liferay.portal.model.User user = users.get(i);
2184
2185 userPKs[i] = user.getPrimaryKey();
2186 }
2187
2188 setUsers(pk, userPKs);
2189 }
2190 catch (Exception e) {
2191 throw processException(e);
2192 }
2193 finally {
2194 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2195 }
2196 }
2197
2198
2205 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
2206 throws SystemException {
2207 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2208 }
2209
2210
2223 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2224 int start, int end) throws SystemException {
2225 return getUserGroups(pk, start, end, null);
2226 }
2227
2228 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2229 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
2230 com.liferay.portal.model.impl.UserGroupImpl.class,
2231 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getUserGroups",
2232 new String[] {
2233 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2234 "com.liferay.portal.kernel.util.OrderByComparator"
2235 });
2236
2237 static {
2238 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
2239 }
2240
2241
2255 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2256 int start, int end, OrderByComparator orderByComparator)
2257 throws SystemException {
2258 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2259
2260 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
2261 finderArgs, this);
2262
2263 if (list == null) {
2264 Session session = null;
2265
2266 try {
2267 session = openSession();
2268
2269 String sql = null;
2270
2271 if (orderByComparator != null) {
2272 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
2273 .concat(orderByComparator.getOrderBy());
2274 }
2275 else {
2276 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
2277 }
2278
2279 SQLQuery q = session.createSQLQuery(sql);
2280
2281 q.addEntity("UserGroup",
2282 com.liferay.portal.model.impl.UserGroupImpl.class);
2283
2284 QueryPos qPos = QueryPos.getInstance(q);
2285
2286 qPos.add(pk);
2287
2288 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
2289 getDialect(), start, end);
2290 }
2291 catch (Exception e) {
2292 throw processException(e);
2293 }
2294 finally {
2295 if (list == null) {
2296 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
2297 finderArgs);
2298 }
2299 else {
2300 userGroupPersistence.cacheResult(list);
2301
2302 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
2303 finderArgs, list);
2304 }
2305
2306 closeSession(session);
2307 }
2308 }
2309
2310 return list;
2311 }
2312
2313 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2314 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Long.class,
2315 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2316 "getUserGroupsSize", new String[] { Long.class.getName() });
2317
2318 static {
2319 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
2320 }
2321
2322
2329 public int getUserGroupsSize(long pk) throws SystemException {
2330 Object[] finderArgs = new Object[] { pk };
2331
2332 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2333 finderArgs, this);
2334
2335 if (count == null) {
2336 Session session = null;
2337
2338 try {
2339 session = openSession();
2340
2341 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
2342
2343 q.addScalar(COUNT_COLUMN_NAME,
2344 com.liferay.portal.kernel.dao.orm.Type.LONG);
2345
2346 QueryPos qPos = QueryPos.getInstance(q);
2347
2348 qPos.add(pk);
2349
2350 count = (Long)q.uniqueResult();
2351 }
2352 catch (Exception e) {
2353 throw processException(e);
2354 }
2355 finally {
2356 if (count == null) {
2357 count = Long.valueOf(0);
2358 }
2359
2360 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2361 finderArgs, count);
2362
2363 closeSession(session);
2364 }
2365 }
2366
2367 return count.intValue();
2368 }
2369
2370 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2371 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Boolean.class,
2372 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2373 "containsUserGroup",
2374 new String[] { Long.class.getName(), Long.class.getName() });
2375
2376
2384 public boolean containsUserGroup(long pk, long userGroupPK)
2385 throws SystemException {
2386 Object[] finderArgs = new Object[] { pk, userGroupPK };
2387
2388 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
2389 finderArgs, this);
2390
2391 if (value == null) {
2392 try {
2393 value = Boolean.valueOf(containsUserGroup.contains(pk,
2394 userGroupPK));
2395 }
2396 catch (Exception e) {
2397 throw processException(e);
2398 }
2399 finally {
2400 if (value == null) {
2401 value = Boolean.FALSE;
2402 }
2403
2404 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
2405 finderArgs, value);
2406 }
2407 }
2408
2409 return value.booleanValue();
2410 }
2411
2412
2419 public boolean containsUserGroups(long pk) throws SystemException {
2420 if (getUserGroupsSize(pk) > 0) {
2421 return true;
2422 }
2423 else {
2424 return false;
2425 }
2426 }
2427
2428
2435 public void addUserGroup(long pk, long userGroupPK)
2436 throws SystemException {
2437 try {
2438 addUserGroup.add(pk, userGroupPK);
2439 }
2440 catch (Exception e) {
2441 throw processException(e);
2442 }
2443 finally {
2444 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2445 }
2446 }
2447
2448
2455 public void addUserGroup(long pk,
2456 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2457 try {
2458 addUserGroup.add(pk, userGroup.getPrimaryKey());
2459 }
2460 catch (Exception e) {
2461 throw processException(e);
2462 }
2463 finally {
2464 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2465 }
2466 }
2467
2468
2475 public void addUserGroups(long pk, long[] userGroupPKs)
2476 throws SystemException {
2477 try {
2478 for (long userGroupPK : userGroupPKs) {
2479 addUserGroup.add(pk, userGroupPK);
2480 }
2481 }
2482 catch (Exception e) {
2483 throw processException(e);
2484 }
2485 finally {
2486 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2487 }
2488 }
2489
2490
2497 public void addUserGroups(long pk,
2498 List<com.liferay.portal.model.UserGroup> userGroups)
2499 throws SystemException {
2500 try {
2501 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2502 addUserGroup.add(pk, userGroup.getPrimaryKey());
2503 }
2504 }
2505 catch (Exception e) {
2506 throw processException(e);
2507 }
2508 finally {
2509 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2510 }
2511 }
2512
2513
2519 public void clearUserGroups(long pk) throws SystemException {
2520 try {
2521 clearUserGroups.clear(pk);
2522 }
2523 catch (Exception e) {
2524 throw processException(e);
2525 }
2526 finally {
2527 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2528 }
2529 }
2530
2531
2538 public void removeUserGroup(long pk, long userGroupPK)
2539 throws SystemException {
2540 try {
2541 removeUserGroup.remove(pk, userGroupPK);
2542 }
2543 catch (Exception e) {
2544 throw processException(e);
2545 }
2546 finally {
2547 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2548 }
2549 }
2550
2551
2558 public void removeUserGroup(long pk,
2559 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2560 try {
2561 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2562 }
2563 catch (Exception e) {
2564 throw processException(e);
2565 }
2566 finally {
2567 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2568 }
2569 }
2570
2571
2578 public void removeUserGroups(long pk, long[] userGroupPKs)
2579 throws SystemException {
2580 try {
2581 for (long userGroupPK : userGroupPKs) {
2582 removeUserGroup.remove(pk, userGroupPK);
2583 }
2584 }
2585 catch (Exception e) {
2586 throw processException(e);
2587 }
2588 finally {
2589 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2590 }
2591 }
2592
2593
2600 public void removeUserGroups(long pk,
2601 List<com.liferay.portal.model.UserGroup> userGroups)
2602 throws SystemException {
2603 try {
2604 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2605 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2606 }
2607 }
2608 catch (Exception e) {
2609 throw processException(e);
2610 }
2611 finally {
2612 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2613 }
2614 }
2615
2616
2623 public void setUserGroups(long pk, long[] userGroupPKs)
2624 throws SystemException {
2625 try {
2626 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
2627
2628 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
2629
2630 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2631 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
2632 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2633 }
2634 }
2635
2636 for (Long userGroupPK : userGroupPKSet) {
2637 addUserGroup.add(pk, userGroupPK);
2638 }
2639 }
2640 catch (Exception e) {
2641 throw processException(e);
2642 }
2643 finally {
2644 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2645 }
2646 }
2647
2648
2655 public void setUserGroups(long pk,
2656 List<com.liferay.portal.model.UserGroup> userGroups)
2657 throws SystemException {
2658 try {
2659 long[] userGroupPKs = new long[userGroups.size()];
2660
2661 for (int i = 0; i < userGroups.size(); i++) {
2662 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
2663
2664 userGroupPKs[i] = userGroup.getPrimaryKey();
2665 }
2666
2667 setUserGroups(pk, userGroupPKs);
2668 }
2669 catch (Exception e) {
2670 throw processException(e);
2671 }
2672 finally {
2673 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2674 }
2675 }
2676
2677
2680 public void afterPropertiesSet() {
2681 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2682 com.liferay.portal.util.PropsUtil.get(
2683 "value.object.listener.com.liferay.portal.model.Team")));
2684
2685 if (listenerClassNames.length > 0) {
2686 try {
2687 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
2688
2689 for (String listenerClassName : listenerClassNames) {
2690 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
2691 listenerClassName));
2692 }
2693
2694 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2695 }
2696 catch (Exception e) {
2697 _log.error(e);
2698 }
2699 }
2700
2701 containsUser = new ContainsUser();
2702
2703 addUser = new AddUser();
2704 clearUsers = new ClearUsers();
2705 removeUser = new RemoveUser();
2706
2707 containsUserGroup = new ContainsUserGroup();
2708
2709 addUserGroup = new AddUserGroup();
2710 clearUserGroups = new ClearUserGroups();
2711 removeUserGroup = new RemoveUserGroup();
2712 }
2713
2714 public void destroy() {
2715 EntityCacheUtil.removeCache(TeamImpl.class.getName());
2716 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2717 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2718 }
2719
2720 @BeanReference(type = AccountPersistence.class)
2721 protected AccountPersistence accountPersistence;
2722 @BeanReference(type = AddressPersistence.class)
2723 protected AddressPersistence addressPersistence;
2724 @BeanReference(type = BrowserTrackerPersistence.class)
2725 protected BrowserTrackerPersistence browserTrackerPersistence;
2726 @BeanReference(type = ClassNamePersistence.class)
2727 protected ClassNamePersistence classNamePersistence;
2728 @BeanReference(type = ClusterGroupPersistence.class)
2729 protected ClusterGroupPersistence clusterGroupPersistence;
2730 @BeanReference(type = CompanyPersistence.class)
2731 protected CompanyPersistence companyPersistence;
2732 @BeanReference(type = ContactPersistence.class)
2733 protected ContactPersistence contactPersistence;
2734 @BeanReference(type = CountryPersistence.class)
2735 protected CountryPersistence countryPersistence;
2736 @BeanReference(type = EmailAddressPersistence.class)
2737 protected EmailAddressPersistence emailAddressPersistence;
2738 @BeanReference(type = GroupPersistence.class)
2739 protected GroupPersistence groupPersistence;
2740 @BeanReference(type = ImagePersistence.class)
2741 protected ImagePersistence imagePersistence;
2742 @BeanReference(type = LayoutPersistence.class)
2743 protected LayoutPersistence layoutPersistence;
2744 @BeanReference(type = LayoutBranchPersistence.class)
2745 protected LayoutBranchPersistence layoutBranchPersistence;
2746 @BeanReference(type = LayoutPrototypePersistence.class)
2747 protected LayoutPrototypePersistence layoutPrototypePersistence;
2748 @BeanReference(type = LayoutRevisionPersistence.class)
2749 protected LayoutRevisionPersistence layoutRevisionPersistence;
2750 @BeanReference(type = LayoutSetPersistence.class)
2751 protected LayoutSetPersistence layoutSetPersistence;
2752 @BeanReference(type = LayoutSetBranchPersistence.class)
2753 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2754 @BeanReference(type = LayoutSetPrototypePersistence.class)
2755 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2756 @BeanReference(type = ListTypePersistence.class)
2757 protected ListTypePersistence listTypePersistence;
2758 @BeanReference(type = LockPersistence.class)
2759 protected LockPersistence lockPersistence;
2760 @BeanReference(type = MembershipRequestPersistence.class)
2761 protected MembershipRequestPersistence membershipRequestPersistence;
2762 @BeanReference(type = OrganizationPersistence.class)
2763 protected OrganizationPersistence organizationPersistence;
2764 @BeanReference(type = OrgGroupPermissionPersistence.class)
2765 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2766 @BeanReference(type = OrgGroupRolePersistence.class)
2767 protected OrgGroupRolePersistence orgGroupRolePersistence;
2768 @BeanReference(type = OrgLaborPersistence.class)
2769 protected OrgLaborPersistence orgLaborPersistence;
2770 @BeanReference(type = PasswordPolicyPersistence.class)
2771 protected PasswordPolicyPersistence passwordPolicyPersistence;
2772 @BeanReference(type = PasswordPolicyRelPersistence.class)
2773 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2774 @BeanReference(type = PasswordTrackerPersistence.class)
2775 protected PasswordTrackerPersistence passwordTrackerPersistence;
2776 @BeanReference(type = PermissionPersistence.class)
2777 protected PermissionPersistence permissionPersistence;
2778 @BeanReference(type = PhonePersistence.class)
2779 protected PhonePersistence phonePersistence;
2780 @BeanReference(type = PluginSettingPersistence.class)
2781 protected PluginSettingPersistence pluginSettingPersistence;
2782 @BeanReference(type = PortalPreferencesPersistence.class)
2783 protected PortalPreferencesPersistence portalPreferencesPersistence;
2784 @BeanReference(type = PortletPersistence.class)
2785 protected PortletPersistence portletPersistence;
2786 @BeanReference(type = PortletItemPersistence.class)
2787 protected PortletItemPersistence portletItemPersistence;
2788 @BeanReference(type = PortletPreferencesPersistence.class)
2789 protected PortletPreferencesPersistence portletPreferencesPersistence;
2790 @BeanReference(type = RegionPersistence.class)
2791 protected RegionPersistence regionPersistence;
2792 @BeanReference(type = ReleasePersistence.class)
2793 protected ReleasePersistence releasePersistence;
2794 @BeanReference(type = RepositoryPersistence.class)
2795 protected RepositoryPersistence repositoryPersistence;
2796 @BeanReference(type = RepositoryEntryPersistence.class)
2797 protected RepositoryEntryPersistence repositoryEntryPersistence;
2798 @BeanReference(type = ResourcePersistence.class)
2799 protected ResourcePersistence resourcePersistence;
2800 @BeanReference(type = ResourceActionPersistence.class)
2801 protected ResourceActionPersistence resourceActionPersistence;
2802 @BeanReference(type = ResourceBlockPersistence.class)
2803 protected ResourceBlockPersistence resourceBlockPersistence;
2804 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2805 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2806 @BeanReference(type = ResourceCodePersistence.class)
2807 protected ResourceCodePersistence resourceCodePersistence;
2808 @BeanReference(type = ResourcePermissionPersistence.class)
2809 protected ResourcePermissionPersistence resourcePermissionPersistence;
2810 @BeanReference(type = ResourceTypePermissionPersistence.class)
2811 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2812 @BeanReference(type = RolePersistence.class)
2813 protected RolePersistence rolePersistence;
2814 @BeanReference(type = ServiceComponentPersistence.class)
2815 protected ServiceComponentPersistence serviceComponentPersistence;
2816 @BeanReference(type = ShardPersistence.class)
2817 protected ShardPersistence shardPersistence;
2818 @BeanReference(type = SubscriptionPersistence.class)
2819 protected SubscriptionPersistence subscriptionPersistence;
2820 @BeanReference(type = TeamPersistence.class)
2821 protected TeamPersistence teamPersistence;
2822 @BeanReference(type = TicketPersistence.class)
2823 protected TicketPersistence ticketPersistence;
2824 @BeanReference(type = UserPersistence.class)
2825 protected UserPersistence userPersistence;
2826 @BeanReference(type = UserGroupPersistence.class)
2827 protected UserGroupPersistence userGroupPersistence;
2828 @BeanReference(type = UserGroupGroupRolePersistence.class)
2829 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2830 @BeanReference(type = UserGroupRolePersistence.class)
2831 protected UserGroupRolePersistence userGroupRolePersistence;
2832 @BeanReference(type = UserIdMapperPersistence.class)
2833 protected UserIdMapperPersistence userIdMapperPersistence;
2834 @BeanReference(type = UserNotificationEventPersistence.class)
2835 protected UserNotificationEventPersistence userNotificationEventPersistence;
2836 @BeanReference(type = UserTrackerPersistence.class)
2837 protected UserTrackerPersistence userTrackerPersistence;
2838 @BeanReference(type = UserTrackerPathPersistence.class)
2839 protected UserTrackerPathPersistence userTrackerPathPersistence;
2840 @BeanReference(type = VirtualHostPersistence.class)
2841 protected VirtualHostPersistence virtualHostPersistence;
2842 @BeanReference(type = WebDAVPropsPersistence.class)
2843 protected WebDAVPropsPersistence webDAVPropsPersistence;
2844 @BeanReference(type = WebsitePersistence.class)
2845 protected WebsitePersistence websitePersistence;
2846 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2847 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2848 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2849 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2850 protected ContainsUser containsUser;
2851 protected AddUser addUser;
2852 protected ClearUsers clearUsers;
2853 protected RemoveUser removeUser;
2854 protected ContainsUserGroup containsUserGroup;
2855 protected AddUserGroup addUserGroup;
2856 protected ClearUserGroups clearUserGroups;
2857 protected RemoveUserGroup removeUserGroup;
2858
2859 protected class ContainsUser {
2860 protected ContainsUser() {
2861 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2862 _SQL_CONTAINSUSER,
2863 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2864 RowMapper.COUNT);
2865 }
2866
2867 protected boolean contains(long teamId, long userId) {
2868 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2869 new Long(teamId), new Long(userId)
2870 });
2871
2872 if (results.size() > 0) {
2873 Integer count = results.get(0);
2874
2875 if (count.intValue() > 0) {
2876 return true;
2877 }
2878 }
2879
2880 return false;
2881 }
2882
2883 private MappingSqlQuery<Integer> _mappingSqlQuery;
2884 }
2885
2886 protected class AddUser {
2887 protected AddUser() {
2888 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2889 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2890 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2891 }
2892
2893 protected void add(long teamId, long userId) throws SystemException {
2894 if (!containsUser.contains(teamId, userId)) {
2895 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2896
2897 for (ModelListener<Team> listener : listeners) {
2898 listener.onBeforeAddAssociation(teamId,
2899 com.liferay.portal.model.User.class.getName(), userId);
2900 }
2901
2902 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2903 listener.onBeforeAddAssociation(userId,
2904 Team.class.getName(), teamId);
2905 }
2906
2907 _sqlUpdate.update(new Object[] {
2908 new Long(teamId), new Long(userId)
2909 });
2910
2911 for (ModelListener<Team> listener : listeners) {
2912 listener.onAfterAddAssociation(teamId,
2913 com.liferay.portal.model.User.class.getName(), userId);
2914 }
2915
2916 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2917 listener.onAfterAddAssociation(userId,
2918 Team.class.getName(), teamId);
2919 }
2920 }
2921 }
2922
2923 private SqlUpdate _sqlUpdate;
2924 }
2925
2926 protected class ClearUsers {
2927 protected ClearUsers() {
2928 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2929 "DELETE FROM Users_Teams WHERE teamId = ?",
2930 new int[] { java.sql.Types.BIGINT });
2931 }
2932
2933 protected void clear(long teamId) throws SystemException {
2934 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2935
2936 List<com.liferay.portal.model.User> users = null;
2937
2938 if ((listeners.length > 0) || (userListeners.length > 0)) {
2939 users = getUsers(teamId);
2940
2941 for (com.liferay.portal.model.User user : users) {
2942 for (ModelListener<Team> listener : listeners) {
2943 listener.onBeforeRemoveAssociation(teamId,
2944 com.liferay.portal.model.User.class.getName(),
2945 user.getPrimaryKey());
2946 }
2947
2948 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2949 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2950 Team.class.getName(), teamId);
2951 }
2952 }
2953 }
2954
2955 _sqlUpdate.update(new Object[] { new Long(teamId) });
2956
2957 if ((listeners.length > 0) || (userListeners.length > 0)) {
2958 for (com.liferay.portal.model.User user : users) {
2959 for (ModelListener<Team> listener : listeners) {
2960 listener.onAfterRemoveAssociation(teamId,
2961 com.liferay.portal.model.User.class.getName(),
2962 user.getPrimaryKey());
2963 }
2964
2965 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2966 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2967 Team.class.getName(), teamId);
2968 }
2969 }
2970 }
2971 }
2972
2973 private SqlUpdate _sqlUpdate;
2974 }
2975
2976 protected class RemoveUser {
2977 protected RemoveUser() {
2978 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2979 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2980 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2981 }
2982
2983 protected void remove(long teamId, long userId)
2984 throws SystemException {
2985 if (containsUser.contains(teamId, userId)) {
2986 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2987
2988 for (ModelListener<Team> listener : listeners) {
2989 listener.onBeforeRemoveAssociation(teamId,
2990 com.liferay.portal.model.User.class.getName(), userId);
2991 }
2992
2993 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2994 listener.onBeforeRemoveAssociation(userId,
2995 Team.class.getName(), teamId);
2996 }
2997
2998 _sqlUpdate.update(new Object[] {
2999 new Long(teamId), new Long(userId)
3000 });
3001
3002 for (ModelListener<Team> listener : listeners) {
3003 listener.onAfterRemoveAssociation(teamId,
3004 com.liferay.portal.model.User.class.getName(), userId);
3005 }
3006
3007 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3008 listener.onAfterRemoveAssociation(userId,
3009 Team.class.getName(), teamId);
3010 }
3011 }
3012 }
3013
3014 private SqlUpdate _sqlUpdate;
3015 }
3016
3017 protected class ContainsUserGroup {
3018 protected ContainsUserGroup() {
3019 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3020 _SQL_CONTAINSUSERGROUP,
3021 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3022 RowMapper.COUNT);
3023 }
3024
3025 protected boolean contains(long teamId, long userGroupId) {
3026 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3027 new Long(teamId), new Long(userGroupId)
3028 });
3029
3030 if (results.size() > 0) {
3031 Integer count = results.get(0);
3032
3033 if (count.intValue() > 0) {
3034 return true;
3035 }
3036 }
3037
3038 return false;
3039 }
3040
3041 private MappingSqlQuery<Integer> _mappingSqlQuery;
3042 }
3043
3044 protected class AddUserGroup {
3045 protected AddUserGroup() {
3046 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3047 "INSERT INTO UserGroups_Teams (teamId, userGroupId) VALUES (?, ?)",
3048 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3049 }
3050
3051 protected void add(long teamId, long userGroupId)
3052 throws SystemException {
3053 if (!containsUserGroup.contains(teamId, userGroupId)) {
3054 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3055 userGroupPersistence.getListeners();
3056
3057 for (ModelListener<Team> listener : listeners) {
3058 listener.onBeforeAddAssociation(teamId,
3059 com.liferay.portal.model.UserGroup.class.getName(),
3060 userGroupId);
3061 }
3062
3063 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3064 listener.onBeforeAddAssociation(userGroupId,
3065 Team.class.getName(), teamId);
3066 }
3067
3068 _sqlUpdate.update(new Object[] {
3069 new Long(teamId), new Long(userGroupId)
3070 });
3071
3072 for (ModelListener<Team> listener : listeners) {
3073 listener.onAfterAddAssociation(teamId,
3074 com.liferay.portal.model.UserGroup.class.getName(),
3075 userGroupId);
3076 }
3077
3078 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3079 listener.onAfterAddAssociation(userGroupId,
3080 Team.class.getName(), teamId);
3081 }
3082 }
3083 }
3084
3085 private SqlUpdate _sqlUpdate;
3086 }
3087
3088 protected class ClearUserGroups {
3089 protected ClearUserGroups() {
3090 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3091 "DELETE FROM UserGroups_Teams WHERE teamId = ?",
3092 new int[] { java.sql.Types.BIGINT });
3093 }
3094
3095 protected void clear(long teamId) throws SystemException {
3096 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3097 userGroupPersistence.getListeners();
3098
3099 List<com.liferay.portal.model.UserGroup> userGroups = null;
3100
3101 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3102 userGroups = getUserGroups(teamId);
3103
3104 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3105 for (ModelListener<Team> listener : listeners) {
3106 listener.onBeforeRemoveAssociation(teamId,
3107 com.liferay.portal.model.UserGroup.class.getName(),
3108 userGroup.getPrimaryKey());
3109 }
3110
3111 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3112 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
3113 Team.class.getName(), teamId);
3114 }
3115 }
3116 }
3117
3118 _sqlUpdate.update(new Object[] { new Long(teamId) });
3119
3120 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3121 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3122 for (ModelListener<Team> listener : listeners) {
3123 listener.onAfterRemoveAssociation(teamId,
3124 com.liferay.portal.model.UserGroup.class.getName(),
3125 userGroup.getPrimaryKey());
3126 }
3127
3128 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3129 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
3130 Team.class.getName(), teamId);
3131 }
3132 }
3133 }
3134 }
3135
3136 private SqlUpdate _sqlUpdate;
3137 }
3138
3139 protected class RemoveUserGroup {
3140 protected RemoveUserGroup() {
3141 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3142 "DELETE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?",
3143 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3144 }
3145
3146 protected void remove(long teamId, long userGroupId)
3147 throws SystemException {
3148 if (containsUserGroup.contains(teamId, userGroupId)) {
3149 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3150 userGroupPersistence.getListeners();
3151
3152 for (ModelListener<Team> listener : listeners) {
3153 listener.onBeforeRemoveAssociation(teamId,
3154 com.liferay.portal.model.UserGroup.class.getName(),
3155 userGroupId);
3156 }
3157
3158 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3159 listener.onBeforeRemoveAssociation(userGroupId,
3160 Team.class.getName(), teamId);
3161 }
3162
3163 _sqlUpdate.update(new Object[] {
3164 new Long(teamId), new Long(userGroupId)
3165 });
3166
3167 for (ModelListener<Team> listener : listeners) {
3168 listener.onAfterRemoveAssociation(teamId,
3169 com.liferay.portal.model.UserGroup.class.getName(),
3170 userGroupId);
3171 }
3172
3173 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3174 listener.onAfterRemoveAssociation(userGroupId,
3175 Team.class.getName(), teamId);
3176 }
3177 }
3178 }
3179
3180 private SqlUpdate _sqlUpdate;
3181 }
3182
3183 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
3184 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
3185 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
3186 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
3187 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
3188 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
3189 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
3190 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN UserGroups_Teams ON (UserGroups_Teams.userGroupId = UserGroup.userGroupId) WHERE (UserGroups_Teams.teamId = ?)";
3191 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ?";
3192 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?";
3193 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
3194 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
3195 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
3196 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
3197 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
3198 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId";
3199 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
3200 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
3201 "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
3202 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
3203 ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
3204 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
3205 private static final String _FILTER_ENTITY_ALIAS = "team";
3206 private static final String _FILTER_ENTITY_TABLE = "Team";
3207 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
3208 private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
3209 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
3210 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
3211 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3212 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
3213 private static Team _nullTeam = new TeamImpl() {
3214 @Override
3215 public Object clone() {
3216 return this;
3217 }
3218
3219 @Override
3220 public CacheModel<Team> toCacheModel() {
3221 return _nullTeamCacheModel;
3222 }
3223 };
3224
3225 private static CacheModel<Team> _nullTeamCacheModel = new CacheModel<Team>() {
3226 public Team toEntityModel() {
3227 return _nullTeam;
3228 }
3229 };
3230 }