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.model.CacheModel;
045 import com.liferay.portal.model.ModelListener;
046 import com.liferay.portal.model.Team;
047 import com.liferay.portal.model.impl.TeamImpl;
048 import com.liferay.portal.model.impl.TeamModelImpl;
049 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
050 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057 import java.util.Set;
058
059
071 public class TeamPersistenceImpl extends BasePersistenceImpl<Team>
072 implements TeamPersistence {
073
078 public static final String FINDER_CLASS_NAME_ENTITY = TeamImpl.class.getName();
079 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
080 ".List1";
081 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
082 ".List2";
083 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
084 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
085 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
086 new String[] {
087 Long.class.getName(),
088
089 "java.lang.Integer", "java.lang.Integer",
090 "com.liferay.portal.kernel.util.OrderByComparator"
091 });
092 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
093 new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
094 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
095 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
096 new String[] { Long.class.getName() },
097 TeamModelImpl.GROUPID_COLUMN_BITMASK);
098 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
099 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
100 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
101 new String[] { Long.class.getName() });
102 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
103 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
104 FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
105 new String[] { Long.class.getName(), String.class.getName() },
106 TeamModelImpl.GROUPID_COLUMN_BITMASK |
107 TeamModelImpl.NAME_COLUMN_BITMASK);
108 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
109 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
110 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
111 new String[] { Long.class.getName(), String.class.getName() });
112 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
113 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
114 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
115 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
116 TeamModelImpl.FINDER_CACHE_ENABLED, TeamImpl.class,
117 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
118 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
119 TeamModelImpl.FINDER_CACHE_ENABLED, Long.class,
120 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
121
122
127 public void cacheResult(Team team) {
128 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
129 TeamImpl.class, team.getPrimaryKey(), team);
130
131 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
132 new Object[] { Long.valueOf(team.getGroupId()), team.getName() },
133 team);
134
135 team.resetOriginalValues();
136 }
137
138
143 public void cacheResult(List<Team> teams) {
144 for (Team team : teams) {
145 if (EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
146 TeamImpl.class, team.getPrimaryKey()) == null) {
147 cacheResult(team);
148 }
149 else {
150 team.resetOriginalValues();
151 }
152 }
153 }
154
155
162 @Override
163 public void clearCache() {
164 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
165 CacheRegistryUtil.clear(TeamImpl.class.getName());
166 }
167
168 EntityCacheUtil.clearCache(TeamImpl.class.getName());
169
170 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
171 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
172 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
173 }
174
175
182 @Override
183 public void clearCache(Team team) {
184 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
185 TeamImpl.class, team.getPrimaryKey());
186
187 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
188 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
189
190 clearUniqueFindersCache(team);
191 }
192
193 @Override
194 public void clearCache(List<Team> teams) {
195 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
196 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
197
198 for (Team team : teams) {
199 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
200 TeamImpl.class, team.getPrimaryKey());
201
202 clearUniqueFindersCache(team);
203 }
204 }
205
206 protected void clearUniqueFindersCache(Team team) {
207 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
208 new Object[] { Long.valueOf(team.getGroupId()), team.getName() });
209 }
210
211
217 public Team create(long teamId) {
218 Team team = new TeamImpl();
219
220 team.setNew(true);
221 team.setPrimaryKey(teamId);
222
223 return team;
224 }
225
226
234 public Team remove(long teamId) throws NoSuchTeamException, SystemException {
235 return remove(Long.valueOf(teamId));
236 }
237
238
246 @Override
247 public Team remove(Serializable primaryKey)
248 throws NoSuchTeamException, SystemException {
249 Session session = null;
250
251 try {
252 session = openSession();
253
254 Team team = (Team)session.get(TeamImpl.class, primaryKey);
255
256 if (team == null) {
257 if (_log.isWarnEnabled()) {
258 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
259 }
260
261 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262 primaryKey);
263 }
264
265 return remove(team);
266 }
267 catch (NoSuchTeamException nsee) {
268 throw nsee;
269 }
270 catch (Exception e) {
271 throw processException(e);
272 }
273 finally {
274 closeSession(session);
275 }
276 }
277
278 @Override
279 protected Team removeImpl(Team team) throws SystemException {
280 team = toUnwrappedModel(team);
281
282 try {
283 clearUsers.clear(team.getPrimaryKey());
284 }
285 catch (Exception e) {
286 throw processException(e);
287 }
288 finally {
289 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
290 }
291
292 try {
293 clearUserGroups.clear(team.getPrimaryKey());
294 }
295 catch (Exception e) {
296 throw processException(e);
297 }
298 finally {
299 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
300 }
301
302 Session session = null;
303
304 try {
305 session = openSession();
306
307 BatchSessionUtil.delete(session, team);
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315
316 clearCache(team);
317
318 return team;
319 }
320
321 @Override
322 public Team updateImpl(com.liferay.portal.model.Team team, boolean merge)
323 throws SystemException {
324 team = toUnwrappedModel(team);
325
326 boolean isNew = team.isNew();
327
328 TeamModelImpl teamModelImpl = (TeamModelImpl)team;
329
330 Session session = null;
331
332 try {
333 session = openSession();
334
335 BatchSessionUtil.update(session, team, merge);
336
337 team.setNew(false);
338 }
339 catch (Exception e) {
340 throw processException(e);
341 }
342 finally {
343 closeSession(session);
344 }
345
346 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
347
348 if (isNew || !TeamModelImpl.COLUMN_BITMASK_ENABLED) {
349 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
350 }
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) {
582 StringBundler query = null;
583
584 if (orderByComparator != null) {
585 query = new StringBundler(3 +
586 (orderByComparator.getOrderByFields().length * 3));
587 }
588 else {
589 query = new StringBundler(3);
590 }
591
592 query.append(_SQL_SELECT_TEAM_WHERE);
593
594 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
595
596 if (orderByComparator != null) {
597 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
598 orderByComparator);
599 }
600
601 else {
602 query.append(TeamModelImpl.ORDER_BY_JPQL);
603 }
604
605 String sql = query.toString();
606
607 Session session = null;
608
609 try {
610 session = openSession();
611
612 Query q = session.createQuery(sql);
613
614 QueryPos qPos = QueryPos.getInstance(q);
615
616 qPos.add(groupId);
617
618 list = (List<Team>)QueryUtil.list(q, getDialect(), start, end);
619 }
620 catch (Exception e) {
621 throw processException(e);
622 }
623 finally {
624 if (list == null) {
625 FinderCacheUtil.removeResult(finderPath, finderArgs);
626 }
627 else {
628 cacheResult(list);
629
630 FinderCacheUtil.putResult(finderPath, finderArgs, list);
631 }
632
633 closeSession(session);
634 }
635 }
636
637 return list;
638 }
639
640
653 public Team findByGroupId_First(long groupId,
654 OrderByComparator orderByComparator)
655 throws NoSuchTeamException, SystemException {
656 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
657
658 if (list.isEmpty()) {
659 StringBundler msg = new StringBundler(4);
660
661 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
662
663 msg.append("groupId=");
664 msg.append(groupId);
665
666 msg.append(StringPool.CLOSE_CURLY_BRACE);
667
668 throw new NoSuchTeamException(msg.toString());
669 }
670 else {
671 return list.get(0);
672 }
673 }
674
675
688 public Team findByGroupId_Last(long groupId,
689 OrderByComparator orderByComparator)
690 throws NoSuchTeamException, SystemException {
691 int count = countByGroupId(groupId);
692
693 List<Team> list = findByGroupId(groupId, count - 1, count,
694 orderByComparator);
695
696 if (list.isEmpty()) {
697 StringBundler msg = new StringBundler(4);
698
699 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
700
701 msg.append("groupId=");
702 msg.append(groupId);
703
704 msg.append(StringPool.CLOSE_CURLY_BRACE);
705
706 throw new NoSuchTeamException(msg.toString());
707 }
708 else {
709 return list.get(0);
710 }
711 }
712
713
727 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
728 OrderByComparator orderByComparator)
729 throws NoSuchTeamException, SystemException {
730 Team team = findByPrimaryKey(teamId);
731
732 Session session = null;
733
734 try {
735 session = openSession();
736
737 Team[] array = new TeamImpl[3];
738
739 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
740 orderByComparator, true);
741
742 array[1] = team;
743
744 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
745 orderByComparator, false);
746
747 return array;
748 }
749 catch (Exception e) {
750 throw processException(e);
751 }
752 finally {
753 closeSession(session);
754 }
755 }
756
757 protected Team getByGroupId_PrevAndNext(Session session, Team team,
758 long groupId, OrderByComparator orderByComparator, boolean previous) {
759 StringBundler query = null;
760
761 if (orderByComparator != null) {
762 query = new StringBundler(6 +
763 (orderByComparator.getOrderByFields().length * 6));
764 }
765 else {
766 query = new StringBundler(3);
767 }
768
769 query.append(_SQL_SELECT_TEAM_WHERE);
770
771 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
772
773 if (orderByComparator != null) {
774 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
775
776 if (orderByConditionFields.length > 0) {
777 query.append(WHERE_AND);
778 }
779
780 for (int i = 0; i < orderByConditionFields.length; i++) {
781 query.append(_ORDER_BY_ENTITY_ALIAS);
782 query.append(orderByConditionFields[i]);
783
784 if ((i + 1) < orderByConditionFields.length) {
785 if (orderByComparator.isAscending() ^ previous) {
786 query.append(WHERE_GREATER_THAN_HAS_NEXT);
787 }
788 else {
789 query.append(WHERE_LESSER_THAN_HAS_NEXT);
790 }
791 }
792 else {
793 if (orderByComparator.isAscending() ^ previous) {
794 query.append(WHERE_GREATER_THAN);
795 }
796 else {
797 query.append(WHERE_LESSER_THAN);
798 }
799 }
800 }
801
802 query.append(ORDER_BY_CLAUSE);
803
804 String[] orderByFields = orderByComparator.getOrderByFields();
805
806 for (int i = 0; i < orderByFields.length; i++) {
807 query.append(_ORDER_BY_ENTITY_ALIAS);
808 query.append(orderByFields[i]);
809
810 if ((i + 1) < orderByFields.length) {
811 if (orderByComparator.isAscending() ^ previous) {
812 query.append(ORDER_BY_ASC_HAS_NEXT);
813 }
814 else {
815 query.append(ORDER_BY_DESC_HAS_NEXT);
816 }
817 }
818 else {
819 if (orderByComparator.isAscending() ^ previous) {
820 query.append(ORDER_BY_ASC);
821 }
822 else {
823 query.append(ORDER_BY_DESC);
824 }
825 }
826 }
827 }
828
829 else {
830 query.append(TeamModelImpl.ORDER_BY_JPQL);
831 }
832
833 String sql = query.toString();
834
835 Query q = session.createQuery(sql);
836
837 q.setFirstResult(0);
838 q.setMaxResults(2);
839
840 QueryPos qPos = QueryPos.getInstance(q);
841
842 qPos.add(groupId);
843
844 if (orderByComparator != null) {
845 Object[] values = orderByComparator.getOrderByConditionValues(team);
846
847 for (Object value : values) {
848 qPos.add(value);
849 }
850 }
851
852 List<Team> list = q.list();
853
854 if (list.size() == 2) {
855 return list.get(1);
856 }
857 else {
858 return null;
859 }
860 }
861
862
869 public List<Team> filterFindByGroupId(long groupId)
870 throws SystemException {
871 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
872 QueryUtil.ALL_POS, null);
873 }
874
875
888 public List<Team> filterFindByGroupId(long groupId, int start, int end)
889 throws SystemException {
890 return filterFindByGroupId(groupId, start, end, null);
891 }
892
893
907 public List<Team> filterFindByGroupId(long groupId, int start, int end,
908 OrderByComparator orderByComparator) throws SystemException {
909 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
910 return findByGroupId(groupId, start, end, orderByComparator);
911 }
912
913 StringBundler query = null;
914
915 if (orderByComparator != null) {
916 query = new StringBundler(3 +
917 (orderByComparator.getOrderByFields().length * 3));
918 }
919 else {
920 query = new StringBundler(3);
921 }
922
923 if (getDB().isSupportsInlineDistinct()) {
924 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
925 }
926 else {
927 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
928 }
929
930 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
931
932 if (!getDB().isSupportsInlineDistinct()) {
933 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
934 }
935
936 if (orderByComparator != null) {
937 if (getDB().isSupportsInlineDistinct()) {
938 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
939 orderByComparator);
940 }
941 else {
942 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
943 orderByComparator);
944 }
945 }
946
947 else {
948 if (getDB().isSupportsInlineDistinct()) {
949 query.append(TeamModelImpl.ORDER_BY_JPQL);
950 }
951 else {
952 query.append(TeamModelImpl.ORDER_BY_SQL);
953 }
954 }
955
956 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
957 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
958 groupId);
959
960 Session session = null;
961
962 try {
963 session = openSession();
964
965 SQLQuery q = session.createSQLQuery(sql);
966
967 if (getDB().isSupportsInlineDistinct()) {
968 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
969 }
970 else {
971 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
972 }
973
974 QueryPos qPos = QueryPos.getInstance(q);
975
976 qPos.add(groupId);
977
978 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
979 }
980 catch (Exception e) {
981 throw processException(e);
982 }
983 finally {
984 closeSession(session);
985 }
986 }
987
988
998 public Team[] filterFindByGroupId_PrevAndNext(long teamId, long groupId,
999 OrderByComparator orderByComparator)
1000 throws NoSuchTeamException, SystemException {
1001 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1002 return findByGroupId_PrevAndNext(teamId, groupId, orderByComparator);
1003 }
1004
1005 Team team = findByPrimaryKey(teamId);
1006
1007 Session session = null;
1008
1009 try {
1010 session = openSession();
1011
1012 Team[] array = new TeamImpl[3];
1013
1014 array[0] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1015 orderByComparator, true);
1016
1017 array[1] = team;
1018
1019 array[2] = filterGetByGroupId_PrevAndNext(session, team, groupId,
1020 orderByComparator, false);
1021
1022 return array;
1023 }
1024 catch (Exception e) {
1025 throw processException(e);
1026 }
1027 finally {
1028 closeSession(session);
1029 }
1030 }
1031
1032 protected Team filterGetByGroupId_PrevAndNext(Session session, Team team,
1033 long groupId, OrderByComparator orderByComparator, boolean previous) {
1034 StringBundler query = null;
1035
1036 if (orderByComparator != null) {
1037 query = new StringBundler(6 +
1038 (orderByComparator.getOrderByFields().length * 6));
1039 }
1040 else {
1041 query = new StringBundler(3);
1042 }
1043
1044 if (getDB().isSupportsInlineDistinct()) {
1045 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
1046 }
1047 else {
1048 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
1049 }
1050
1051 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1052
1053 if (!getDB().isSupportsInlineDistinct()) {
1054 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
1055 }
1056
1057 if (orderByComparator != null) {
1058 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1059
1060 if (orderByConditionFields.length > 0) {
1061 query.append(WHERE_AND);
1062 }
1063
1064 for (int i = 0; i < orderByConditionFields.length; i++) {
1065 if (getDB().isSupportsInlineDistinct()) {
1066 query.append(_ORDER_BY_ENTITY_ALIAS);
1067 }
1068 else {
1069 query.append(_ORDER_BY_ENTITY_TABLE);
1070 }
1071
1072 query.append(orderByConditionFields[i]);
1073
1074 if ((i + 1) < orderByConditionFields.length) {
1075 if (orderByComparator.isAscending() ^ previous) {
1076 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1077 }
1078 else {
1079 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1080 }
1081 }
1082 else {
1083 if (orderByComparator.isAscending() ^ previous) {
1084 query.append(WHERE_GREATER_THAN);
1085 }
1086 else {
1087 query.append(WHERE_LESSER_THAN);
1088 }
1089 }
1090 }
1091
1092 query.append(ORDER_BY_CLAUSE);
1093
1094 String[] orderByFields = orderByComparator.getOrderByFields();
1095
1096 for (int i = 0; i < orderByFields.length; i++) {
1097 if (getDB().isSupportsInlineDistinct()) {
1098 query.append(_ORDER_BY_ENTITY_ALIAS);
1099 }
1100 else {
1101 query.append(_ORDER_BY_ENTITY_TABLE);
1102 }
1103
1104 query.append(orderByFields[i]);
1105
1106 if ((i + 1) < orderByFields.length) {
1107 if (orderByComparator.isAscending() ^ previous) {
1108 query.append(ORDER_BY_ASC_HAS_NEXT);
1109 }
1110 else {
1111 query.append(ORDER_BY_DESC_HAS_NEXT);
1112 }
1113 }
1114 else {
1115 if (orderByComparator.isAscending() ^ previous) {
1116 query.append(ORDER_BY_ASC);
1117 }
1118 else {
1119 query.append(ORDER_BY_DESC);
1120 }
1121 }
1122 }
1123 }
1124
1125 else {
1126 if (getDB().isSupportsInlineDistinct()) {
1127 query.append(TeamModelImpl.ORDER_BY_JPQL);
1128 }
1129 else {
1130 query.append(TeamModelImpl.ORDER_BY_SQL);
1131 }
1132 }
1133
1134 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1135 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1136 groupId);
1137
1138 SQLQuery q = session.createSQLQuery(sql);
1139
1140 q.setFirstResult(0);
1141 q.setMaxResults(2);
1142
1143 if (getDB().isSupportsInlineDistinct()) {
1144 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
1145 }
1146 else {
1147 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
1148 }
1149
1150 QueryPos qPos = QueryPos.getInstance(q);
1151
1152 qPos.add(groupId);
1153
1154 if (orderByComparator != null) {
1155 Object[] values = orderByComparator.getOrderByConditionValues(team);
1156
1157 for (Object value : values) {
1158 qPos.add(value);
1159 }
1160 }
1161
1162 List<Team> list = q.list();
1163
1164 if (list.size() == 2) {
1165 return list.get(1);
1166 }
1167 else {
1168 return null;
1169 }
1170 }
1171
1172
1181 public Team findByG_N(long groupId, String name)
1182 throws NoSuchTeamException, SystemException {
1183 Team team = fetchByG_N(groupId, name);
1184
1185 if (team == null) {
1186 StringBundler msg = new StringBundler(6);
1187
1188 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1189
1190 msg.append("groupId=");
1191 msg.append(groupId);
1192
1193 msg.append(", name=");
1194 msg.append(name);
1195
1196 msg.append(StringPool.CLOSE_CURLY_BRACE);
1197
1198 if (_log.isWarnEnabled()) {
1199 _log.warn(msg.toString());
1200 }
1201
1202 throw new NoSuchTeamException(msg.toString());
1203 }
1204
1205 return team;
1206 }
1207
1208
1216 public Team fetchByG_N(long groupId, String name) throws SystemException {
1217 return fetchByG_N(groupId, name, true);
1218 }
1219
1220
1229 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
1230 throws SystemException {
1231 Object[] finderArgs = new Object[] { groupId, name };
1232
1233 Object result = null;
1234
1235 if (retrieveFromCache) {
1236 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
1237 finderArgs, this);
1238 }
1239
1240 if (result == null) {
1241 StringBundler query = new StringBundler(4);
1242
1243 query.append(_SQL_SELECT_TEAM_WHERE);
1244
1245 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1246
1247 if (name == null) {
1248 query.append(_FINDER_COLUMN_G_N_NAME_1);
1249 }
1250 else {
1251 if (name.equals(StringPool.BLANK)) {
1252 query.append(_FINDER_COLUMN_G_N_NAME_3);
1253 }
1254 else {
1255 query.append(_FINDER_COLUMN_G_N_NAME_2);
1256 }
1257 }
1258
1259 query.append(TeamModelImpl.ORDER_BY_JPQL);
1260
1261 String sql = query.toString();
1262
1263 Session session = null;
1264
1265 try {
1266 session = openSession();
1267
1268 Query q = session.createQuery(sql);
1269
1270 QueryPos qPos = QueryPos.getInstance(q);
1271
1272 qPos.add(groupId);
1273
1274 if (name != null) {
1275 qPos.add(name);
1276 }
1277
1278 List<Team> list = q.list();
1279
1280 result = list;
1281
1282 Team team = null;
1283
1284 if (list.isEmpty()) {
1285 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1286 finderArgs, list);
1287 }
1288 else {
1289 team = list.get(0);
1290
1291 cacheResult(team);
1292
1293 if ((team.getGroupId() != groupId) ||
1294 (team.getName() == null) ||
1295 !team.getName().equals(name)) {
1296 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1297 finderArgs, team);
1298 }
1299 }
1300
1301 return team;
1302 }
1303 catch (Exception e) {
1304 throw processException(e);
1305 }
1306 finally {
1307 if (result == null) {
1308 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1309 finderArgs);
1310 }
1311
1312 closeSession(session);
1313 }
1314 }
1315 else {
1316 if (result instanceof List<?>) {
1317 return null;
1318 }
1319 else {
1320 return (Team)result;
1321 }
1322 }
1323 }
1324
1325
1331 public List<Team> findAll() throws SystemException {
1332 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1333 }
1334
1335
1347 public List<Team> findAll(int start, int end) throws SystemException {
1348 return findAll(start, end, null);
1349 }
1350
1351
1364 public List<Team> findAll(int start, int end,
1365 OrderByComparator orderByComparator) throws SystemException {
1366 FinderPath finderPath = null;
1367 Object[] finderArgs = new Object[] { start, end, orderByComparator };
1368
1369 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1370 (orderByComparator == null)) {
1371 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1372 finderArgs = FINDER_ARGS_EMPTY;
1373 }
1374 else {
1375 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1376 finderArgs = new Object[] { start, end, orderByComparator };
1377 }
1378
1379 List<Team> list = (List<Team>)FinderCacheUtil.getResult(finderPath,
1380 finderArgs, this);
1381
1382 if (list == null) {
1383 StringBundler query = null;
1384 String sql = null;
1385
1386 if (orderByComparator != null) {
1387 query = new StringBundler(2 +
1388 (orderByComparator.getOrderByFields().length * 3));
1389
1390 query.append(_SQL_SELECT_TEAM);
1391
1392 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1393 orderByComparator);
1394
1395 sql = query.toString();
1396 }
1397 else {
1398 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1399 }
1400
1401 Session session = null;
1402
1403 try {
1404 session = openSession();
1405
1406 Query q = session.createQuery(sql);
1407
1408 if (orderByComparator == null) {
1409 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1410 end, false);
1411
1412 Collections.sort(list);
1413 }
1414 else {
1415 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1416 end);
1417 }
1418 }
1419 catch (Exception e) {
1420 throw processException(e);
1421 }
1422 finally {
1423 if (list == null) {
1424 FinderCacheUtil.removeResult(finderPath, finderArgs);
1425 }
1426 else {
1427 cacheResult(list);
1428
1429 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1430 }
1431
1432 closeSession(session);
1433 }
1434 }
1435
1436 return list;
1437 }
1438
1439
1445 public void removeByGroupId(long groupId) throws SystemException {
1446 for (Team team : findByGroupId(groupId)) {
1447 remove(team);
1448 }
1449 }
1450
1451
1458 public void removeByG_N(long groupId, String name)
1459 throws NoSuchTeamException, SystemException {
1460 Team team = findByG_N(groupId, name);
1461
1462 remove(team);
1463 }
1464
1465
1470 public void removeAll() throws SystemException {
1471 for (Team team : findAll()) {
1472 remove(team);
1473 }
1474 }
1475
1476
1483 public int countByGroupId(long groupId) throws SystemException {
1484 Object[] finderArgs = new Object[] { groupId };
1485
1486 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1487 finderArgs, this);
1488
1489 if (count == null) {
1490 StringBundler query = new StringBundler(2);
1491
1492 query.append(_SQL_COUNT_TEAM_WHERE);
1493
1494 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1495
1496 String sql = query.toString();
1497
1498 Session session = null;
1499
1500 try {
1501 session = openSession();
1502
1503 Query q = session.createQuery(sql);
1504
1505 QueryPos qPos = QueryPos.getInstance(q);
1506
1507 qPos.add(groupId);
1508
1509 count = (Long)q.uniqueResult();
1510 }
1511 catch (Exception e) {
1512 throw processException(e);
1513 }
1514 finally {
1515 if (count == null) {
1516 count = Long.valueOf(0);
1517 }
1518
1519 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1520 finderArgs, count);
1521
1522 closeSession(session);
1523 }
1524 }
1525
1526 return count.intValue();
1527 }
1528
1529
1536 public int filterCountByGroupId(long groupId) throws SystemException {
1537 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1538 return countByGroupId(groupId);
1539 }
1540
1541 StringBundler query = new StringBundler(2);
1542
1543 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1544
1545 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1546
1547 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1548 Team.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN,
1549 groupId);
1550
1551 Session session = null;
1552
1553 try {
1554 session = openSession();
1555
1556 SQLQuery q = session.createSQLQuery(sql);
1557
1558 q.addScalar(COUNT_COLUMN_NAME,
1559 com.liferay.portal.kernel.dao.orm.Type.LONG);
1560
1561 QueryPos qPos = QueryPos.getInstance(q);
1562
1563 qPos.add(groupId);
1564
1565 Long count = (Long)q.uniqueResult();
1566
1567 return count.intValue();
1568 }
1569 catch (Exception e) {
1570 throw processException(e);
1571 }
1572 finally {
1573 closeSession(session);
1574 }
1575 }
1576
1577
1585 public int countByG_N(long groupId, String name) throws SystemException {
1586 Object[] finderArgs = new Object[] { groupId, name };
1587
1588 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1589 finderArgs, this);
1590
1591 if (count == null) {
1592 StringBundler query = new StringBundler(3);
1593
1594 query.append(_SQL_COUNT_TEAM_WHERE);
1595
1596 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1597
1598 if (name == null) {
1599 query.append(_FINDER_COLUMN_G_N_NAME_1);
1600 }
1601 else {
1602 if (name.equals(StringPool.BLANK)) {
1603 query.append(_FINDER_COLUMN_G_N_NAME_3);
1604 }
1605 else {
1606 query.append(_FINDER_COLUMN_G_N_NAME_2);
1607 }
1608 }
1609
1610 String sql = query.toString();
1611
1612 Session session = null;
1613
1614 try {
1615 session = openSession();
1616
1617 Query q = session.createQuery(sql);
1618
1619 QueryPos qPos = QueryPos.getInstance(q);
1620
1621 qPos.add(groupId);
1622
1623 if (name != null) {
1624 qPos.add(name);
1625 }
1626
1627 count = (Long)q.uniqueResult();
1628 }
1629 catch (Exception e) {
1630 throw processException(e);
1631 }
1632 finally {
1633 if (count == null) {
1634 count = Long.valueOf(0);
1635 }
1636
1637 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1638 count);
1639
1640 closeSession(session);
1641 }
1642 }
1643
1644 return count.intValue();
1645 }
1646
1647
1653 public int countAll() throws SystemException {
1654 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1655 FINDER_ARGS_EMPTY, this);
1656
1657 if (count == null) {
1658 Session session = null;
1659
1660 try {
1661 session = openSession();
1662
1663 Query q = session.createQuery(_SQL_COUNT_TEAM);
1664
1665 count = (Long)q.uniqueResult();
1666 }
1667 catch (Exception e) {
1668 throw processException(e);
1669 }
1670 finally {
1671 if (count == null) {
1672 count = Long.valueOf(0);
1673 }
1674
1675 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
1676 FINDER_ARGS_EMPTY, count);
1677
1678 closeSession(session);
1679 }
1680 }
1681
1682 return count.intValue();
1683 }
1684
1685
1692 public List<com.liferay.portal.model.User> getUsers(long pk)
1693 throws SystemException {
1694 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1695 }
1696
1697
1710 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1711 int end) throws SystemException {
1712 return getUsers(pk, start, end, null);
1713 }
1714
1715 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1716 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1717 com.liferay.portal.model.impl.UserImpl.class,
1718 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1719 new String[] {
1720 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1721 "com.liferay.portal.kernel.util.OrderByComparator"
1722 });
1723
1724
1738 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1739 int end, OrderByComparator orderByComparator) throws SystemException {
1740 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
1741
1742 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1743 finderArgs, this);
1744
1745 if (list == null) {
1746 Session session = null;
1747
1748 try {
1749 session = openSession();
1750
1751 String sql = null;
1752
1753 if (orderByComparator != null) {
1754 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1755 .concat(orderByComparator.getOrderBy());
1756 }
1757 else {
1758 sql = _SQL_GETUSERS;
1759 }
1760
1761 SQLQuery q = session.createSQLQuery(sql);
1762
1763 q.addEntity("User_",
1764 com.liferay.portal.model.impl.UserImpl.class);
1765
1766 QueryPos qPos = QueryPos.getInstance(q);
1767
1768 qPos.add(pk);
1769
1770 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1771 getDialect(), start, end);
1772 }
1773 catch (Exception e) {
1774 throw processException(e);
1775 }
1776 finally {
1777 if (list == null) {
1778 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
1779 finderArgs);
1780 }
1781 else {
1782 userPersistence.cacheResult(list);
1783
1784 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
1785 finderArgs, list);
1786 }
1787
1788 closeSession(session);
1789 }
1790 }
1791
1792 return list;
1793 }
1794
1795 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1796 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Long.class,
1797 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1798 new String[] { Long.class.getName() });
1799
1800
1807 public int getUsersSize(long pk) throws SystemException {
1808 Object[] finderArgs = new Object[] { pk };
1809
1810 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1811 finderArgs, this);
1812
1813 if (count == null) {
1814 Session session = null;
1815
1816 try {
1817 session = openSession();
1818
1819 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1820
1821 q.addScalar(COUNT_COLUMN_NAME,
1822 com.liferay.portal.kernel.dao.orm.Type.LONG);
1823
1824 QueryPos qPos = QueryPos.getInstance(q);
1825
1826 qPos.add(pk);
1827
1828 count = (Long)q.uniqueResult();
1829 }
1830 catch (Exception e) {
1831 throw processException(e);
1832 }
1833 finally {
1834 if (count == null) {
1835 count = Long.valueOf(0);
1836 }
1837
1838 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1839 finderArgs, count);
1840
1841 closeSession(session);
1842 }
1843 }
1844
1845 return count.intValue();
1846 }
1847
1848 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1849 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS, Boolean.class,
1850 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1851 new String[] { Long.class.getName(), Long.class.getName() });
1852
1853
1861 public boolean containsUser(long pk, long userPK) throws SystemException {
1862 Object[] finderArgs = new Object[] { pk, userPK };
1863
1864 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1865 finderArgs, this);
1866
1867 if (value == null) {
1868 try {
1869 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1870 }
1871 catch (Exception e) {
1872 throw processException(e);
1873 }
1874 finally {
1875 if (value == null) {
1876 value = Boolean.FALSE;
1877 }
1878
1879 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1880 finderArgs, value);
1881 }
1882 }
1883
1884 return value.booleanValue();
1885 }
1886
1887
1894 public boolean containsUsers(long pk) throws SystemException {
1895 if (getUsersSize(pk) > 0) {
1896 return true;
1897 }
1898 else {
1899 return false;
1900 }
1901 }
1902
1903
1910 public void addUser(long pk, long userPK) throws SystemException {
1911 try {
1912 addUser.add(pk, userPK);
1913 }
1914 catch (Exception e) {
1915 throw processException(e);
1916 }
1917 finally {
1918 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1919 }
1920 }
1921
1922
1929 public void addUser(long pk, com.liferay.portal.model.User user)
1930 throws SystemException {
1931 try {
1932 addUser.add(pk, user.getPrimaryKey());
1933 }
1934 catch (Exception e) {
1935 throw processException(e);
1936 }
1937 finally {
1938 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1939 }
1940 }
1941
1942
1949 public void addUsers(long pk, long[] userPKs) throws SystemException {
1950 try {
1951 for (long userPK : userPKs) {
1952 addUser.add(pk, userPK);
1953 }
1954 }
1955 catch (Exception e) {
1956 throw processException(e);
1957 }
1958 finally {
1959 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1960 }
1961 }
1962
1963
1970 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1971 throws SystemException {
1972 try {
1973 for (com.liferay.portal.model.User user : users) {
1974 addUser.add(pk, user.getPrimaryKey());
1975 }
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
1991 public void clearUsers(long pk) throws SystemException {
1992 try {
1993 clearUsers.clear(pk);
1994 }
1995 catch (Exception e) {
1996 throw processException(e);
1997 }
1998 finally {
1999 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2000 }
2001 }
2002
2003
2010 public void removeUser(long pk, long userPK) throws SystemException {
2011 try {
2012 removeUser.remove(pk, userPK);
2013 }
2014 catch (Exception e) {
2015 throw processException(e);
2016 }
2017 finally {
2018 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2019 }
2020 }
2021
2022
2029 public void removeUser(long pk, com.liferay.portal.model.User user)
2030 throws SystemException {
2031 try {
2032 removeUser.remove(pk, user.getPrimaryKey());
2033 }
2034 catch (Exception e) {
2035 throw processException(e);
2036 }
2037 finally {
2038 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2039 }
2040 }
2041
2042
2049 public void removeUsers(long pk, long[] userPKs) throws SystemException {
2050 try {
2051 for (long userPK : userPKs) {
2052 removeUser.remove(pk, userPK);
2053 }
2054 }
2055 catch (Exception e) {
2056 throw processException(e);
2057 }
2058 finally {
2059 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2060 }
2061 }
2062
2063
2070 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
2071 throws SystemException {
2072 try {
2073 for (com.liferay.portal.model.User user : users) {
2074 removeUser.remove(pk, user.getPrimaryKey());
2075 }
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 setUsers(long pk, long[] userPKs) throws SystemException {
2093 try {
2094 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
2095
2096 List<com.liferay.portal.model.User> users = getUsers(pk);
2097
2098 for (com.liferay.portal.model.User user : users) {
2099 if (!userPKSet.remove(user.getPrimaryKey())) {
2100 removeUser.remove(pk, user.getPrimaryKey());
2101 }
2102 }
2103
2104 for (Long userPK : userPKSet) {
2105 addUser.add(pk, userPK);
2106 }
2107 }
2108 catch (Exception e) {
2109 throw processException(e);
2110 }
2111 finally {
2112 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2113 }
2114 }
2115
2116
2123 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
2124 throws SystemException {
2125 try {
2126 long[] userPKs = new long[users.size()];
2127
2128 for (int i = 0; i < users.size(); i++) {
2129 com.liferay.portal.model.User user = users.get(i);
2130
2131 userPKs[i] = user.getPrimaryKey();
2132 }
2133
2134 setUsers(pk, userPKs);
2135 }
2136 catch (Exception e) {
2137 throw processException(e);
2138 }
2139 finally {
2140 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
2141 }
2142 }
2143
2144
2151 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk)
2152 throws SystemException {
2153 return getUserGroups(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
2154 }
2155
2156
2169 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2170 int start, int end) throws SystemException {
2171 return getUserGroups(pk, start, end, null);
2172 }
2173
2174 public static final FinderPath FINDER_PATH_GET_USERGROUPS = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2175 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS,
2176 com.liferay.portal.model.impl.UserGroupImpl.class,
2177 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME, "getUserGroups",
2178 new String[] {
2179 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
2180 "com.liferay.portal.kernel.util.OrderByComparator"
2181 });
2182
2183
2197 public List<com.liferay.portal.model.UserGroup> getUserGroups(long pk,
2198 int start, int end, OrderByComparator orderByComparator)
2199 throws SystemException {
2200 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
2201
2202 List<com.liferay.portal.model.UserGroup> list = (List<com.liferay.portal.model.UserGroup>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS,
2203 finderArgs, this);
2204
2205 if (list == null) {
2206 Session session = null;
2207
2208 try {
2209 session = openSession();
2210
2211 String sql = null;
2212
2213 if (orderByComparator != null) {
2214 sql = _SQL_GETUSERGROUPS.concat(ORDER_BY_CLAUSE)
2215 .concat(orderByComparator.getOrderBy());
2216 }
2217 else {
2218 sql = _SQL_GETUSERGROUPS.concat(com.liferay.portal.model.impl.UserGroupModelImpl.ORDER_BY_SQL);
2219 }
2220
2221 SQLQuery q = session.createSQLQuery(sql);
2222
2223 q.addEntity("UserGroup",
2224 com.liferay.portal.model.impl.UserGroupImpl.class);
2225
2226 QueryPos qPos = QueryPos.getInstance(q);
2227
2228 qPos.add(pk);
2229
2230 list = (List<com.liferay.portal.model.UserGroup>)QueryUtil.list(q,
2231 getDialect(), start, end);
2232 }
2233 catch (Exception e) {
2234 throw processException(e);
2235 }
2236 finally {
2237 if (list == null) {
2238 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERGROUPS,
2239 finderArgs);
2240 }
2241 else {
2242 userGroupPersistence.cacheResult(list);
2243
2244 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS,
2245 finderArgs, list);
2246 }
2247
2248 closeSession(session);
2249 }
2250 }
2251
2252 return list;
2253 }
2254
2255 public static final FinderPath FINDER_PATH_GET_USERGROUPS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2256 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Long.class,
2257 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2258 "getUserGroupsSize", new String[] { Long.class.getName() });
2259
2260
2267 public int getUserGroupsSize(long pk) throws SystemException {
2268 Object[] finderArgs = new Object[] { pk };
2269
2270 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2271 finderArgs, this);
2272
2273 if (count == null) {
2274 Session session = null;
2275
2276 try {
2277 session = openSession();
2278
2279 SQLQuery q = session.createSQLQuery(_SQL_GETUSERGROUPSSIZE);
2280
2281 q.addScalar(COUNT_COLUMN_NAME,
2282 com.liferay.portal.kernel.dao.orm.Type.LONG);
2283
2284 QueryPos qPos = QueryPos.getInstance(q);
2285
2286 qPos.add(pk);
2287
2288 count = (Long)q.uniqueResult();
2289 }
2290 catch (Exception e) {
2291 throw processException(e);
2292 }
2293 finally {
2294 if (count == null) {
2295 count = Long.valueOf(0);
2296 }
2297
2298 FinderCacheUtil.putResult(FINDER_PATH_GET_USERGROUPS_SIZE,
2299 finderArgs, count);
2300
2301 closeSession(session);
2302 }
2303 }
2304
2305 return count.intValue();
2306 }
2307
2308 public static final FinderPath FINDER_PATH_CONTAINS_USERGROUP = new FinderPath(com.liferay.portal.model.impl.UserGroupModelImpl.ENTITY_CACHE_ENABLED,
2309 TeamModelImpl.FINDER_CACHE_ENABLED_USERGROUPS_TEAMS, Boolean.class,
2310 TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME,
2311 "containsUserGroup",
2312 new String[] { Long.class.getName(), Long.class.getName() });
2313
2314
2322 public boolean containsUserGroup(long pk, long userGroupPK)
2323 throws SystemException {
2324 Object[] finderArgs = new Object[] { pk, userGroupPK };
2325
2326 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USERGROUP,
2327 finderArgs, this);
2328
2329 if (value == null) {
2330 try {
2331 value = Boolean.valueOf(containsUserGroup.contains(pk,
2332 userGroupPK));
2333 }
2334 catch (Exception e) {
2335 throw processException(e);
2336 }
2337 finally {
2338 if (value == null) {
2339 value = Boolean.FALSE;
2340 }
2341
2342 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USERGROUP,
2343 finderArgs, value);
2344 }
2345 }
2346
2347 return value.booleanValue();
2348 }
2349
2350
2357 public boolean containsUserGroups(long pk) throws SystemException {
2358 if (getUserGroupsSize(pk) > 0) {
2359 return true;
2360 }
2361 else {
2362 return false;
2363 }
2364 }
2365
2366
2373 public void addUserGroup(long pk, long userGroupPK)
2374 throws SystemException {
2375 try {
2376 addUserGroup.add(pk, userGroupPK);
2377 }
2378 catch (Exception e) {
2379 throw processException(e);
2380 }
2381 finally {
2382 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2383 }
2384 }
2385
2386
2393 public void addUserGroup(long pk,
2394 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2395 try {
2396 addUserGroup.add(pk, userGroup.getPrimaryKey());
2397 }
2398 catch (Exception e) {
2399 throw processException(e);
2400 }
2401 finally {
2402 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2403 }
2404 }
2405
2406
2413 public void addUserGroups(long pk, long[] userGroupPKs)
2414 throws SystemException {
2415 try {
2416 for (long userGroupPK : userGroupPKs) {
2417 addUserGroup.add(pk, userGroupPK);
2418 }
2419 }
2420 catch (Exception e) {
2421 throw processException(e);
2422 }
2423 finally {
2424 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2425 }
2426 }
2427
2428
2435 public void addUserGroups(long pk,
2436 List<com.liferay.portal.model.UserGroup> userGroups)
2437 throws SystemException {
2438 try {
2439 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2440 addUserGroup.add(pk, userGroup.getPrimaryKey());
2441 }
2442 }
2443 catch (Exception e) {
2444 throw processException(e);
2445 }
2446 finally {
2447 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2448 }
2449 }
2450
2451
2457 public void clearUserGroups(long pk) throws SystemException {
2458 try {
2459 clearUserGroups.clear(pk);
2460 }
2461 catch (Exception e) {
2462 throw processException(e);
2463 }
2464 finally {
2465 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2466 }
2467 }
2468
2469
2476 public void removeUserGroup(long pk, long userGroupPK)
2477 throws SystemException {
2478 try {
2479 removeUserGroup.remove(pk, userGroupPK);
2480 }
2481 catch (Exception e) {
2482 throw processException(e);
2483 }
2484 finally {
2485 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2486 }
2487 }
2488
2489
2496 public void removeUserGroup(long pk,
2497 com.liferay.portal.model.UserGroup userGroup) throws SystemException {
2498 try {
2499 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2500 }
2501 catch (Exception e) {
2502 throw processException(e);
2503 }
2504 finally {
2505 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2506 }
2507 }
2508
2509
2516 public void removeUserGroups(long pk, long[] userGroupPKs)
2517 throws SystemException {
2518 try {
2519 for (long userGroupPK : userGroupPKs) {
2520 removeUserGroup.remove(pk, userGroupPK);
2521 }
2522 }
2523 catch (Exception e) {
2524 throw processException(e);
2525 }
2526 finally {
2527 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2528 }
2529 }
2530
2531
2538 public void removeUserGroups(long pk,
2539 List<com.liferay.portal.model.UserGroup> userGroups)
2540 throws SystemException {
2541 try {
2542 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2543 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2544 }
2545 }
2546 catch (Exception e) {
2547 throw processException(e);
2548 }
2549 finally {
2550 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2551 }
2552 }
2553
2554
2561 public void setUserGroups(long pk, long[] userGroupPKs)
2562 throws SystemException {
2563 try {
2564 Set<Long> userGroupPKSet = SetUtil.fromArray(userGroupPKs);
2565
2566 List<com.liferay.portal.model.UserGroup> userGroups = getUserGroups(pk);
2567
2568 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
2569 if (!userGroupPKSet.remove(userGroup.getPrimaryKey())) {
2570 removeUserGroup.remove(pk, userGroup.getPrimaryKey());
2571 }
2572 }
2573
2574 for (Long userGroupPK : userGroupPKSet) {
2575 addUserGroup.add(pk, userGroupPK);
2576 }
2577 }
2578 catch (Exception e) {
2579 throw processException(e);
2580 }
2581 finally {
2582 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2583 }
2584 }
2585
2586
2593 public void setUserGroups(long pk,
2594 List<com.liferay.portal.model.UserGroup> userGroups)
2595 throws SystemException {
2596 try {
2597 long[] userGroupPKs = new long[userGroups.size()];
2598
2599 for (int i = 0; i < userGroups.size(); i++) {
2600 com.liferay.portal.model.UserGroup userGroup = userGroups.get(i);
2601
2602 userGroupPKs[i] = userGroup.getPrimaryKey();
2603 }
2604
2605 setUserGroups(pk, userGroupPKs);
2606 }
2607 catch (Exception e) {
2608 throw processException(e);
2609 }
2610 finally {
2611 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERGROUPS_TEAMS_NAME);
2612 }
2613 }
2614
2615
2618 public void afterPropertiesSet() {
2619 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2620 com.liferay.portal.util.PropsUtil.get(
2621 "value.object.listener.com.liferay.portal.model.Team")));
2622
2623 if (listenerClassNames.length > 0) {
2624 try {
2625 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
2626
2627 for (String listenerClassName : listenerClassNames) {
2628 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
2629 listenerClassName));
2630 }
2631
2632 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2633 }
2634 catch (Exception e) {
2635 _log.error(e);
2636 }
2637 }
2638
2639 containsUser = new ContainsUser();
2640
2641 addUser = new AddUser();
2642 clearUsers = new ClearUsers();
2643 removeUser = new RemoveUser();
2644
2645 containsUserGroup = new ContainsUserGroup();
2646
2647 addUserGroup = new AddUserGroup();
2648 clearUserGroups = new ClearUserGroups();
2649 removeUserGroup = new RemoveUserGroup();
2650 }
2651
2652 public void destroy() {
2653 EntityCacheUtil.removeCache(TeamImpl.class.getName());
2654 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2655 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2656 }
2657
2658 @BeanReference(type = AccountPersistence.class)
2659 protected AccountPersistence accountPersistence;
2660 @BeanReference(type = AddressPersistence.class)
2661 protected AddressPersistence addressPersistence;
2662 @BeanReference(type = BrowserTrackerPersistence.class)
2663 protected BrowserTrackerPersistence browserTrackerPersistence;
2664 @BeanReference(type = ClassNamePersistence.class)
2665 protected ClassNamePersistence classNamePersistence;
2666 @BeanReference(type = ClusterGroupPersistence.class)
2667 protected ClusterGroupPersistence clusterGroupPersistence;
2668 @BeanReference(type = CompanyPersistence.class)
2669 protected CompanyPersistence companyPersistence;
2670 @BeanReference(type = ContactPersistence.class)
2671 protected ContactPersistence contactPersistence;
2672 @BeanReference(type = CountryPersistence.class)
2673 protected CountryPersistence countryPersistence;
2674 @BeanReference(type = EmailAddressPersistence.class)
2675 protected EmailAddressPersistence emailAddressPersistence;
2676 @BeanReference(type = GroupPersistence.class)
2677 protected GroupPersistence groupPersistence;
2678 @BeanReference(type = ImagePersistence.class)
2679 protected ImagePersistence imagePersistence;
2680 @BeanReference(type = LayoutPersistence.class)
2681 protected LayoutPersistence layoutPersistence;
2682 @BeanReference(type = LayoutBranchPersistence.class)
2683 protected LayoutBranchPersistence layoutBranchPersistence;
2684 @BeanReference(type = LayoutPrototypePersistence.class)
2685 protected LayoutPrototypePersistence layoutPrototypePersistence;
2686 @BeanReference(type = LayoutRevisionPersistence.class)
2687 protected LayoutRevisionPersistence layoutRevisionPersistence;
2688 @BeanReference(type = LayoutSetPersistence.class)
2689 protected LayoutSetPersistence layoutSetPersistence;
2690 @BeanReference(type = LayoutSetBranchPersistence.class)
2691 protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2692 @BeanReference(type = LayoutSetPrototypePersistence.class)
2693 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2694 @BeanReference(type = ListTypePersistence.class)
2695 protected ListTypePersistence listTypePersistence;
2696 @BeanReference(type = LockPersistence.class)
2697 protected LockPersistence lockPersistence;
2698 @BeanReference(type = MembershipRequestPersistence.class)
2699 protected MembershipRequestPersistence membershipRequestPersistence;
2700 @BeanReference(type = OrganizationPersistence.class)
2701 protected OrganizationPersistence organizationPersistence;
2702 @BeanReference(type = OrgGroupPermissionPersistence.class)
2703 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2704 @BeanReference(type = OrgGroupRolePersistence.class)
2705 protected OrgGroupRolePersistence orgGroupRolePersistence;
2706 @BeanReference(type = OrgLaborPersistence.class)
2707 protected OrgLaborPersistence orgLaborPersistence;
2708 @BeanReference(type = PasswordPolicyPersistence.class)
2709 protected PasswordPolicyPersistence passwordPolicyPersistence;
2710 @BeanReference(type = PasswordPolicyRelPersistence.class)
2711 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2712 @BeanReference(type = PasswordTrackerPersistence.class)
2713 protected PasswordTrackerPersistence passwordTrackerPersistence;
2714 @BeanReference(type = PermissionPersistence.class)
2715 protected PermissionPersistence permissionPersistence;
2716 @BeanReference(type = PhonePersistence.class)
2717 protected PhonePersistence phonePersistence;
2718 @BeanReference(type = PluginSettingPersistence.class)
2719 protected PluginSettingPersistence pluginSettingPersistence;
2720 @BeanReference(type = PortalPreferencesPersistence.class)
2721 protected PortalPreferencesPersistence portalPreferencesPersistence;
2722 @BeanReference(type = PortletPersistence.class)
2723 protected PortletPersistence portletPersistence;
2724 @BeanReference(type = PortletItemPersistence.class)
2725 protected PortletItemPersistence portletItemPersistence;
2726 @BeanReference(type = PortletPreferencesPersistence.class)
2727 protected PortletPreferencesPersistence portletPreferencesPersistence;
2728 @BeanReference(type = RegionPersistence.class)
2729 protected RegionPersistence regionPersistence;
2730 @BeanReference(type = ReleasePersistence.class)
2731 protected ReleasePersistence releasePersistence;
2732 @BeanReference(type = RepositoryPersistence.class)
2733 protected RepositoryPersistence repositoryPersistence;
2734 @BeanReference(type = RepositoryEntryPersistence.class)
2735 protected RepositoryEntryPersistence repositoryEntryPersistence;
2736 @BeanReference(type = ResourcePersistence.class)
2737 protected ResourcePersistence resourcePersistence;
2738 @BeanReference(type = ResourceActionPersistence.class)
2739 protected ResourceActionPersistence resourceActionPersistence;
2740 @BeanReference(type = ResourceBlockPersistence.class)
2741 protected ResourceBlockPersistence resourceBlockPersistence;
2742 @BeanReference(type = ResourceBlockPermissionPersistence.class)
2743 protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2744 @BeanReference(type = ResourceCodePersistence.class)
2745 protected ResourceCodePersistence resourceCodePersistence;
2746 @BeanReference(type = ResourcePermissionPersistence.class)
2747 protected ResourcePermissionPersistence resourcePermissionPersistence;
2748 @BeanReference(type = ResourceTypePermissionPersistence.class)
2749 protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2750 @BeanReference(type = RolePersistence.class)
2751 protected RolePersistence rolePersistence;
2752 @BeanReference(type = ServiceComponentPersistence.class)
2753 protected ServiceComponentPersistence serviceComponentPersistence;
2754 @BeanReference(type = ShardPersistence.class)
2755 protected ShardPersistence shardPersistence;
2756 @BeanReference(type = SubscriptionPersistence.class)
2757 protected SubscriptionPersistence subscriptionPersistence;
2758 @BeanReference(type = TeamPersistence.class)
2759 protected TeamPersistence teamPersistence;
2760 @BeanReference(type = TicketPersistence.class)
2761 protected TicketPersistence ticketPersistence;
2762 @BeanReference(type = UserPersistence.class)
2763 protected UserPersistence userPersistence;
2764 @BeanReference(type = UserGroupPersistence.class)
2765 protected UserGroupPersistence userGroupPersistence;
2766 @BeanReference(type = UserGroupGroupRolePersistence.class)
2767 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2768 @BeanReference(type = UserGroupRolePersistence.class)
2769 protected UserGroupRolePersistence userGroupRolePersistence;
2770 @BeanReference(type = UserIdMapperPersistence.class)
2771 protected UserIdMapperPersistence userIdMapperPersistence;
2772 @BeanReference(type = UserNotificationEventPersistence.class)
2773 protected UserNotificationEventPersistence userNotificationEventPersistence;
2774 @BeanReference(type = UserTrackerPersistence.class)
2775 protected UserTrackerPersistence userTrackerPersistence;
2776 @BeanReference(type = UserTrackerPathPersistence.class)
2777 protected UserTrackerPathPersistence userTrackerPathPersistence;
2778 @BeanReference(type = VirtualHostPersistence.class)
2779 protected VirtualHostPersistence virtualHostPersistence;
2780 @BeanReference(type = WebDAVPropsPersistence.class)
2781 protected WebDAVPropsPersistence webDAVPropsPersistence;
2782 @BeanReference(type = WebsitePersistence.class)
2783 protected WebsitePersistence websitePersistence;
2784 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2785 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2786 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2787 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2788 protected ContainsUser containsUser;
2789 protected AddUser addUser;
2790 protected ClearUsers clearUsers;
2791 protected RemoveUser removeUser;
2792 protected ContainsUserGroup containsUserGroup;
2793 protected AddUserGroup addUserGroup;
2794 protected ClearUserGroups clearUserGroups;
2795 protected RemoveUserGroup removeUserGroup;
2796
2797 protected class ContainsUser {
2798 protected ContainsUser() {
2799 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2800 _SQL_CONTAINSUSER,
2801 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2802 RowMapper.COUNT);
2803 }
2804
2805 protected boolean contains(long teamId, long userId) {
2806 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2807 new Long(teamId), new Long(userId)
2808 });
2809
2810 if (results.size() > 0) {
2811 Integer count = results.get(0);
2812
2813 if (count.intValue() > 0) {
2814 return true;
2815 }
2816 }
2817
2818 return false;
2819 }
2820
2821 private MappingSqlQuery<Integer> _mappingSqlQuery;
2822 }
2823
2824 protected class AddUser {
2825 protected AddUser() {
2826 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2827 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2828 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2829 }
2830
2831 protected void add(long teamId, long userId) throws SystemException {
2832 if (!containsUser.contains(teamId, userId)) {
2833 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2834
2835 for (ModelListener<Team> listener : listeners) {
2836 listener.onBeforeAddAssociation(teamId,
2837 com.liferay.portal.model.User.class.getName(), userId);
2838 }
2839
2840 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2841 listener.onBeforeAddAssociation(userId,
2842 Team.class.getName(), teamId);
2843 }
2844
2845 _sqlUpdate.update(new Object[] {
2846 new Long(teamId), new Long(userId)
2847 });
2848
2849 for (ModelListener<Team> listener : listeners) {
2850 listener.onAfterAddAssociation(teamId,
2851 com.liferay.portal.model.User.class.getName(), userId);
2852 }
2853
2854 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2855 listener.onAfterAddAssociation(userId,
2856 Team.class.getName(), teamId);
2857 }
2858 }
2859 }
2860
2861 private SqlUpdate _sqlUpdate;
2862 }
2863
2864 protected class ClearUsers {
2865 protected ClearUsers() {
2866 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2867 "DELETE FROM Users_Teams WHERE teamId = ?",
2868 new int[] { java.sql.Types.BIGINT });
2869 }
2870
2871 protected void clear(long teamId) throws SystemException {
2872 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2873
2874 List<com.liferay.portal.model.User> users = null;
2875
2876 if ((listeners.length > 0) || (userListeners.length > 0)) {
2877 users = getUsers(teamId);
2878
2879 for (com.liferay.portal.model.User user : users) {
2880 for (ModelListener<Team> listener : listeners) {
2881 listener.onBeforeRemoveAssociation(teamId,
2882 com.liferay.portal.model.User.class.getName(),
2883 user.getPrimaryKey());
2884 }
2885
2886 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2887 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2888 Team.class.getName(), teamId);
2889 }
2890 }
2891 }
2892
2893 _sqlUpdate.update(new Object[] { new Long(teamId) });
2894
2895 if ((listeners.length > 0) || (userListeners.length > 0)) {
2896 for (com.liferay.portal.model.User user : users) {
2897 for (ModelListener<Team> listener : listeners) {
2898 listener.onAfterRemoveAssociation(teamId,
2899 com.liferay.portal.model.User.class.getName(),
2900 user.getPrimaryKey());
2901 }
2902
2903 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2904 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2905 Team.class.getName(), teamId);
2906 }
2907 }
2908 }
2909 }
2910
2911 private SqlUpdate _sqlUpdate;
2912 }
2913
2914 protected class RemoveUser {
2915 protected RemoveUser() {
2916 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2917 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2918 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2919 }
2920
2921 protected void remove(long teamId, long userId)
2922 throws SystemException {
2923 if (containsUser.contains(teamId, userId)) {
2924 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2925
2926 for (ModelListener<Team> listener : listeners) {
2927 listener.onBeforeRemoveAssociation(teamId,
2928 com.liferay.portal.model.User.class.getName(), userId);
2929 }
2930
2931 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2932 listener.onBeforeRemoveAssociation(userId,
2933 Team.class.getName(), teamId);
2934 }
2935
2936 _sqlUpdate.update(new Object[] {
2937 new Long(teamId), new Long(userId)
2938 });
2939
2940 for (ModelListener<Team> listener : listeners) {
2941 listener.onAfterRemoveAssociation(teamId,
2942 com.liferay.portal.model.User.class.getName(), userId);
2943 }
2944
2945 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2946 listener.onAfterRemoveAssociation(userId,
2947 Team.class.getName(), teamId);
2948 }
2949 }
2950 }
2951
2952 private SqlUpdate _sqlUpdate;
2953 }
2954
2955 protected class ContainsUserGroup {
2956 protected ContainsUserGroup() {
2957 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2958 _SQL_CONTAINSUSERGROUP,
2959 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2960 RowMapper.COUNT);
2961 }
2962
2963 protected boolean contains(long teamId, long userGroupId) {
2964 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2965 new Long(teamId), new Long(userGroupId)
2966 });
2967
2968 if (results.size() > 0) {
2969 Integer count = results.get(0);
2970
2971 if (count.intValue() > 0) {
2972 return true;
2973 }
2974 }
2975
2976 return false;
2977 }
2978
2979 private MappingSqlQuery<Integer> _mappingSqlQuery;
2980 }
2981
2982 protected class AddUserGroup {
2983 protected AddUserGroup() {
2984 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2985 "INSERT INTO UserGroups_Teams (teamId, userGroupId) VALUES (?, ?)",
2986 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2987 }
2988
2989 protected void add(long teamId, long userGroupId)
2990 throws SystemException {
2991 if (!containsUserGroup.contains(teamId, userGroupId)) {
2992 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
2993 userGroupPersistence.getListeners();
2994
2995 for (ModelListener<Team> listener : listeners) {
2996 listener.onBeforeAddAssociation(teamId,
2997 com.liferay.portal.model.UserGroup.class.getName(),
2998 userGroupId);
2999 }
3000
3001 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3002 listener.onBeforeAddAssociation(userGroupId,
3003 Team.class.getName(), teamId);
3004 }
3005
3006 _sqlUpdate.update(new Object[] {
3007 new Long(teamId), new Long(userGroupId)
3008 });
3009
3010 for (ModelListener<Team> listener : listeners) {
3011 listener.onAfterAddAssociation(teamId,
3012 com.liferay.portal.model.UserGroup.class.getName(),
3013 userGroupId);
3014 }
3015
3016 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3017 listener.onAfterAddAssociation(userGroupId,
3018 Team.class.getName(), teamId);
3019 }
3020 }
3021 }
3022
3023 private SqlUpdate _sqlUpdate;
3024 }
3025
3026 protected class ClearUserGroups {
3027 protected ClearUserGroups() {
3028 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3029 "DELETE FROM UserGroups_Teams WHERE teamId = ?",
3030 new int[] { java.sql.Types.BIGINT });
3031 }
3032
3033 protected void clear(long teamId) throws SystemException {
3034 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3035 userGroupPersistence.getListeners();
3036
3037 List<com.liferay.portal.model.UserGroup> userGroups = null;
3038
3039 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3040 userGroups = getUserGroups(teamId);
3041
3042 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3043 for (ModelListener<Team> listener : listeners) {
3044 listener.onBeforeRemoveAssociation(teamId,
3045 com.liferay.portal.model.UserGroup.class.getName(),
3046 userGroup.getPrimaryKey());
3047 }
3048
3049 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3050 listener.onBeforeRemoveAssociation(userGroup.getPrimaryKey(),
3051 Team.class.getName(), teamId);
3052 }
3053 }
3054 }
3055
3056 _sqlUpdate.update(new Object[] { new Long(teamId) });
3057
3058 if ((listeners.length > 0) || (userGroupListeners.length > 0)) {
3059 for (com.liferay.portal.model.UserGroup userGroup : userGroups) {
3060 for (ModelListener<Team> listener : listeners) {
3061 listener.onAfterRemoveAssociation(teamId,
3062 com.liferay.portal.model.UserGroup.class.getName(),
3063 userGroup.getPrimaryKey());
3064 }
3065
3066 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3067 listener.onAfterRemoveAssociation(userGroup.getPrimaryKey(),
3068 Team.class.getName(), teamId);
3069 }
3070 }
3071 }
3072 }
3073
3074 private SqlUpdate _sqlUpdate;
3075 }
3076
3077 protected class RemoveUserGroup {
3078 protected RemoveUserGroup() {
3079 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
3080 "DELETE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?",
3081 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
3082 }
3083
3084 protected void remove(long teamId, long userGroupId)
3085 throws SystemException {
3086 if (containsUserGroup.contains(teamId, userGroupId)) {
3087 ModelListener<com.liferay.portal.model.UserGroup>[] userGroupListeners =
3088 userGroupPersistence.getListeners();
3089
3090 for (ModelListener<Team> listener : listeners) {
3091 listener.onBeforeRemoveAssociation(teamId,
3092 com.liferay.portal.model.UserGroup.class.getName(),
3093 userGroupId);
3094 }
3095
3096 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3097 listener.onBeforeRemoveAssociation(userGroupId,
3098 Team.class.getName(), teamId);
3099 }
3100
3101 _sqlUpdate.update(new Object[] {
3102 new Long(teamId), new Long(userGroupId)
3103 });
3104
3105 for (ModelListener<Team> listener : listeners) {
3106 listener.onAfterRemoveAssociation(teamId,
3107 com.liferay.portal.model.UserGroup.class.getName(),
3108 userGroupId);
3109 }
3110
3111 for (ModelListener<com.liferay.portal.model.UserGroup> listener : userGroupListeners) {
3112 listener.onAfterRemoveAssociation(userGroupId,
3113 Team.class.getName(), teamId);
3114 }
3115 }
3116 }
3117
3118 private SqlUpdate _sqlUpdate;
3119 }
3120
3121 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
3122 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
3123 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
3124 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
3125 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
3126 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
3127 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
3128 private static final String _SQL_GETUSERGROUPS = "SELECT {UserGroup.*} FROM UserGroup INNER JOIN UserGroups_Teams ON (UserGroups_Teams.userGroupId = UserGroup.userGroupId) WHERE (UserGroups_Teams.teamId = ?)";
3129 private static final String _SQL_GETUSERGROUPSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ?";
3130 private static final String _SQL_CONTAINSUSERGROUP = "SELECT COUNT(*) AS COUNT_VALUE FROM UserGroups_Teams WHERE teamId = ? AND userGroupId = ?";
3131 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
3132 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
3133 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
3134 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
3135 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
3136 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "team.teamId";
3137 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
3138 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
3139 "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
3140 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
3141 ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
3142 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
3143 private static final String _FILTER_ENTITY_ALIAS = "team";
3144 private static final String _FILTER_ENTITY_TABLE = "Team";
3145 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
3146 private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
3147 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
3148 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
3149 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3150 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
3151 private static Team _nullTeam = new TeamImpl() {
3152 @Override
3153 public Object clone() {
3154 return this;
3155 }
3156
3157 @Override
3158 public CacheModel<Team> toCacheModel() {
3159 return _nullTeamCacheModel;
3160 }
3161 };
3162
3163 private static CacheModel<Team> _nullTeamCacheModel = new CacheModel<Team>() {
3164 public Team toEntityModel() {
3165 return _nullTeam;
3166 }
3167 };
3168 }