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.annotation.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.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
075 public class TeamPersistenceImpl extends BasePersistenceImpl<Team>
076 implements TeamPersistence {
077 public static final String FINDER_CLASS_NAME_ENTITY = TeamImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
079 ".List";
080 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
081 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
082 "findByGroupId",
083 new String[] {
084 Long.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
090 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
091 "countByGroupId", new String[] { Long.class.getName() });
092 public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
093 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_ENTITY,
094 "fetchByG_N",
095 new String[] { Long.class.getName(), String.class.getName() });
096 public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
097 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
098 "countByG_N",
099 new String[] { Long.class.getName(), String.class.getName() });
100 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
101 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
102 "findAll", new String[0]);
103 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TeamModelImpl.ENTITY_CACHE_ENABLED,
104 TeamModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
105 "countAll", new String[0]);
106
107
112 public void cacheResult(Team team) {
113 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
114 TeamImpl.class, team.getPrimaryKey(), team);
115
116 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
117 new Object[] { new Long(team.getGroupId()), team.getName() }, team);
118 }
119
120
125 public void cacheResult(List<Team> teams) {
126 for (Team team : teams) {
127 if (EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
128 TeamImpl.class, team.getPrimaryKey(), this) == null) {
129 cacheResult(team);
130 }
131 }
132 }
133
134
141 public void clearCache() {
142 CacheRegistryUtil.clear(TeamImpl.class.getName());
143 EntityCacheUtil.clearCache(TeamImpl.class.getName());
144 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
145 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
146 }
147
148
155 public void clearCache(Team team) {
156 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
157 TeamImpl.class, team.getPrimaryKey());
158
159 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
160 new Object[] { new Long(team.getGroupId()), team.getName() });
161 }
162
163
169 public Team create(long teamId) {
170 Team team = new TeamImpl();
171
172 team.setNew(true);
173 team.setPrimaryKey(teamId);
174
175 return team;
176 }
177
178
186 public Team remove(Serializable primaryKey)
187 throws NoSuchModelException, SystemException {
188 return remove(((Long)primaryKey).longValue());
189 }
190
191
199 public Team remove(long teamId) throws NoSuchTeamException, SystemException {
200 Session session = null;
201
202 try {
203 session = openSession();
204
205 Team team = (Team)session.get(TeamImpl.class, new Long(teamId));
206
207 if (team == null) {
208 if (_log.isWarnEnabled()) {
209 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + teamId);
210 }
211
212 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
213 teamId);
214 }
215
216 return remove(team);
217 }
218 catch (NoSuchTeamException nsee) {
219 throw nsee;
220 }
221 catch (Exception e) {
222 throw processException(e);
223 }
224 finally {
225 closeSession(session);
226 }
227 }
228
229 protected Team removeImpl(Team team) throws SystemException {
230 team = toUnwrappedModel(team);
231
232 try {
233 clearUsers.clear(team.getPrimaryKey());
234 }
235 catch (Exception e) {
236 throw processException(e);
237 }
238 finally {
239 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
240 }
241
242 Session session = null;
243
244 try {
245 session = openSession();
246
247 BatchSessionUtil.delete(session, team);
248 }
249 catch (Exception e) {
250 throw processException(e);
251 }
252 finally {
253 closeSession(session);
254 }
255
256 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
257
258 TeamModelImpl teamModelImpl = (TeamModelImpl)team;
259
260 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
261 new Object[] {
262 new Long(teamModelImpl.getOriginalGroupId()),
263
264 teamModelImpl.getOriginalName()
265 });
266
267 EntityCacheUtil.removeResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
268 TeamImpl.class, team.getPrimaryKey());
269
270 return team;
271 }
272
273 public Team updateImpl(com.liferay.portal.model.Team team, boolean merge)
274 throws SystemException {
275 team = toUnwrappedModel(team);
276
277 boolean isNew = team.isNew();
278
279 TeamModelImpl teamModelImpl = (TeamModelImpl)team;
280
281 Session session = null;
282
283 try {
284 session = openSession();
285
286 BatchSessionUtil.update(session, team, merge);
287
288 team.setNew(false);
289 }
290 catch (Exception e) {
291 throw processException(e);
292 }
293 finally {
294 closeSession(session);
295 }
296
297 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
298
299 EntityCacheUtil.putResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
300 TeamImpl.class, team.getPrimaryKey(), team);
301
302 if (!isNew &&
303 ((team.getGroupId() != teamModelImpl.getOriginalGroupId()) ||
304 !Validator.equals(team.getName(),
305 teamModelImpl.getOriginalName()))) {
306 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
307 new Object[] {
308 new Long(teamModelImpl.getOriginalGroupId()),
309
310 teamModelImpl.getOriginalName()
311 });
312 }
313
314 if (isNew ||
315 ((team.getGroupId() != teamModelImpl.getOriginalGroupId()) ||
316 !Validator.equals(team.getName(),
317 teamModelImpl.getOriginalName()))) {
318 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
319 new Object[] { new Long(team.getGroupId()), team.getName() },
320 team);
321 }
322
323 return team;
324 }
325
326 protected Team toUnwrappedModel(Team team) {
327 if (team instanceof TeamImpl) {
328 return team;
329 }
330
331 TeamImpl teamImpl = new TeamImpl();
332
333 teamImpl.setNew(team.isNew());
334 teamImpl.setPrimaryKey(team.getPrimaryKey());
335
336 teamImpl.setTeamId(team.getTeamId());
337 teamImpl.setCompanyId(team.getCompanyId());
338 teamImpl.setUserId(team.getUserId());
339 teamImpl.setUserName(team.getUserName());
340 teamImpl.setCreateDate(team.getCreateDate());
341 teamImpl.setModifiedDate(team.getModifiedDate());
342 teamImpl.setGroupId(team.getGroupId());
343 teamImpl.setName(team.getName());
344 teamImpl.setDescription(team.getDescription());
345
346 return teamImpl;
347 }
348
349
357 public Team findByPrimaryKey(Serializable primaryKey)
358 throws NoSuchModelException, SystemException {
359 return findByPrimaryKey(((Long)primaryKey).longValue());
360 }
361
362
370 public Team findByPrimaryKey(long teamId)
371 throws NoSuchTeamException, SystemException {
372 Team team = fetchByPrimaryKey(teamId);
373
374 if (team == null) {
375 if (_log.isWarnEnabled()) {
376 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + teamId);
377 }
378
379 throw new NoSuchTeamException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
380 teamId);
381 }
382
383 return team;
384 }
385
386
393 public Team fetchByPrimaryKey(Serializable primaryKey)
394 throws SystemException {
395 return fetchByPrimaryKey(((Long)primaryKey).longValue());
396 }
397
398
405 public Team fetchByPrimaryKey(long teamId) throws SystemException {
406 Team team = (Team)EntityCacheUtil.getResult(TeamModelImpl.ENTITY_CACHE_ENABLED,
407 TeamImpl.class, teamId, this);
408
409 if (team == null) {
410 Session session = null;
411
412 try {
413 session = openSession();
414
415 team = (Team)session.get(TeamImpl.class, new Long(teamId));
416 }
417 catch (Exception e) {
418 throw processException(e);
419 }
420 finally {
421 if (team != null) {
422 cacheResult(team);
423 }
424
425 closeSession(session);
426 }
427 }
428
429 return team;
430 }
431
432
439 public List<Team> findByGroupId(long groupId) throws SystemException {
440 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
441 }
442
443
456 public List<Team> findByGroupId(long groupId, int start, int end)
457 throws SystemException {
458 return findByGroupId(groupId, start, end, null);
459 }
460
461
475 public List<Team> findByGroupId(long groupId, int start, int end,
476 OrderByComparator orderByComparator) throws SystemException {
477 Object[] finderArgs = new Object[] {
478 groupId,
479
480 String.valueOf(start), String.valueOf(end),
481 String.valueOf(orderByComparator)
482 };
483
484 List<Team> list = (List<Team>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
485 finderArgs, this);
486
487 if (list == null) {
488 Session session = null;
489
490 try {
491 session = openSession();
492
493 StringBundler query = null;
494
495 if (orderByComparator != null) {
496 query = new StringBundler(3 +
497 (orderByComparator.getOrderByFields().length * 3));
498 }
499 else {
500 query = new StringBundler(3);
501 }
502
503 query.append(_SQL_SELECT_TEAM_WHERE);
504
505 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
506
507 if (orderByComparator != null) {
508 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
509 orderByComparator);
510 }
511
512 else {
513 query.append(TeamModelImpl.ORDER_BY_JPQL);
514 }
515
516 String sql = query.toString();
517
518 Query q = session.createQuery(sql);
519
520 QueryPos qPos = QueryPos.getInstance(q);
521
522 qPos.add(groupId);
523
524 list = (List<Team>)QueryUtil.list(q, getDialect(), start, end);
525 }
526 catch (Exception e) {
527 throw processException(e);
528 }
529 finally {
530 if (list == null) {
531 list = new ArrayList<Team>();
532 }
533
534 cacheResult(list);
535
536 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
537 finderArgs, list);
538
539 closeSession(session);
540 }
541 }
542
543 return list;
544 }
545
546
559 public Team findByGroupId_First(long groupId,
560 OrderByComparator orderByComparator)
561 throws NoSuchTeamException, SystemException {
562 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
563
564 if (list.isEmpty()) {
565 StringBundler msg = new StringBundler(4);
566
567 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
568
569 msg.append("groupId=");
570 msg.append(groupId);
571
572 msg.append(StringPool.CLOSE_CURLY_BRACE);
573
574 throw new NoSuchTeamException(msg.toString());
575 }
576 else {
577 return list.get(0);
578 }
579 }
580
581
594 public Team findByGroupId_Last(long groupId,
595 OrderByComparator orderByComparator)
596 throws NoSuchTeamException, SystemException {
597 int count = countByGroupId(groupId);
598
599 List<Team> list = findByGroupId(groupId, count - 1, count,
600 orderByComparator);
601
602 if (list.isEmpty()) {
603 StringBundler msg = new StringBundler(4);
604
605 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
606
607 msg.append("groupId=");
608 msg.append(groupId);
609
610 msg.append(StringPool.CLOSE_CURLY_BRACE);
611
612 throw new NoSuchTeamException(msg.toString());
613 }
614 else {
615 return list.get(0);
616 }
617 }
618
619
633 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
634 OrderByComparator orderByComparator)
635 throws NoSuchTeamException, SystemException {
636 Team team = findByPrimaryKey(teamId);
637
638 Session session = null;
639
640 try {
641 session = openSession();
642
643 Team[] array = new TeamImpl[3];
644
645 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
646 orderByComparator, true);
647
648 array[1] = team;
649
650 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
651 orderByComparator, false);
652
653 return array;
654 }
655 catch (Exception e) {
656 throw processException(e);
657 }
658 finally {
659 closeSession(session);
660 }
661 }
662
663 protected Team getByGroupId_PrevAndNext(Session session, Team team,
664 long groupId, OrderByComparator orderByComparator, boolean previous) {
665 StringBundler query = null;
666
667 if (orderByComparator != null) {
668 query = new StringBundler(6 +
669 (orderByComparator.getOrderByFields().length * 6));
670 }
671 else {
672 query = new StringBundler(3);
673 }
674
675 query.append(_SQL_SELECT_TEAM_WHERE);
676
677 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
678
679 if (orderByComparator != null) {
680 String[] orderByFields = orderByComparator.getOrderByFields();
681
682 if (orderByFields.length > 0) {
683 query.append(WHERE_AND);
684 }
685
686 for (int i = 0; i < orderByFields.length; i++) {
687 query.append(_ORDER_BY_ENTITY_ALIAS);
688 query.append(orderByFields[i]);
689
690 if ((i + 1) < orderByFields.length) {
691 if (orderByComparator.isAscending() ^ previous) {
692 query.append(WHERE_GREATER_THAN_HAS_NEXT);
693 }
694 else {
695 query.append(WHERE_LESSER_THAN_HAS_NEXT);
696 }
697 }
698 else {
699 if (orderByComparator.isAscending() ^ previous) {
700 query.append(WHERE_GREATER_THAN);
701 }
702 else {
703 query.append(WHERE_LESSER_THAN);
704 }
705 }
706 }
707
708 query.append(ORDER_BY_CLAUSE);
709
710 for (int i = 0; i < orderByFields.length; i++) {
711 query.append(_ORDER_BY_ENTITY_ALIAS);
712 query.append(orderByFields[i]);
713
714 if ((i + 1) < orderByFields.length) {
715 if (orderByComparator.isAscending() ^ previous) {
716 query.append(ORDER_BY_ASC_HAS_NEXT);
717 }
718 else {
719 query.append(ORDER_BY_DESC_HAS_NEXT);
720 }
721 }
722 else {
723 if (orderByComparator.isAscending() ^ previous) {
724 query.append(ORDER_BY_ASC);
725 }
726 else {
727 query.append(ORDER_BY_DESC);
728 }
729 }
730 }
731 }
732
733 else {
734 query.append(TeamModelImpl.ORDER_BY_JPQL);
735 }
736
737 String sql = query.toString();
738
739 Query q = session.createQuery(sql);
740
741 q.setFirstResult(0);
742 q.setMaxResults(2);
743
744 QueryPos qPos = QueryPos.getInstance(q);
745
746 qPos.add(groupId);
747
748 if (orderByComparator != null) {
749 Object[] values = orderByComparator.getOrderByValues(team);
750
751 for (Object value : values) {
752 qPos.add(value);
753 }
754 }
755
756 List<Team> list = q.list();
757
758 if (list.size() == 2) {
759 return list.get(1);
760 }
761 else {
762 return null;
763 }
764 }
765
766
773 public List<Team> filterFindByGroupId(long groupId)
774 throws SystemException {
775 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
776 QueryUtil.ALL_POS, null);
777 }
778
779
792 public List<Team> filterFindByGroupId(long groupId, int start, int end)
793 throws SystemException {
794 return filterFindByGroupId(groupId, start, end, null);
795 }
796
797
811 public List<Team> filterFindByGroupId(long groupId, int start, int end,
812 OrderByComparator orderByComparator) throws SystemException {
813 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
814 return findByGroupId(groupId, start, end, orderByComparator);
815 }
816
817 Session session = null;
818
819 try {
820 session = openSession();
821
822 StringBundler query = null;
823
824 if (orderByComparator != null) {
825 query = new StringBundler(3 +
826 (orderByComparator.getOrderByFields().length * 3));
827 }
828 else {
829 query = new StringBundler(3);
830 }
831
832 if (getDB().isSupportsInlineDistinct()) {
833 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
834 }
835 else {
836 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE);
837 }
838
839 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
840
841 if (orderByComparator != null) {
842 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
843 orderByComparator);
844 }
845
846 else {
847 query.append(TeamModelImpl.ORDER_BY_JPQL);
848 }
849
850 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
851 Team.class.getName(), _FILTER_COLUMN_PK,
852 _FILTER_COLUMN_USERID, groupId);
853
854 SQLQuery q = session.createSQLQuery(sql);
855
856 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
857
858 QueryPos qPos = QueryPos.getInstance(q);
859
860 qPos.add(groupId);
861
862 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
863 }
864 catch (Exception e) {
865 throw processException(e);
866 }
867 finally {
868 closeSession(session);
869 }
870 }
871
872
881 public Team findByG_N(long groupId, String name)
882 throws NoSuchTeamException, SystemException {
883 Team team = fetchByG_N(groupId, name);
884
885 if (team == null) {
886 StringBundler msg = new StringBundler(6);
887
888 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
889
890 msg.append("groupId=");
891 msg.append(groupId);
892
893 msg.append(", name=");
894 msg.append(name);
895
896 msg.append(StringPool.CLOSE_CURLY_BRACE);
897
898 if (_log.isWarnEnabled()) {
899 _log.warn(msg.toString());
900 }
901
902 throw new NoSuchTeamException(msg.toString());
903 }
904
905 return team;
906 }
907
908
916 public Team fetchByG_N(long groupId, String name) throws SystemException {
917 return fetchByG_N(groupId, name, true);
918 }
919
920
928 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
929 throws SystemException {
930 Object[] finderArgs = new Object[] { groupId, name };
931
932 Object result = null;
933
934 if (retrieveFromCache) {
935 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
936 finderArgs, this);
937 }
938
939 if (result == null) {
940 Session session = null;
941
942 try {
943 session = openSession();
944
945 StringBundler query = new StringBundler(4);
946
947 query.append(_SQL_SELECT_TEAM_WHERE);
948
949 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
950
951 if (name == null) {
952 query.append(_FINDER_COLUMN_G_N_NAME_1);
953 }
954 else {
955 if (name.equals(StringPool.BLANK)) {
956 query.append(_FINDER_COLUMN_G_N_NAME_3);
957 }
958 else {
959 query.append(_FINDER_COLUMN_G_N_NAME_2);
960 }
961 }
962
963 query.append(TeamModelImpl.ORDER_BY_JPQL);
964
965 String sql = query.toString();
966
967 Query q = session.createQuery(sql);
968
969 QueryPos qPos = QueryPos.getInstance(q);
970
971 qPos.add(groupId);
972
973 if (name != null) {
974 qPos.add(name);
975 }
976
977 List<Team> list = q.list();
978
979 result = list;
980
981 Team team = null;
982
983 if (list.isEmpty()) {
984 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
985 finderArgs, list);
986 }
987 else {
988 team = list.get(0);
989
990 cacheResult(team);
991
992 if ((team.getGroupId() != groupId) ||
993 (team.getName() == null) ||
994 !team.getName().equals(name)) {
995 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
996 finderArgs, team);
997 }
998 }
999
1000 return team;
1001 }
1002 catch (Exception e) {
1003 throw processException(e);
1004 }
1005 finally {
1006 if (result == null) {
1007 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1008 finderArgs, new ArrayList<Team>());
1009 }
1010
1011 closeSession(session);
1012 }
1013 }
1014 else {
1015 if (result instanceof List<?>) {
1016 return null;
1017 }
1018 else {
1019 return (Team)result;
1020 }
1021 }
1022 }
1023
1024
1030 public List<Team> findAll() throws SystemException {
1031 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1032 }
1033
1034
1046 public List<Team> findAll(int start, int end) throws SystemException {
1047 return findAll(start, end, null);
1048 }
1049
1050
1063 public List<Team> findAll(int start, int end,
1064 OrderByComparator orderByComparator) throws SystemException {
1065 Object[] finderArgs = new Object[] {
1066 String.valueOf(start), String.valueOf(end),
1067 String.valueOf(orderByComparator)
1068 };
1069
1070 List<Team> list = (List<Team>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1071 finderArgs, this);
1072
1073 if (list == null) {
1074 Session session = null;
1075
1076 try {
1077 session = openSession();
1078
1079 StringBundler query = null;
1080 String sql = null;
1081
1082 if (orderByComparator != null) {
1083 query = new StringBundler(2 +
1084 (orderByComparator.getOrderByFields().length * 3));
1085
1086 query.append(_SQL_SELECT_TEAM);
1087
1088 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1089 orderByComparator);
1090
1091 sql = query.toString();
1092 }
1093 else {
1094 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1095 }
1096
1097 Query q = session.createQuery(sql);
1098
1099 if (orderByComparator == null) {
1100 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1101 end, false);
1102
1103 Collections.sort(list);
1104 }
1105 else {
1106 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1107 end);
1108 }
1109 }
1110 catch (Exception e) {
1111 throw processException(e);
1112 }
1113 finally {
1114 if (list == null) {
1115 list = new ArrayList<Team>();
1116 }
1117
1118 cacheResult(list);
1119
1120 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1121
1122 closeSession(session);
1123 }
1124 }
1125
1126 return list;
1127 }
1128
1129
1135 public void removeByGroupId(long groupId) throws SystemException {
1136 for (Team team : findByGroupId(groupId)) {
1137 remove(team);
1138 }
1139 }
1140
1141
1148 public void removeByG_N(long groupId, String name)
1149 throws NoSuchTeamException, SystemException {
1150 Team team = findByG_N(groupId, name);
1151
1152 remove(team);
1153 }
1154
1155
1160 public void removeAll() throws SystemException {
1161 for (Team team : findAll()) {
1162 remove(team);
1163 }
1164 }
1165
1166
1173 public int countByGroupId(long groupId) throws SystemException {
1174 Object[] finderArgs = new Object[] { groupId };
1175
1176 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1177 finderArgs, this);
1178
1179 if (count == null) {
1180 Session session = null;
1181
1182 try {
1183 session = openSession();
1184
1185 StringBundler query = new StringBundler(2);
1186
1187 query.append(_SQL_COUNT_TEAM_WHERE);
1188
1189 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1190
1191 String sql = query.toString();
1192
1193 Query q = session.createQuery(sql);
1194
1195 QueryPos qPos = QueryPos.getInstance(q);
1196
1197 qPos.add(groupId);
1198
1199 count = (Long)q.uniqueResult();
1200 }
1201 catch (Exception e) {
1202 throw processException(e);
1203 }
1204 finally {
1205 if (count == null) {
1206 count = Long.valueOf(0);
1207 }
1208
1209 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1210 finderArgs, count);
1211
1212 closeSession(session);
1213 }
1214 }
1215
1216 return count.intValue();
1217 }
1218
1219
1226 public int filterCountByGroupId(long groupId) throws SystemException {
1227 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1228 return countByGroupId(groupId);
1229 }
1230
1231 Session session = null;
1232
1233 try {
1234 session = openSession();
1235
1236 StringBundler query = new StringBundler(2);
1237
1238 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1239
1240 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1241
1242 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1243 Team.class.getName(), _FILTER_COLUMN_PK,
1244 _FILTER_COLUMN_USERID, groupId);
1245
1246 SQLQuery q = session.createSQLQuery(sql);
1247
1248 q.addScalar(COUNT_COLUMN_NAME,
1249 com.liferay.portal.kernel.dao.orm.Type.LONG);
1250
1251 QueryPos qPos = QueryPos.getInstance(q);
1252
1253 qPos.add(groupId);
1254
1255 Long count = (Long)q.uniqueResult();
1256
1257 return count.intValue();
1258 }
1259 catch (Exception e) {
1260 throw processException(e);
1261 }
1262 finally {
1263 closeSession(session);
1264 }
1265 }
1266
1267
1275 public int countByG_N(long groupId, String name) throws SystemException {
1276 Object[] finderArgs = new Object[] { groupId, name };
1277
1278 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1279 finderArgs, this);
1280
1281 if (count == null) {
1282 Session session = null;
1283
1284 try {
1285 session = openSession();
1286
1287 StringBundler query = new StringBundler(3);
1288
1289 query.append(_SQL_COUNT_TEAM_WHERE);
1290
1291 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1292
1293 if (name == null) {
1294 query.append(_FINDER_COLUMN_G_N_NAME_1);
1295 }
1296 else {
1297 if (name.equals(StringPool.BLANK)) {
1298 query.append(_FINDER_COLUMN_G_N_NAME_3);
1299 }
1300 else {
1301 query.append(_FINDER_COLUMN_G_N_NAME_2);
1302 }
1303 }
1304
1305 String sql = query.toString();
1306
1307 Query q = session.createQuery(sql);
1308
1309 QueryPos qPos = QueryPos.getInstance(q);
1310
1311 qPos.add(groupId);
1312
1313 if (name != null) {
1314 qPos.add(name);
1315 }
1316
1317 count = (Long)q.uniqueResult();
1318 }
1319 catch (Exception e) {
1320 throw processException(e);
1321 }
1322 finally {
1323 if (count == null) {
1324 count = Long.valueOf(0);
1325 }
1326
1327 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1328 count);
1329
1330 closeSession(session);
1331 }
1332 }
1333
1334 return count.intValue();
1335 }
1336
1337
1345 public int filterCountByG_N(long groupId, String name)
1346 throws SystemException {
1347 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1348 return countByG_N(groupId, name);
1349 }
1350
1351 Session session = null;
1352
1353 try {
1354 session = openSession();
1355
1356 StringBundler query = new StringBundler(3);
1357
1358 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1359
1360 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1361
1362 if (name == null) {
1363 query.append(_FINDER_COLUMN_G_N_NAME_1);
1364 }
1365 else {
1366 if (name.equals(StringPool.BLANK)) {
1367 query.append(_FINDER_COLUMN_G_N_NAME_3);
1368 }
1369 else {
1370 query.append(_FINDER_COLUMN_G_N_NAME_2);
1371 }
1372 }
1373
1374 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1375 Team.class.getName(), _FILTER_COLUMN_PK,
1376 _FILTER_COLUMN_USERID, groupId);
1377
1378 SQLQuery q = session.createSQLQuery(sql);
1379
1380 q.addScalar(COUNT_COLUMN_NAME,
1381 com.liferay.portal.kernel.dao.orm.Type.LONG);
1382
1383 QueryPos qPos = QueryPos.getInstance(q);
1384
1385 qPos.add(groupId);
1386
1387 if (name != null) {
1388 qPos.add(name);
1389 }
1390
1391 Long count = (Long)q.uniqueResult();
1392
1393 return count.intValue();
1394 }
1395 catch (Exception e) {
1396 throw processException(e);
1397 }
1398 finally {
1399 closeSession(session);
1400 }
1401 }
1402
1403
1409 public int countAll() throws SystemException {
1410 Object[] finderArgs = new Object[0];
1411
1412 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1413 finderArgs, this);
1414
1415 if (count == null) {
1416 Session session = null;
1417
1418 try {
1419 session = openSession();
1420
1421 Query q = session.createQuery(_SQL_COUNT_TEAM);
1422
1423 count = (Long)q.uniqueResult();
1424 }
1425 catch (Exception e) {
1426 throw processException(e);
1427 }
1428 finally {
1429 if (count == null) {
1430 count = Long.valueOf(0);
1431 }
1432
1433 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1434 count);
1435
1436 closeSession(session);
1437 }
1438 }
1439
1440 return count.intValue();
1441 }
1442
1443
1450 public List<com.liferay.portal.model.User> getUsers(long pk)
1451 throws SystemException {
1452 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1453 }
1454
1455
1468 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1469 int end) throws SystemException {
1470 return getUsers(pk, start, end, null);
1471 }
1472
1473 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1474 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1475 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1476 new String[] {
1477 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1478 "com.liferay.portal.kernel.util.OrderByComparator"
1479 });
1480
1481
1495 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1496 int end, OrderByComparator orderByComparator) throws SystemException {
1497 Object[] finderArgs = new Object[] {
1498 pk, String.valueOf(start), String.valueOf(end),
1499 String.valueOf(orderByComparator)
1500 };
1501
1502 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1503 finderArgs, this);
1504
1505 if (list == null) {
1506 Session session = null;
1507
1508 try {
1509 session = openSession();
1510
1511 String sql = null;
1512
1513 if (orderByComparator != null) {
1514 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1515 .concat(orderByComparator.getOrderBy());
1516 }
1517 else {
1518 sql = _SQL_GETUSERS;
1519 }
1520
1521 SQLQuery q = session.createSQLQuery(sql);
1522
1523 q.addEntity("User_",
1524 com.liferay.portal.model.impl.UserImpl.class);
1525
1526 QueryPos qPos = QueryPos.getInstance(q);
1527
1528 qPos.add(pk);
1529
1530 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1531 getDialect(), start, end);
1532 }
1533 catch (Exception e) {
1534 throw processException(e);
1535 }
1536 finally {
1537 if (list == null) {
1538 list = new ArrayList<com.liferay.portal.model.User>();
1539 }
1540
1541 userPersistence.cacheResult(list);
1542
1543 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS, finderArgs,
1544 list);
1545
1546 closeSession(session);
1547 }
1548 }
1549
1550 return list;
1551 }
1552
1553 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1554 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1555 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1556 new String[] { Long.class.getName() });
1557
1558
1565 public int getUsersSize(long pk) throws SystemException {
1566 Object[] finderArgs = new Object[] { pk };
1567
1568 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1569 finderArgs, this);
1570
1571 if (count == null) {
1572 Session session = null;
1573
1574 try {
1575 session = openSession();
1576
1577 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1578
1579 q.addScalar(COUNT_COLUMN_NAME,
1580 com.liferay.portal.kernel.dao.orm.Type.LONG);
1581
1582 QueryPos qPos = QueryPos.getInstance(q);
1583
1584 qPos.add(pk);
1585
1586 count = (Long)q.uniqueResult();
1587 }
1588 catch (Exception e) {
1589 throw processException(e);
1590 }
1591 finally {
1592 if (count == null) {
1593 count = Long.valueOf(0);
1594 }
1595
1596 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1597 finderArgs, count);
1598
1599 closeSession(session);
1600 }
1601 }
1602
1603 return count.intValue();
1604 }
1605
1606 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1607 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1608 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1609 new String[] { Long.class.getName(), Long.class.getName() });
1610
1611
1619 public boolean containsUser(long pk, long userPK) throws SystemException {
1620 Object[] finderArgs = new Object[] { pk, userPK };
1621
1622 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1623 finderArgs, this);
1624
1625 if (value == null) {
1626 try {
1627 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1628 }
1629 catch (Exception e) {
1630 throw processException(e);
1631 }
1632 finally {
1633 if (value == null) {
1634 value = Boolean.FALSE;
1635 }
1636
1637 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1638 finderArgs, value);
1639 }
1640 }
1641
1642 return value.booleanValue();
1643 }
1644
1645
1652 public boolean containsUsers(long pk) throws SystemException {
1653 if (getUsersSize(pk) > 0) {
1654 return true;
1655 }
1656 else {
1657 return false;
1658 }
1659 }
1660
1661
1668 public void addUser(long pk, long userPK) throws SystemException {
1669 try {
1670 addUser.add(pk, userPK);
1671 }
1672 catch (Exception e) {
1673 throw processException(e);
1674 }
1675 finally {
1676 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1677 }
1678 }
1679
1680
1687 public void addUser(long pk, com.liferay.portal.model.User user)
1688 throws SystemException {
1689 try {
1690 addUser.add(pk, user.getPrimaryKey());
1691 }
1692 catch (Exception e) {
1693 throw processException(e);
1694 }
1695 finally {
1696 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1697 }
1698 }
1699
1700
1707 public void addUsers(long pk, long[] userPKs) throws SystemException {
1708 try {
1709 for (long userPK : userPKs) {
1710 addUser.add(pk, userPK);
1711 }
1712 }
1713 catch (Exception e) {
1714 throw processException(e);
1715 }
1716 finally {
1717 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1718 }
1719 }
1720
1721
1728 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1729 throws SystemException {
1730 try {
1731 for (com.liferay.portal.model.User user : users) {
1732 addUser.add(pk, user.getPrimaryKey());
1733 }
1734 }
1735 catch (Exception e) {
1736 throw processException(e);
1737 }
1738 finally {
1739 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1740 }
1741 }
1742
1743
1749 public void clearUsers(long pk) throws SystemException {
1750 try {
1751 clearUsers.clear(pk);
1752 }
1753 catch (Exception e) {
1754 throw processException(e);
1755 }
1756 finally {
1757 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1758 }
1759 }
1760
1761
1768 public void removeUser(long pk, long userPK) throws SystemException {
1769 try {
1770 removeUser.remove(pk, userPK);
1771 }
1772 catch (Exception e) {
1773 throw processException(e);
1774 }
1775 finally {
1776 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1777 }
1778 }
1779
1780
1787 public void removeUser(long pk, com.liferay.portal.model.User user)
1788 throws SystemException {
1789 try {
1790 removeUser.remove(pk, user.getPrimaryKey());
1791 }
1792 catch (Exception e) {
1793 throw processException(e);
1794 }
1795 finally {
1796 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1797 }
1798 }
1799
1800
1807 public void removeUsers(long pk, long[] userPKs) throws SystemException {
1808 try {
1809 for (long userPK : userPKs) {
1810 removeUser.remove(pk, userPK);
1811 }
1812 }
1813 catch (Exception e) {
1814 throw processException(e);
1815 }
1816 finally {
1817 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1818 }
1819 }
1820
1821
1828 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
1829 throws SystemException {
1830 try {
1831 for (com.liferay.portal.model.User user : users) {
1832 removeUser.remove(pk, user.getPrimaryKey());
1833 }
1834 }
1835 catch (Exception e) {
1836 throw processException(e);
1837 }
1838 finally {
1839 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1840 }
1841 }
1842
1843
1850 public void setUsers(long pk, long[] userPKs) throws SystemException {
1851 try {
1852 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
1853
1854 List<com.liferay.portal.model.User> users = getUsers(pk);
1855
1856 for (com.liferay.portal.model.User user : users) {
1857 if (!userPKSet.remove(user.getPrimaryKey())) {
1858 removeUser.remove(pk, user.getPrimaryKey());
1859 }
1860 }
1861
1862 for (Long userPK : userPKSet) {
1863 addUser.add(pk, userPK);
1864 }
1865 }
1866 catch (Exception e) {
1867 throw processException(e);
1868 }
1869 finally {
1870 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1871 }
1872 }
1873
1874
1881 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
1882 throws SystemException {
1883 try {
1884 long[] userPKs = new long[users.size()];
1885
1886 for (int i = 0; i < users.size(); i++) {
1887 com.liferay.portal.model.User user = users.get(i);
1888
1889 userPKs[i] = user.getPrimaryKey();
1890 }
1891
1892 setUsers(pk, userPKs);
1893 }
1894 catch (Exception e) {
1895 throw processException(e);
1896 }
1897 finally {
1898 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1899 }
1900 }
1901
1902
1905 public void afterPropertiesSet() {
1906 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1907 com.liferay.portal.util.PropsUtil.get(
1908 "value.object.listener.com.liferay.portal.model.Team")));
1909
1910 if (listenerClassNames.length > 0) {
1911 try {
1912 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
1913
1914 for (String listenerClassName : listenerClassNames) {
1915 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
1916 listenerClassName));
1917 }
1918
1919 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1920 }
1921 catch (Exception e) {
1922 _log.error(e);
1923 }
1924 }
1925
1926 containsUser = new ContainsUser(this);
1927
1928 addUser = new AddUser(this);
1929 clearUsers = new ClearUsers(this);
1930 removeUser = new RemoveUser(this);
1931 }
1932
1933 public void destroy() {
1934 EntityCacheUtil.removeCache(TeamImpl.class.getName());
1935 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1936 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1937 }
1938
1939 @BeanReference(type = AccountPersistence.class)
1940 protected AccountPersistence accountPersistence;
1941 @BeanReference(type = AddressPersistence.class)
1942 protected AddressPersistence addressPersistence;
1943 @BeanReference(type = BrowserTrackerPersistence.class)
1944 protected BrowserTrackerPersistence browserTrackerPersistence;
1945 @BeanReference(type = ClassNamePersistence.class)
1946 protected ClassNamePersistence classNamePersistence;
1947 @BeanReference(type = ClusterGroupPersistence.class)
1948 protected ClusterGroupPersistence clusterGroupPersistence;
1949 @BeanReference(type = CompanyPersistence.class)
1950 protected CompanyPersistence companyPersistence;
1951 @BeanReference(type = ContactPersistence.class)
1952 protected ContactPersistence contactPersistence;
1953 @BeanReference(type = CountryPersistence.class)
1954 protected CountryPersistence countryPersistence;
1955 @BeanReference(type = EmailAddressPersistence.class)
1956 protected EmailAddressPersistence emailAddressPersistence;
1957 @BeanReference(type = GroupPersistence.class)
1958 protected GroupPersistence groupPersistence;
1959 @BeanReference(type = ImagePersistence.class)
1960 protected ImagePersistence imagePersistence;
1961 @BeanReference(type = LayoutPersistence.class)
1962 protected LayoutPersistence layoutPersistence;
1963 @BeanReference(type = LayoutPrototypePersistence.class)
1964 protected LayoutPrototypePersistence layoutPrototypePersistence;
1965 @BeanReference(type = LayoutSetPersistence.class)
1966 protected LayoutSetPersistence layoutSetPersistence;
1967 @BeanReference(type = LayoutSetPrototypePersistence.class)
1968 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1969 @BeanReference(type = ListTypePersistence.class)
1970 protected ListTypePersistence listTypePersistence;
1971 @BeanReference(type = LockPersistence.class)
1972 protected LockPersistence lockPersistence;
1973 @BeanReference(type = MembershipRequestPersistence.class)
1974 protected MembershipRequestPersistence membershipRequestPersistence;
1975 @BeanReference(type = OrganizationPersistence.class)
1976 protected OrganizationPersistence organizationPersistence;
1977 @BeanReference(type = OrgGroupPermissionPersistence.class)
1978 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1979 @BeanReference(type = OrgGroupRolePersistence.class)
1980 protected OrgGroupRolePersistence orgGroupRolePersistence;
1981 @BeanReference(type = OrgLaborPersistence.class)
1982 protected OrgLaborPersistence orgLaborPersistence;
1983 @BeanReference(type = PasswordPolicyPersistence.class)
1984 protected PasswordPolicyPersistence passwordPolicyPersistence;
1985 @BeanReference(type = PasswordPolicyRelPersistence.class)
1986 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1987 @BeanReference(type = PasswordTrackerPersistence.class)
1988 protected PasswordTrackerPersistence passwordTrackerPersistence;
1989 @BeanReference(type = PermissionPersistence.class)
1990 protected PermissionPersistence permissionPersistence;
1991 @BeanReference(type = PhonePersistence.class)
1992 protected PhonePersistence phonePersistence;
1993 @BeanReference(type = PluginSettingPersistence.class)
1994 protected PluginSettingPersistence pluginSettingPersistence;
1995 @BeanReference(type = PortletPersistence.class)
1996 protected PortletPersistence portletPersistence;
1997 @BeanReference(type = PortletItemPersistence.class)
1998 protected PortletItemPersistence portletItemPersistence;
1999 @BeanReference(type = PortletPreferencesPersistence.class)
2000 protected PortletPreferencesPersistence portletPreferencesPersistence;
2001 @BeanReference(type = RegionPersistence.class)
2002 protected RegionPersistence regionPersistence;
2003 @BeanReference(type = ReleasePersistence.class)
2004 protected ReleasePersistence releasePersistence;
2005 @BeanReference(type = ResourcePersistence.class)
2006 protected ResourcePersistence resourcePersistence;
2007 @BeanReference(type = ResourceActionPersistence.class)
2008 protected ResourceActionPersistence resourceActionPersistence;
2009 @BeanReference(type = ResourceCodePersistence.class)
2010 protected ResourceCodePersistence resourceCodePersistence;
2011 @BeanReference(type = ResourcePermissionPersistence.class)
2012 protected ResourcePermissionPersistence resourcePermissionPersistence;
2013 @BeanReference(type = RolePersistence.class)
2014 protected RolePersistence rolePersistence;
2015 @BeanReference(type = ServiceComponentPersistence.class)
2016 protected ServiceComponentPersistence serviceComponentPersistence;
2017 @BeanReference(type = ShardPersistence.class)
2018 protected ShardPersistence shardPersistence;
2019 @BeanReference(type = SubscriptionPersistence.class)
2020 protected SubscriptionPersistence subscriptionPersistence;
2021 @BeanReference(type = TicketPersistence.class)
2022 protected TicketPersistence ticketPersistence;
2023 @BeanReference(type = TeamPersistence.class)
2024 protected TeamPersistence teamPersistence;
2025 @BeanReference(type = UserPersistence.class)
2026 protected UserPersistence userPersistence;
2027 @BeanReference(type = UserGroupPersistence.class)
2028 protected UserGroupPersistence userGroupPersistence;
2029 @BeanReference(type = UserGroupGroupRolePersistence.class)
2030 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2031 @BeanReference(type = UserGroupRolePersistence.class)
2032 protected UserGroupRolePersistence userGroupRolePersistence;
2033 @BeanReference(type = UserIdMapperPersistence.class)
2034 protected UserIdMapperPersistence userIdMapperPersistence;
2035 @BeanReference(type = UserTrackerPersistence.class)
2036 protected UserTrackerPersistence userTrackerPersistence;
2037 @BeanReference(type = UserTrackerPathPersistence.class)
2038 protected UserTrackerPathPersistence userTrackerPathPersistence;
2039 @BeanReference(type = WebDAVPropsPersistence.class)
2040 protected WebDAVPropsPersistence webDAVPropsPersistence;
2041 @BeanReference(type = WebsitePersistence.class)
2042 protected WebsitePersistence websitePersistence;
2043 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2044 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2045 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2046 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2047 protected ContainsUser containsUser;
2048 protected AddUser addUser;
2049 protected ClearUsers clearUsers;
2050 protected RemoveUser removeUser;
2051
2052 protected class ContainsUser {
2053 protected ContainsUser(TeamPersistenceImpl persistenceImpl) {
2054 super();
2055
2056 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2057 _SQL_CONTAINSUSER,
2058 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2059 RowMapper.COUNT);
2060 }
2061
2062 protected boolean contains(long teamId, long userId) {
2063 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2064 new Long(teamId), new Long(userId)
2065 });
2066
2067 if (results.size() > 0) {
2068 Integer count = results.get(0);
2069
2070 if (count.intValue() > 0) {
2071 return true;
2072 }
2073 }
2074
2075 return false;
2076 }
2077
2078 private MappingSqlQuery<Integer> _mappingSqlQuery;
2079 }
2080
2081 protected class AddUser {
2082 protected AddUser(TeamPersistenceImpl persistenceImpl) {
2083 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2084 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2085 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2086 _persistenceImpl = persistenceImpl;
2087 }
2088
2089 protected void add(long teamId, long userId) throws SystemException {
2090 if (!_persistenceImpl.containsUser.contains(teamId, userId)) {
2091 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2092
2093 for (ModelListener<Team> listener : listeners) {
2094 listener.onBeforeAddAssociation(teamId,
2095 com.liferay.portal.model.User.class.getName(), userId);
2096 }
2097
2098 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2099 listener.onBeforeAddAssociation(userId,
2100 Team.class.getName(), teamId);
2101 }
2102
2103 _sqlUpdate.update(new Object[] {
2104 new Long(teamId), new Long(userId)
2105 });
2106
2107 for (ModelListener<Team> listener : listeners) {
2108 listener.onAfterAddAssociation(teamId,
2109 com.liferay.portal.model.User.class.getName(), userId);
2110 }
2111
2112 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2113 listener.onAfterAddAssociation(userId,
2114 Team.class.getName(), teamId);
2115 }
2116 }
2117 }
2118
2119 private SqlUpdate _sqlUpdate;
2120 private TeamPersistenceImpl _persistenceImpl;
2121 }
2122
2123 protected class ClearUsers {
2124 protected ClearUsers(TeamPersistenceImpl persistenceImpl) {
2125 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2126 "DELETE FROM Users_Teams WHERE teamId = ?",
2127 new int[] { java.sql.Types.BIGINT });
2128 }
2129
2130 protected void clear(long teamId) throws SystemException {
2131 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2132
2133 List<com.liferay.portal.model.User> users = null;
2134
2135 if ((listeners.length > 0) || (userListeners.length > 0)) {
2136 users = getUsers(teamId);
2137
2138 for (com.liferay.portal.model.User user : users) {
2139 for (ModelListener<Team> listener : listeners) {
2140 listener.onBeforeRemoveAssociation(teamId,
2141 com.liferay.portal.model.User.class.getName(),
2142 user.getPrimaryKey());
2143 }
2144
2145 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2146 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2147 Team.class.getName(), teamId);
2148 }
2149 }
2150 }
2151
2152 _sqlUpdate.update(new Object[] { new Long(teamId) });
2153
2154 if ((listeners.length > 0) || (userListeners.length > 0)) {
2155 for (com.liferay.portal.model.User user : users) {
2156 for (ModelListener<Team> listener : listeners) {
2157 listener.onAfterRemoveAssociation(teamId,
2158 com.liferay.portal.model.User.class.getName(),
2159 user.getPrimaryKey());
2160 }
2161
2162 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2163 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2164 Team.class.getName(), teamId);
2165 }
2166 }
2167 }
2168 }
2169
2170 private SqlUpdate _sqlUpdate;
2171 }
2172
2173 protected class RemoveUser {
2174 protected RemoveUser(TeamPersistenceImpl persistenceImpl) {
2175 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2176 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2177 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2178 _persistenceImpl = persistenceImpl;
2179 }
2180
2181 protected void remove(long teamId, long userId)
2182 throws SystemException {
2183 if (_persistenceImpl.containsUser.contains(teamId, userId)) {
2184 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2185
2186 for (ModelListener<Team> listener : listeners) {
2187 listener.onBeforeRemoveAssociation(teamId,
2188 com.liferay.portal.model.User.class.getName(), userId);
2189 }
2190
2191 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2192 listener.onBeforeRemoveAssociation(userId,
2193 Team.class.getName(), teamId);
2194 }
2195
2196 _sqlUpdate.update(new Object[] {
2197 new Long(teamId), new Long(userId)
2198 });
2199
2200 for (ModelListener<Team> listener : listeners) {
2201 listener.onAfterRemoveAssociation(teamId,
2202 com.liferay.portal.model.User.class.getName(), userId);
2203 }
2204
2205 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2206 listener.onAfterRemoveAssociation(userId,
2207 Team.class.getName(), teamId);
2208 }
2209 }
2210 }
2211
2212 private SqlUpdate _sqlUpdate;
2213 private TeamPersistenceImpl _persistenceImpl;
2214 }
2215
2216 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
2217 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
2218 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
2219 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
2220 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
2221 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
2222 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
2223 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
2224 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
2225 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
2226 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
2227 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
2228 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
2229 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE =
2230 "SELECT {team.*} FROM (SELECT DISTINCT teamId FROM Team) team2 INNER JOIN Team team ON (team2.teamId = team.teamId) WHERE ";
2231 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
2232 private static final String _FILTER_COLUMN_PK = "team.teamId";
2233 private static final String _FILTER_COLUMN_USERID = "team.userId";
2234 private static final String _FILTER_ENTITY_ALIAS = "team";
2235 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
2236 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
2237 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
2238 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
2239 }