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 else {
353 if ((teamModelImpl.getColumnBitmask() &
354 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
355 Object[] args = new Object[] {
356 Long.valueOf(teamModelImpl.getOriginalGroupId())
357 };
358
359 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
360 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
361 args);
362
363 args = new Object[] { Long.valueOf(teamModelImpl.getGroupId()) };
364
365 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
366 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
367 args);
368 }
369 }
370
371 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
372 TeamImpl.class, team.getPrimaryKey(), team);
373
374 if (isNew) {
375 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
376 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
377 team);
378 }
379 else {
380 if ((teamModelImpl.getColumnBitmask() &
381 FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
382 Object[] args = new Object[] {
383 Long.valueOf(teamModelImpl.getOriginalGroupId()),
384
385 teamModelImpl.getOriginalName()
386 };
387
388 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
389 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
390
391 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
392 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
393 team);
394 }
395 }
396
397 return team;
398 }
399
400 protected Team toUnwrappedModel(Team team) {
401 if (team instanceof TeamImpl) {
402 return team;
403 }
404
405 TeamImpl teamImpl = new TeamImpl();
406
407 teamImpl.setNew(team.isNew());
408 teamImpl.setPrimaryKey(team.getPrimaryKey());
409
410 teamImpl.setTeamId(team.getTeamId());
411 teamImpl.setCompanyId(team.getCompanyId());
412 teamImpl.setUserId(team.getUserId());
413 teamImpl.setUserName(team.getUserName());
414 teamImpl.setCreateDate(team.getCreateDate());
415 teamImpl.setModifiedDate(team.getModifiedDate());
416 teamImpl.setGroupId(team.getGroupId());
417 teamImpl.setName(team.getName());
418 teamImpl.setDescription(team.getDescription());
419
420 return teamImpl;
421 }
422
423
431 @Override
432 public Team findByPrimaryKey(Serializable primaryKey)
433 throws NoSuchModelException, SystemException {
434 return findByPrimaryKey(((Long)primaryKey).longValue());
435 }
436
437
445 public Team findByPrimaryKey(long teamId)
446 throws NoSuchTeamException, SystemException {
447 Team team = fetchByPrimaryKey(teamId);
448
449 if (team == null) {
450 if (_log.isWarnEnabled()) {
451 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + teamId);
452 }
453
454 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
455 teamId);
456 }
457
458 return team;
459 }
460
461
468 @Override
469 public Team fetchByPrimaryKey(Serializable primaryKey)
470 throws SystemException {
471 return fetchByPrimaryKey(((Long)primaryKey).longValue());
472 }
473
474
481 public Team fetchByPrimaryKey(long teamId) throws SystemException {
482 Team team = (Team)EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
483 TeamImpl.class, teamId);
484
485 if (team == _nullTeam) {
486 return null;
487 }
488
489 if (team == null) {
490 Session session = null;
491
492 boolean hasException = false;
493
494 try {
495 session = openSession();
496
497 team = (Team)session.get(TeamImpl.class, Long.valueOf(teamId));
498 }
499 catch (Exception e) {
500 hasException = true;
501
502 throw processException(e);
503 }
504 finally {
505 if (team != null) {
506 cacheResult(team);
507 }
508 else if (!hasException) {
509 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
510 TeamImpl.class, teamId, _nullTeam);
511 }
512
513 closeSession(session);
514 }
515 }
516
517 return team;
518 }
519
520
527 public List<Team> findByGroupId(long groupId) throws SystemException {
528 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
529 }
530
531
544 public List<Team> findByGroupId(long groupId, int start, int end)
545 throws SystemException {
546 return findByGroupId(groupId, start, end, null);
547 }
548
549
563 public List<Team> findByGroupId(long groupId, int start, int end,
564 OrderByComparator orderByComparator) throws SystemException {
565 FinderPath finderPath = null;
566 Object[] finderArgs = null;
567
568 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
569 (orderByComparator == null)) {
570 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
571 finderArgs = new Object[] { groupId };
572 }
573 else {
574 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
575 finderArgs = new Object[] { groupId, start, end, orderByComparator };
576 }
577
578 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
579 finderArgs, this);
580
581 if ((list != null) && !list.isEmpty()) {
582 for (Team team : list) {
583 if ((groupId != team.getGroupId())) {
584 list = null;
585
586 break;
587 }
588 }
589 }
590
591 if (list == null) {
592 StringBundler query = null;
593
594 if (orderByComparator != null) {
595 query = new StringBundler(3 +
596 (orderByComparator.getOrderByFields().length * 3));
597 }
598 else {
599 query = new StringBundler(3);
600 }
601
602 query.append(_SQL_SELECT_TEAM_WHERE);
603
604 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
605
606 if (orderByComparator != null) {
607 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
608 orderByComparator);
609 }
610
611 else {
612 query.append(TeamModelImpl.ORDER_BY_JPQL);
613 }
614
615 String sql = query.toString();
616
617 Session session = null;
618
619 try {
620 session = openSession();
621
622 Query q = session.createQuery(sql);
623
624 QueryPos qPos = QueryPos.getInstance(q);
625
626 qPos.add(groupId);
627
628 list = (List<Team>)QueryUtil.list(q, getDialect(), start, end);
629 }
630 catch (Exception e) {
631 throw processException(e);
632 }
633 finally {
634 if (list == null) {
635 FinderCacheUtil.removeResult(finderPath, finderArgs);
636 }
637 else {
638 cacheResult(list);
639
640 FinderCacheUtil.putResult(finderPath, finderArgs, list);
641 }
642
643 closeSession(session);
644 }
645 }
646
647 return list;
648 }
649
650
663 public Team findByGroupId_First(long groupId,
664 OrderByComparator orderByComparator)
665 throws NoSuchTeamException, SystemException {
666 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
667
668 if (list.isEmpty()) {
669 StringBundler msg = new StringBundler(4);
670
671 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
672
673 msg.append("groupId=");
674 msg.append(groupId);
675
676 msg.append(StringPool.CLOSE_CURLY_BRACE);
677
678 throw new NoSuchTeamException(msg.toString());
679 }
680 else {
681 return list.get(0);
682 }
683 }
684
685
698 public Team findByGroupId_Last(long groupId,
699 OrderByComparator orderByComparator)
700 throws NoSuchTeamException, SystemException {
701 int count = countByGroupId(groupId);
702
703 List<Team> list = findByGroupId(groupId, count - 1, count,
704 orderByComparator);
705
706 if (list.isEmpty()) {
707 StringBundler msg = new StringBundler(4);
708
709 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
710
711 msg.append("groupId=");
712 msg.append(groupId);
713
714 msg.append(StringPool.CLOSE_CURLY_BRACE);
715
716 throw new NoSuchTeamException(msg.toString());
717 }
718 else {
719 return list.get(0);
720 }
721 }
722
723
737 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
738 OrderByComparator orderByComparator)
739 throws NoSuchTeamException, SystemException {
740 Team team = findByPrimaryKey(teamId);
741
742 Session session = null;
743
744 try {
745 session = openSession();
746
747 Team[] array = new TeamImpl[3];
748
749 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
750 orderByComparator, true);
751
752 array[1] = team;
753
754 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
755 orderByComparator, false);
756
757 return array;
758 }
759 catch (Exception e) {
760 throw processException(e);
761 }
762 finally {
763 closeSession(session);
764 }
765 }
766
767 protected Team getByGroupId_PrevAndNext(Session session, Team team,
768 long groupId, OrderByComparator orderByComparator, boolean previous) {
769 StringBundler query = null;
770
771 if (orderByComparator != null) {
772 query = new StringBundler(6 +
773 (orderByComparator.getOrderByFields().length * 6));
774 }
775 else {
776 query = new StringBundler(3);
777 }
778
779 query.append(_SQL_SELECT_TEAM_WHERE);
780
781 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
782
783 if (orderByComparator != null) {
784 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
785
786 if (orderByConditionFields.length > 0) {
787 query.append(WHERE_AND);
788 }
789
790 for (int i = 0; i < orderByConditionFields.length; i++) {
791 query.append(_ORDER_BY_ENTITY_ALIAS);
792 query.append(orderByConditionFields[i]);
793
794 if ((i + 1) < orderByConditionFields.length) {
795 if (orderByComparator.isAscending() ^ previous) {
796 query.append(WHERE_GREATER_THAN_HAS_NEXT);
797 }
798 else {
799 query.append(WHERE_LESSER_THAN_HAS_NEXT);
800 }
801 }
802 else {
803 if (orderByComparator.isAscending() ^ previous) {
804 query.append(WHERE_GREATER_THAN);
805 }
806 else {
807 query.append(WHERE_LESSER_THAN);
808 }
809 }
810 }
811
812 query.append(ORDER_BY_CLAUSE);
813
814 String[] orderByFields = orderByComparator.getOrderByFields();
815
816 for (int i = 0; i < orderByFields.length; i++) {
817 query.append(_ORDER_BY_ENTITY_ALIAS);
818 query.append(orderByFields[i]);
819
820 if ((i + 1) < orderByFields.length) {
821 if (orderByComparator.isAscending() ^ previous) {
822 query.append(ORDER_BY_ASC_HAS_NEXT);
823 }
824 else {
825 query.append(ORDER_BY_DESC_HAS_NEXT);
826 }
827 }
828 else {
829 if (orderByComparator.isAscending() ^ previous) {
830 query.append(ORDER_BY_ASC);
831 }
832 else {
833 query.append(ORDER_BY_DESC);
834 }
835 }
836 }
837 }
838
839 else {
840 query.append(TeamModelImpl.ORDER_BY_JPQL);
841 }
842
843 String sql = query.toString();
844
845 Query q = session.createQuery(sql);
846
847 q.setFirstResult(0);
848 q.setMaxResults(2);
849
850 QueryPos qPos = QueryPos.getInstance(q);
851
852 qPos.add(groupId);
853
854 if (orderByComparator != null) {
855 Object[] values = orderByComparator.getOrderByConditionValues(team);
856
857 for (Object value : values) {
858 qPos.add(value);
859 }
860 }
861
862 List<Team> list = q.list();
863
864 if (list.size() == 2) {
865 return list.get(1);
866 }
867 else {
868 return null;
869 }
870 }
871
872
879 public List<Team> filterFindByGroupId(long groupId)
880 throws SystemException {
881 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
882 QueryUtil.ALL_POS, null);
883 }
884
885
898 public List<Team> filterFindByGroupId(long groupId, int start, int end)
899 throws SystemException {
900 return filterFindByGroupId(groupId, start, end, null);
901 }
902
903
917 public List<Team> filterFindByGroupId(long groupId, int start, int end,
918 OrderByComparator orderByComparator) throws SystemException {
919 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
920 return findByGroupId(groupId, start, end, orderByComparator);
921 }
922
923 StringBundler query = null;
924
925 if (orderByComparator != null) {
926 query = new StringBundler(3 +
927 (orderByComparator.getOrderByFields().length * 3));
928 }
929 else {
930 query = new StringBundler(3);
931 }
932
933 if (getDB().isSupportsInlineDistinct()) {
934 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
935 }
936 else {
937 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
938 }
939
940 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
941
942 if (!getDB().isSupportsInlineDistinct()) {
943 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
944 }
945
946 if (orderByComparator != null) {
947 if (getDB().isSupportsInlineDistinct()) {
948 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
949 orderByComparator);
950 }
951 else {
952 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
953 orderByComparator);
954 }
955 }
956
957 else {
958 if (getDB().isSupportsInlineDistinct()) {
959 query.append(TeamModelImpl.ORDER_BY_JPQL);
960 }
961 else {
962 query.append(TeamModelImpl.ORDER_BY_SQL);
963 }
964 }
965
966 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
967 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
968 groupId);
969
970 Session session = null;
971
972 try {
973 session = openSession();
974
975 SQLQuery q = session.createSQLQuery(sql);
976
977 if (getDB().isSupportsInlineDistinct()) {
978 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
979 }
980 else {
981 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
982 }
983
984 QueryPos qPos = QueryPos.getInstance(q);
985
986 qPos.add(groupId);
987
988 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
989 }
990 catch (Exception e) {
991 throw processException(e);
992 }
993 finally {
994 closeSession(session);
995 }
996 }
997
998
1008 public Team[] filterFindByGroupId_PrevAndNext(long teamId, long groupId,
1009 OrderByComparator orderByComparator)
1010 throws NoSuchTeamException, SystemException {
1011 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1012 return findByGroupId_PrevAndNext(teamId, groupId, orderByComparator);
1013 }
1014
1015 Team team = findByPrimaryKey(teamId);
1016
1017 Session session = null;
1018
1019 try {
1020 session = openSession();
1021
1022 Team[] array = new TeamImpl[3];
1023
1024 array[0] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1025 orderByComparator, true);
1026
1027 array[1] = team;
1028
1029 array[2] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1030 orderByComparator, false);
1031
1032 return array;
1033 }
1034 catch (Exception e) {
1035 throw processException(e);
1036 }
1037 finally {
1038 closeSession(session);
1039 }
1040 }
1041
1042 protected Team filterGetByGroupId_PrevAndNext(Session session, Team team,
1043 long groupId, OrderByComparator orderByComparator, boolean previous) {
1044 StringBundler query = null;
1045
1046 if (orderByComparator != null) {
1047 query = new StringBundler(6 +
1048 (orderByComparator.getOrderByFields().length * 6));
1049 }
1050 else {
1051 query = new StringBundler(3);
1052 }
1053
1054 if (getDB().isSupportsInlineDistinct()) {
1055 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
1056 }
1057 else {
1058 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
1059 }
1060
1061 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1062
1063 if (!getDB().isSupportsInlineDistinct()) {
1064 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
1065 }
1066
1067 if (orderByComparator != null) {
1068 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1069
1070 if (orderByConditionFields.length > 0) {
1071 query.append(WHERE_AND);
1072 }
1073
1074 for (int i = 0; i < orderByConditionFields.length; i++) {
1075 if (getDB().isSupportsInlineDistinct()) {
1076 query.append(_ORDER_BY_ENTITY_ALIAS);
1077 }
1078 else {
1079 query.append(_ORDER_BY_ENTITY_TABLE);
1080 }
1081
1082 query.append(orderByConditionFields[i]);
1083
1084 if ((i + 1) < orderByConditionFields.length) {
1085 if (orderByComparator.isAscending() ^ previous) {
1086 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1087 }
1088 else {
1089 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1090 }
1091 }
1092 else {
1093 if (orderByComparator.isAscending() ^ previous) {
1094 query.append(WHERE_GREATER_THAN);
1095 }
1096 else {
1097 query.append(WHERE_LESSER_THAN);
1098 }
1099 }
1100 }
1101
1102 query.append(ORDER_BY_CLAUSE);
1103
1104 String[] orderByFields = orderByComparator.getOrderByFields();
1105
1106 for (int i = 0; i < orderByFields.length; i++) {
1107 if (getDB().isSupportsInlineDistinct()) {
1108 query.append(_ORDER_BY_ENTITY_ALIAS);
1109 }
1110 else {
1111 query.append(_ORDER_BY_ENTITY_TABLE);
1112 }
1113
1114 query.append(orderByFields[i]);
1115
1116 if ((i + 1) < orderByFields.length) {
1117 if (orderByComparator.isAscending() ^ previous) {
1118 query.append(ORDER_BY_ASC_HAS_NEXT);
1119 }
1120 else {
1121 query.append(ORDER_BY_DESC_HAS_NEXT);
1122 }
1123 }
1124 else {
1125 if (orderByComparator.isAscending() ^ previous) {
1126 query.append(ORDER_BY_ASC);
1127 }
1128 else {
1129 query.append(ORDER_BY_DESC);
1130 }
1131 }
1132 }
1133 }
1134
1135 else {
1136 if (getDB().isSupportsInlineDistinct()) {
1137 query.append(TeamModelImpl.ORDER_BY_JPQL);
1138 }
1139 else {
1140 query.append(TeamModelImpl.ORDER_BY_SQL);
1141 }
1142 }
1143
1144 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1145 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1146 groupId);
1147
1148 SQLQuery q = session.createSQLQuery(sql);
1149
1150 q.setFirstResult(0);
1151 q.setMaxResults(2);
1152
1153 if (getDB().isSupportsInlineDistinct()) {
1154 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1155 }
1156 else {
1157 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1158 }
1159
1160 QueryPos qPos = QueryPos.getInstance(q);
1161
1162 qPos.add(groupId);
1163
1164 if (orderByComparator != null) {
1165 Object[] values = orderByComparator.getOrderByConditionValues(team);
1166
1167 for (Object value : values) {
1168 qPos.add(value);
1169 }
1170 }
1171
1172 List<Team> list = q.list();
1173
1174 if (list.size() == 2) {
1175 return list.get(1);
1176 }
1177 else {
1178 return null;
1179 }
1180 }
1181
1182
1191 public Team findByG_N(long groupId, String name)
1192 throws NoSuchTeamException, SystemException {
1193 Team team = fetchByG_N(groupId, name);
1194
1195 if (team == null) {
1196 StringBundler msg = new StringBundler(6);
1197
1198 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1199
1200 msg.append("groupId=");
1201 msg.append(groupId);
1202
1203 msg.append(", name=");
1204 msg.append(name);
1205
1206 msg.append(StringPool.CLOSE_CURLY_BRACE);
1207
1208 if (_log.isWarnEnabled()) {
1209 _log.warn(msg.toString());
1210 }
1211
1212 throw new NoSuchTeamException(msg.toString());
1213 }
1214
1215 return team;
1216 }
1217
1218
1226 public Team fetchByG_N(long groupId, String name) throws SystemException {
1227 return fetchByG_N(groupId, name, true);
1228 }
1229
1230
1239 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
1240 throws SystemException {
1241 Object[] finderArgs = new Object[] { groupId, name };
1242
1243 Object result = null;
1244
1245 if (retrieveFromCache) {
1246 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1247 finderArgs, this);
1248 }
1249
1250 if (result instanceof Team) {
1251 Team team = (Team)result;
1252
1253 if ((groupId != team.getGroupId()) ||
1254 !Validator.equals(name, team.getName())) {
1255 result = null;
1256 }
1257 }
1258
1259 if (result == null) {
1260 StringBundler query = new StringBundler(4);
1261
1262 query.append(_SQL_SELECT_TEAM_WHERE);
1263
1264 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1265
1266 if (name == null) {
1267 query.append(_FINDER_COLUMN_G_N_NAME_1);
1268 }
1269 else {
1270 if (name.equals(StringPool.BLANK)) {
1271 query.append(_FINDER_COLUMN_G_N_NAME_3);
1272 }
1273 else {
1274 query.append(_FINDER_COLUMN_G_N_NAME_2);
1275 }
1276 }
1277
1278 query.append(TeamModelImpl.ORDER_BY_JPQL);
1279
1280 String sql = query.toString();
1281
1282 Session session = null;
1283
1284 try {
1285 session = openSession();
1286
1287 Query q = session.createQuery(sql);
1288
1289 QueryPos qPos = QueryPos.getInstance(q);
1290
1291 qPos.add(groupId);
1292
1293 if (name != null) {
1294 qPos.add(name);
1295 }
1296
1297 List<Team> list = q.list();
1298
1299 result = list;
1300
1301 Team team = null;
1302
1303 if (list.isEmpty()) {
1304 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1305 finderArgs, list);
1306 }
1307 else {
1308 team = list.get(0);
1309
1310 cacheResult(team);
1311
1312 if ((team.getGroupId() != groupId) ||
1313 (team.getName() == null) ||
1314 !team.getName().equals(name)) {
1315 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1316 finderArgs, team);
1317 }
1318 }
1319
1320 return team;
1321 }
1322 catch (Exception e) {
1323 throw processException(e);
1324 }
1325 finally {
1326 if (result == null) {
1327 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1328 finderArgs);
1329 }
1330
1331 closeSession(session);
1332 }
1333 }
1334 else {
1335 if (result instanceof List<?>) {
1336 return null;
1337 }
1338 else {
1339 return (Team)result;
1340 }
1341 }
1342 }
1343
1344
1350 public List<Team> findAll() throws SystemException {
1351 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1352 }
1353
1354
1366 public List<Team> findAll(int start, int end) throws SystemException {
1367 return findAll(start, end, null);
1368 }
1369
1370
1383 public List<Team> findAll(int start, int end,
1384 OrderByComparator orderByComparator) throws SystemException {
1385 FinderPath finderPath = null;
1386 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1387
1388 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1389 (orderByComparator == null)) {
1390 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1391 finderArgs = FINDER_ARGS_EMPTY;
1392 }
1393 else {
1394 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1395 finderArgs = new Object[] { start, end, orderByComparator };
1396 }
1397
1398 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
1399 finderArgs, this);
1400
1401 if (list == null) {
1402 StringBundler query = null;
1403 String sql = null;
1404
1405 if (orderByComparator != null) {
1406 query = new StringBundler(2 +
1407 (orderByComparator.getOrderByFields().length * 3));
1408
1409 query.append(_SQL_SELECT_TEAM);
1410
1411 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1412 orderByComparator);
1413
1414 sql = query.toString();
1415 }
1416 else {
1417 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1418 }
1419
1420 Session session = null;
1421
1422 try {
1423 session = openSession();
1424
1425 Query q = session.createQuery(sql);
1426
1427 if (orderByComparator == null) {
1428 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1429 end, false);
1430
1431 Collections.sort(list);
1432 }
1433 else {
1434 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1435 end);
1436 }
1437 }
1438 catch (Exception e) {
1439 throw processException(e);
1440 }
1441 finally {
1442 if (list == null) {
1443 FinderCacheUtil.removeResult(finderPath, finderArgs);
1444 }
1445 else {
1446 cacheResult(list);
1447
1448 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1449 }
1450
1451 closeSession(session);
1452 }
1453 }
1454
1455 return list;
1456 }
1457
1458
1464 public void removeByGroupId(long groupId) throws SystemException {
1465 for (Team team : findByGroupId(groupId)) {
1466 remove(team);
1467 }
1468 }
1469
1470
1477 public void removeByG_N(long groupId, String name)
1478 throws NoSuchTeamException, SystemException {
1479 Team team = findByG_N(groupId, name);
1480
1481 remove(team);
1482 }
1483
1484
1489 public void removeAll() throws SystemException {
1490 for (Team team : findAll()) {
1491 remove(team);
1492 }
1493 }
1494
1495
1502 public int countByGroupId(long groupId) throws SystemException {
1503 Object[] finderArgs = new Object[] { groupId };
1504
1505 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1506 finderArgs, this);
1507
1508 if (count == null) {
1509 StringBundler query = new StringBundler(2);
1510
1511 query.append(_SQL_COUNT_TEAM_WHERE);
1512
1513 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1514
1515 String sql = query.toString();
1516
1517 Session session = null;
1518
1519 try {
1520 session = openSession();
1521
1522 Query q = session.createQuery(sql);
1523
1524 QueryPos qPos = QueryPos.getInstance(q);
1525
1526 qPos.add(groupId);
1527
1528 count = (Long)q.uniqueResult();
1529 }
1530 catch (Exception e) {
1531 throw processException(e);
1532 }
1533 finally {
1534 if (count == null) {
1535 count = Long.valueOf(0);
1536 }
1537
1538 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1539 finderArgs, count);
1540
1541 closeSession(session);
1542 }
1543 }
1544
1545 return count.intValue();
1546 }
1547
1548
1555 public int filterCountByGroupId(long groupId) throws SystemException {
1556 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1557 return countByGroupId(groupId);
1558 }
1559
1560 StringBundler query = new StringBundler(2);
1561
1562 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1563
1564 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1565
1566 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1567 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1568 groupId);
1569
1570 Session session = null;
1571
1572 try {
1573 session = openSession();
1574
1575 SQLQuery q = session.createSQLQuery(sql);
1576
1577 q.addScalar(COUNT_COLUMN_NAME,
1578 com.liferay.portal.kernel.dao.orm.Type.LONG);
1579
1580 QueryPos qPos = QueryPos.getInstance(q);
1581
1582 qPos.add(groupId);
1583
1584 Long count = (Long)q.uniqueResult();
1585
1586 return count.intValue();
1587 }
1588 catch (Exception e) {
1589 throw processException(e);
1590 }
1591 finally {
1592 closeSession(session);
1593 }
1594 }
1595
1596
1604 public int countByG_N(long groupId, String name) throws SystemException {
1605 Object[] finderArgs = new Object[] { groupId, name };
1606
1607 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1608 finderArgs, this);
1609
1610 if (count == null) {
1611 StringBundler query = new StringBundler(3);
1612
1613 query.append(_SQL_COUNT_TEAM_WHERE);
1614
1615 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1616
1617 if (name == null) {
1618 query.append(_FINDER_COLUMN_G_N_NAME_1);
1619 }
1620 else {
1621 if (name.equals(StringPool.BLANK)) {
1622 query.append(_FINDER_COLUMN_G_N_NAME_3);
1623 }
1624 else {
1625 query.append(_FINDER_COLUMN_G_N_NAME_2);
1626 }
1627 }
1628
1629 String sql = query.toString();
1630
1631 Session session = null;
1632
1633 try {
1634 session = openSession();
1635
1636 Query q = session.createQuery(sql);
1637
1638 QueryPos qPos = QueryPos.getInstance(q);
1639
1640 qPos.add(groupId);
1641
1642 if (name != null) {
1643 qPos.add(name);
1644 }
1645
1646 count = (Long)q.uniqueResult();
1647 }
1648 catch (Exception e) {
1649 throw processException(e);
1650 }
1651 finally {
1652 if (count == null) {
1653 count = Long.valueOf(0);
1654 }
1655
1656 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1657 count);
1658
1659 closeSession(session);
1660 }
1661 }
1662
1663 return count.intValue();
1664 }
1665
1666
1672 public int countAll() throws SystemException {
1673 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1674 FINDER_ARGS_EMPTY, this);
1675
1676 if (count == null) {
1677 Session session = null;
1678
1679 try {
1680 session = openSession();
1681
1682 Query q = session.createQuery(_SQL_COUNT_TEAM);
1683
1684 count = (Long)q.uniqueResult();
1685 }
1686 catch (Exception e) {
1687 throw processException(e);
1688 }
1689 finally {
1690 if (count == null) {
1691 count = Long.valueOf(0);
1692 }
1693
1694 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1695 FINDER_ARGS_EMPTY, count);
1696
1697 closeSession(session);
1698 }
1699 }
1700
1701 return count.intValue();
1702 }
1703
1704
1711 public List<com.liferay.portal.model.User> getUsers(long pk)
1712 throws SystemException {
1713 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1714 }
1715
1716
1729 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1730 int end) throws SystemException {
1731 return getUsers(pk, start, end, null);
1732 }
1733
1734 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1735 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1736 com.liferay.portal.model.impl.UserImpl.class,
1737 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1738 new String[] {
1739 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1740 "com.liferay.portal.kernel.util.OrderByComparator"
1741 });
1742
1743 static {
1744 FINDER_PATH_GET_USERS.setCacheKeyGeneratorCacheName(null);
1745 }
1746
1747
1761 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1762 int end, OrderByComparator orderByComparator) throws SystemException {
1763 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1764
1765 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1766 finderArgs, this);
1767
1768 if (list == null) {
1769 Session session = null;
1770
1771 try {
1772 session = openSession();
1773
1774 String sql = null;
1775
1776 if (orderByComparator != null) {
1777 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1778 .concat(orderByComparator.getOrderBy());
1779 }
1780 else {
1781 sql = _SQL_GETUSERS;
1782 }
1783
1784 SQLQuery q = session.createSQLQuery(sql);
1785
1786 q.addEntity("User_",
1787 com.liferay.portal.model.impl.UserImpl.class);
1788
1789 QueryPos qPos = QueryPos.getInstance(q);
1790
1791 qPos.add(pk);
1792
1793 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1794 getDialect(), start, end);
1795 }
1796 catch (Exception e) {
1797 throw processException(e);
1798 }
1799 finally {
1800 if (list == null) {
1801 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
1802 finderArgs);
1803 }
1804 else {
1805 userPersistence.cacheResult(list);
1806
1807 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
1808 finderArgs, list);
1809 }
1810
1811 closeSession(session);
1812 }
1813 }
1814
1815 return list;
1816 }
1817
1818 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1819 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
1820 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1821 new String[] { Long.class.getName() });
1822
1823 static {
1824 FINDER_PATH_GET_USERS_SIZE.setCacheKeyGeneratorCacheName(null);
1825 }
1826
1827
1834 public int getUsersSize(long pk) throws SystemException {
1835 Object[] finderArgs = new Object[] { pk };
1836
1837 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1838 finderArgs, this);
1839
1840 if (count == null) {
1841 Session session = null;
1842
1843 try {
1844 session = openSession();
1845
1846 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1847
1848 q.addScalar(COUNT_COLUMN_NAME,
1849 com.liferay.portal.kernel.dao.orm.Type.LONG);
1850
1851 QueryPos qPos = QueryPos.getInstance(q);
1852
1853 qPos.add(pk);
1854
1855 count = (Long)q.uniqueResult();
1856 }
1857 catch (Exception e) {
1858 throw processException(e);
1859 }
1860 finally {
1861 if (count == null) {
1862 count = Long.valueOf(0);
1863 }
1864
1865 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1866 finderArgs, count);
1867
1868 closeSession(session);
1869 }
1870 }
1871
1872 return count.intValue();
1873 }
1874
1875 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1876 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
1877 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1878 new String[] { Long.class.getName(), Long.class.getName() });
1879
1880
1888 public boolean containsUser(long pk, long userPK) throws SystemException {
1889 Object[] finderArgs = new Object[] { pk, userPK };
1890
1891 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1892 finderArgs, this);
1893
1894 if (value == null) {
1895 try {
1896 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1897 }
1898 catch (Exception e) {
1899 throw processException(e);
1900 }
1901 finally {
1902 if (value == null) {
1903 value = Boolean.FALSE;
1904 }
1905
1906 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1907 finderArgs, value);
1908 }
1909 }
1910
1911 return value.booleanValue();
1912 }
1913
1914
1921 public boolean containsUsers(long pk) throws SystemException {
1922 if (getUsersSize(pk) > 0) {
1923 return true;
1924 }
1925 else {
1926 return false;
1927 }
1928 }
1929
1930
1937 public void addUser(long pk, long userPK) throws SystemException {
1938 try {
1939 addUser.add(pk, userPK);
1940 }
1941 catch (Exception e) {
1942 throw processException(e);
1943 }
1944 finally {
1945 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1946 }
1947 }
1948
1949
1956 public void addUser(long pk, com.liferay.portal.model.User user)
1957 throws SystemException {
1958 try {
1959 addUser.add(pk, user.getPrimaryKey());
1960 }
1961 catch (Exception e) {
1962 throw processException(e);
1963 }
1964 finally {
1965 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1966 }
1967 }
1968
1969
1976 public void addUsers(long pk, long[] userPKs) throws SystemException {
1977 try {
1978 for (long userPK : userPKs) {
1979 addUser.add(pk, userPK);
1980 }
1981 }
1982 catch (Exception e) {
1983 throw processException(e);
1984 }
1985 finally {
1986 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1987 }
1988 }
1989
1990
1997 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1998 throws SystemException {
1999 try {
2000 for (com.liferay.portal.model.User user : users) {
2001 addUser.add(pk, user.getPrimaryKey());
2002 }
2003 }
2004 catch (Exception e) {
2005 throw processException(e);
2006 }
2007 finally {
2008 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2009 }
2010 }
2011
2012
2018 public void clearUsers(long pk) throws SystemException {
2019 try {
2020 clearUsers.clear(pk);
2021 }
2022 catch (Exception e) {
2023 throw processException(e);
2024 }
2025 finally {
2026 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2027 }
2028 }
2029
2030
2037 public void removeUser(long pk, long userPK) throws SystemException {
2038 try {
2039 removeUser.remove(pk, userPK);
2040 }
2041 catch (Exception e) {
2042 throw processException(e);
2043 }
2044 finally {
2045 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2046 }
2047 }
2048
2049
2056 public void removeUser(long pk, com.liferay.portal.model.User user)
2057 throws SystemException {
2058 try {
2059 removeUser.remove(pk, user.getPrimaryKey());
2060 }
2061 catch (Exception e) {
2062 throw processException(e);
2063 }
2064 finally {
2065 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2066 }
2067 }
2068
2069
2076 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2077 try {
2078 for (long userPK : userPKs) {
2079 removeUser.remove(pk, userPK);
2080 }
2081 }
2082 catch (Exception e) {
2083 throw processException(e);
2084 }
2085 finally {
2086 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2087 }
2088 }
2089
2090
2097 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2098 throws SystemException {
2099 try {
2100 for (com.liferay.portal.model.User user : users) {
2101 removeUser.remove(pk, user.getPrimaryKey());
2102 }
2103 }
2104 catch (Exception e) {
2105 throw processException(e);
2106 }
2107 finally {
2108 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2109 }
2110 }
2111
2112
2119 public void setUsers(long pk, long[] userPKs) throws SystemException {
2120 try {
2121 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2122
2123 List<com.liferay.portal.model.User> users = getUsers(pk);
2124
2125 for (com.liferay.portal.model.User user : users) {
2126 if (!userPKSet.remove(user.getPrimaryKey())) {
2127 removeUser.remove(pk, user.getPrimaryKey());
2128 }
2129 }
2130
2131 for (Long userPK : userPKSet) {
2132 addUser.add(pk, userPK);
2133 }
2134 }
2135 catch (Exception e) {
2136 throw processException(e);
2137 }
2138 finally {
2139 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2140 }
2141 }
2142
2143
2150 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2151 throws SystemException {
2152 try {
2153 long[] userPKs = new long[users.size()];
2154
2155 for (int i = 0; i < users.size(); i++) {
2156 com.liferay.portal.model.User user = users.get(i);
2157
2158 userPKs[i] = user.getPrimaryKey();
2159 }
2160
2161 setUsers(pk, userPKs);
2162 }
2163 catch (Exception e) {
2164 throw processException(e);
2165 }
2166 finally {
2167 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2168 }
2169 }
2170
2171
2178 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
2179 throws SystemException {
2180 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2181 }
2182
2183
2196 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2197 int start, int end) throws SystemException {
2198 return getUserGroups(pk, start, end, null);
2199 }
2200
2201 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2202 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
2203 com.liferay.portal.model.impl.UserGroupImpl.class,
2204 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getUserGroups",
2205 new String[] {
2206 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2207 "com.liferay.portal.kernel.util.OrderByComparator"
2208 });
2209
2210 static {
2211 FINDER_PATH_GET_USERGROUPS.setCacheKeyGeneratorCacheName(null);
2212 }
2213
2214
2228 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2229 int start, int end, OrderByComparator orderByComparator)
2230 throws SystemException {
2231 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2232
2233 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
2234 finderArgs, this);
2235
2236 if (list == null) {
2237 Session session = null;
2238
2239 try {
2240 session = openSession();
2241
2242 String sql = null;
2243
2244 if (orderByComparator != null) {
2245 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
2246 .concat(orderByComparator.getOrderBy());
2247 }
2248 else {
2249 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
2250 }
2251
2252 SQLQuery q = session.createSQLQuery(sql);
2253
2254 q.addEntity("UserGroup",
2255 com.liferay.portal.model.impl.UserGroupImpl.class);
2256
2257 QueryPos qPos = QueryPos.getInstance(q);
2258
2259 qPos.add(pk);
2260
2261 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
2262 getDialect(), start, end);
2263 }
2264 catch (Exception e) {
2265 throw processException(e);
2266 }
2267 finally {
2268 if (list == null) {
2269 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
2270 finderArgs);
2271 }
2272 else {
2273 userGroupPersistence.cacheResult(list);
2274
2275 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
2276 finderArgs, list);
2277 }
2278
2279 closeSession(session);
2280 }
2281 }
2282
2283 return list;
2284 }
2285
2286 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2287 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Long.class,
2288 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2289 "getUserGroupsSize", new String[] { Long.class.getName() });
2290
2291 static {
2292 FINDER_PATH_GET_USERGROUPS_SIZE.setCacheKeyGeneratorCacheName(null);
2293 }
2294
2295
2302 public int getUserGroupsSize(long pk) throws SystemException {
2303 Object[] finderArgs = new Object[] { pk };
2304
2305 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2306 finderArgs, this);
2307
2308 if (count == null) {
2309 Session session = null;
2310
2311 try {
2312 session = openSession();
2313
2314 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
2315
2316 q.addScalar(COUNT_COLUMN_NAME,
2317 com.liferay.portal.kernel.dao.orm.Type.LONG);
2318
2319 QueryPos qPos = QueryPos.getInstance(q);
2320
2321 qPos.add(pk);
2322
2323 count = (Long)q.uniqueResult();
2324 }
2325 catch (Exception e) {
2326 throw processException(e);
2327 }
2328 finally {
2329 if (count == null) {
2330 count = Long.valueOf(0);
2331 }
2332
2333 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2334 finderArgs, count);
2335
2336 closeSession(session);
2337 }
2338 }
2339
2340 return count.intValue();
2341 }
2342
2343 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2344 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Boolean.class,
2345 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2346 "containsUserGroup",
2347 new String[] { Long.class.getName(), Long.class.getName() });
2348
2349
2357 public boolean containsUserGroup(long pk, long userGroupPK)
2358 throws SystemException {
2359 Object[] finderArgs = new Object[] { pk, userGroupPK };
2360
2361 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
2362 finderArgs, this);
2363
2364 if (value == null) {
2365 try {
2366 value = Boolean.valueOf(containsUserGroup.contains(pk,
2367 userGroupPK));
2368 }
2369 catch (Exception e) {
2370 throw processException(e);
2371 }
2372 finally {
2373 if (value == null) {
2374 value = Boolean.FALSE;
2375 }
2376
2377 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
2378 finderArgs, value);
2379 }
2380 }
2381
2382 return value.booleanValue();
2383 }
2384
2385
2392 public boolean containsUserGroups(long pk) throws SystemException {
2393 if (getUserGroupsSize(pk) > 0) {
2394 return true;
2395 }
2396 else {
2397 return false;
2398 }
2399 }
2400
2401
2408 public void addUserGroup(long pk, long userGroupPK)
2409 throws SystemException {
2410 try {
2411 addUserGroup.add(pk, userGroupPK);
2412 }
2413 catch (Exception e) {
2414 throw processException(e);
2415 }
2416 finally {
2417 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2418 }
2419 }
2420
2421
2428 public void addUserGroup(long pk,
2429 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2430 try {
2431 addUserGroup.add(pk, userGroup.getPrimaryKey());
2432 }
2433 catch (Exception e) {
2434 throw processException(e);
2435 }
2436 finally {
2437 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2438 }
2439 }
2440
2441
2448 public void addUserGroups(long pk, long[] userGroupPKs)
2449 throws SystemException {
2450 try {
2451 for (long userGroupPK : userGroupPKs) {
2452 addUserGroup.add(pk, userGroupPK);
2453 }
2454 }
2455 catch (Exception e) {
2456 throw processException(e);
2457 }
2458 finally {
2459 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2460 }
2461 }
2462
2463
2470 public void addUserGroups(long pk,
2471 List<com.liferay.portal.model.UserGroup> userGroups)
2472 throws SystemException {
2473 try {
2474 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2475 addUserGroup.add(pk, userGroup.getPrimaryKey());
2476 }
2477 }
2478 catch (Exception e) {
2479 throw processException(e);
2480 }
2481 finally {
2482 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2483 }
2484 }
2485
2486
2492 public void clearUserGroups(long pk) throws SystemException {
2493 try {
2494 clearUserGroups.clear(pk);
2495 }
2496 catch (Exception e) {
2497 throw processException(e);
2498 }
2499 finally {
2500 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2501 }
2502 }
2503
2504
2511 public void removeUserGroup(long pk, long userGroupPK)
2512 throws SystemException {
2513 try {
2514 removeUserGroup.remove(pk, userGroupPK);
2515 }
2516 catch (Exception e) {
2517 throw processException(e);
2518 }
2519 finally {
2520 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2521 }
2522 }
2523
2524
2531 public void removeUserGroup(long pk,
2532 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2533 try {
2534 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2535 }
2536 catch (Exception e) {
2537 throw processException(e);
2538 }
2539 finally {
2540 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2541 }
2542 }
2543
2544
2551 public void removeUserGroups(long pk, long[] userGroupPKs)
2552 throws SystemException {
2553 try {
2554 for (long userGroupPK : userGroupPKs) {
2555 removeUserGroup.remove(pk, userGroupPK);
2556 }
2557 }
2558 catch (Exception e) {
2559 throw processException(e);
2560 }
2561 finally {
2562 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2563 }
2564 }
2565
2566
2573 public void removeUserGroups(long pk,
2574 List<com.liferay.portal.model.UserGroup> userGroups)
2575 throws SystemException {
2576 try {
2577 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2578 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2579 }
2580 }
2581 catch (Exception e) {
2582 throw processException(e);
2583 }
2584 finally {
2585 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2586 }
2587 }
2588
2589
2596 public void setUserGroups(long pk, long[] userGroupPKs)
2597 throws SystemException {
2598 try {
2599 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
2600
2601 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
2602
2603 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2604 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
2605 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2606 }
2607 }
2608
2609 for (Long userGroupPK : userGroupPKSet) {
2610 addUserGroup.add(pk, userGroupPK);
2611 }
2612 }
2613 catch (Exception e) {
2614 throw processException(e);
2615 }
2616 finally {
2617 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2618 }
2619 }
2620
2621
2628 public void setUserGroups(long pk,
2629 List<com.liferay.portal.model.UserGroup> userGroups)
2630 throws SystemException {
2631 try {
2632 long[] userGroupPKs = new long[userGroups.size()];
2633
2634 for (int i = 0; i < userGroups.size(); i++) {
2635 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
2636
2637 userGroupPKs[i] = userGroup.getPrimaryKey();
2638 }
2639
2640 setUserGroups(pk, userGroupPKs);
2641 }
2642 catch (Exception e) {
2643 throw processException(e);
2644 }
2645 finally {
2646 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2647 }
2648 }
2649
2650
2653 public void afterPropertiesSet() {
2654 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2655 com.liferay.portal.util.PropsUtil.get(
2656 "value.object.listener.com.liferay.portal.model.Team")));
2657
2658 if (listenerClassNames.length > 0) {
2659 try {
2660 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
2661
2662 for (String listenerClassName : listenerClassNames) {
2663 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
2664 listenerClassName));
2665 }
2666
2667 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2668 }
2669 catch (Exception e) {
2670 _log.error(e);
2671 }
2672 }
2673
2674 containsUser = new ContainsUser();
2675
2676 addUser = new AddUser();
2677 clearUsers = new ClearUsers();
2678 removeUser = new RemoveUser();
2679
2680 containsUserGroup = new ContainsUserGroup();
2681
2682 addUserGroup = new AddUserGroup();
2683 clearUserGroups = new ClearUserGroups();
2684 removeUserGroup = new RemoveUserGroup();
2685 }
2686
2687 public void destroy() {
2688 EntityCacheUtil.removeCache(TeamImpl.class.getName());
2689 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2690 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2691 }
2692
2693 @BeanReference(type = AccountPersistence.class)
2694 protected AccountPersistence accountPersistence;
2695 @BeanReference(type = AddressPersistence.class)
2696 protected AddressPersistence addressPersistence;
2697 @BeanReference(type = BrowserTrackerPersistence.class)
2698 protected BrowserTrackerPersistence browserTrackerPersistence;
2699 @BeanReference(type = ClassNamePersistence.class)
2700 protected ClassNamePersistence classNamePersistence;
2701 @BeanReference(type = ClusterGroupPersistence.class)
2702 protected ClusterGroupPersistence clusterGroupPersistence;
2703 @BeanReference(type = CompanyPersistence.class)
2704 protected CompanyPersistence companyPersistence;
2705 @BeanReference(type = ContactPersistence.class)
2706 protected ContactPersistence contactPersistence;
2707 @BeanReference(type = CountryPersistence.class)
2708 protected CountryPersistence countryPersistence;
2709 @BeanReference(type = EmailAddressPersistence.class)
2710 protected EmailAddressPersistence emailAddressPersistence;
2711 @BeanReference(type = GroupPersistence.class)
2712 protected GroupPersistence groupPersistence;
2713 @BeanReference(type = ImagePersistence.class)
2714 protected ImagePersistence imagePersistence;
2715 @BeanReference(type = LayoutPersistence.class)
2716 protected LayoutPersistence layoutPersistence;
2717 @BeanReference(type = LayoutBranchPersistence.class)
2718 protected LayoutBranchPersistence layoutBranchPersistence;
2719 @BeanReference(type = LayoutPrototypePersistence.class)
2720 protected LayoutPrototypePersistence layoutPrototypePersistence;
2721 @BeanReference(type = LayoutRevisionPersistence.class)
2722 protected LayoutRevisionPersistence layoutRevisionPersistence;
2723 @BeanReference(type = LayoutSetPersistence.class)
2724 protected LayoutSetPersistence layoutSetPersistence;
2725 @BeanReference(type = LayoutSetBranchPersistence.class)
2726 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2727 @BeanReference(type = LayoutSetPrototypePersistence.class)
2728 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2729 @BeanReference(type = ListTypePersistence.class)
2730 protected ListTypePersistence listTypePersistence;
2731 @BeanReference(type = LockPersistence.class)
2732 protected LockPersistence lockPersistence;
2733 @BeanReference(type = MembershipRequestPersistence.class)
2734 protected MembershipRequestPersistence membershipRequestPersistence;
2735 @BeanReference(type = OrganizationPersistence.class)
2736 protected OrganizationPersistence organizationPersistence;
2737 @BeanReference(type = OrgGroupPermissionPersistence.class)
2738 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2739 @BeanReference(type = OrgGroupRolePersistence.class)
2740 protected OrgGroupRolePersistence orgGroupRolePersistence;
2741 @BeanReference(type = OrgLaborPersistence.class)
2742 protected OrgLaborPersistence orgLaborPersistence;
2743 @BeanReference(type = PasswordPolicyPersistence.class)
2744 protected PasswordPolicyPersistence passwordPolicyPersistence;
2745 @BeanReference(type = PasswordPolicyRelPersistence.class)
2746 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2747 @BeanReference(type = PasswordTrackerPersistence.class)
2748 protected PasswordTrackerPersistence passwordTrackerPersistence;
2749 @BeanReference(type = PermissionPersistence.class)
2750 protected PermissionPersistence permissionPersistence;
2751 @BeanReference(type = PhonePersistence.class)
2752 protected PhonePersistence phonePersistence;
2753 @BeanReference(type = PluginSettingPersistence.class)
2754 protected PluginSettingPersistence pluginSettingPersistence;
2755 @BeanReference(type = PortalPreferencesPersistence.class)
2756 protected PortalPreferencesPersistence portalPreferencesPersistence;
2757 @BeanReference(type = PortletPersistence.class)
2758 protected PortletPersistence portletPersistence;
2759 @BeanReference(type = PortletItemPersistence.class)
2760 protected PortletItemPersistence portletItemPersistence;
2761 @BeanReference(type = PortletPreferencesPersistence.class)
2762 protected PortletPreferencesPersistence portletPreferencesPersistence;
2763 @BeanReference(type = RegionPersistence.class)
2764 protected RegionPersistence regionPersistence;
2765 @BeanReference(type = ReleasePersistence.class)
2766 protected ReleasePersistence releasePersistence;
2767 @BeanReference(type = RepositoryPersistence.class)
2768 protected RepositoryPersistence repositoryPersistence;
2769 @BeanReference(type = RepositoryEntryPersistence.class)
2770 protected RepositoryEntryPersistence repositoryEntryPersistence;
2771 @BeanReference(type = ResourcePersistence.class)
2772 protected ResourcePersistence resourcePersistence;
2773 @BeanReference(type = ResourceActionPersistence.class)
2774 protected ResourceActionPersistence resourceActionPersistence;
2775 @BeanReference(type = ResourceBlockPersistence.class)
2776 protected ResourceBlockPersistence resourceBlockPersistence;
2777 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2778 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2779 @BeanReference(type = ResourceCodePersistence.class)
2780 protected ResourceCodePersistence resourceCodePersistence;
2781 @BeanReference(type = ResourcePermissionPersistence.class)
2782 protected ResourcePermissionPersistence resourcePermissionPersistence;
2783 @BeanReference(type = ResourceTypePermissionPersistence.class)
2784 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2785 @BeanReference(type = RolePersistence.class)
2786 protected RolePersistence rolePersistence;
2787 @BeanReference(type = ServiceComponentPersistence.class)
2788 protected ServiceComponentPersistence serviceComponentPersistence;
2789 @BeanReference(type = ShardPersistence.class)
2790 protected ShardPersistence shardPersistence;
2791 @BeanReference(type = SubscriptionPersistence.class)
2792 protected SubscriptionPersistence subscriptionPersistence;
2793 @BeanReference(type = TeamPersistence.class)
2794 protected TeamPersistence teamPersistence;
2795 @BeanReference(type = TicketPersistence.class)
2796 protected TicketPersistence ticketPersistence;
2797 @BeanReference(type = UserPersistence.class)
2798 protected UserPersistence userPersistence;
2799 @BeanReference(type = UserGroupPersistence.class)
2800 protected UserGroupPersistence userGroupPersistence;
2801 @BeanReference(type = UserGroupGroupRolePersistence.class)
2802 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2803 @BeanReference(type = UserGroupRolePersistence.class)
2804 protected UserGroupRolePersistence userGroupRolePersistence;
2805 @BeanReference(type = UserIdMapperPersistence.class)
2806 protected UserIdMapperPersistence userIdMapperPersistence;
2807 @BeanReference(type = UserNotificationEventPersistence.class)
2808 protected UserNotificationEventPersistence userNotificationEventPersistence;
2809 @BeanReference(type = UserTrackerPersistence.class)
2810 protected UserTrackerPersistence userTrackerPersistence;
2811 @BeanReference(type = UserTrackerPathPersistence.class)
2812 protected UserTrackerPathPersistence userTrackerPathPersistence;
2813 @BeanReference(type = VirtualHostPersistence.class)
2814 protected VirtualHostPersistence virtualHostPersistence;
2815 @BeanReference(type = WebDAVPropsPersistence.class)
2816 protected WebDAVPropsPersistence webDAVPropsPersistence;
2817 @BeanReference(type = WebsitePersistence.class)
2818 protected WebsitePersistence websitePersistence;
2819 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2820 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2821 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2822 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2823 protected ContainsUser containsUser;
2824 protected AddUser addUser;
2825 protected ClearUsers clearUsers;
2826 protected RemoveUser removeUser;
2827 protected ContainsUserGroup containsUserGroup;
2828 protected AddUserGroup addUserGroup;
2829 protected ClearUserGroups clearUserGroups;
2830 protected RemoveUserGroup removeUserGroup;
2831
2832 protected class ContainsUser {
2833 protected ContainsUser() {
2834 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2835 _SQL_CONTAINSUSER,
2836 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2837 RowMapper.COUNT);
2838 }
2839
2840 protected boolean contains(long teamId, long userId) {
2841 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2842 new Long(teamId), new Long(userId)
2843 });
2844
2845 if (results.size() > 0) {
2846 Integer count = results.get(0);
2847
2848 if (count.intValue() > 0) {
2849 return true;
2850 }
2851 }
2852
2853 return false;
2854 }
2855
2856 private MappingSqlQuery<Integer> _mappingSqlQuery;
2857 }
2858
2859 protected class AddUser {
2860 protected AddUser() {
2861 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2862 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2863 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2864 }
2865
2866 protected void add(long teamId, long userId) throws SystemException {
2867 if (!containsUser.contains(teamId, userId)) {
2868 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2869
2870 for (ModelListener<Team> listener : listeners) {
2871 listener.onBeforeAddAssociation(teamId,
2872 com.liferay.portal.model.User.class.getName(), userId);
2873 }
2874
2875 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2876 listener.onBeforeAddAssociation(userId,
2877 Team.class.getName(), teamId);
2878 }
2879
2880 _sqlUpdate.update(new Object[] {
2881 new Long(teamId), new Long(userId)
2882 });
2883
2884 for (ModelListener<Team> listener : listeners) {
2885 listener.onAfterAddAssociation(teamId,
2886 com.liferay.portal.model.User.class.getName(), userId);
2887 }
2888
2889 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2890 listener.onAfterAddAssociation(userId,
2891 Team.class.getName(), teamId);
2892 }
2893 }
2894 }
2895
2896 private SqlUpdate _sqlUpdate;
2897 }
2898
2899 protected class ClearUsers {
2900 protected ClearUsers() {
2901 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2902 "DELETE FROM Users_Teams WHERE teamId = ?",
2903 new int[] { java.sql.Types.BIGINT });
2904 }
2905
2906 protected void clear(long teamId) throws SystemException {
2907 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2908
2909 List<com.liferay.portal.model.User> users = null;
2910
2911 if ((listeners.length > 0) || (userListeners.length > 0)) {
2912 users = getUsers(teamId);
2913
2914 for (com.liferay.portal.model.User user : users) {
2915 for (ModelListener<Team> listener : listeners) {
2916 listener.onBeforeRemoveAssociation(teamId,
2917 com.liferay.portal.model.User.class.getName(),
2918 user.getPrimaryKey());
2919 }
2920
2921 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2922 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2923 Team.class.getName(), teamId);
2924 }
2925 }
2926 }
2927
2928 _sqlUpdate.update(new Object[] { new Long(teamId) });
2929
2930 if ((listeners.length > 0) || (userListeners.length > 0)) {
2931 for (com.liferay.portal.model.User user : users) {
2932 for (ModelListener<Team> listener : listeners) {
2933 listener.onAfterRemoveAssociation(teamId,
2934 com.liferay.portal.model.User.class.getName(),
2935 user.getPrimaryKey());
2936 }
2937
2938 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2939 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2940 Team.class.getName(), teamId);
2941 }
2942 }
2943 }
2944 }
2945
2946 private SqlUpdate _sqlUpdate;
2947 }
2948
2949 protected class RemoveUser {
2950 protected RemoveUser() {
2951 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2952 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2953 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2954 }
2955
2956 protected void remove(long teamId, long userId)
2957 throws SystemException {
2958 if (containsUser.contains(teamId, userId)) {
2959 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2960
2961 for (ModelListener<Team> listener : listeners) {
2962 listener.onBeforeRemoveAssociation(teamId,
2963 com.liferay.portal.model.User.class.getName(), userId);
2964 }
2965
2966 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2967 listener.onBeforeRemoveAssociation(userId,
2968 Team.class.getName(), teamId);
2969 }
2970
2971 _sqlUpdate.update(new Object[] {
2972 new Long(teamId), new Long(userId)
2973 });
2974
2975 for (ModelListener<Team> listener : listeners) {
2976 listener.onAfterRemoveAssociation(teamId,
2977 com.liferay.portal.model.User.class.getName(), userId);
2978 }
2979
2980 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2981 listener.onAfterRemoveAssociation(userId,
2982 Team.class.getName(), teamId);
2983 }
2984 }
2985 }
2986
2987 private SqlUpdate _sqlUpdate;
2988 }
2989
2990 protected class ContainsUserGroup {
2991 protected ContainsUserGroup() {
2992 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2993 _SQL_CONTAINSUSERGROUP,
2994 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2995 RowMapper.COUNT);
2996 }
2997
2998 protected boolean contains(long teamId, long userGroupId) {
2999 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
3000 new Long(teamId), new Long(userGroupId)
3001 });
3002
3003 if (results.size() > 0) {
3004 Integer count = results.get(0);
3005
3006 if (count.intValue() > 0) {
3007 return true;
3008 }
3009 }
3010
3011 return false;
3012 }
3013
3014 private MappingSqlQuery<Integer> _mappingSqlQuery;
3015 }
3016
3017 protected class AddUserGroup {
3018 protected AddUserGroup() {
3019 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3020 "INSERT INTO UserGroups_Teams (teamId, userGroupId) VALUES (?, ?)",
3021 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3022 }
3023
3024 protected void add(long teamId, long userGroupId)
3025 throws SystemException {
3026 if (!containsUserGroup.contains(teamId, userGroupId)) {
3027 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3028 userGroupPersistence.getListeners();
3029
3030 for (ModelListener<Team> listener : listeners) {
3031 listener.onBeforeAddAssociation(teamId,
3032 com.liferay.portal.model.UserGroup.class.getName(),
3033 userGroupId);
3034 }
3035
3036 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3037 listener.onBeforeAddAssociation(userGroupId,
3038 Team.class.getName(), teamId);
3039 }
3040
3041 _sqlUpdate.update(new Object[] {
3042 new Long(teamId), new Long(userGroupId)
3043 });
3044
3045 for (ModelListener<Team> listener : listeners) {
3046 listener.onAfterAddAssociation(teamId,
3047 com.liferay.portal.model.UserGroup.class.getName(),
3048 userGroupId);
3049 }
3050
3051 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3052 listener.onAfterAddAssociation(userGroupId,
3053 Team.class.getName(), teamId);
3054 }
3055 }
3056 }
3057
3058 private SqlUpdate _sqlUpdate;
3059 }
3060
3061 protected class ClearUserGroups {
3062 protected ClearUserGroups() {
3063 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3064 "DELETE FROM UserGroups_Teams WHERE teamId = ?",
3065 new int[] { java.sql.Types.BIGINT });
3066 }
3067
3068 protected void clear(long teamId) throws SystemException {
3069 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3070 userGroupPersistence.getListeners();
3071
3072 List<com.liferay.portal.model.UserGroup> userGroups = null;
3073
3074 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3075 userGroups = getUserGroups(teamId);
3076
3077 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3078 for (ModelListener<Team> listener : listeners) {
3079 listener.onBeforeRemoveAssociation(teamId,
3080 com.liferay.portal.model.UserGroup.class.getName(),
3081 userGroup.getPrimaryKey());
3082 }
3083
3084 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3085 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
3086 Team.class.getName(), teamId);
3087 }
3088 }
3089 }
3090
3091 _sqlUpdate.update(new Object[] { new Long(teamId) });
3092
3093 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3094 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3095 for (ModelListener<Team> listener : listeners) {
3096 listener.onAfterRemoveAssociation(teamId,
3097 com.liferay.portal.model.UserGroup.class.getName(),
3098 userGroup.getPrimaryKey());
3099 }
3100
3101 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3102 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
3103 Team.class.getName(), teamId);
3104 }
3105 }
3106 }
3107 }
3108
3109 private SqlUpdate _sqlUpdate;
3110 }
3111
3112 protected class RemoveUserGroup {
3113 protected RemoveUserGroup() {
3114 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3115 "DELETE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?",
3116 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3117 }
3118
3119 protected void remove(long teamId, long userGroupId)
3120 throws SystemException {
3121 if (containsUserGroup.contains(teamId, userGroupId)) {
3122 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3123 userGroupPersistence.getListeners();
3124
3125 for (ModelListener<Team> listener : listeners) {
3126 listener.onBeforeRemoveAssociation(teamId,
3127 com.liferay.portal.model.UserGroup.class.getName(),
3128 userGroupId);
3129 }
3130
3131 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3132 listener.onBeforeRemoveAssociation(userGroupId,
3133 Team.class.getName(), teamId);
3134 }
3135
3136 _sqlUpdate.update(new Object[] {
3137 new Long(teamId), new Long(userGroupId)
3138 });
3139
3140 for (ModelListener<Team> listener : listeners) {
3141 listener.onAfterRemoveAssociation(teamId,
3142 com.liferay.portal.model.UserGroup.class.getName(),
3143 userGroupId);
3144 }
3145
3146 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3147 listener.onAfterRemoveAssociation(userGroupId,
3148 Team.class.getName(), teamId);
3149 }
3150 }
3151 }
3152
3153 private SqlUpdate _sqlUpdate;
3154 }
3155
3156 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
3157 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
3158 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
3159 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
3160 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
3161 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
3162 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
3163 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN UserGroups_Teams ON (UserGroups_Teams.userGroupId = UserGroup.userGroupId) WHERE (UserGroups_Teams.teamId = ?)";
3164 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ?";
3165 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?";
3166 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
3167 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
3168 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
3169 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
3170 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
3171 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId";
3172 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
3173 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
3174 "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
3175 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
3176 ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
3177 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
3178 private static final String _FILTER_ENTITY_ALIAS = "team";
3179 private static final String _FILTER_ENTITY_TABLE = "Team";
3180 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
3181 private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
3182 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
3183 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
3184 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3185 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
3186 private static Team _nullTeam = new TeamImpl() {
3187 @Override
3188 public Object clone() {
3189 return this;
3190 }
3191
3192 @Override
3193 public CacheModel<Team> toCacheModel() {
3194 return _nullTeamCacheModel;
3195 }
3196 };
3197
3198 private static CacheModel<Team> _nullTeamCacheModel = new CacheModel<Team>() {
3199 public Team toEntityModel() {
3200 return _nullTeam;
3201 }
3202 };
3203 }