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.getGroupId()),
263
264 teamModelImpl.getName()
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 StringBundler query = null;
489
490 if (orderByComparator != null) {
491 query = new StringBundler(3 +
492 (orderByComparator.getOrderByFields().length * 3));
493 }
494 else {
495 query = new StringBundler(3);
496 }
497
498 query.append(_SQL_SELECT_TEAM_WHERE);
499
500 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
501
502 if (orderByComparator != null) {
503 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
504 orderByComparator);
505 }
506
507 else {
508 query.append(TeamModelImpl.ORDER_BY_JPQL);
509 }
510
511 String sql = query.toString();
512
513 Session session = null;
514
515 try {
516 session = openSession();
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 FinderCacheUtil.removeResult(FINDER_PATH_FIND_BY_GROUPID,
532 finderArgs);
533 }
534 else {
535 cacheResult(list);
536
537 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
538 finderArgs, list);
539 }
540
541 closeSession(session);
542 }
543 }
544
545 return list;
546 }
547
548
561 public Team findByGroupId_First(long groupId,
562 OrderByComparator orderByComparator)
563 throws NoSuchTeamException, SystemException {
564 List<Team> list = findByGroupId(groupId, 0, 1, orderByComparator);
565
566 if (list.isEmpty()) {
567 StringBundler msg = new StringBundler(4);
568
569 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
570
571 msg.append("groupId=");
572 msg.append(groupId);
573
574 msg.append(StringPool.CLOSE_CURLY_BRACE);
575
576 throw new NoSuchTeamException(msg.toString());
577 }
578 else {
579 return list.get(0);
580 }
581 }
582
583
596 public Team findByGroupId_Last(long groupId,
597 OrderByComparator orderByComparator)
598 throws NoSuchTeamException, SystemException {
599 int count = countByGroupId(groupId);
600
601 List<Team> list = findByGroupId(groupId, count - 1, count,
602 orderByComparator);
603
604 if (list.isEmpty()) {
605 StringBundler msg = new StringBundler(4);
606
607 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
608
609 msg.append("groupId=");
610 msg.append(groupId);
611
612 msg.append(StringPool.CLOSE_CURLY_BRACE);
613
614 throw new NoSuchTeamException(msg.toString());
615 }
616 else {
617 return list.get(0);
618 }
619 }
620
621
635 public Team[] findByGroupId_PrevAndNext(long teamId, long groupId,
636 OrderByComparator orderByComparator)
637 throws NoSuchTeamException, SystemException {
638 Team team = findByPrimaryKey(teamId);
639
640 Session session = null;
641
642 try {
643 session = openSession();
644
645 Team[] array = new TeamImpl[3];
646
647 array[0] = getByGroupId_PrevAndNext(session, team, groupId,
648 orderByComparator, true);
649
650 array[1] = team;
651
652 array[2] = getByGroupId_PrevAndNext(session, team, groupId,
653 orderByComparator, false);
654
655 return array;
656 }
657 catch (Exception e) {
658 throw processException(e);
659 }
660 finally {
661 closeSession(session);
662 }
663 }
664
665 protected Team getByGroupId_PrevAndNext(Session session, Team team,
666 long groupId, OrderByComparator orderByComparator, boolean previous) {
667 StringBundler query = null;
668
669 if (orderByComparator != null) {
670 query = new StringBundler(6 +
671 (orderByComparator.getOrderByFields().length * 6));
672 }
673 else {
674 query = new StringBundler(3);
675 }
676
677 query.append(_SQL_SELECT_TEAM_WHERE);
678
679 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
680
681 if (orderByComparator != null) {
682 String[] orderByFields = orderByComparator.getOrderByFields();
683
684 if (orderByFields.length > 0) {
685 query.append(WHERE_AND);
686 }
687
688 for (int i = 0; i < orderByFields.length; i++) {
689 query.append(_ORDER_BY_ENTITY_ALIAS);
690 query.append(orderByFields[i]);
691
692 if ((i + 1) < orderByFields.length) {
693 if (orderByComparator.isAscending() ^ previous) {
694 query.append(WHERE_GREATER_THAN_HAS_NEXT);
695 }
696 else {
697 query.append(WHERE_LESSER_THAN_HAS_NEXT);
698 }
699 }
700 else {
701 if (orderByComparator.isAscending() ^ previous) {
702 query.append(WHERE_GREATER_THAN);
703 }
704 else {
705 query.append(WHERE_LESSER_THAN);
706 }
707 }
708 }
709
710 query.append(ORDER_BY_CLAUSE);
711
712 for (int i = 0; i < orderByFields.length; i++) {
713 query.append(_ORDER_BY_ENTITY_ALIAS);
714 query.append(orderByFields[i]);
715
716 if ((i + 1) < orderByFields.length) {
717 if (orderByComparator.isAscending() ^ previous) {
718 query.append(ORDER_BY_ASC_HAS_NEXT);
719 }
720 else {
721 query.append(ORDER_BY_DESC_HAS_NEXT);
722 }
723 }
724 else {
725 if (orderByComparator.isAscending() ^ previous) {
726 query.append(ORDER_BY_ASC);
727 }
728 else {
729 query.append(ORDER_BY_DESC);
730 }
731 }
732 }
733 }
734
735 else {
736 query.append(TeamModelImpl.ORDER_BY_JPQL);
737 }
738
739 String sql = query.toString();
740
741 Query q = session.createQuery(sql);
742
743 q.setFirstResult(0);
744 q.setMaxResults(2);
745
746 QueryPos qPos = QueryPos.getInstance(q);
747
748 qPos.add(groupId);
749
750 if (orderByComparator != null) {
751 Object[] values = orderByComparator.getOrderByValues(team);
752
753 for (Object value : values) {
754 qPos.add(value);
755 }
756 }
757
758 List<Team> list = q.list();
759
760 if (list.size() == 2) {
761 return list.get(1);
762 }
763 else {
764 return null;
765 }
766 }
767
768
775 public List<Team> filterFindByGroupId(long groupId)
776 throws SystemException {
777 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
778 QueryUtil.ALL_POS, null);
779 }
780
781
794 public List<Team> filterFindByGroupId(long groupId, int start, int end)
795 throws SystemException {
796 return filterFindByGroupId(groupId, start, end, null);
797 }
798
799
813 public List<Team> filterFindByGroupId(long groupId, int start, int end,
814 OrderByComparator orderByComparator) throws SystemException {
815 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
816 return findByGroupId(groupId, start, end, orderByComparator);
817 }
818
819 StringBundler query = null;
820
821 if (orderByComparator != null) {
822 query = new StringBundler(3 +
823 (orderByComparator.getOrderByFields().length * 3));
824 }
825 else {
826 query = new StringBundler(3);
827 }
828
829 if (getDB().isSupportsInlineDistinct()) {
830 query.append(_FILTER_SQL_SELECT_TEAM_WHERE);
831 }
832 else {
833 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1);
834 }
835
836 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
837
838 if (!getDB().isSupportsInlineDistinct()) {
839 query.append(_FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2);
840 }
841
842 if (orderByComparator != null) {
843 if (getDB().isSupportsInlineDistinct()) {
844 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
845 orderByComparator);
846 }
847 else {
848 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
849 orderByComparator);
850 }
851 }
852
853 else {
854 if (getDB().isSupportsInlineDistinct()) {
855 query.append(TeamModelImpl.ORDER_BY_JPQL);
856 }
857 else {
858 query.append(TeamModelImpl.ORDER_BY_SQL);
859 }
860 }
861
862 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
863 Team.class.getName(), _FILTER_COLUMN_PK, _FILTER_COLUMN_USERID,
864 groupId);
865
866 Session session = null;
867
868 try {
869 session = openSession();
870
871 SQLQuery q = session.createSQLQuery(sql);
872
873 if (getDB().isSupportsInlineDistinct()) {
874 q.addEntity(_FILTER_ENTITY_ALIAS, TeamImpl.class);
875 }
876 else {
877 q.addEntity(_FILTER_ENTITY_TABLE, TeamImpl.class);
878 }
879
880 QueryPos qPos = QueryPos.getInstance(q);
881
882 qPos.add(groupId);
883
884 return (List<Team>)QueryUtil.list(q, getDialect(), start, end);
885 }
886 catch (Exception e) {
887 throw processException(e);
888 }
889 finally {
890 closeSession(session);
891 }
892 }
893
894
903 public Team findByG_N(long groupId, String name)
904 throws NoSuchTeamException, SystemException {
905 Team team = fetchByG_N(groupId, name);
906
907 if (team == null) {
908 StringBundler msg = new StringBundler(6);
909
910 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
911
912 msg.append("groupId=");
913 msg.append(groupId);
914
915 msg.append(", name=");
916 msg.append(name);
917
918 msg.append(StringPool.CLOSE_CURLY_BRACE);
919
920 if (_log.isWarnEnabled()) {
921 _log.warn(msg.toString());
922 }
923
924 throw new NoSuchTeamException(msg.toString());
925 }
926
927 return team;
928 }
929
930
938 public Team fetchByG_N(long groupId, String name) throws SystemException {
939 return fetchByG_N(groupId, name, true);
940 }
941
942
950 public Team fetchByG_N(long groupId, String name, boolean retrieveFromCache)
951 throws SystemException {
952 Object[] finderArgs = new Object[] { groupId, name };
953
954 Object result = null;
955
956 if (retrieveFromCache) {
957 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
958 finderArgs, this);
959 }
960
961 if (result == null) {
962 StringBundler query = new StringBundler(4);
963
964 query.append(_SQL_SELECT_TEAM_WHERE);
965
966 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
967
968 if (name == null) {
969 query.append(_FINDER_COLUMN_G_N_NAME_1);
970 }
971 else {
972 if (name.equals(StringPool.BLANK)) {
973 query.append(_FINDER_COLUMN_G_N_NAME_3);
974 }
975 else {
976 query.append(_FINDER_COLUMN_G_N_NAME_2);
977 }
978 }
979
980 query.append(TeamModelImpl.ORDER_BY_JPQL);
981
982 String sql = query.toString();
983
984 Session session = null;
985
986 try {
987 session = openSession();
988
989 Query q = session.createQuery(sql);
990
991 QueryPos qPos = QueryPos.getInstance(q);
992
993 qPos.add(groupId);
994
995 if (name != null) {
996 qPos.add(name);
997 }
998
999 List<Team> list = q.list();
1000
1001 result = list;
1002
1003 Team team = null;
1004
1005 if (list.isEmpty()) {
1006 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1007 finderArgs, list);
1008 }
1009 else {
1010 team = list.get(0);
1011
1012 cacheResult(team);
1013
1014 if ((team.getGroupId() != groupId) ||
1015 (team.getName() == null) ||
1016 !team.getName().equals(name)) {
1017 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
1018 finderArgs, team);
1019 }
1020 }
1021
1022 return team;
1023 }
1024 catch (Exception e) {
1025 throw processException(e);
1026 }
1027 finally {
1028 if (result == null) {
1029 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
1030 finderArgs);
1031 }
1032
1033 closeSession(session);
1034 }
1035 }
1036 else {
1037 if (result instanceof List<?>) {
1038 return null;
1039 }
1040 else {
1041 return (Team)result;
1042 }
1043 }
1044 }
1045
1046
1052 public List<Team> findAll() throws SystemException {
1053 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1054 }
1055
1056
1068 public List<Team> findAll(int start, int end) throws SystemException {
1069 return findAll(start, end, null);
1070 }
1071
1072
1085 public List<Team> findAll(int start, int end,
1086 OrderByComparator orderByComparator) throws SystemException {
1087 Object[] finderArgs = new Object[] {
1088 String.valueOf(start), String.valueOf(end),
1089 String.valueOf(orderByComparator)
1090 };
1091
1092 List<Team> list = (List<Team>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1093 finderArgs, this);
1094
1095 if (list == null) {
1096 StringBundler query = null;
1097 String sql = null;
1098
1099 if (orderByComparator != null) {
1100 query = new StringBundler(2 +
1101 (orderByComparator.getOrderByFields().length * 3));
1102
1103 query.append(_SQL_SELECT_TEAM);
1104
1105 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1106 orderByComparator);
1107
1108 sql = query.toString();
1109 }
1110 else {
1111 sql = _SQL_SELECT_TEAM.concat(TeamModelImpl.ORDER_BY_JPQL);
1112 }
1113
1114 Session session = null;
1115
1116 try {
1117 session = openSession();
1118
1119 Query q = session.createQuery(sql);
1120
1121 if (orderByComparator == null) {
1122 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1123 end, false);
1124
1125 Collections.sort(list);
1126 }
1127 else {
1128 list = (List<Team>)QueryUtil.list(q, getDialect(), start,
1129 end);
1130 }
1131 }
1132 catch (Exception e) {
1133 throw processException(e);
1134 }
1135 finally {
1136 if (list == null) {
1137 FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
1138 finderArgs);
1139 }
1140 else {
1141 cacheResult(list);
1142
1143 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
1144 list);
1145 }
1146
1147 closeSession(session);
1148 }
1149 }
1150
1151 return list;
1152 }
1153
1154
1160 public void removeByGroupId(long groupId) throws SystemException {
1161 for (Team team : findByGroupId(groupId)) {
1162 remove(team);
1163 }
1164 }
1165
1166
1173 public void removeByG_N(long groupId, String name)
1174 throws NoSuchTeamException, SystemException {
1175 Team team = findByG_N(groupId, name);
1176
1177 remove(team);
1178 }
1179
1180
1185 public void removeAll() throws SystemException {
1186 for (Team team : findAll()) {
1187 remove(team);
1188 }
1189 }
1190
1191
1198 public int countByGroupId(long groupId) throws SystemException {
1199 Object[] finderArgs = new Object[] { groupId };
1200
1201 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1202 finderArgs, this);
1203
1204 if (count == null) {
1205 StringBundler query = new StringBundler(2);
1206
1207 query.append(_SQL_COUNT_TEAM_WHERE);
1208
1209 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1210
1211 String sql = query.toString();
1212
1213 Session session = null;
1214
1215 try {
1216 session = openSession();
1217
1218 Query q = session.createQuery(sql);
1219
1220 QueryPos qPos = QueryPos.getInstance(q);
1221
1222 qPos.add(groupId);
1223
1224 count = (Long)q.uniqueResult();
1225 }
1226 catch (Exception e) {
1227 throw processException(e);
1228 }
1229 finally {
1230 if (count == null) {
1231 count = Long.valueOf(0);
1232 }
1233
1234 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1235 finderArgs, count);
1236
1237 closeSession(session);
1238 }
1239 }
1240
1241 return count.intValue();
1242 }
1243
1244
1251 public int filterCountByGroupId(long groupId) throws SystemException {
1252 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1253 return countByGroupId(groupId);
1254 }
1255
1256 StringBundler query = new StringBundler(2);
1257
1258 query.append(_FILTER_SQL_COUNT_TEAM_WHERE);
1259
1260 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1261
1262 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1263 Team.class.getName(), _FILTER_COLUMN_PK, _FILTER_COLUMN_USERID,
1264 groupId);
1265
1266 Session session = null;
1267
1268 try {
1269 session = openSession();
1270
1271 SQLQuery q = session.createSQLQuery(sql);
1272
1273 q.addScalar(COUNT_COLUMN_NAME,
1274 com.liferay.portal.kernel.dao.orm.Type.LONG);
1275
1276 QueryPos qPos = QueryPos.getInstance(q);
1277
1278 qPos.add(groupId);
1279
1280 Long count = (Long)q.uniqueResult();
1281
1282 return count.intValue();
1283 }
1284 catch (Exception e) {
1285 throw processException(e);
1286 }
1287 finally {
1288 closeSession(session);
1289 }
1290 }
1291
1292
1300 public int countByG_N(long groupId, String name) throws SystemException {
1301 Object[] finderArgs = new Object[] { groupId, name };
1302
1303 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
1304 finderArgs, this);
1305
1306 if (count == null) {
1307 StringBundler query = new StringBundler(3);
1308
1309 query.append(_SQL_COUNT_TEAM_WHERE);
1310
1311 query.append(_FINDER_COLUMN_G_N_GROUPID_2);
1312
1313 if (name == null) {
1314 query.append(_FINDER_COLUMN_G_N_NAME_1);
1315 }
1316 else {
1317 if (name.equals(StringPool.BLANK)) {
1318 query.append(_FINDER_COLUMN_G_N_NAME_3);
1319 }
1320 else {
1321 query.append(_FINDER_COLUMN_G_N_NAME_2);
1322 }
1323 }
1324
1325 String sql = query.toString();
1326
1327 Session session = null;
1328
1329 try {
1330 session = openSession();
1331
1332 Query q = session.createQuery(sql);
1333
1334 QueryPos qPos = QueryPos.getInstance(q);
1335
1336 qPos.add(groupId);
1337
1338 if (name != null) {
1339 qPos.add(name);
1340 }
1341
1342 count = (Long)q.uniqueResult();
1343 }
1344 catch (Exception e) {
1345 throw processException(e);
1346 }
1347 finally {
1348 if (count == null) {
1349 count = Long.valueOf(0);
1350 }
1351
1352 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
1353 count);
1354
1355 closeSession(session);
1356 }
1357 }
1358
1359 return count.intValue();
1360 }
1361
1362
1368 public int countAll() throws SystemException {
1369 Object[] finderArgs = new Object[0];
1370
1371 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1372 finderArgs, this);
1373
1374 if (count == null) {
1375 Session session = null;
1376
1377 try {
1378 session = openSession();
1379
1380 Query q = session.createQuery(_SQL_COUNT_TEAM);
1381
1382 count = (Long)q.uniqueResult();
1383 }
1384 catch (Exception e) {
1385 throw processException(e);
1386 }
1387 finally {
1388 if (count == null) {
1389 count = Long.valueOf(0);
1390 }
1391
1392 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1393 count);
1394
1395 closeSession(session);
1396 }
1397 }
1398
1399 return count.intValue();
1400 }
1401
1402
1409 public List<com.liferay.portal.model.User> getUsers(long pk)
1410 throws SystemException {
1411 return getUsers(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
1412 }
1413
1414
1427 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1428 int end) throws SystemException {
1429 return getUsers(pk, start, end, null);
1430 }
1431
1432 public static final FinderPath FINDER_PATH_GET_USERS = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1433 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1434 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsers",
1435 new String[] {
1436 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
1437 "com.liferay.portal.kernel.util.OrderByComparator"
1438 });
1439
1440
1454 public List<com.liferay.portal.model.User> getUsers(long pk, int start,
1455 int end, OrderByComparator orderByComparator) throws SystemException {
1456 Object[] finderArgs = new Object[] {
1457 pk, String.valueOf(start), String.valueOf(end),
1458 String.valueOf(orderByComparator)
1459 };
1460
1461 List<com.liferay.portal.model.User> list = (List<com.liferay.portal.model.User>)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS,
1462 finderArgs, this);
1463
1464 if (list == null) {
1465 Session session = null;
1466
1467 try {
1468 session = openSession();
1469
1470 String sql = null;
1471
1472 if (orderByComparator != null) {
1473 sql = _SQL_GETUSERS.concat(ORDER_BY_CLAUSE)
1474 .concat(orderByComparator.getOrderBy());
1475 }
1476 else {
1477 sql = _SQL_GETUSERS;
1478 }
1479
1480 SQLQuery q = session.createSQLQuery(sql);
1481
1482 q.addEntity("User_",
1483 com.liferay.portal.model.impl.UserImpl.class);
1484
1485 QueryPos qPos = QueryPos.getInstance(q);
1486
1487 qPos.add(pk);
1488
1489 list = (List<com.liferay.portal.model.User>)QueryUtil.list(q,
1490 getDialect(), start, end);
1491 }
1492 catch (Exception e) {
1493 throw processException(e);
1494 }
1495 finally {
1496 if (list == null) {
1497 FinderCacheUtil.removeResult(FINDER_PATH_GET_USERS,
1498 finderArgs);
1499 }
1500 else {
1501 userPersistence.cacheResult(list);
1502
1503 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS,
1504 finderArgs, list);
1505 }
1506
1507 closeSession(session);
1508 }
1509 }
1510
1511 return list;
1512 }
1513
1514 public static final FinderPath FINDER_PATH_GET_USERS_SIZE = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1515 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1516 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "getUsersSize",
1517 new String[] { Long.class.getName() });
1518
1519
1526 public int getUsersSize(long pk) throws SystemException {
1527 Object[] finderArgs = new Object[] { pk };
1528
1529 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_USERS_SIZE,
1530 finderArgs, this);
1531
1532 if (count == null) {
1533 Session session = null;
1534
1535 try {
1536 session = openSession();
1537
1538 SQLQuery q = session.createSQLQuery(_SQL_GETUSERSSIZE);
1539
1540 q.addScalar(COUNT_COLUMN_NAME,
1541 com.liferay.portal.kernel.dao.orm.Type.LONG);
1542
1543 QueryPos qPos = QueryPos.getInstance(q);
1544
1545 qPos.add(pk);
1546
1547 count = (Long)q.uniqueResult();
1548 }
1549 catch (Exception e) {
1550 throw processException(e);
1551 }
1552 finally {
1553 if (count == null) {
1554 count = Long.valueOf(0);
1555 }
1556
1557 FinderCacheUtil.putResult(FINDER_PATH_GET_USERS_SIZE,
1558 finderArgs, count);
1559
1560 closeSession(session);
1561 }
1562 }
1563
1564 return count.intValue();
1565 }
1566
1567 public static final FinderPath FINDER_PATH_CONTAINS_USER = new FinderPath(com.liferay.portal.model.impl.UserModelImpl.ENTITY_CACHE_ENABLED,
1568 TeamModelImpl.FINDER_CACHE_ENABLED_USERS_TEAMS,
1569 TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME, "containsUser",
1570 new String[] { Long.class.getName(), Long.class.getName() });
1571
1572
1580 public boolean containsUser(long pk, long userPK) throws SystemException {
1581 Object[] finderArgs = new Object[] { pk, userPK };
1582
1583 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_USER,
1584 finderArgs, this);
1585
1586 if (value == null) {
1587 try {
1588 value = Boolean.valueOf(containsUser.contains(pk, userPK));
1589 }
1590 catch (Exception e) {
1591 throw processException(e);
1592 }
1593 finally {
1594 if (value == null) {
1595 value = Boolean.FALSE;
1596 }
1597
1598 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_USER,
1599 finderArgs, value);
1600 }
1601 }
1602
1603 return value.booleanValue();
1604 }
1605
1606
1613 public boolean containsUsers(long pk) throws SystemException {
1614 if (getUsersSize(pk) > 0) {
1615 return true;
1616 }
1617 else {
1618 return false;
1619 }
1620 }
1621
1622
1629 public void addUser(long pk, long userPK) throws SystemException {
1630 try {
1631 addUser.add(pk, userPK);
1632 }
1633 catch (Exception e) {
1634 throw processException(e);
1635 }
1636 finally {
1637 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1638 }
1639 }
1640
1641
1648 public void addUser(long pk, com.liferay.portal.model.User user)
1649 throws SystemException {
1650 try {
1651 addUser.add(pk, user.getPrimaryKey());
1652 }
1653 catch (Exception e) {
1654 throw processException(e);
1655 }
1656 finally {
1657 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1658 }
1659 }
1660
1661
1668 public void addUsers(long pk, long[] userPKs) throws SystemException {
1669 try {
1670 for (long userPK : userPKs) {
1671 addUser.add(pk, userPK);
1672 }
1673 }
1674 catch (Exception e) {
1675 throw processException(e);
1676 }
1677 finally {
1678 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1679 }
1680 }
1681
1682
1689 public void addUsers(long pk, List<com.liferay.portal.model.User> users)
1690 throws SystemException {
1691 try {
1692 for (com.liferay.portal.model.User user : users) {
1693 addUser.add(pk, user.getPrimaryKey());
1694 }
1695 }
1696 catch (Exception e) {
1697 throw processException(e);
1698 }
1699 finally {
1700 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1701 }
1702 }
1703
1704
1710 public void clearUsers(long pk) throws SystemException {
1711 try {
1712 clearUsers.clear(pk);
1713 }
1714 catch (Exception e) {
1715 throw processException(e);
1716 }
1717 finally {
1718 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1719 }
1720 }
1721
1722
1729 public void removeUser(long pk, long userPK) throws SystemException {
1730 try {
1731 removeUser.remove(pk, userPK);
1732 }
1733 catch (Exception e) {
1734 throw processException(e);
1735 }
1736 finally {
1737 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1738 }
1739 }
1740
1741
1748 public void removeUser(long pk, com.liferay.portal.model.User user)
1749 throws SystemException {
1750 try {
1751 removeUser.remove(pk, user.getPrimaryKey());
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 removeUsers(long pk, long[] userPKs) throws SystemException {
1769 try {
1770 for (long userPK : userPKs) {
1771 removeUser.remove(pk, userPK);
1772 }
1773 }
1774 catch (Exception e) {
1775 throw processException(e);
1776 }
1777 finally {
1778 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1779 }
1780 }
1781
1782
1789 public void removeUsers(long pk, List<com.liferay.portal.model.User> users)
1790 throws SystemException {
1791 try {
1792 for (com.liferay.portal.model.User user : users) {
1793 removeUser.remove(pk, user.getPrimaryKey());
1794 }
1795 }
1796 catch (Exception e) {
1797 throw processException(e);
1798 }
1799 finally {
1800 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1801 }
1802 }
1803
1804
1811 public void setUsers(long pk, long[] userPKs) throws SystemException {
1812 try {
1813 Set<Long> userPKSet = SetUtil.fromArray(userPKs);
1814
1815 List<com.liferay.portal.model.User> users = getUsers(pk);
1816
1817 for (com.liferay.portal.model.User user : users) {
1818 if (!userPKSet.remove(user.getPrimaryKey())) {
1819 removeUser.remove(pk, user.getPrimaryKey());
1820 }
1821 }
1822
1823 for (Long userPK : userPKSet) {
1824 addUser.add(pk, userPK);
1825 }
1826 }
1827 catch (Exception e) {
1828 throw processException(e);
1829 }
1830 finally {
1831 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1832 }
1833 }
1834
1835
1842 public void setUsers(long pk, List<com.liferay.portal.model.User> users)
1843 throws SystemException {
1844 try {
1845 long[] userPKs = new long[users.size()];
1846
1847 for (int i = 0; i < users.size(); i++) {
1848 com.liferay.portal.model.User user = users.get(i);
1849
1850 userPKs[i] = user.getPrimaryKey();
1851 }
1852
1853 setUsers(pk, userPKs);
1854 }
1855 catch (Exception e) {
1856 throw processException(e);
1857 }
1858 finally {
1859 FinderCacheUtil.clearCache(TeamModelImpl.MAPPING_TABLE_USERS_TEAMS_NAME);
1860 }
1861 }
1862
1863
1866 public void afterPropertiesSet() {
1867 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1868 com.liferay.portal.util.PropsUtil.get(
1869 "value.object.listener.com.liferay.portal.model.Team")));
1870
1871 if (listenerClassNames.length > 0) {
1872 try {
1873 List<ModelListener<Team>> listenersList = new ArrayList<ModelListener<Team>>();
1874
1875 for (String listenerClassName : listenerClassNames) {
1876 listenersList.add((ModelListener<Team>)InstanceFactory.newInstance(
1877 listenerClassName));
1878 }
1879
1880 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1881 }
1882 catch (Exception e) {
1883 _log.error(e);
1884 }
1885 }
1886
1887 containsUser = new ContainsUser(this);
1888
1889 addUser = new AddUser(this);
1890 clearUsers = new ClearUsers(this);
1891 removeUser = new RemoveUser(this);
1892 }
1893
1894 public void destroy() {
1895 EntityCacheUtil.removeCache(TeamImpl.class.getName());
1896 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
1897 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
1898 }
1899
1900 @BeanReference(type = AccountPersistence.class)
1901 protected AccountPersistence accountPersistence;
1902 @BeanReference(type = AddressPersistence.class)
1903 protected AddressPersistence addressPersistence;
1904 @BeanReference(type = BrowserTrackerPersistence.class)
1905 protected BrowserTrackerPersistence browserTrackerPersistence;
1906 @BeanReference(type = ClassNamePersistence.class)
1907 protected ClassNamePersistence classNamePersistence;
1908 @BeanReference(type = ClusterGroupPersistence.class)
1909 protected ClusterGroupPersistence clusterGroupPersistence;
1910 @BeanReference(type = CompanyPersistence.class)
1911 protected CompanyPersistence companyPersistence;
1912 @BeanReference(type = ContactPersistence.class)
1913 protected ContactPersistence contactPersistence;
1914 @BeanReference(type = CountryPersistence.class)
1915 protected CountryPersistence countryPersistence;
1916 @BeanReference(type = EmailAddressPersistence.class)
1917 protected EmailAddressPersistence emailAddressPersistence;
1918 @BeanReference(type = GroupPersistence.class)
1919 protected GroupPersistence groupPersistence;
1920 @BeanReference(type = ImagePersistence.class)
1921 protected ImagePersistence imagePersistence;
1922 @BeanReference(type = LayoutPersistence.class)
1923 protected LayoutPersistence layoutPersistence;
1924 @BeanReference(type = LayoutPrototypePersistence.class)
1925 protected LayoutPrototypePersistence layoutPrototypePersistence;
1926 @BeanReference(type = LayoutSetPersistence.class)
1927 protected LayoutSetPersistence layoutSetPersistence;
1928 @BeanReference(type = LayoutSetPrototypePersistence.class)
1929 protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
1930 @BeanReference(type = ListTypePersistence.class)
1931 protected ListTypePersistence listTypePersistence;
1932 @BeanReference(type = LockPersistence.class)
1933 protected LockPersistence lockPersistence;
1934 @BeanReference(type = MembershipRequestPersistence.class)
1935 protected MembershipRequestPersistence membershipRequestPersistence;
1936 @BeanReference(type = OrganizationPersistence.class)
1937 protected OrganizationPersistence organizationPersistence;
1938 @BeanReference(type = OrgGroupPermissionPersistence.class)
1939 protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1940 @BeanReference(type = OrgGroupRolePersistence.class)
1941 protected OrgGroupRolePersistence orgGroupRolePersistence;
1942 @BeanReference(type = OrgLaborPersistence.class)
1943 protected OrgLaborPersistence orgLaborPersistence;
1944 @BeanReference(type = PasswordPolicyPersistence.class)
1945 protected PasswordPolicyPersistence passwordPolicyPersistence;
1946 @BeanReference(type = PasswordPolicyRelPersistence.class)
1947 protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1948 @BeanReference(type = PasswordTrackerPersistence.class)
1949 protected PasswordTrackerPersistence passwordTrackerPersistence;
1950 @BeanReference(type = PermissionPersistence.class)
1951 protected PermissionPersistence permissionPersistence;
1952 @BeanReference(type = PhonePersistence.class)
1953 protected PhonePersistence phonePersistence;
1954 @BeanReference(type = PluginSettingPersistence.class)
1955 protected PluginSettingPersistence pluginSettingPersistence;
1956 @BeanReference(type = PortletPersistence.class)
1957 protected PortletPersistence portletPersistence;
1958 @BeanReference(type = PortletItemPersistence.class)
1959 protected PortletItemPersistence portletItemPersistence;
1960 @BeanReference(type = PortletPreferencesPersistence.class)
1961 protected PortletPreferencesPersistence portletPreferencesPersistence;
1962 @BeanReference(type = RegionPersistence.class)
1963 protected RegionPersistence regionPersistence;
1964 @BeanReference(type = ReleasePersistence.class)
1965 protected ReleasePersistence releasePersistence;
1966 @BeanReference(type = ResourcePersistence.class)
1967 protected ResourcePersistence resourcePersistence;
1968 @BeanReference(type = ResourceActionPersistence.class)
1969 protected ResourceActionPersistence resourceActionPersistence;
1970 @BeanReference(type = ResourceCodePersistence.class)
1971 protected ResourceCodePersistence resourceCodePersistence;
1972 @BeanReference(type = ResourcePermissionPersistence.class)
1973 protected ResourcePermissionPersistence resourcePermissionPersistence;
1974 @BeanReference(type = RolePersistence.class)
1975 protected RolePersistence rolePersistence;
1976 @BeanReference(type = ServiceComponentPersistence.class)
1977 protected ServiceComponentPersistence serviceComponentPersistence;
1978 @BeanReference(type = ShardPersistence.class)
1979 protected ShardPersistence shardPersistence;
1980 @BeanReference(type = SubscriptionPersistence.class)
1981 protected SubscriptionPersistence subscriptionPersistence;
1982 @BeanReference(type = TicketPersistence.class)
1983 protected TicketPersistence ticketPersistence;
1984 @BeanReference(type = TeamPersistence.class)
1985 protected TeamPersistence teamPersistence;
1986 @BeanReference(type = UserPersistence.class)
1987 protected UserPersistence userPersistence;
1988 @BeanReference(type = UserGroupPersistence.class)
1989 protected UserGroupPersistence userGroupPersistence;
1990 @BeanReference(type = UserGroupGroupRolePersistence.class)
1991 protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
1992 @BeanReference(type = UserGroupRolePersistence.class)
1993 protected UserGroupRolePersistence userGroupRolePersistence;
1994 @BeanReference(type = UserIdMapperPersistence.class)
1995 protected UserIdMapperPersistence userIdMapperPersistence;
1996 @BeanReference(type = UserTrackerPersistence.class)
1997 protected UserTrackerPersistence userTrackerPersistence;
1998 @BeanReference(type = UserTrackerPathPersistence.class)
1999 protected UserTrackerPathPersistence userTrackerPathPersistence;
2000 @BeanReference(type = WebDAVPropsPersistence.class)
2001 protected WebDAVPropsPersistence webDAVPropsPersistence;
2002 @BeanReference(type = WebsitePersistence.class)
2003 protected WebsitePersistence websitePersistence;
2004 @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2005 protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2006 @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2007 protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2008 protected ContainsUser containsUser;
2009 protected AddUser addUser;
2010 protected ClearUsers clearUsers;
2011 protected RemoveUser removeUser;
2012
2013 protected class ContainsUser {
2014 protected ContainsUser(TeamPersistenceImpl persistenceImpl) {
2015 super();
2016
2017 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
2018 _SQL_CONTAINSUSER,
2019 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
2020 RowMapper.COUNT);
2021 }
2022
2023 protected boolean contains(long teamId, long userId) {
2024 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
2025 new Long(teamId), new Long(userId)
2026 });
2027
2028 if (results.size() > 0) {
2029 Integer count = results.get(0);
2030
2031 if (count.intValue() > 0) {
2032 return true;
2033 }
2034 }
2035
2036 return false;
2037 }
2038
2039 private MappingSqlQuery<Integer> _mappingSqlQuery;
2040 }
2041
2042 protected class AddUser {
2043 protected AddUser(TeamPersistenceImpl persistenceImpl) {
2044 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2045 "INSERT INTO Users_Teams (teamId, userId) VALUES (?, ?)",
2046 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2047 _persistenceImpl = persistenceImpl;
2048 }
2049
2050 protected void add(long teamId, long userId) throws SystemException {
2051 if (!_persistenceImpl.containsUser.contains(teamId, userId)) {
2052 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2053
2054 for (ModelListener<Team> listener : listeners) {
2055 listener.onBeforeAddAssociation(teamId,
2056 com.liferay.portal.model.User.class.getName(), userId);
2057 }
2058
2059 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2060 listener.onBeforeAddAssociation(userId,
2061 Team.class.getName(), teamId);
2062 }
2063
2064 _sqlUpdate.update(new Object[] {
2065 new Long(teamId), new Long(userId)
2066 });
2067
2068 for (ModelListener<Team> listener : listeners) {
2069 listener.onAfterAddAssociation(teamId,
2070 com.liferay.portal.model.User.class.getName(), userId);
2071 }
2072
2073 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2074 listener.onAfterAddAssociation(userId,
2075 Team.class.getName(), teamId);
2076 }
2077 }
2078 }
2079
2080 private SqlUpdate _sqlUpdate;
2081 private TeamPersistenceImpl _persistenceImpl;
2082 }
2083
2084 protected class ClearUsers {
2085 protected ClearUsers(TeamPersistenceImpl persistenceImpl) {
2086 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2087 "DELETE FROM Users_Teams WHERE teamId = ?",
2088 new int[] { java.sql.Types.BIGINT });
2089 }
2090
2091 protected void clear(long teamId) throws SystemException {
2092 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2093
2094 List<com.liferay.portal.model.User> users = null;
2095
2096 if ((listeners.length > 0) || (userListeners.length > 0)) {
2097 users = getUsers(teamId);
2098
2099 for (com.liferay.portal.model.User user : users) {
2100 for (ModelListener<Team> listener : listeners) {
2101 listener.onBeforeRemoveAssociation(teamId,
2102 com.liferay.portal.model.User.class.getName(),
2103 user.getPrimaryKey());
2104 }
2105
2106 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2107 listener.onBeforeRemoveAssociation(user.getPrimaryKey(),
2108 Team.class.getName(), teamId);
2109 }
2110 }
2111 }
2112
2113 _sqlUpdate.update(new Object[] { new Long(teamId) });
2114
2115 if ((listeners.length > 0) || (userListeners.length > 0)) {
2116 for (com.liferay.portal.model.User user : users) {
2117 for (ModelListener<Team> listener : listeners) {
2118 listener.onAfterRemoveAssociation(teamId,
2119 com.liferay.portal.model.User.class.getName(),
2120 user.getPrimaryKey());
2121 }
2122
2123 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2124 listener.onAfterRemoveAssociation(user.getPrimaryKey(),
2125 Team.class.getName(), teamId);
2126 }
2127 }
2128 }
2129 }
2130
2131 private SqlUpdate _sqlUpdate;
2132 }
2133
2134 protected class RemoveUser {
2135 protected RemoveUser(TeamPersistenceImpl persistenceImpl) {
2136 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
2137 "DELETE FROM Users_Teams WHERE teamId = ? AND userId = ?",
2138 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
2139 _persistenceImpl = persistenceImpl;
2140 }
2141
2142 protected void remove(long teamId, long userId)
2143 throws SystemException {
2144 if (_persistenceImpl.containsUser.contains(teamId, userId)) {
2145 ModelListener<com.liferay.portal.model.User>[] userListeners = userPersistence.getListeners();
2146
2147 for (ModelListener<Team> listener : listeners) {
2148 listener.onBeforeRemoveAssociation(teamId,
2149 com.liferay.portal.model.User.class.getName(), userId);
2150 }
2151
2152 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2153 listener.onBeforeRemoveAssociation(userId,
2154 Team.class.getName(), teamId);
2155 }
2156
2157 _sqlUpdate.update(new Object[] {
2158 new Long(teamId), new Long(userId)
2159 });
2160
2161 for (ModelListener<Team> listener : listeners) {
2162 listener.onAfterRemoveAssociation(teamId,
2163 com.liferay.portal.model.User.class.getName(), userId);
2164 }
2165
2166 for (ModelListener<com.liferay.portal.model.User> listener : userListeners) {
2167 listener.onAfterRemoveAssociation(userId,
2168 Team.class.getName(), teamId);
2169 }
2170 }
2171 }
2172
2173 private SqlUpdate _sqlUpdate;
2174 private TeamPersistenceImpl _persistenceImpl;
2175 }
2176
2177 private static final String _SQL_SELECT_TEAM = "SELECT team FROM Team team";
2178 private static final String _SQL_SELECT_TEAM_WHERE = "SELECT team FROM Team team WHERE ";
2179 private static final String _SQL_COUNT_TEAM = "SELECT COUNT(team) FROM Team team";
2180 private static final String _SQL_COUNT_TEAM_WHERE = "SELECT COUNT(team) FROM Team team WHERE ";
2181 private static final String _SQL_GETUSERS = "SELECT {User_.*} FROM User_ INNER JOIN Users_Teams ON (Users_Teams.userId = User_.userId) WHERE (Users_Teams.teamId = ?)";
2182 private static final String _SQL_GETUSERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ?";
2183 private static final String _SQL_CONTAINSUSER = "SELECT COUNT(*) AS COUNT_VALUE FROM Users_Teams WHERE teamId = ? AND userId = ?";
2184 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "team.groupId = ?";
2185 private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "team.groupId = ? AND ";
2186 private static final String _FINDER_COLUMN_G_N_NAME_1 = "team.name IS NULL";
2187 private static final String _FINDER_COLUMN_G_N_NAME_2 = "team.name = ?";
2188 private static final String _FINDER_COLUMN_G_N_NAME_3 = "(team.name IS NULL OR team.name = ?)";
2189 private static final String _FILTER_SQL_SELECT_TEAM_WHERE = "SELECT DISTINCT {team.*} FROM Team team WHERE ";
2190 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_1 =
2191 "SELECT {Team.*} FROM (SELECT DISTINCT team.teamId FROM Team team WHERE ";
2192 private static final String _FILTER_SQL_SELECT_TEAM_NO_INLINE_DISTINCT_WHERE_2 =
2193 ") TEMP_TABLE INNER JOIN Team ON TEMP_TABLE.teamId = Team.teamId";
2194 private static final String _FILTER_SQL_COUNT_TEAM_WHERE = "SELECT COUNT(DISTINCT team.teamId) AS COUNT_VALUE FROM Team team WHERE ";
2195 private static final String _FILTER_COLUMN_PK = "team.teamId";
2196 private static final String _FILTER_COLUMN_USERID = "team.userId";
2197 private static final String _FILTER_ENTITY_ALIAS = "team";
2198 private static final String _FILTER_ENTITY_TABLE = "Team";
2199 private static final String _ORDER_BY_ENTITY_ALIAS = "team.";
2200 private static final String _ORDER_BY_ENTITY_TABLE = "Team.";
2201 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Team exists with the primary key ";
2202 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Team exists with the key {";
2203 private static Log _log = LogFactoryUtil.getLog(TeamPersistenceImpl.class);
2204 }