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 if (team.isCachedModel()) {
309 team = (Team)session.get(TeamImpl.class, team.getPrimaryKeyObj());
310 }
311
312 session.delete(team);
313 }
314 catch (Exception e) {
315 throw processException(e);
316 }
317 finally {
318 closeSession(session);
319 }
320
321 clearCache(team);
322
323 return team;
324 }
325
326 @Override
327 public Team updateImpl(com.liferay.portal.model.Team team)
328 throws SystemException {
329 team = toUnwrappedModel(team);
330
331 boolean isNew = team.isNew();
332
333 TeamModelImpl teamModelImpl = (TeamModelImpl)team;
334
335 Session session = null;
336
337 try {
338 session = openSession();
339
340 if (team.isNew()) {
341 session.save(team);
342
343 team.setNew(false);
344 }
345 else {
346 session.merge(team);
347 }
348 }
349 catch (Exception e) {
350 throw processException(e);
351 }
352 finally {
353 closeSession(session);
354 }
355
356 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
357
358 if (isNew || !TeamModelImpl.COLUMN_BITMASK_ENABLED) {
359 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
360 }
361
362 else {
363 if ((teamModelImpl.getColumnBitmask() &
364 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
365 Object[] args = new Object[] {
366 Long.valueOf(teamModelImpl.getOriginalGroupId())
367 };
368
369 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
370 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
371 args);
372
373 args = new Object[] { Long.valueOf(teamModelImpl.getGroupId()) };
374
375 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
376 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
377 args);
378 }
379 }
380
381 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
382 TeamImpl.class, team.getPrimaryKey(), team);
383
384 if (isNew) {
385 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
386 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
387 team);
388 }
389 else {
390 if ((teamModelImpl.getColumnBitmask() &
391 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
392 Object[] args = new Object[] {
393 Long.valueOf(teamModelImpl.getOriginalGroupId()),
394
395 teamModelImpl.getOriginalName()
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
399
400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
401
402 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
403 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
404 team);
405 }
406 }
407
408 return team;
409 }
410
411 protected Team toUnwrappedModel(Team team) {
412 if (team instanceof TeamImpl) {
413 return team;
414 }
415
416 TeamImpl teamImpl = new TeamImpl();
417
418 teamImpl.setNew(team.isNew());
419 teamImpl.setPrimaryKey(team.getPrimaryKey());
420
421 teamImpl.setTeamId(team.getTeamId());
422 teamImpl.setCompanyId(team.getCompanyId());
423 teamImpl.setUserId(team.getUserId());
424 teamImpl.setUserName(team.getUserName());
425 teamImpl.setCreateDate(team.getCreateDate());
426 teamImpl.setModifiedDate(team.getModifiedDate());
427 teamImpl.setGroupId(team.getGroupId());
428 teamImpl.setName(team.getName());
429 teamImpl.setDescription(team.getDescription());
430
431 return teamImpl;
432 }
433
434
442 @Override
443 public Team findByPrimaryKey(Serializable primaryKey)
444 throws NoSuchModelException, SystemException {
445 return findByPrimaryKey(((Long)primaryKey).longValue());
446 }
447
448
456 public Team findByPrimaryKey(long teamId)
457 throws NoSuchTeamException, SystemException {
458 Team team = fetchByPrimaryKey(teamId);
459
460 if (team == null) {
461 if (_log.isWarnEnabled()) {
462 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + teamId);
463 }
464
465 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
466 teamId);
467 }
468
469 return team;
470 }
471
472
479 @Override
480 public Team fetchByPrimaryKey(Serializable primaryKey)
481 throws SystemException {
482 return fetchByPrimaryKey(((Long)primaryKey).longValue());
483 }
484
485
492 public Team fetchByPrimaryKey(long teamId) throws SystemException {
493 Team team = (Team)EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
494 TeamImpl.class, teamId);
495
496 if (team == _nullTeam) {
497 return null;
498 }
499
500 if (team == null) {
501 Session session = null;
502
503 boolean hasException = false;
504
505 try {
506 session = openSession();
507
508 team = (Team)session.get(TeamImpl.class, Long.valueOf(teamId));
509 }
510 catch (Exception e) {
511 hasException = true;
512
513 throw processException(e);
514 }
515 finally {
516 if (team != null) {
517 cacheResult(team);
518 }
519 else if (!hasException) {
520 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
521 TeamImpl.class, teamId, _nullTeam);
522 }
523
524 closeSession(session);
525 }
526 }
527
528 return team;
529 }
530
531
538 public List<Team> findByGroupId(long groupId) throws SystemException {
539 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
540 }
541
542
555 public List<Team> findByGroupId(long groupId, int start, int end)
556 throws SystemException {
557 return findByGroupId(groupId, start, end, null);
558 }
559
560
574 public List<Team> findByGroupId(long groupId, int start, int end,
575 OrderByComparator orderByComparator) throws SystemException {
576 FinderPath finderPath = null;
577 Object[] finderArgs = null;
578
579 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
580 (orderByComparator == null)) {
581 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
582 finderArgs = new Object[] { groupId };
583 }
584 else {
585 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
586 finderArgs = new Object[] { groupId, start, end, orderByComparator };
587 }
588
589 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
590 finderArgs, this);
591
592 if ((list != null) && !list.isEmpty()) {
593 for (Team team : list) {
594 if ((groupId != team.getGroupId())) {
595 list = null;
596
597 break;
598 }
599 }
600 }
601
602 if (list == null) {
603 StringBundler query = null;
604
605 if (orderByComparator != null) {
606 query = new StringBundler(3 +
607 (orderByComparator.getOrderByFields().length * 3));
608 }
609 else {
610 query = new StringBundler(3);
611 }
612
613 query.append(_SQL_SELECT_TEAM_WHERE);
614
615 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
616
617 if (orderByComparator != null) {
618 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
619 orderByComparator);
620 }
621
622 else {
623 query.append(TeamModelImpl.ORDER_BY_JPQL);
624 }
625
626 String sql = query.toString();
627
628 Session session = null;
629
630 try {
631 session = openSession();
632
633 Query q = session.createQuery(sql);
634
635 QueryPos qPos = QueryPos.getInstance(q);
636
637 qPos.add(groupId);
638
639 list = (List<Team>)QueryUtil.list(q, getDialect(), start, end);
640 }
641 catch (Exception e) {
642 throw processException(e);
643 }
644 finally {
645 if (list == null) {
646 FinderCacheUtil.removeResult(finderPath, finderArgs);
647 }
648 else {
649 cacheResult(list);
650
651 FinderCacheUtil.putResult(finderPath, finderArgs, list);
652 }
653
654 closeSession(session);
655 }
656 }
657
658 return list;
659 }
660
661
670 public Team findByGroupId_First(long groupId,
671 OrderByComparator orderByComparator)
672 throws NoSuchTeamException, SystemException {
673 Team team = fetchByGroupId_First(groupId, orderByComparator);
674
675 if (team != null) {
676 return team;
677 }
678
679 StringBundler msg = new StringBundler(4);
680
681 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
682
683 msg.append("groupId=");
684 msg.append(groupId);
685
686 msg.append(StringPool.CLOSE_CURLY_BRACE);
687
688 throw new NoSuchTeamException(msg.toString());
689 }
690
691
699 public Team fetchByGroupId_First(long groupId,
700 OrderByComparator orderByComparator) throws SystemException {
701 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
702
703 if (!list.isEmpty()) {
704 return list.get(0);
705 }
706
707 return null;
708 }
709
710
719 public Team findByGroupId_Last(long groupId,
720 OrderByComparator orderByComparator)
721 throws NoSuchTeamException, SystemException {
722 Team team = fetchByGroupId_Last(groupId, orderByComparator);
723
724 if (team != null) {
725 return team;
726 }
727
728 StringBundler msg = new StringBundler(4);
729
730 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
731
732 msg.append("groupId=");
733 msg.append(groupId);
734
735 msg.append(StringPool.CLOSE_CURLY_BRACE);
736
737 throw new NoSuchTeamException(msg.toString());
738 }
739
740
748 public Team fetchByGroupId_Last(long groupId,
749 OrderByComparator orderByComparator) throws SystemException {
750 int count = countByGroupId(groupId);
751
752 List<Team> list = findByGroupId(groupId, count - 1, count,
753 orderByComparator);
754
755 if (!list.isEmpty()) {
756 return list.get(0);
757 }
758
759 return null;
760 }
761
762
772 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
773 OrderByComparator orderByComparator)
774 throws NoSuchTeamException, SystemException {
775 Team team = findByPrimaryKey(teamId);
776
777 Session session = null;
778
779 try {
780 session = openSession();
781
782 Team[] array = new TeamImpl[3];
783
784 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
785 orderByComparator, true);
786
787 array[1] = team;
788
789 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
790 orderByComparator, false);
791
792 return array;
793 }
794 catch (Exception e) {
795 throw processException(e);
796 }
797 finally {
798 closeSession(session);
799 }
800 }
801
802 protected Team getByGroupId_PrevAndNext(Session session, Team team,
803 long groupId, OrderByComparator orderByComparator, boolean previous) {
804 StringBundler query = null;
805
806 if (orderByComparator != null) {
807 query = new StringBundler(6 +
808 (orderByComparator.getOrderByFields().length * 6));
809 }
810 else {
811 query = new StringBundler(3);
812 }
813
814 query.append(_SQL_SELECT_TEAM_WHERE);
815
816 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
817
818 if (orderByComparator != null) {
819 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
820
821 if (orderByConditionFields.length > 0) {
822 query.append(WHERE_AND);
823 }
824
825 for (int i = 0; i < orderByConditionFields.length; i++) {
826 query.append(_ORDER_BY_ENTITY_ALIAS);
827 query.append(orderByConditionFields[i]);
828
829 if ((i + 1) < orderByConditionFields.length) {
830 if (orderByComparator.isAscending() ^ previous) {
831 query.append(WHERE_GREATER_THAN_HAS_NEXT);
832 }
833 else {
834 query.append(WHERE_LESSER_THAN_HAS_NEXT);
835 }
836 }
837 else {
838 if (orderByComparator.isAscending() ^ previous) {
839 query.append(WHERE_GREATER_THAN);
840 }
841 else {
842 query.append(WHERE_LESSER_THAN);
843 }
844 }
845 }
846
847 query.append(ORDER_BY_CLAUSE);
848
849 String[] orderByFields = orderByComparator.getOrderByFields();
850
851 for (int i = 0; i < orderByFields.length; i++) {
852 query.append(_ORDER_BY_ENTITY_ALIAS);
853 query.append(orderByFields[i]);
854
855 if ((i + 1) < orderByFields.length) {
856 if (orderByComparator.isAscending() ^ previous) {
857 query.append(ORDER_BY_ASC_HAS_NEXT);
858 }
859 else {
860 query.append(ORDER_BY_DESC_HAS_NEXT);
861 }
862 }
863 else {
864 if (orderByComparator.isAscending() ^ previous) {
865 query.append(ORDER_BY_ASC);
866 }
867 else {
868 query.append(ORDER_BY_DESC);
869 }
870 }
871 }
872 }
873
874 else {
875 query.append(TeamModelImpl.ORDER_BY_JPQL);
876 }
877
878 String sql = query.toString();
879
880 Query q = session.createQuery(sql);
881
882 q.setFirstResult(0);
883 q.setMaxResults(2);
884
885 QueryPos qPos = QueryPos.getInstance(q);
886
887 qPos.add(groupId);
888
889 if (orderByComparator != null) {
890 Object[] values = orderByComparator.getOrderByConditionValues(team);
891
892 for (Object value : values) {
893 qPos.add(value);
894 }
895 }
896
897 List<Team> list = q.list();
898
899 if (list.size() == 2) {
900 return list.get(1);
901 }
902 else {
903 return null;
904 }
905 }
906
907
914 public List<Team> filterFindByGroupId(long groupId)
915 throws SystemException {
916 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
917 QueryUtil.ALL_POS, null);
918 }
919
920
933 public List<Team> filterFindByGroupId(long groupId, int start, int end)
934 throws SystemException {
935 return filterFindByGroupId(groupId, start, end, null);
936 }
937
938
952 public List<Team> filterFindByGroupId(long groupId, int start, int end,
953 OrderByComparator orderByComparator) throws SystemException {
954 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
955 return findByGroupId(groupId, start, end, orderByComparator);
956 }
957
958 StringBundler query = null;
959
960 if (orderByComparator != null) {
961 query = new StringBundler(3 +
962 (orderByComparator.getOrderByFields().length * 3));
963 }
964 else {
965 query = new StringBundler(3);
966 }
967
968 if (getDB().isSupportsInlineDistinct()) {
969 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
970 }
971 else {
972 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
973 }
974
975 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
976
977 if (!getDB().isSupportsInlineDistinct()) {
978 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
979 }
980
981 if (orderByComparator != null) {
982 if (getDB().isSupportsInlineDistinct()) {
983 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
984 orderByComparator);
985 }
986 else {
987 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
988 orderByComparator);
989 }
990 }
991
992 else {
993 if (getDB().isSupportsInlineDistinct()) {
994 query.append(TeamModelImpl.ORDER_BY_JPQL);
995 }
996 else {
997 query.append(TeamModelImpl.ORDER_BY_SQL);
998 }
999 }
1000
1001 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1002 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1003 groupId);
1004
1005 Session session = null;
1006
1007 try {
1008 session = openSession();
1009
1010 SQLQuery q = session.createSQLQuery(sql);
1011
1012 if (getDB().isSupportsInlineDistinct()) {
1013 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1014 }
1015 else {
1016 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1017 }
1018
1019 QueryPos qPos = QueryPos.getInstance(q);
1020
1021 qPos.add(groupId);
1022
1023 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
1024 }
1025 catch (Exception e) {
1026 throw processException(e);
1027 }
1028 finally {
1029 closeSession(session);
1030 }
1031 }
1032
1033
1043 public Team[] filterFindByGroupId_PrevAndNext(long teamId, long groupId,
1044 OrderByComparator orderByComparator)
1045 throws NoSuchTeamException, SystemException {
1046 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1047 return findByGroupId_PrevAndNext(teamId, groupId, orderByComparator);
1048 }
1049
1050 Team team = findByPrimaryKey(teamId);
1051
1052 Session session = null;
1053
1054 try {
1055 session = openSession();
1056
1057 Team[] array = new TeamImpl[3];
1058
1059 array[0] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1060 orderByComparator, true);
1061
1062 array[1] = team;
1063
1064 array[2] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1065 orderByComparator, false);
1066
1067 return array;
1068 }
1069 catch (Exception e) {
1070 throw processException(e);
1071 }
1072 finally {
1073 closeSession(session);
1074 }
1075 }
1076
1077 protected Team filterGetByGroupId_PrevAndNext(Session session, Team team,
1078 long groupId, OrderByComparator orderByComparator, boolean previous) {
1079 StringBundler query = null;
1080
1081 if (orderByComparator != null) {
1082 query = new StringBundler(6 +
1083 (orderByComparator.getOrderByFields().length * 6));
1084 }
1085 else {
1086 query = new StringBundler(3);
1087 }
1088
1089 if (getDB().isSupportsInlineDistinct()) {
1090 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
1091 }
1092 else {
1093 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
1094 }
1095
1096 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1097
1098 if (!getDB().isSupportsInlineDistinct()) {
1099 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
1100 }
1101
1102 if (orderByComparator != null) {
1103 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1104
1105 if (orderByConditionFields.length > 0) {
1106 query.append(WHERE_AND);
1107 }
1108
1109 for (int i = 0; i < orderByConditionFields.length; i++) {
1110 if (getDB().isSupportsInlineDistinct()) {
1111 query.append(_ORDER_BY_ENTITY_ALIAS);
1112 }
1113 else {
1114 query.append(_ORDER_BY_ENTITY_TABLE);
1115 }
1116
1117 query.append(orderByConditionFields[i]);
1118
1119 if ((i + 1) < orderByConditionFields.length) {
1120 if (orderByComparator.isAscending() ^ previous) {
1121 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1122 }
1123 else {
1124 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1125 }
1126 }
1127 else {
1128 if (orderByComparator.isAscending() ^ previous) {
1129 query.append(WHERE_GREATER_THAN);
1130 }
1131 else {
1132 query.append(WHERE_LESSER_THAN);
1133 }
1134 }
1135 }
1136
1137 query.append(ORDER_BY_CLAUSE);
1138
1139 String[] orderByFields = orderByComparator.getOrderByFields();
1140
1141 for (int i = 0; i < orderByFields.length; i++) {
1142 if (getDB().isSupportsInlineDistinct()) {
1143 query.append(_ORDER_BY_ENTITY_ALIAS);
1144 }
1145 else {
1146 query.append(_ORDER_BY_ENTITY_TABLE);
1147 }
1148
1149 query.append(orderByFields[i]);
1150
1151 if ((i + 1) < orderByFields.length) {
1152 if (orderByComparator.isAscending() ^ previous) {
1153 query.append(ORDER_BY_ASC_HAS_NEXT);
1154 }
1155 else {
1156 query.append(ORDER_BY_DESC_HAS_NEXT);
1157 }
1158 }
1159 else {
1160 if (orderByComparator.isAscending() ^ previous) {
1161 query.append(ORDER_BY_ASC);
1162 }
1163 else {
1164 query.append(ORDER_BY_DESC);
1165 }
1166 }
1167 }
1168 }
1169
1170 else {
1171 if (getDB().isSupportsInlineDistinct()) {
1172 query.append(TeamModelImpl.ORDER_BY_JPQL);
1173 }
1174 else {
1175 query.append(TeamModelImpl.ORDER_BY_SQL);
1176 }
1177 }
1178
1179 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1180 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1181 groupId);
1182
1183 SQLQuery q = session.createSQLQuery(sql);
1184
1185 q.setFirstResult(0);
1186 q.setMaxResults(2);
1187
1188 if (getDB().isSupportsInlineDistinct()) {
1189 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1190 }
1191 else {
1192 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1193 }
1194
1195 QueryPos qPos = QueryPos.getInstance(q);
1196
1197 qPos.add(groupId);
1198
1199 if (orderByComparator != null) {
1200 Object[] values = orderByComparator.getOrderByConditionValues(team);
1201
1202 for (Object value : values) {
1203 qPos.add(value);
1204 }
1205 }
1206
1207 List<Team> list = q.list();
1208
1209 if (list.size() == 2) {
1210 return list.get(1);
1211 }
1212 else {
1213 return null;
1214 }
1215 }
1216
1217
1226 public Team findByG_N(long groupId, String name)
1227 throws NoSuchTeamException, SystemException {
1228 Team team = fetchByG_N(groupId, name);
1229
1230 if (team == null) {
1231 StringBundler msg = new StringBundler(6);
1232
1233 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1234
1235 msg.append("groupId=");
1236 msg.append(groupId);
1237
1238 msg.append(", name=");
1239 msg.append(name);
1240
1241 msg.append(StringPool.CLOSE_CURLY_BRACE);
1242
1243 if (_log.isWarnEnabled()) {
1244 _log.warn(msg.toString());
1245 }
1246
1247 throw new NoSuchTeamException(msg.toString());
1248 }
1249
1250 return team;
1251 }
1252
1253
1261 public Team fetchByG_N(long groupId, String name) throws SystemException {
1262 return fetchByG_N(groupId, name, true);
1263 }
1264
1265
1274 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
1275 throws SystemException {
1276 Object[] finderArgs = new Object[] { groupId, name };
1277
1278 Object result = null;
1279
1280 if (retrieveFromCache) {
1281 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1282 finderArgs, this);
1283 }
1284
1285 if (result instanceof Team) {
1286 Team team = (Team)result;
1287
1288 if ((groupId != team.getGroupId()) ||
1289 !Validator.equals(name, team.getName())) {
1290 result = null;
1291 }
1292 }
1293
1294 if (result == null) {
1295 StringBundler query = new StringBundler(4);
1296
1297 query.append(_SQL_SELECT_TEAM_WHERE);
1298
1299 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1300
1301 if (name == null) {
1302 query.append(_FINDER_COLUMN_G_N_NAME_1);
1303 }
1304 else {
1305 if (name.equals(StringPool.BLANK)) {
1306 query.append(_FINDER_COLUMN_G_N_NAME_3);
1307 }
1308 else {
1309 query.append(_FINDER_COLUMN_G_N_NAME_2);
1310 }
1311 }
1312
1313 query.append(TeamModelImpl.ORDER_BY_JPQL);
1314
1315 String sql = query.toString();
1316
1317 Session session = null;
1318
1319 try {
1320 session = openSession();
1321
1322 Query q = session.createQuery(sql);
1323
1324 QueryPos qPos = QueryPos.getInstance(q);
1325
1326 qPos.add(groupId);
1327
1328 if (name != null) {
1329 qPos.add(name);
1330 }
1331
1332 List<Team> list = q.list();
1333
1334 result = list;
1335
1336 Team team = null;
1337
1338 if (list.isEmpty()) {
1339 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1340 finderArgs, list);
1341 }
1342 else {
1343 team = list.get(0);
1344
1345 cacheResult(team);
1346
1347 if ((team.getGroupId() != groupId) ||
1348 (team.getName() == null) ||
1349 !team.getName().equals(name)) {
1350 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1351 finderArgs, team);
1352 }
1353 }
1354
1355 return team;
1356 }
1357 catch (Exception e) {
1358 throw processException(e);
1359 }
1360 finally {
1361 if (result == null) {
1362 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1363 finderArgs);
1364 }
1365
1366 closeSession(session);
1367 }
1368 }
1369 else {
1370 if (result instanceof List<?>) {
1371 return null;
1372 }
1373 else {
1374 return (Team)result;
1375 }
1376 }
1377 }
1378
1379
1385 public List<Team> findAll() throws SystemException {
1386 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1387 }
1388
1389
1401 public List<Team> findAll(int start, int end) throws SystemException {
1402 return findAll(start, end, null);
1403 }
1404
1405
1418 public List<Team> findAll(int start, int end,
1419 OrderByComparator orderByComparator) throws SystemException {
1420 FinderPath finderPath = null;
1421 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1422
1423 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1424 (orderByComparator == null)) {
1425 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1426 finderArgs = FINDER_ARGS_EMPTY;
1427 }
1428 else {
1429 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1430 finderArgs = new Object[] { start, end, orderByComparator };
1431 }
1432
1433 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
1434 finderArgs, this);
1435
1436 if (list == null) {
1437 StringBundler query = null;
1438 String sql = null;
1439
1440 if (orderByComparator != null) {
1441 query = new StringBundler(2 +
1442 (orderByComparator.getOrderByFields().length * 3));
1443
1444 query.append(_SQL_SELECT_TEAM);
1445
1446 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1447 orderByComparator);
1448
1449 sql = query.toString();
1450 }
1451 else {
1452 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1453 }
1454
1455 Session session = null;
1456
1457 try {
1458 session = openSession();
1459
1460 Query q = session.createQuery(sql);
1461
1462 if (orderByComparator == null) {
1463 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1464 end, false);
1465
1466 Collections.sort(list);
1467 }
1468 else {
1469 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1470 end);
1471 }
1472 }
1473 catch (Exception e) {
1474 throw processException(e);
1475 }
1476 finally {
1477 if (list == null) {
1478 FinderCacheUtil.removeResult(finderPath, finderArgs);
1479 }
1480 else {
1481 cacheResult(list);
1482
1483 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1484 }
1485
1486 closeSession(session);
1487 }
1488 }
1489
1490 return list;
1491 }
1492
1493
1499 public void removeByGroupId(long groupId) throws SystemException {
1500 for (Team team : findByGroupId(groupId)) {
1501 remove(team);
1502 }
1503 }
1504
1505
1513 public Team removeByG_N(long groupId, String name)
1514 throws NoSuchTeamException, SystemException {
1515 Team team = findByG_N(groupId, name);
1516
1517 return remove(team);
1518 }
1519
1520
1525 public void removeAll() throws SystemException {
1526 for (Team team : findAll()) {
1527 remove(team);
1528 }
1529 }
1530
1531
1538 public int countByGroupId(long groupId) throws SystemException {
1539 Object[] finderArgs = new Object[] { groupId };
1540
1541 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1542 finderArgs, this);
1543
1544 if (count == null) {
1545 StringBundler query = new StringBundler(2);
1546
1547 query.append(_SQL_COUNT_TEAM_WHERE);
1548
1549 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1550
1551 String sql = query.toString();
1552
1553 Session session = null;
1554
1555 try {
1556 session = openSession();
1557
1558 Query q = session.createQuery(sql);
1559
1560 QueryPos qPos = QueryPos.getInstance(q);
1561
1562 qPos.add(groupId);
1563
1564 count = (Long)q.uniqueResult();
1565 }
1566 catch (Exception e) {
1567 throw processException(e);
1568 }
1569 finally {
1570 if (count == null) {
1571 count = Long.valueOf(0);
1572 }
1573
1574 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1575 finderArgs, count);
1576
1577 closeSession(session);
1578 }
1579 }
1580
1581 return count.intValue();
1582 }
1583
1584
1591 public int filterCountByGroupId(long groupId) throws SystemException {
1592 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1593 return countByGroupId(groupId);
1594 }
1595
1596 StringBundler query = new StringBundler(2);
1597
1598 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1599
1600 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1601
1602 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1603 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1604 groupId);
1605
1606 Session session = null;
1607
1608 try {
1609 session = openSession();
1610
1611 SQLQuery q = session.createSQLQuery(sql);
1612
1613 q.addScalar(COUNT_COLUMN_NAME,
1614 com.liferay.portal.kernel.dao.orm.Type.LONG);
1615
1616 QueryPos qPos = QueryPos.getInstance(q);
1617
1618 qPos.add(groupId);
1619
1620 Long count = (Long)q.uniqueResult();
1621
1622 return count.intValue();
1623 }
1624 catch (Exception e) {
1625 throw processException(e);
1626 }
1627 finally {
1628 closeSession(session);
1629 }
1630 }
1631
1632
1640 public int countByG_N(long groupId, String name) throws SystemException {
1641 Object[] finderArgs = new Object[] { groupId, name };
1642
1643 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1644 finderArgs, this);
1645
1646 if (count == null) {
1647 StringBundler query = new StringBundler(3);
1648
1649 query.append(_SQL_COUNT_TEAM_WHERE);
1650
1651 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1652
1653 if (name == null) {
1654 query.append(_FINDER_COLUMN_G_N_NAME_1);
1655 }
1656 else {
1657 if (name.equals(StringPool.BLANK)) {
1658 query.append(_FINDER_COLUMN_G_N_NAME_3);
1659 }
1660 else {
1661 query.append(_FINDER_COLUMN_G_N_NAME_2);
1662 }
1663 }
1664
1665 String sql = query.toString();
1666
1667 Session session = null;
1668
1669 try {
1670 session = openSession();
1671
1672 Query q = session.createQuery(sql);
1673
1674 QueryPos qPos = QueryPos.getInstance(q);
1675
1676 qPos.add(groupId);
1677
1678 if (name != null) {
1679 qPos.add(name);
1680 }
1681
1682 count = (Long)q.uniqueResult();
1683 }
1684 catch (Exception e) {
1685 throw processException(e);
1686 }
1687 finally {
1688 if (count == null) {
1689 count = Long.valueOf(0);
1690 }
1691
1692 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1693 count);
1694
1695 closeSession(session);
1696 }
1697 }
1698
1699 return count.intValue();
1700 }
1701
1702
1708 public int countAll() throws SystemException {
1709 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1710 FINDER_ARGS_EMPTY, this);
1711
1712 if (count == null) {
1713 Session session = null;
1714
1715 try {
1716 session = openSession();
1717
1718 Query q = session.createQuery(_SQL_COUNT_TEAM);
1719
1720 count = (Long)q.uniqueResult();
1721 }
1722 catch (Exception e) {
1723 throw processException(e);
1724 }
1725 finally {
1726 if (count == null) {
1727 count = Long.valueOf(0);
1728 }
1729
1730 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1731 FINDER_ARGS_EMPTY, count);
1732
1733 closeSession(session);
1734 }
1735 }
1736
1737 return count.intValue();
1738 }
1739
1740
1747 public List<com.liferay.portal.model.User> getUsers(long pk)
1748 throws SystemException {
1749 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1750 }
1751
1752
1765 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1766 int end) throws SystemException {
1767 return getUsers(pk, start, end, null);
1768 }
1769
1770 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1771 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1772 com.liferay.portal.model.impl.UserImpl.class,
1773 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1774 new String[] {
1775 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1776 "com.liferay.portal.kernel.util.OrderByComparator"
1777 });
1778
1779 static {
1780 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
1781 }
1782
1783
1797 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1798 int end, OrderByComparator orderByComparator) throws SystemException {
1799 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1800
1801 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1802 finderArgs, this);
1803
1804 if (list == null) {
1805 Session session = null;
1806
1807 try {
1808 session = openSession();
1809
1810 String sql = null;
1811
1812 if (orderByComparator != null) {
1813 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1814 .concat(orderByComparator.getOrderBy());
1815 }
1816 else {
1817 sql = _SQL_GETUSERS;
1818 }
1819
1820 SQLQuery q = session.createSQLQuery(sql);
1821
1822 q.addEntity("User_",
1823 com.liferay.portal.model.impl.UserImpl.class);
1824
1825 QueryPos qPos = QueryPos.getInstance(q);
1826
1827 qPos.add(pk);
1828
1829 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1830 getDialect(), start, end);
1831 }
1832 catch (Exception e) {
1833 throw processException(e);
1834 }
1835 finally {
1836 if (list == null) {
1837 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
1838 finderArgs);
1839 }
1840 else {
1841 userPersistence.cacheResult(list);
1842
1843 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
1844 finderArgs, list);
1845 }
1846
1847 closeSession(session);
1848 }
1849 }
1850
1851 return list;
1852 }
1853
1854 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1855 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
1856 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1857 new String[] { Long.class.getName() });
1858
1859 static {
1860 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
1861 }
1862
1863
1870 public int getUsersSize(long pk) throws SystemException {
1871 Object[] finderArgs = new Object[] { pk };
1872
1873 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1874 finderArgs, this);
1875
1876 if (count == null) {
1877 Session session = null;
1878
1879 try {
1880 session = openSession();
1881
1882 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1883
1884 q.addScalar(COUNT_COLUMN_NAME,
1885 com.liferay.portal.kernel.dao.orm.Type.LONG);
1886
1887 QueryPos qPos = QueryPos.getInstance(q);
1888
1889 qPos.add(pk);
1890
1891 count = (Long)q.uniqueResult();
1892 }
1893 catch (Exception e) {
1894 throw processException(e);
1895 }
1896 finally {
1897 if (count == null) {
1898 count = Long.valueOf(0);
1899 }
1900
1901 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1902 finderArgs, count);
1903
1904 closeSession(session);
1905 }
1906 }
1907
1908 return count.intValue();
1909 }
1910
1911 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1912 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
1913 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1914 new String[] { Long.class.getName(), Long.class.getName() });
1915
1916
1924 public boolean containsUser(long pk, long userPK) throws SystemException {
1925 Object[] finderArgs = new Object[] { pk, userPK };
1926
1927 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1928 finderArgs, this);
1929
1930 if (value == null) {
1931 try {
1932 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1933 }
1934 catch (Exception e) {
1935 throw processException(e);
1936 }
1937 finally {
1938 if (value == null) {
1939 value = Boolean.FALSE;
1940 }
1941
1942 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1943 finderArgs, value);
1944 }
1945 }
1946
1947 return value.booleanValue();
1948 }
1949
1950
1957 public boolean containsUsers(long pk) throws SystemException {
1958 if (getUsersSize(pk) > 0) {
1959 return true;
1960 }
1961 else {
1962 return false;
1963 }
1964 }
1965
1966
1973 public void addUser(long pk, long userPK) throws SystemException {
1974 try {
1975 addUser.add(pk, userPK);
1976 }
1977 catch (Exception e) {
1978 throw processException(e);
1979 }
1980 finally {
1981 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1982 }
1983 }
1984
1985
1992 public void addUser(long pk, com.liferay.portal.model.User user)
1993 throws SystemException {
1994 try {
1995 addUser.add(pk, user.getPrimaryKey());
1996 }
1997 catch (Exception e) {
1998 throw processException(e);
1999 }
2000 finally {
2001 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2002 }
2003 }
2004
2005
2012 public void addUsers(long pk, long[] userPKs) throws SystemException {
2013 try {
2014 for (long userPK : userPKs) {
2015 addUser.add(pk, userPK);
2016 }
2017 }
2018 catch (Exception e) {
2019 throw processException(e);
2020 }
2021 finally {
2022 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2023 }
2024 }
2025
2026
2033 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
2034 throws SystemException {
2035 try {
2036 for (com.liferay.portal.model.User user : users) {
2037 addUser.add(pk, user.getPrimaryKey());
2038 }
2039 }
2040 catch (Exception e) {
2041 throw processException(e);
2042 }
2043 finally {
2044 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2045 }
2046 }
2047
2048
2054 public void clearUsers(long pk) throws SystemException {
2055 try {
2056 clearUsers.clear(pk);
2057 }
2058 catch (Exception e) {
2059 throw processException(e);
2060 }
2061 finally {
2062 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2063 }
2064 }
2065
2066
2073 public void removeUser(long pk, long userPK) throws SystemException {
2074 try {
2075 removeUser.remove(pk, userPK);
2076 }
2077 catch (Exception e) {
2078 throw processException(e);
2079 }
2080 finally {
2081 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2082 }
2083 }
2084
2085
2092 public void removeUser(long pk, com.liferay.portal.model.User user)
2093 throws SystemException {
2094 try {
2095 removeUser.remove(pk, user.getPrimaryKey());
2096 }
2097 catch (Exception e) {
2098 throw processException(e);
2099 }
2100 finally {
2101 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2102 }
2103 }
2104
2105
2112 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2113 try {
2114 for (long userPK : userPKs) {
2115 removeUser.remove(pk, userPK);
2116 }
2117 }
2118 catch (Exception e) {
2119 throw processException(e);
2120 }
2121 finally {
2122 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2123 }
2124 }
2125
2126
2133 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2134 throws SystemException {
2135 try {
2136 for (com.liferay.portal.model.User user : users) {
2137 removeUser.remove(pk, user.getPrimaryKey());
2138 }
2139 }
2140 catch (Exception e) {
2141 throw processException(e);
2142 }
2143 finally {
2144 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2145 }
2146 }
2147
2148
2155 public void setUsers(long pk, long[] userPKs) throws SystemException {
2156 try {
2157 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2158
2159 List<com.liferay.portal.model.User> users = getUsers(pk);
2160
2161 for (com.liferay.portal.model.User user : users) {
2162 if (!userPKSet.remove(user.getPrimaryKey())) {
2163 removeUser.remove(pk, user.getPrimaryKey());
2164 }
2165 }
2166
2167 for (Long userPK : userPKSet) {
2168 addUser.add(pk, userPK);
2169 }
2170 }
2171 catch (Exception e) {
2172 throw processException(e);
2173 }
2174 finally {
2175 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2176 }
2177 }
2178
2179
2186 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2187 throws SystemException {
2188 try {
2189 long[] userPKs = new long[users.size()];
2190
2191 for (int i = 0; i < users.size(); i++) {
2192 com.liferay.portal.model.User user = users.get(i);
2193
2194 userPKs[i] = user.getPrimaryKey();
2195 }
2196
2197 setUsers(pk, userPKs);
2198 }
2199 catch (Exception e) {
2200 throw processException(e);
2201 }
2202 finally {
2203 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2204 }
2205 }
2206
2207
2214 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
2215 throws SystemException {
2216 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2217 }
2218
2219
2232 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2233 int start, int end) throws SystemException {
2234 return getUserGroups(pk, start, end, null);
2235 }
2236
2237 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2238 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
2239 com.liferay.portal.model.impl.UserGroupImpl.class,
2240 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getUserGroups",
2241 new String[] {
2242 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2243 "com.liferay.portal.kernel.util.OrderByComparator"
2244 });
2245
2246 static {
2247 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
2248 }
2249
2250
2264 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2265 int start, int end, OrderByComparator orderByComparator)
2266 throws SystemException {
2267 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2268
2269 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
2270 finderArgs, this);
2271
2272 if (list == null) {
2273 Session session = null;
2274
2275 try {
2276 session = openSession();
2277
2278 String sql = null;
2279
2280 if (orderByComparator != null) {
2281 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
2282 .concat(orderByComparator.getOrderBy());
2283 }
2284 else {
2285 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
2286 }
2287
2288 SQLQuery q = session.createSQLQuery(sql);
2289
2290 q.addEntity("UserGroup",
2291 com.liferay.portal.model.impl.UserGroupImpl.class);
2292
2293 QueryPos qPos = QueryPos.getInstance(q);
2294
2295 qPos.add(pk);
2296
2297 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
2298 getDialect(), start, end);
2299 }
2300 catch (Exception e) {
2301 throw processException(e);
2302 }
2303 finally {
2304 if (list == null) {
2305 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
2306 finderArgs);
2307 }
2308 else {
2309 userGroupPersistence.cacheResult(list);
2310
2311 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
2312 finderArgs, list);
2313 }
2314
2315 closeSession(session);
2316 }
2317 }
2318
2319 return list;
2320 }
2321
2322 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2323 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Long.class,
2324 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2325 "getUserGroupsSize", new String[] { Long.class.getName() });
2326
2327 static {
2328 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
2329 }
2330
2331
2338 public int getUserGroupsSize(long pk) throws SystemException {
2339 Object[] finderArgs = new Object[] { pk };
2340
2341 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2342 finderArgs, this);
2343
2344 if (count == null) {
2345 Session session = null;
2346
2347 try {
2348 session = openSession();
2349
2350 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
2351
2352 q.addScalar(COUNT_COLUMN_NAME,
2353 com.liferay.portal.kernel.dao.orm.Type.LONG);
2354
2355 QueryPos qPos = QueryPos.getInstance(q);
2356
2357 qPos.add(pk);
2358
2359 count = (Long)q.uniqueResult();
2360 }
2361 catch (Exception e) {
2362 throw processException(e);
2363 }
2364 finally {
2365 if (count == null) {
2366 count = Long.valueOf(0);
2367 }
2368
2369 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2370 finderArgs, count);
2371
2372 closeSession(session);
2373 }
2374 }
2375
2376 return count.intValue();
2377 }
2378
2379 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2380 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Boolean.class,
2381 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2382 "containsUserGroup",
2383 new String[] { Long.class.getName(), Long.class.getName() });
2384
2385
2393 public boolean containsUserGroup(long pk, long userGroupPK)
2394 throws SystemException {
2395 Object[] finderArgs = new Object[] { pk, userGroupPK };
2396
2397 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
2398 finderArgs, this);
2399
2400 if (value == null) {
2401 try {
2402 value = Boolean.valueOf(containsUserGroup.contains(pk,
2403 userGroupPK));
2404 }
2405 catch (Exception e) {
2406 throw processException(e);
2407 }
2408 finally {
2409 if (value == null) {
2410 value = Boolean.FALSE;
2411 }
2412
2413 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
2414 finderArgs, value);
2415 }
2416 }
2417
2418 return value.booleanValue();
2419 }
2420
2421
2428 public boolean containsUserGroups(long pk) throws SystemException {
2429 if (getUserGroupsSize(pk) > 0) {
2430 return true;
2431 }
2432 else {
2433 return false;
2434 }
2435 }
2436
2437
2444 public void addUserGroup(long pk, long userGroupPK)
2445 throws SystemException {
2446 try {
2447 addUserGroup.add(pk, userGroupPK);
2448 }
2449 catch (Exception e) {
2450 throw processException(e);
2451 }
2452 finally {
2453 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2454 }
2455 }
2456
2457
2464 public void addUserGroup(long pk,
2465 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2466 try {
2467 addUserGroup.add(pk, userGroup.getPrimaryKey());
2468 }
2469 catch (Exception e) {
2470 throw processException(e);
2471 }
2472 finally {
2473 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2474 }
2475 }
2476
2477
2484 public void addUserGroups(long pk, long[] userGroupPKs)
2485 throws SystemException {
2486 try {
2487 for (long userGroupPK : userGroupPKs) {
2488 addUserGroup.add(pk, userGroupPK);
2489 }
2490 }
2491 catch (Exception e) {
2492 throw processException(e);
2493 }
2494 finally {
2495 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2496 }
2497 }
2498
2499
2506 public void addUserGroups(long pk,
2507 List<com.liferay.portal.model.UserGroup> userGroups)
2508 throws SystemException {
2509 try {
2510 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2511 addUserGroup.add(pk, userGroup.getPrimaryKey());
2512 }
2513 }
2514 catch (Exception e) {
2515 throw processException(e);
2516 }
2517 finally {
2518 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2519 }
2520 }
2521
2522
2528 public void clearUserGroups(long pk) throws SystemException {
2529 try {
2530 clearUserGroups.clear(pk);
2531 }
2532 catch (Exception e) {
2533 throw processException(e);
2534 }
2535 finally {
2536 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2537 }
2538 }
2539
2540
2547 public void removeUserGroup(long pk, long userGroupPK)
2548 throws SystemException {
2549 try {
2550 removeUserGroup.remove(pk, userGroupPK);
2551 }
2552 catch (Exception e) {
2553 throw processException(e);
2554 }
2555 finally {
2556 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2557 }
2558 }
2559
2560
2567 public void removeUserGroup(long pk,
2568 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2569 try {
2570 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2571 }
2572 catch (Exception e) {
2573 throw processException(e);
2574 }
2575 finally {
2576 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2577 }
2578 }
2579
2580
2587 public void removeUserGroups(long pk, long[] userGroupPKs)
2588 throws SystemException {
2589 try {
2590 for (long userGroupPK : userGroupPKs) {
2591 removeUserGroup.remove(pk, userGroupPK);
2592 }
2593 }
2594 catch (Exception e) {
2595 throw processException(e);
2596 }
2597 finally {
2598 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2599 }
2600 }
2601
2602
2609 public void removeUserGroups(long pk,
2610 List<com.liferay.portal.model.UserGroup> userGroups)
2611 throws SystemException {
2612 try {
2613 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2614 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2615 }
2616 }
2617 catch (Exception e) {
2618 throw processException(e);
2619 }
2620 finally {
2621 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2622 }
2623 }
2624
2625
2632 public void setUserGroups(long pk, long[] userGroupPKs)
2633 throws SystemException {
2634 try {
2635 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
2636
2637 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
2638
2639 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2640 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
2641 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2642 }
2643 }
2644
2645 for (Long userGroupPK : userGroupPKSet) {
2646 addUserGroup.add(pk, userGroupPK);
2647 }
2648 }
2649 catch (Exception e) {
2650 throw processException(e);
2651 }
2652 finally {
2653 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2654 }
2655 }
2656
2657
2664 public void setUserGroups(long pk,
2665 List<com.liferay.portal.model.UserGroup> userGroups)
2666 throws SystemException {
2667 try {
2668 long[] userGroupPKs = new long[userGroups.size()];
2669
2670 for (int i = 0; i < userGroups.size(); i++) {
2671 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
2672
2673 userGroupPKs[i] = userGroup.getPrimaryKey();
2674 }
2675
2676 setUserGroups(pk, userGroupPKs);
2677 }
2678 catch (Exception e) {
2679 throw processException(e);
2680 }
2681 finally {
2682 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2683 }
2684 }
2685
2686
2689 public void afterPropertiesSet() {
2690 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2691 com.liferay.portal.util.PropsUtil.get(
2692 "value.object.listener.com.liferay.portal.model.Team")));
2693
2694 if (listenerClassNames.length > 0) {
2695 try {
2696 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
2697
2698 for (String listenerClassName : listenerClassNames) {
2699 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
2700 listenerClassName));
2701 }
2702
2703 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2704 }
2705 catch (Exception e) {
2706 _log.error(e);
2707 }
2708 }
2709
2710 containsUser = new ContainsUser();
2711
2712 addUser = new AddUser();
2713 clearUsers = new ClearUsers();
2714 removeUser = new RemoveUser();
2715
2716 containsUserGroup = new ContainsUserGroup();
2717
2718 addUserGroup = new AddUserGroup();
2719 clearUserGroups = new ClearUserGroups();
2720 removeUserGroup = new RemoveUserGroup();
2721 }
2722
2723 public void destroy() {
2724 EntityCacheUtil.removeCache(TeamImpl.class.getName());
2725 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2726 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2727 }
2728
2729 @BeanReference(type = AccountPersistence.class)
2730 protected AccountPersistence accountPersistence;
2731 @BeanReference(type = AddressPersistence.class)
2732 protected AddressPersistence addressPersistence;
2733 @BeanReference(type = BrowserTrackerPersistence.class)
2734 protected BrowserTrackerPersistence browserTrackerPersistence;
2735 @BeanReference(type = ClassNamePersistence.class)
2736 protected ClassNamePersistence classNamePersistence;
2737 @BeanReference(type = ClusterGroupPersistence.class)
2738 protected ClusterGroupPersistence clusterGroupPersistence;
2739 @BeanReference(type = CompanyPersistence.class)
2740 protected CompanyPersistence companyPersistence;
2741 @BeanReference(type = ContactPersistence.class)
2742 protected ContactPersistence contactPersistence;
2743 @BeanReference(type = CountryPersistence.class)
2744 protected CountryPersistence countryPersistence;
2745 @BeanReference(type = EmailAddressPersistence.class)
2746 protected EmailAddressPersistence emailAddressPersistence;
2747 @BeanReference(type = GroupPersistence.class)
2748 protected GroupPersistence groupPersistence;
2749 @BeanReference(type = ImagePersistence.class)
2750 protected ImagePersistence imagePersistence;
2751 @BeanReference(type = LayoutPersistence.class)
2752 protected LayoutPersistence layoutPersistence;
2753 @BeanReference(type = LayoutBranchPersistence.class)
2754 protected LayoutBranchPersistence layoutBranchPersistence;
2755 @BeanReference(type = LayoutPrototypePersistence.class)
2756 protected LayoutPrototypePersistence layoutPrototypePersistence;
2757 @BeanReference(type = LayoutRevisionPersistence.class)
2758 protected LayoutRevisionPersistence layoutRevisionPersistence;
2759 @BeanReference(type = LayoutSetPersistence.class)
2760 protected LayoutSetPersistence layoutSetPersistence;
2761 @BeanReference(type = LayoutSetBranchPersistence.class)
2762 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2763 @BeanReference(type = LayoutSetPrototypePersistence.class)
2764 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2765 @BeanReference(type = ListTypePersistence.class)
2766 protected ListTypePersistence listTypePersistence;
2767 @BeanReference(type = LockPersistence.class)
2768 protected LockPersistence lockPersistence;
2769 @BeanReference(type = MembershipRequestPersistence.class)
2770 protected MembershipRequestPersistence membershipRequestPersistence;
2771 @BeanReference(type = OrganizationPersistence.class)
2772 protected OrganizationPersistence organizationPersistence;
2773 @BeanReference(type = OrgGroupRolePersistence.class)
2774 protected OrgGroupRolePersistence orgGroupRolePersistence;
2775 @BeanReference(type = OrgLaborPersistence.class)
2776 protected OrgLaborPersistence orgLaborPersistence;
2777 @BeanReference(type = PasswordPolicyPersistence.class)
2778 protected PasswordPolicyPersistence passwordPolicyPersistence;
2779 @BeanReference(type = PasswordPolicyRelPersistence.class)
2780 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2781 @BeanReference(type = PasswordTrackerPersistence.class)
2782 protected PasswordTrackerPersistence passwordTrackerPersistence;
2783 @BeanReference(type = PhonePersistence.class)
2784 protected PhonePersistence phonePersistence;
2785 @BeanReference(type = PluginSettingPersistence.class)
2786 protected PluginSettingPersistence pluginSettingPersistence;
2787 @BeanReference(type = PortalPreferencesPersistence.class)
2788 protected PortalPreferencesPersistence portalPreferencesPersistence;
2789 @BeanReference(type = PortletPersistence.class)
2790 protected PortletPersistence portletPersistence;
2791 @BeanReference(type = PortletItemPersistence.class)
2792 protected PortletItemPersistence portletItemPersistence;
2793 @BeanReference(type = PortletPreferencesPersistence.class)
2794 protected PortletPreferencesPersistence portletPreferencesPersistence;
2795 @BeanReference(type = RegionPersistence.class)
2796 protected RegionPersistence regionPersistence;
2797 @BeanReference(type = ReleasePersistence.class)
2798 protected ReleasePersistence releasePersistence;
2799 @BeanReference(type = RepositoryPersistence.class)
2800 protected RepositoryPersistence repositoryPersistence;
2801 @BeanReference(type = RepositoryEntryPersistence.class)
2802 protected RepositoryEntryPersistence repositoryEntryPersistence;
2803 @BeanReference(type = ResourceActionPersistence.class)
2804 protected ResourceActionPersistence resourceActionPersistence;
2805 @BeanReference(type = ResourceBlockPersistence.class)
2806 protected ResourceBlockPersistence resourceBlockPersistence;
2807 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2808 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2809 @BeanReference(type = ResourcePermissionPersistence.class)
2810 protected ResourcePermissionPersistence resourcePermissionPersistence;
2811 @BeanReference(type = ResourceTypePermissionPersistence.class)
2812 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2813 @BeanReference(type = RolePersistence.class)
2814 protected RolePersistence rolePersistence;
2815 @BeanReference(type = ServiceComponentPersistence.class)
2816 protected ServiceComponentPersistence serviceComponentPersistence;
2817 @BeanReference(type = ShardPersistence.class)
2818 protected ShardPersistence shardPersistence;
2819 @BeanReference(type = SubscriptionPersistence.class)
2820 protected SubscriptionPersistence subscriptionPersistence;
2821 @BeanReference(type = TeamPersistence.class)
2822 protected TeamPersistence teamPersistence;
2823 @BeanReference(type = TicketPersistence.class)
2824 protected TicketPersistence ticketPersistence;
2825 @BeanReference(type = UserPersistence.class)
2826 protected UserPersistence userPersistence;
2827 @BeanReference(type = UserGroupPersistence.class)
2828 protected UserGroupPersistence userGroupPersistence;
2829 @BeanReference(type = UserGroupGroupRolePersistence.class)
2830 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2831 @BeanReference(type = UserGroupRolePersistence.class)
2832 protected UserGroupRolePersistence userGroupRolePersistence;
2833 @BeanReference(type = UserIdMapperPersistence.class)
2834 protected UserIdMapperPersistence userIdMapperPersistence;
2835 @BeanReference(type = UserNotificationEventPersistence.class)
2836 protected UserNotificationEventPersistence userNotificationEventPersistence;
2837 @BeanReference(type = UserTrackerPersistence.class)
2838 protected UserTrackerPersistence userTrackerPersistence;
2839 @BeanReference(type = UserTrackerPathPersistence.class)
2840 protected UserTrackerPathPersistence userTrackerPathPersistence;
2841 @BeanReference(type = VirtualHostPersistence.class)
2842 protected VirtualHostPersistence virtualHostPersistence;
2843 @BeanReference(type = WebDAVPropsPersistence.class)
2844 protected WebDAVPropsPersistence webDAVPropsPersistence;
2845 @BeanReference(type = WebsitePersistence.class)
2846 protected WebsitePersistence websitePersistence;
2847 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2848 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2849 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2850 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2851 protected ContainsUser containsUser;
2852 protected AddUser addUser;
2853 protected ClearUsers clearUsers;
2854 protected RemoveUser removeUser;
2855 protected ContainsUserGroup containsUserGroup;
2856 protected AddUserGroup addUserGroup;
2857 protected ClearUserGroups clearUserGroups;
2858 protected RemoveUserGroup removeUserGroup;
2859
2860 protected class ContainsUser {
2861 protected ContainsUser() {
2862 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2863 _SQL_CONTAINSUSER,
2864 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2865 RowMapper.COUNT);
2866 }
2867
2868 protected boolean contains(long teamId, long userId) {
2869 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2870 new Long(teamId), new Long(userId)
2871 });
2872
2873 if (results.size() > 0) {
2874 Integer count = results.get(0);
2875
2876 if (count.intValue() > 0) {
2877 return true;
2878 }
2879 }
2880
2881 return false;
2882 }
2883
2884 private MappingSqlQuery<Integer> _mappingSqlQuery;
2885 }
2886
2887 protected class AddUser {
2888 protected AddUser() {
2889 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2890 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2891 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2892 }
2893
2894 protected void add(long teamId, long userId) throws SystemException {
2895 if (!containsUser.contains(teamId, userId)) {
2896 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2897
2898 for (ModelListener<Team> listener : listeners) {
2899 listener.onBeforeAddAssociation(teamId,
2900 com.liferay.portal.model.User.class.getName(), userId);
2901 }
2902
2903 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2904 listener.onBeforeAddAssociation(userId,
2905 Team.class.getName(), teamId);
2906 }
2907
2908 _sqlUpdate.update(new Object[] {
2909 new Long(teamId), new Long(userId)
2910 });
2911
2912 for (ModelListener<Team> listener : listeners) {
2913 listener.onAfterAddAssociation(teamId,
2914 com.liferay.portal.model.User.class.getName(), userId);
2915 }
2916
2917 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2918 listener.onAfterAddAssociation(userId,
2919 Team.class.getName(), teamId);
2920 }
2921 }
2922 }
2923
2924 private SqlUpdate _sqlUpdate;
2925 }
2926
2927 protected class ClearUsers {
2928 protected ClearUsers() {
2929 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2930 "DELETE FROM Users_Teams WHERE teamId = ?",
2931 new int[] { java.sql.Types.BIGINT });
2932 }
2933
2934 protected void clear(long teamId) throws SystemException {
2935 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2936
2937 List<com.liferay.portal.model.User> users = null;
2938
2939 if ((listeners.length > 0) || (userListeners.length > 0)) {
2940 users = getUsers(teamId);
2941
2942 for (com.liferay.portal.model.User user : users) {
2943 for (ModelListener<Team> listener : listeners) {
2944 listener.onBeforeRemoveAssociation(teamId,
2945 com.liferay.portal.model.User.class.getName(),
2946 user.getPrimaryKey());
2947 }
2948
2949 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2950 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2951 Team.class.getName(), teamId);
2952 }
2953 }
2954 }
2955
2956 _sqlUpdate.update(new Object[] { new Long(teamId) });
2957
2958 if ((listeners.length > 0) || (userListeners.length > 0)) {
2959 for (com.liferay.portal.model.User user : users) {
2960 for (ModelListener<Team> listener : listeners) {
2961 listener.onAfterRemoveAssociation(teamId,
2962 com.liferay.portal.model.User.class.getName(),
2963 user.getPrimaryKey());
2964 }
2965
2966 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2967 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2968 Team.class.getName(), teamId);
2969 }
2970 }
2971 }
2972 }
2973
2974 private SqlUpdate _sqlUpdate;
2975 }
2976
2977 protected class RemoveUser {
2978 protected RemoveUser() {
2979 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2980 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2981 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2982 }
2983
2984 protected void remove(long teamId, long userId)
2985 throws SystemException {
2986 if (containsUser.contains(teamId, userId)) {
2987 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2988
2989 for (ModelListener<Team> listener : listeners) {
2990 listener.onBeforeRemoveAssociation(teamId,
2991 com.liferay.portal.model.User.class.getName(), userId);
2992 }
2993
2994 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2995 listener.onBeforeRemoveAssociation(userId,
2996 Team.class.getName(), teamId);
2997 }
2998
2999 _sqlUpdate.update(new Object[] {
3000 new Long(teamId), new Long(userId)
3001 });
3002
3003 for (ModelListener<Team> listener : listeners) {
3004 listener.onAfterRemoveAssociation(teamId,
3005 com.liferay.portal.model.User.class.getName(), userId);
3006 }
3007
3008 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
3009 listener.onAfterRemoveAssociation(userId,
3010 Team.class.getName(), teamId);
3011 }
3012 }
3013 }
3014
3015 private SqlUpdate _sqlUpdate;
3016 }
3017
3018 protected class ContainsUserGroup {
3019 protected ContainsUserGroup() {
3020 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
3021 _SQL_CONTAINSUSERGROUP,
3022 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
3023 RowMapper.COUNT);
3024 }
3025
3026 protected boolean contains(long teamId, long userGroupId) {
3027 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3028 new Long(teamId), new Long(userGroupId)
3029 });
3030
3031 if (results.size() > 0) {
3032 Integer count = results.get(0);
3033
3034 if (count.intValue() > 0) {
3035 return true;
3036 }
3037 }
3038
3039 return false;
3040 }
3041
3042 private MappingSqlQuery<Integer> _mappingSqlQuery;
3043 }
3044
3045 protected class AddUserGroup {
3046 protected AddUserGroup() {
3047 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3048 "INSERT INTO UserGroups_Teams (teamId, userGroupId) VALUES (?, ?)",
3049 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3050 }
3051
3052 protected void add(long teamId, long userGroupId)
3053 throws SystemException {
3054 if (!containsUserGroup.contains(teamId, userGroupId)) {
3055 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3056 userGroupPersistence.getListeners();
3057
3058 for (ModelListener<Team> listener : listeners) {
3059 listener.onBeforeAddAssociation(teamId,
3060 com.liferay.portal.model.UserGroup.class.getName(),
3061 userGroupId);
3062 }
3063
3064 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3065 listener.onBeforeAddAssociation(userGroupId,
3066 Team.class.getName(), teamId);
3067 }
3068
3069 _sqlUpdate.update(new Object[] {
3070 new Long(teamId), new Long(userGroupId)
3071 });
3072
3073 for (ModelListener<Team> listener : listeners) {
3074 listener.onAfterAddAssociation(teamId,
3075 com.liferay.portal.model.UserGroup.class.getName(),
3076 userGroupId);
3077 }
3078
3079 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3080 listener.onAfterAddAssociation(userGroupId,
3081 Team.class.getName(), teamId);
3082 }
3083 }
3084 }
3085
3086 private SqlUpdate _sqlUpdate;
3087 }
3088
3089 protected class ClearUserGroups {
3090 protected ClearUserGroups() {
3091 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3092 "DELETE FROM UserGroups_Teams WHERE teamId = ?",
3093 new int[] { java.sql.Types.BIGINT });
3094 }
3095
3096 protected void clear(long teamId) throws SystemException {
3097 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3098 userGroupPersistence.getListeners();
3099
3100 List<com.liferay.portal.model.UserGroup> userGroups = null;
3101
3102 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3103 userGroups = getUserGroups(teamId);
3104
3105 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3106 for (ModelListener<Team> listener : listeners) {
3107 listener.onBeforeRemoveAssociation(teamId,
3108 com.liferay.portal.model.UserGroup.class.getName(),
3109 userGroup.getPrimaryKey());
3110 }
3111
3112 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3113 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
3114 Team.class.getName(), teamId);
3115 }
3116 }
3117 }
3118
3119 _sqlUpdate.update(new Object[] { new Long(teamId) });
3120
3121 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3122 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3123 for (ModelListener<Team> listener : listeners) {
3124 listener.onAfterRemoveAssociation(teamId,
3125 com.liferay.portal.model.UserGroup.class.getName(),
3126 userGroup.getPrimaryKey());
3127 }
3128
3129 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3130 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
3131 Team.class.getName(), teamId);
3132 }
3133 }
3134 }
3135 }
3136
3137 private SqlUpdate _sqlUpdate;
3138 }
3139
3140 protected class RemoveUserGroup {
3141 protected RemoveUserGroup() {
3142 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3143 "DELETE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?",
3144 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3145 }
3146
3147 protected void remove(long teamId, long userGroupId)
3148 throws SystemException {
3149 if (containsUserGroup.contains(teamId, userGroupId)) {
3150 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3151 userGroupPersistence.getListeners();
3152
3153 for (ModelListener<Team> listener : listeners) {
3154 listener.onBeforeRemoveAssociation(teamId,
3155 com.liferay.portal.model.UserGroup.class.getName(),
3156 userGroupId);
3157 }
3158
3159 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3160 listener.onBeforeRemoveAssociation(userGroupId,
3161 Team.class.getName(), teamId);
3162 }
3163
3164 _sqlUpdate.update(new Object[] {
3165 new Long(teamId), new Long(userGroupId)
3166 });
3167
3168 for (ModelListener<Team> listener : listeners) {
3169 listener.onAfterRemoveAssociation(teamId,
3170 com.liferay.portal.model.UserGroup.class.getName(),
3171 userGroupId);
3172 }
3173
3174 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3175 listener.onAfterRemoveAssociation(userGroupId,
3176 Team.class.getName(), teamId);
3177 }
3178 }
3179 }
3180
3181 private SqlUpdate _sqlUpdate;
3182 }
3183
3184 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
3185 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
3186 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
3187 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
3188 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
3189 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
3190 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
3191 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN UserGroups_Teams ON (UserGroups_Teams.userGroupId = UserGroup.userGroupId) WHERE (UserGroups_Teams.teamId = ?)";
3192 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ?";
3193 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?";
3194 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
3195 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
3196 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
3197 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
3198 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
3199 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId";
3200 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
3201 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
3202 "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
3203 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
3204 ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
3205 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
3206 private static final String _FILTER_ENTITY_ALIAS = "team";
3207 private static final String _FILTER_ENTITY_TABLE = "Team";
3208 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
3209 private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
3210 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
3211 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
3212 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3213 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
3214 private static Team _nullTeam = new TeamImpl() {
3215 @Override
3216 public Object clone() {
3217 return this;
3218 }
3219
3220 @Override
3221 public CacheModel<Team> toCacheModel() {
3222 return _nullTeamCacheModel;
3223 }
3224 };
3225
3226 private static CacheModel<Team> _nullTeamCacheModel = new CacheModel<Team>() {
3227 public Team toEntityModel() {
3228 return _nullTeam;
3229 }
3230 };
3231 }