001
014
015 package com.liferay.portlet.tasks.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.model.ModelListener;
039 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
040 import com.liferay.portal.service.persistence.BatchSessionUtil;
041 import com.liferay.portal.service.persistence.ResourcePersistence;
042 import com.liferay.portal.service.persistence.UserPersistence;
043 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044
045 import com.liferay.portlet.messageboards.service.persistence.MBMessagePersistence;
046 import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
047 import com.liferay.portlet.tasks.NoSuchProposalException;
048 import com.liferay.portlet.tasks.model.TasksProposal;
049 import com.liferay.portlet.tasks.model.impl.TasksProposalImpl;
050 import com.liferay.portlet.tasks.model.impl.TasksProposalModelImpl;
051
052 import java.io.Serializable;
053
054 import java.util.ArrayList;
055 import java.util.Collections;
056 import java.util.List;
057
058
074 public class TasksProposalPersistenceImpl extends BasePersistenceImpl<TasksProposal>
075 implements TasksProposalPersistence {
076 public static final String FINDER_CLASS_NAME_ENTITY = TasksProposalImpl.class.getName();
077 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
078 ".List";
079 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
080 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
081 FINDER_CLASS_NAME_LIST, "findByGroupId",
082 new String[] {
083 Long.class.getName(),
084
085 "java.lang.Integer", "java.lang.Integer",
086 "com.liferay.portal.kernel.util.OrderByComparator"
087 });
088 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
089 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
090 FINDER_CLASS_NAME_LIST, "countByGroupId",
091 new String[] { Long.class.getName() });
092 public static final FinderPath FINDER_PATH_FIND_BY_G_U = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
093 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
094 FINDER_CLASS_NAME_LIST, "findByG_U",
095 new String[] {
096 Long.class.getName(), Long.class.getName(),
097
098 "java.lang.Integer", "java.lang.Integer",
099 "com.liferay.portal.kernel.util.OrderByComparator"
100 });
101 public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
102 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "countByG_U",
104 new String[] { Long.class.getName(), Long.class.getName() });
105 public static final FinderPath FINDER_PATH_FETCH_BY_C_C = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
106 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
107 FINDER_CLASS_NAME_ENTITY, "fetchByC_C",
108 new String[] { Long.class.getName(), String.class.getName() });
109 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
110 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
111 FINDER_CLASS_NAME_LIST, "countByC_C",
112 new String[] { Long.class.getName(), String.class.getName() });
113 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
114 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
115 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
116 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
117 TasksProposalModelImpl.FINDER_CACHE_ENABLED,
118 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
119
120
125 public void cacheResult(TasksProposal tasksProposal) {
126 EntityCacheUtil.putResult(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
127 TasksProposalImpl.class, tasksProposal.getPrimaryKey(),
128 tasksProposal);
129
130 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
131 new Object[] {
132 new Long(tasksProposal.getClassNameId()),
133
134 tasksProposal.getClassPK()
135 }, tasksProposal);
136 }
137
138
143 public void cacheResult(List<TasksProposal> tasksProposals) {
144 for (TasksProposal tasksProposal : tasksProposals) {
145 if (EntityCacheUtil.getResult(
146 TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
147 TasksProposalImpl.class, tasksProposal.getPrimaryKey(),
148 this) == null) {
149 cacheResult(tasksProposal);
150 }
151 }
152 }
153
154
161 public void clearCache() {
162 CacheRegistryUtil.clear(TasksProposalImpl.class.getName());
163 EntityCacheUtil.clearCache(TasksProposalImpl.class.getName());
164 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
165 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
166 }
167
168
175 public void clearCache(TasksProposal tasksProposal) {
176 EntityCacheUtil.removeResult(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
177 TasksProposalImpl.class, tasksProposal.getPrimaryKey());
178
179 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
180 new Object[] {
181 new Long(tasksProposal.getClassNameId()),
182
183 tasksProposal.getClassPK()
184 });
185 }
186
187
193 public TasksProposal create(long proposalId) {
194 TasksProposal tasksProposal = new TasksProposalImpl();
195
196 tasksProposal.setNew(true);
197 tasksProposal.setPrimaryKey(proposalId);
198
199 return tasksProposal;
200 }
201
202
210 public TasksProposal remove(Serializable primaryKey)
211 throws NoSuchModelException, SystemException {
212 return remove(((Long)primaryKey).longValue());
213 }
214
215
223 public TasksProposal remove(long proposalId)
224 throws NoSuchProposalException, SystemException {
225 Session session = null;
226
227 try {
228 session = openSession();
229
230 TasksProposal tasksProposal = (TasksProposal)session.get(TasksProposalImpl.class,
231 new Long(proposalId));
232
233 if (tasksProposal == null) {
234 if (_log.isWarnEnabled()) {
235 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + proposalId);
236 }
237
238 throw new NoSuchProposalException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
239 proposalId);
240 }
241
242 return remove(tasksProposal);
243 }
244 catch (NoSuchProposalException nsee) {
245 throw nsee;
246 }
247 catch (Exception e) {
248 throw processException(e);
249 }
250 finally {
251 closeSession(session);
252 }
253 }
254
255 protected TasksProposal removeImpl(TasksProposal tasksProposal)
256 throws SystemException {
257 tasksProposal = toUnwrappedModel(tasksProposal);
258
259 Session session = null;
260
261 try {
262 session = openSession();
263
264 if (tasksProposal.isCachedModel() || BatchSessionUtil.isEnabled()) {
265 Object staleObject = session.get(TasksProposalImpl.class,
266 tasksProposal.getPrimaryKeyObj());
267
268 if (staleObject != null) {
269 session.evict(staleObject);
270 }
271 }
272
273 session.delete(tasksProposal);
274
275 session.flush();
276 }
277 catch (Exception e) {
278 throw processException(e);
279 }
280 finally {
281 closeSession(session);
282 }
283
284 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
285
286 TasksProposalModelImpl tasksProposalModelImpl = (TasksProposalModelImpl)tasksProposal;
287
288 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
289 new Object[] {
290 new Long(tasksProposalModelImpl.getOriginalClassNameId()),
291
292 tasksProposalModelImpl.getOriginalClassPK()
293 });
294
295 EntityCacheUtil.removeResult(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
296 TasksProposalImpl.class, tasksProposal.getPrimaryKey());
297
298 return tasksProposal;
299 }
300
301 public TasksProposal updateImpl(
302 com.liferay.portlet.tasks.model.TasksProposal tasksProposal,
303 boolean merge) throws SystemException {
304 tasksProposal = toUnwrappedModel(tasksProposal);
305
306 boolean isNew = tasksProposal.isNew();
307
308 TasksProposalModelImpl tasksProposalModelImpl = (TasksProposalModelImpl)tasksProposal;
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 BatchSessionUtil.update(session, tasksProposal, merge);
316
317 tasksProposal.setNew(false);
318 }
319 catch (Exception e) {
320 throw processException(e);
321 }
322 finally {
323 closeSession(session);
324 }
325
326 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
327
328 EntityCacheUtil.putResult(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
329 TasksProposalImpl.class, tasksProposal.getPrimaryKey(),
330 tasksProposal);
331
332 if (!isNew &&
333 ((tasksProposal.getClassNameId() != tasksProposalModelImpl.getOriginalClassNameId()) ||
334 !Validator.equals(tasksProposal.getClassPK(),
335 tasksProposalModelImpl.getOriginalClassPK()))) {
336 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_C,
337 new Object[] {
338 new Long(tasksProposalModelImpl.getOriginalClassNameId()),
339
340 tasksProposalModelImpl.getOriginalClassPK()
341 });
342 }
343
344 if (isNew ||
345 ((tasksProposal.getClassNameId() != tasksProposalModelImpl.getOriginalClassNameId()) ||
346 !Validator.equals(tasksProposal.getClassPK(),
347 tasksProposalModelImpl.getOriginalClassPK()))) {
348 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
349 new Object[] {
350 new Long(tasksProposal.getClassNameId()),
351
352 tasksProposal.getClassPK()
353 }, tasksProposal);
354 }
355
356 return tasksProposal;
357 }
358
359 protected TasksProposal toUnwrappedModel(TasksProposal tasksProposal) {
360 if (tasksProposal instanceof TasksProposalImpl) {
361 return tasksProposal;
362 }
363
364 TasksProposalImpl tasksProposalImpl = new TasksProposalImpl();
365
366 tasksProposalImpl.setNew(tasksProposal.isNew());
367 tasksProposalImpl.setPrimaryKey(tasksProposal.getPrimaryKey());
368
369 tasksProposalImpl.setProposalId(tasksProposal.getProposalId());
370 tasksProposalImpl.setGroupId(tasksProposal.getGroupId());
371 tasksProposalImpl.setCompanyId(tasksProposal.getCompanyId());
372 tasksProposalImpl.setUserId(tasksProposal.getUserId());
373 tasksProposalImpl.setUserName(tasksProposal.getUserName());
374 tasksProposalImpl.setCreateDate(tasksProposal.getCreateDate());
375 tasksProposalImpl.setModifiedDate(tasksProposal.getModifiedDate());
376 tasksProposalImpl.setClassNameId(tasksProposal.getClassNameId());
377 tasksProposalImpl.setClassPK(tasksProposal.getClassPK());
378 tasksProposalImpl.setName(tasksProposal.getName());
379 tasksProposalImpl.setDescription(tasksProposal.getDescription());
380 tasksProposalImpl.setPublishDate(tasksProposal.getPublishDate());
381 tasksProposalImpl.setDueDate(tasksProposal.getDueDate());
382
383 return tasksProposalImpl;
384 }
385
386
394 public TasksProposal findByPrimaryKey(Serializable primaryKey)
395 throws NoSuchModelException, SystemException {
396 return findByPrimaryKey(((Long)primaryKey).longValue());
397 }
398
399
407 public TasksProposal findByPrimaryKey(long proposalId)
408 throws NoSuchProposalException, SystemException {
409 TasksProposal tasksProposal = fetchByPrimaryKey(proposalId);
410
411 if (tasksProposal == null) {
412 if (_log.isWarnEnabled()) {
413 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + proposalId);
414 }
415
416 throw new NoSuchProposalException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
417 proposalId);
418 }
419
420 return tasksProposal;
421 }
422
423
430 public TasksProposal fetchByPrimaryKey(Serializable primaryKey)
431 throws SystemException {
432 return fetchByPrimaryKey(((Long)primaryKey).longValue());
433 }
434
435
442 public TasksProposal fetchByPrimaryKey(long proposalId)
443 throws SystemException {
444 TasksProposal tasksProposal = (TasksProposal)EntityCacheUtil.getResult(TasksProposalModelImpl.ENTITY_CACHE_ENABLED,
445 TasksProposalImpl.class, proposalId, this);
446
447 if (tasksProposal == null) {
448 Session session = null;
449
450 try {
451 session = openSession();
452
453 tasksProposal = (TasksProposal)session.get(TasksProposalImpl.class,
454 new Long(proposalId));
455 }
456 catch (Exception e) {
457 throw processException(e);
458 }
459 finally {
460 if (tasksProposal != null) {
461 cacheResult(tasksProposal);
462 }
463
464 closeSession(session);
465 }
466 }
467
468 return tasksProposal;
469 }
470
471
478 public List<TasksProposal> findByGroupId(long groupId)
479 throws SystemException {
480 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
481 }
482
483
496 public List<TasksProposal> findByGroupId(long groupId, int start, int end)
497 throws SystemException {
498 return findByGroupId(groupId, start, end, null);
499 }
500
501
515 public List<TasksProposal> findByGroupId(long groupId, int start, int end,
516 OrderByComparator orderByComparator) throws SystemException {
517 Object[] finderArgs = new Object[] {
518 groupId,
519
520 String.valueOf(start), String.valueOf(end),
521 String.valueOf(orderByComparator)
522 };
523
524 List<TasksProposal> list = (List<TasksProposal>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
525 finderArgs, this);
526
527 if (list == null) {
528 Session session = null;
529
530 try {
531 session = openSession();
532
533 StringBundler query = null;
534
535 if (orderByComparator != null) {
536 query = new StringBundler(3 +
537 (orderByComparator.getOrderByFields().length * 3));
538 }
539 else {
540 query = new StringBundler(3);
541 }
542
543 query.append(_SQL_SELECT_TASKSPROPOSAL_WHERE);
544
545 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
546
547 if (orderByComparator != null) {
548 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
549 orderByComparator);
550 }
551
552 else {
553 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
554 }
555
556 String sql = query.toString();
557
558 Query q = session.createQuery(sql);
559
560 QueryPos qPos = QueryPos.getInstance(q);
561
562 qPos.add(groupId);
563
564 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
565 start, end);
566 }
567 catch (Exception e) {
568 throw processException(e);
569 }
570 finally {
571 if (list == null) {
572 list = new ArrayList<TasksProposal>();
573 }
574
575 cacheResult(list);
576
577 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
578 finderArgs, list);
579
580 closeSession(session);
581 }
582 }
583
584 return list;
585 }
586
587
600 public TasksProposal findByGroupId_First(long groupId,
601 OrderByComparator orderByComparator)
602 throws NoSuchProposalException, SystemException {
603 List<TasksProposal> list = findByGroupId(groupId, 0, 1,
604 orderByComparator);
605
606 if (list.isEmpty()) {
607 StringBundler msg = new StringBundler(4);
608
609 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
610
611 msg.append("groupId=");
612 msg.append(groupId);
613
614 msg.append(StringPool.CLOSE_CURLY_BRACE);
615
616 throw new NoSuchProposalException(msg.toString());
617 }
618 else {
619 return list.get(0);
620 }
621 }
622
623
636 public TasksProposal findByGroupId_Last(long groupId,
637 OrderByComparator orderByComparator)
638 throws NoSuchProposalException, SystemException {
639 int count = countByGroupId(groupId);
640
641 List<TasksProposal> list = findByGroupId(groupId, count - 1, count,
642 orderByComparator);
643
644 if (list.isEmpty()) {
645 StringBundler msg = new StringBundler(4);
646
647 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
648
649 msg.append("groupId=");
650 msg.append(groupId);
651
652 msg.append(StringPool.CLOSE_CURLY_BRACE);
653
654 throw new NoSuchProposalException(msg.toString());
655 }
656 else {
657 return list.get(0);
658 }
659 }
660
661
675 public TasksProposal[] findByGroupId_PrevAndNext(long proposalId,
676 long groupId, OrderByComparator orderByComparator)
677 throws NoSuchProposalException, SystemException {
678 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
679
680 Session session = null;
681
682 try {
683 session = openSession();
684
685 TasksProposal[] array = new TasksProposalImpl[3];
686
687 array[0] = getByGroupId_PrevAndNext(session, tasksProposal,
688 groupId, orderByComparator, true);
689
690 array[1] = tasksProposal;
691
692 array[2] = getByGroupId_PrevAndNext(session, tasksProposal,
693 groupId, orderByComparator, false);
694
695 return array;
696 }
697 catch (Exception e) {
698 throw processException(e);
699 }
700 finally {
701 closeSession(session);
702 }
703 }
704
705 protected TasksProposal getByGroupId_PrevAndNext(Session session,
706 TasksProposal tasksProposal, long groupId,
707 OrderByComparator orderByComparator, boolean previous) {
708 StringBundler query = null;
709
710 if (orderByComparator != null) {
711 query = new StringBundler(6 +
712 (orderByComparator.getOrderByFields().length * 6));
713 }
714 else {
715 query = new StringBundler(3);
716 }
717
718 query.append(_SQL_SELECT_TASKSPROPOSAL_WHERE);
719
720 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
721
722 if (orderByComparator != null) {
723 String[] orderByFields = orderByComparator.getOrderByFields();
724
725 if (orderByFields.length > 0) {
726 query.append(WHERE_AND);
727 }
728
729 for (int i = 0; i < orderByFields.length; i++) {
730 query.append(_ORDER_BY_ENTITY_ALIAS);
731 query.append(orderByFields[i]);
732
733 if ((i + 1) < orderByFields.length) {
734 if (orderByComparator.isAscending() ^ previous) {
735 query.append(WHERE_GREATER_THAN_HAS_NEXT);
736 }
737 else {
738 query.append(WHERE_LESSER_THAN_HAS_NEXT);
739 }
740 }
741 else {
742 if (orderByComparator.isAscending() ^ previous) {
743 query.append(WHERE_GREATER_THAN);
744 }
745 else {
746 query.append(WHERE_LESSER_THAN);
747 }
748 }
749 }
750
751 query.append(ORDER_BY_CLAUSE);
752
753 for (int i = 0; i < orderByFields.length; i++) {
754 query.append(_ORDER_BY_ENTITY_ALIAS);
755 query.append(orderByFields[i]);
756
757 if ((i + 1) < orderByFields.length) {
758 if (orderByComparator.isAscending() ^ previous) {
759 query.append(ORDER_BY_ASC_HAS_NEXT);
760 }
761 else {
762 query.append(ORDER_BY_DESC_HAS_NEXT);
763 }
764 }
765 else {
766 if (orderByComparator.isAscending() ^ previous) {
767 query.append(ORDER_BY_ASC);
768 }
769 else {
770 query.append(ORDER_BY_DESC);
771 }
772 }
773 }
774 }
775
776 else {
777 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
778 }
779
780 String sql = query.toString();
781
782 Query q = session.createQuery(sql);
783
784 q.setFirstResult(0);
785 q.setMaxResults(2);
786
787 QueryPos qPos = QueryPos.getInstance(q);
788
789 qPos.add(groupId);
790
791 if (orderByComparator != null) {
792 Object[] values = orderByComparator.getOrderByValues(tasksProposal);
793
794 for (Object value : values) {
795 qPos.add(value);
796 }
797 }
798
799 List<TasksProposal> list = q.list();
800
801 if (list.size() == 2) {
802 return list.get(1);
803 }
804 else {
805 return null;
806 }
807 }
808
809
816 public List<TasksProposal> filterFindByGroupId(long groupId)
817 throws SystemException {
818 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
819 QueryUtil.ALL_POS, null);
820 }
821
822
835 public List<TasksProposal> filterFindByGroupId(long groupId, int start,
836 int end) throws SystemException {
837 return filterFindByGroupId(groupId, start, end, null);
838 }
839
840
854 public List<TasksProposal> filterFindByGroupId(long groupId, int start,
855 int end, OrderByComparator orderByComparator) throws SystemException {
856 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
857 return findByGroupId(groupId, start, end, orderByComparator);
858 }
859
860 Session session = null;
861
862 try {
863 session = openSession();
864
865 StringBundler query = null;
866
867 if (orderByComparator != null) {
868 query = new StringBundler(3 +
869 (orderByComparator.getOrderByFields().length * 3));
870 }
871 else {
872 query = new StringBundler(3);
873 }
874
875 query.append(_FILTER_SQL_SELECT_TASKSPROPOSAL_WHERE);
876
877 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
878
879 if (orderByComparator != null) {
880 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
881 orderByComparator);
882 }
883
884 else {
885 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
886 }
887
888 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
889 TasksProposal.class.getName(), _FILTER_COLUMN_PK,
890 _FILTER_COLUMN_USERID, groupId);
891
892 SQLQuery q = session.createSQLQuery(sql);
893
894 q.addEntity(_FILTER_ENTITY_ALIAS, TasksProposalImpl.class);
895
896 QueryPos qPos = QueryPos.getInstance(q);
897
898 qPos.add(groupId);
899
900 return (List<TasksProposal>)QueryUtil.list(q, getDialect(), start,
901 end);
902 }
903 catch (Exception e) {
904 throw processException(e);
905 }
906 finally {
907 closeSession(session);
908 }
909 }
910
911
919 public List<TasksProposal> findByG_U(long groupId, long userId)
920 throws SystemException {
921 return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
922 null);
923 }
924
925
939 public List<TasksProposal> findByG_U(long groupId, long userId, int start,
940 int end) throws SystemException {
941 return findByG_U(groupId, userId, start, end, null);
942 }
943
944
959 public List<TasksProposal> findByG_U(long groupId, long userId, int start,
960 int end, OrderByComparator orderByComparator) throws SystemException {
961 Object[] finderArgs = new Object[] {
962 groupId, userId,
963
964 String.valueOf(start), String.valueOf(end),
965 String.valueOf(orderByComparator)
966 };
967
968 List<TasksProposal> list = (List<TasksProposal>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_U,
969 finderArgs, this);
970
971 if (list == null) {
972 Session session = null;
973
974 try {
975 session = openSession();
976
977 StringBundler query = null;
978
979 if (orderByComparator != null) {
980 query = new StringBundler(4 +
981 (orderByComparator.getOrderByFields().length * 3));
982 }
983 else {
984 query = new StringBundler(4);
985 }
986
987 query.append(_SQL_SELECT_TASKSPROPOSAL_WHERE);
988
989 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
990
991 query.append(_FINDER_COLUMN_G_U_USERID_2);
992
993 if (orderByComparator != null) {
994 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
995 orderByComparator);
996 }
997
998 else {
999 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
1000 }
1001
1002 String sql = query.toString();
1003
1004 Query q = session.createQuery(sql);
1005
1006 QueryPos qPos = QueryPos.getInstance(q);
1007
1008 qPos.add(groupId);
1009
1010 qPos.add(userId);
1011
1012 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
1013 start, end);
1014 }
1015 catch (Exception e) {
1016 throw processException(e);
1017 }
1018 finally {
1019 if (list == null) {
1020 list = new ArrayList<TasksProposal>();
1021 }
1022
1023 cacheResult(list);
1024
1025 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_U, finderArgs,
1026 list);
1027
1028 closeSession(session);
1029 }
1030 }
1031
1032 return list;
1033 }
1034
1035
1049 public TasksProposal findByG_U_First(long groupId, long userId,
1050 OrderByComparator orderByComparator)
1051 throws NoSuchProposalException, SystemException {
1052 List<TasksProposal> list = findByG_U(groupId, userId, 0, 1,
1053 orderByComparator);
1054
1055 if (list.isEmpty()) {
1056 StringBundler msg = new StringBundler(6);
1057
1058 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1059
1060 msg.append("groupId=");
1061 msg.append(groupId);
1062
1063 msg.append(", userId=");
1064 msg.append(userId);
1065
1066 msg.append(StringPool.CLOSE_CURLY_BRACE);
1067
1068 throw new NoSuchProposalException(msg.toString());
1069 }
1070 else {
1071 return list.get(0);
1072 }
1073 }
1074
1075
1089 public TasksProposal findByG_U_Last(long groupId, long userId,
1090 OrderByComparator orderByComparator)
1091 throws NoSuchProposalException, SystemException {
1092 int count = countByG_U(groupId, userId);
1093
1094 List<TasksProposal> list = findByG_U(groupId, userId, count - 1, count,
1095 orderByComparator);
1096
1097 if (list.isEmpty()) {
1098 StringBundler msg = new StringBundler(6);
1099
1100 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1101
1102 msg.append("groupId=");
1103 msg.append(groupId);
1104
1105 msg.append(", userId=");
1106 msg.append(userId);
1107
1108 msg.append(StringPool.CLOSE_CURLY_BRACE);
1109
1110 throw new NoSuchProposalException(msg.toString());
1111 }
1112 else {
1113 return list.get(0);
1114 }
1115 }
1116
1117
1132 public TasksProposal[] findByG_U_PrevAndNext(long proposalId, long groupId,
1133 long userId, OrderByComparator orderByComparator)
1134 throws NoSuchProposalException, SystemException {
1135 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
1136
1137 Session session = null;
1138
1139 try {
1140 session = openSession();
1141
1142 TasksProposal[] array = new TasksProposalImpl[3];
1143
1144 array[0] = getByG_U_PrevAndNext(session, tasksProposal, groupId,
1145 userId, orderByComparator, true);
1146
1147 array[1] = tasksProposal;
1148
1149 array[2] = getByG_U_PrevAndNext(session, tasksProposal, groupId,
1150 userId, orderByComparator, false);
1151
1152 return array;
1153 }
1154 catch (Exception e) {
1155 throw processException(e);
1156 }
1157 finally {
1158 closeSession(session);
1159 }
1160 }
1161
1162 protected TasksProposal getByG_U_PrevAndNext(Session session,
1163 TasksProposal tasksProposal, long groupId, long userId,
1164 OrderByComparator orderByComparator, boolean previous) {
1165 StringBundler query = null;
1166
1167 if (orderByComparator != null) {
1168 query = new StringBundler(6 +
1169 (orderByComparator.getOrderByFields().length * 6));
1170 }
1171 else {
1172 query = new StringBundler(3);
1173 }
1174
1175 query.append(_SQL_SELECT_TASKSPROPOSAL_WHERE);
1176
1177 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1178
1179 query.append(_FINDER_COLUMN_G_U_USERID_2);
1180
1181 if (orderByComparator != null) {
1182 String[] orderByFields = orderByComparator.getOrderByFields();
1183
1184 if (orderByFields.length > 0) {
1185 query.append(WHERE_AND);
1186 }
1187
1188 for (int i = 0; i < orderByFields.length; i++) {
1189 query.append(_ORDER_BY_ENTITY_ALIAS);
1190 query.append(orderByFields[i]);
1191
1192 if ((i + 1) < orderByFields.length) {
1193 if (orderByComparator.isAscending() ^ previous) {
1194 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1195 }
1196 else {
1197 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1198 }
1199 }
1200 else {
1201 if (orderByComparator.isAscending() ^ previous) {
1202 query.append(WHERE_GREATER_THAN);
1203 }
1204 else {
1205 query.append(WHERE_LESSER_THAN);
1206 }
1207 }
1208 }
1209
1210 query.append(ORDER_BY_CLAUSE);
1211
1212 for (int i = 0; i < orderByFields.length; i++) {
1213 query.append(_ORDER_BY_ENTITY_ALIAS);
1214 query.append(orderByFields[i]);
1215
1216 if ((i + 1) < orderByFields.length) {
1217 if (orderByComparator.isAscending() ^ previous) {
1218 query.append(ORDER_BY_ASC_HAS_NEXT);
1219 }
1220 else {
1221 query.append(ORDER_BY_DESC_HAS_NEXT);
1222 }
1223 }
1224 else {
1225 if (orderByComparator.isAscending() ^ previous) {
1226 query.append(ORDER_BY_ASC);
1227 }
1228 else {
1229 query.append(ORDER_BY_DESC);
1230 }
1231 }
1232 }
1233 }
1234
1235 else {
1236 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
1237 }
1238
1239 String sql = query.toString();
1240
1241 Query q = session.createQuery(sql);
1242
1243 q.setFirstResult(0);
1244 q.setMaxResults(2);
1245
1246 QueryPos qPos = QueryPos.getInstance(q);
1247
1248 qPos.add(groupId);
1249
1250 qPos.add(userId);
1251
1252 if (orderByComparator != null) {
1253 Object[] values = orderByComparator.getOrderByValues(tasksProposal);
1254
1255 for (Object value : values) {
1256 qPos.add(value);
1257 }
1258 }
1259
1260 List<TasksProposal> list = q.list();
1261
1262 if (list.size() == 2) {
1263 return list.get(1);
1264 }
1265 else {
1266 return null;
1267 }
1268 }
1269
1270
1278 public List<TasksProposal> filterFindByG_U(long groupId, long userId)
1279 throws SystemException {
1280 return filterFindByG_U(groupId, userId, QueryUtil.ALL_POS,
1281 QueryUtil.ALL_POS, null);
1282 }
1283
1284
1298 public List<TasksProposal> filterFindByG_U(long groupId, long userId,
1299 int start, int end) throws SystemException {
1300 return filterFindByG_U(groupId, userId, start, end, null);
1301 }
1302
1303
1318 public List<TasksProposal> filterFindByG_U(long groupId, long userId,
1319 int start, int end, OrderByComparator orderByComparator)
1320 throws SystemException {
1321 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1322 return findByG_U(groupId, userId, start, end, orderByComparator);
1323 }
1324
1325 Session session = null;
1326
1327 try {
1328 session = openSession();
1329
1330 StringBundler query = null;
1331
1332 if (orderByComparator != null) {
1333 query = new StringBundler(4 +
1334 (orderByComparator.getOrderByFields().length * 3));
1335 }
1336 else {
1337 query = new StringBundler(4);
1338 }
1339
1340 query.append(_FILTER_SQL_SELECT_TASKSPROPOSAL_WHERE);
1341
1342 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1343
1344 query.append(_FINDER_COLUMN_G_U_USERID_2);
1345
1346 if (orderByComparator != null) {
1347 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1348 orderByComparator);
1349 }
1350
1351 else {
1352 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
1353 }
1354
1355 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1356 TasksProposal.class.getName(), _FILTER_COLUMN_PK,
1357 _FILTER_COLUMN_USERID, groupId);
1358
1359 SQLQuery q = session.createSQLQuery(sql);
1360
1361 q.addEntity(_FILTER_ENTITY_ALIAS, TasksProposalImpl.class);
1362
1363 QueryPos qPos = QueryPos.getInstance(q);
1364
1365 qPos.add(groupId);
1366
1367 qPos.add(userId);
1368
1369 return (List<TasksProposal>)QueryUtil.list(q, getDialect(), start,
1370 end);
1371 }
1372 catch (Exception e) {
1373 throw processException(e);
1374 }
1375 finally {
1376 closeSession(session);
1377 }
1378 }
1379
1380
1389 public TasksProposal findByC_C(long classNameId, String classPK)
1390 throws NoSuchProposalException, SystemException {
1391 TasksProposal tasksProposal = fetchByC_C(classNameId, classPK);
1392
1393 if (tasksProposal == null) {
1394 StringBundler msg = new StringBundler(6);
1395
1396 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1397
1398 msg.append("classNameId=");
1399 msg.append(classNameId);
1400
1401 msg.append(", classPK=");
1402 msg.append(classPK);
1403
1404 msg.append(StringPool.CLOSE_CURLY_BRACE);
1405
1406 if (_log.isWarnEnabled()) {
1407 _log.warn(msg.toString());
1408 }
1409
1410 throw new NoSuchProposalException(msg.toString());
1411 }
1412
1413 return tasksProposal;
1414 }
1415
1416
1424 public TasksProposal fetchByC_C(long classNameId, String classPK)
1425 throws SystemException {
1426 return fetchByC_C(classNameId, classPK, true);
1427 }
1428
1429
1437 public TasksProposal fetchByC_C(long classNameId, String classPK,
1438 boolean retrieveFromCache) throws SystemException {
1439 Object[] finderArgs = new Object[] { classNameId, classPK };
1440
1441 Object result = null;
1442
1443 if (retrieveFromCache) {
1444 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_C,
1445 finderArgs, this);
1446 }
1447
1448 if (result == null) {
1449 Session session = null;
1450
1451 try {
1452 session = openSession();
1453
1454 StringBundler query = new StringBundler(4);
1455
1456 query.append(_SQL_SELECT_TASKSPROPOSAL_WHERE);
1457
1458 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1459
1460 if (classPK == null) {
1461 query.append(_FINDER_COLUMN_C_C_CLASSPK_1);
1462 }
1463 else {
1464 if (classPK.equals(StringPool.BLANK)) {
1465 query.append(_FINDER_COLUMN_C_C_CLASSPK_3);
1466 }
1467 else {
1468 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1469 }
1470 }
1471
1472 query.append(TasksProposalModelImpl.ORDER_BY_JPQL);
1473
1474 String sql = query.toString();
1475
1476 Query q = session.createQuery(sql);
1477
1478 QueryPos qPos = QueryPos.getInstance(q);
1479
1480 qPos.add(classNameId);
1481
1482 if (classPK != null) {
1483 qPos.add(classPK);
1484 }
1485
1486 List<TasksProposal> list = q.list();
1487
1488 result = list;
1489
1490 TasksProposal tasksProposal = null;
1491
1492 if (list.isEmpty()) {
1493 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1494 finderArgs, list);
1495 }
1496 else {
1497 tasksProposal = list.get(0);
1498
1499 cacheResult(tasksProposal);
1500
1501 if ((tasksProposal.getClassNameId() != classNameId) ||
1502 (tasksProposal.getClassPK() == null) ||
1503 !tasksProposal.getClassPK().equals(classPK)) {
1504 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1505 finderArgs, tasksProposal);
1506 }
1507 }
1508
1509 return tasksProposal;
1510 }
1511 catch (Exception e) {
1512 throw processException(e);
1513 }
1514 finally {
1515 if (result == null) {
1516 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_C,
1517 finderArgs, new ArrayList<TasksProposal>());
1518 }
1519
1520 closeSession(session);
1521 }
1522 }
1523 else {
1524 if (result instanceof List<?>) {
1525 return null;
1526 }
1527 else {
1528 return (TasksProposal)result;
1529 }
1530 }
1531 }
1532
1533
1539 public List<TasksProposal> findAll() throws SystemException {
1540 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1541 }
1542
1543
1555 public List<TasksProposal> findAll(int start, int end)
1556 throws SystemException {
1557 return findAll(start, end, null);
1558 }
1559
1560
1573 public List<TasksProposal> findAll(int start, int end,
1574 OrderByComparator orderByComparator) throws SystemException {
1575 Object[] finderArgs = new Object[] {
1576 String.valueOf(start), String.valueOf(end),
1577 String.valueOf(orderByComparator)
1578 };
1579
1580 List<TasksProposal> list = (List<TasksProposal>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
1581 finderArgs, this);
1582
1583 if (list == null) {
1584 Session session = null;
1585
1586 try {
1587 session = openSession();
1588
1589 StringBundler query = null;
1590 String sql = null;
1591
1592 if (orderByComparator != null) {
1593 query = new StringBundler(2 +
1594 (orderByComparator.getOrderByFields().length * 3));
1595
1596 query.append(_SQL_SELECT_TASKSPROPOSAL);
1597
1598 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1599 orderByComparator);
1600
1601 sql = query.toString();
1602 }
1603 else {
1604 sql = _SQL_SELECT_TASKSPROPOSAL.concat(TasksProposalModelImpl.ORDER_BY_JPQL);
1605 }
1606
1607 Query q = session.createQuery(sql);
1608
1609 if (orderByComparator == null) {
1610 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
1611 start, end, false);
1612
1613 Collections.sort(list);
1614 }
1615 else {
1616 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
1617 start, end);
1618 }
1619 }
1620 catch (Exception e) {
1621 throw processException(e);
1622 }
1623 finally {
1624 if (list == null) {
1625 list = new ArrayList<TasksProposal>();
1626 }
1627
1628 cacheResult(list);
1629
1630 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
1631
1632 closeSession(session);
1633 }
1634 }
1635
1636 return list;
1637 }
1638
1639
1645 public void removeByGroupId(long groupId) throws SystemException {
1646 for (TasksProposal tasksProposal : findByGroupId(groupId)) {
1647 remove(tasksProposal);
1648 }
1649 }
1650
1651
1658 public void removeByG_U(long groupId, long userId)
1659 throws SystemException {
1660 for (TasksProposal tasksProposal : findByG_U(groupId, userId)) {
1661 remove(tasksProposal);
1662 }
1663 }
1664
1665
1672 public void removeByC_C(long classNameId, String classPK)
1673 throws NoSuchProposalException, SystemException {
1674 TasksProposal tasksProposal = findByC_C(classNameId, classPK);
1675
1676 remove(tasksProposal);
1677 }
1678
1679
1684 public void removeAll() throws SystemException {
1685 for (TasksProposal tasksProposal : findAll()) {
1686 remove(tasksProposal);
1687 }
1688 }
1689
1690
1697 public int countByGroupId(long groupId) throws SystemException {
1698 Object[] finderArgs = new Object[] { groupId };
1699
1700 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
1701 finderArgs, this);
1702
1703 if (count == null) {
1704 Session session = null;
1705
1706 try {
1707 session = openSession();
1708
1709 StringBundler query = new StringBundler(2);
1710
1711 query.append(_SQL_COUNT_TASKSPROPOSAL_WHERE);
1712
1713 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1714
1715 String sql = query.toString();
1716
1717 Query q = session.createQuery(sql);
1718
1719 QueryPos qPos = QueryPos.getInstance(q);
1720
1721 qPos.add(groupId);
1722
1723 count = (Long)q.uniqueResult();
1724 }
1725 catch (Exception e) {
1726 throw processException(e);
1727 }
1728 finally {
1729 if (count == null) {
1730 count = Long.valueOf(0);
1731 }
1732
1733 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
1734 finderArgs, count);
1735
1736 closeSession(session);
1737 }
1738 }
1739
1740 return count.intValue();
1741 }
1742
1743
1750 public int filterCountByGroupId(long groupId) throws SystemException {
1751 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1752 return countByGroupId(groupId);
1753 }
1754
1755 Session session = null;
1756
1757 try {
1758 session = openSession();
1759
1760 StringBundler query = new StringBundler(2);
1761
1762 query.append(_FILTER_SQL_COUNT_TASKSPROPOSAL_WHERE);
1763
1764 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1765
1766 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1767 TasksProposal.class.getName(), _FILTER_COLUMN_PK,
1768 _FILTER_COLUMN_USERID, groupId);
1769
1770 SQLQuery q = session.createSQLQuery(sql);
1771
1772 q.addScalar(COUNT_COLUMN_NAME,
1773 com.liferay.portal.kernel.dao.orm.Type.LONG);
1774
1775 QueryPos qPos = QueryPos.getInstance(q);
1776
1777 qPos.add(groupId);
1778
1779 Long count = (Long)q.uniqueResult();
1780
1781 return count.intValue();
1782 }
1783 catch (Exception e) {
1784 throw processException(e);
1785 }
1786 finally {
1787 closeSession(session);
1788 }
1789 }
1790
1791
1799 public int countByG_U(long groupId, long userId) throws SystemException {
1800 Object[] finderArgs = new Object[] { groupId, userId };
1801
1802 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
1803 finderArgs, this);
1804
1805 if (count == null) {
1806 Session session = null;
1807
1808 try {
1809 session = openSession();
1810
1811 StringBundler query = new StringBundler(3);
1812
1813 query.append(_SQL_COUNT_TASKSPROPOSAL_WHERE);
1814
1815 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1816
1817 query.append(_FINDER_COLUMN_G_U_USERID_2);
1818
1819 String sql = query.toString();
1820
1821 Query q = session.createQuery(sql);
1822
1823 QueryPos qPos = QueryPos.getInstance(q);
1824
1825 qPos.add(groupId);
1826
1827 qPos.add(userId);
1828
1829 count = (Long)q.uniqueResult();
1830 }
1831 catch (Exception e) {
1832 throw processException(e);
1833 }
1834 finally {
1835 if (count == null) {
1836 count = Long.valueOf(0);
1837 }
1838
1839 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
1840 count);
1841
1842 closeSession(session);
1843 }
1844 }
1845
1846 return count.intValue();
1847 }
1848
1849
1857 public int filterCountByG_U(long groupId, long userId)
1858 throws SystemException {
1859 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1860 return countByG_U(groupId, userId);
1861 }
1862
1863 Session session = null;
1864
1865 try {
1866 session = openSession();
1867
1868 StringBundler query = new StringBundler(3);
1869
1870 query.append(_FILTER_SQL_COUNT_TASKSPROPOSAL_WHERE);
1871
1872 query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1873
1874 query.append(_FINDER_COLUMN_G_U_USERID_2);
1875
1876 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1877 TasksProposal.class.getName(), _FILTER_COLUMN_PK,
1878 _FILTER_COLUMN_USERID, groupId);
1879
1880 SQLQuery q = session.createSQLQuery(sql);
1881
1882 q.addScalar(COUNT_COLUMN_NAME,
1883 com.liferay.portal.kernel.dao.orm.Type.LONG);
1884
1885 QueryPos qPos = QueryPos.getInstance(q);
1886
1887 qPos.add(groupId);
1888
1889 qPos.add(userId);
1890
1891 Long count = (Long)q.uniqueResult();
1892
1893 return count.intValue();
1894 }
1895 catch (Exception e) {
1896 throw processException(e);
1897 }
1898 finally {
1899 closeSession(session);
1900 }
1901 }
1902
1903
1911 public int countByC_C(long classNameId, String classPK)
1912 throws SystemException {
1913 Object[] finderArgs = new Object[] { classNameId, classPK };
1914
1915 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
1916 finderArgs, this);
1917
1918 if (count == null) {
1919 Session session = null;
1920
1921 try {
1922 session = openSession();
1923
1924 StringBundler query = new StringBundler(3);
1925
1926 query.append(_SQL_COUNT_TASKSPROPOSAL_WHERE);
1927
1928 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
1929
1930 if (classPK == null) {
1931 query.append(_FINDER_COLUMN_C_C_CLASSPK_1);
1932 }
1933 else {
1934 if (classPK.equals(StringPool.BLANK)) {
1935 query.append(_FINDER_COLUMN_C_C_CLASSPK_3);
1936 }
1937 else {
1938 query.append(_FINDER_COLUMN_C_C_CLASSPK_2);
1939 }
1940 }
1941
1942 String sql = query.toString();
1943
1944 Query q = session.createQuery(sql);
1945
1946 QueryPos qPos = QueryPos.getInstance(q);
1947
1948 qPos.add(classNameId);
1949
1950 if (classPK != null) {
1951 qPos.add(classPK);
1952 }
1953
1954 count = (Long)q.uniqueResult();
1955 }
1956 catch (Exception e) {
1957 throw processException(e);
1958 }
1959 finally {
1960 if (count == null) {
1961 count = Long.valueOf(0);
1962 }
1963
1964 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
1965 count);
1966
1967 closeSession(session);
1968 }
1969 }
1970
1971 return count.intValue();
1972 }
1973
1974
1980 public int countAll() throws SystemException {
1981 Object[] finderArgs = new Object[0];
1982
1983 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1984 finderArgs, this);
1985
1986 if (count == null) {
1987 Session session = null;
1988
1989 try {
1990 session = openSession();
1991
1992 Query q = session.createQuery(_SQL_COUNT_TASKSPROPOSAL);
1993
1994 count = (Long)q.uniqueResult();
1995 }
1996 catch (Exception e) {
1997 throw processException(e);
1998 }
1999 finally {
2000 if (count == null) {
2001 count = Long.valueOf(0);
2002 }
2003
2004 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
2005 count);
2006
2007 closeSession(session);
2008 }
2009 }
2010
2011 return count.intValue();
2012 }
2013
2014
2017 public void afterPropertiesSet() {
2018 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2019 com.liferay.portal.util.PropsUtil.get(
2020 "value.object.listener.com.liferay.portlet.tasks.model.TasksProposal")));
2021
2022 if (listenerClassNames.length > 0) {
2023 try {
2024 List<ModelListener<TasksProposal>> listenersList = new ArrayList<ModelListener<TasksProposal>>();
2025
2026 for (String listenerClassName : listenerClassNames) {
2027 listenersList.add((ModelListener<TasksProposal>)InstanceFactory.newInstance(
2028 listenerClassName));
2029 }
2030
2031 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2032 }
2033 catch (Exception e) {
2034 _log.error(e);
2035 }
2036 }
2037 }
2038
2039 @BeanReference(type = TasksProposalPersistence.class)
2040 protected TasksProposalPersistence tasksProposalPersistence;
2041 @BeanReference(type = TasksReviewPersistence.class)
2042 protected TasksReviewPersistence tasksReviewPersistence;
2043 @BeanReference(type = ResourcePersistence.class)
2044 protected ResourcePersistence resourcePersistence;
2045 @BeanReference(type = UserPersistence.class)
2046 protected UserPersistence userPersistence;
2047 @BeanReference(type = MBMessagePersistence.class)
2048 protected MBMessagePersistence mbMessagePersistence;
2049 @BeanReference(type = SocialActivityPersistence.class)
2050 protected SocialActivityPersistence socialActivityPersistence;
2051 private static final String _SQL_SELECT_TASKSPROPOSAL = "SELECT tasksProposal FROM TasksProposal tasksProposal";
2052 private static final String _SQL_SELECT_TASKSPROPOSAL_WHERE = "SELECT tasksProposal FROM TasksProposal tasksProposal WHERE ";
2053 private static final String _SQL_COUNT_TASKSPROPOSAL = "SELECT COUNT(tasksProposal) FROM TasksProposal tasksProposal";
2054 private static final String _SQL_COUNT_TASKSPROPOSAL_WHERE = "SELECT COUNT(tasksProposal) FROM TasksProposal tasksProposal WHERE ";
2055 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "tasksProposal.groupId = ?";
2056 private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "tasksProposal.groupId = ? AND ";
2057 private static final String _FINDER_COLUMN_G_U_USERID_2 = "tasksProposal.userId = ?";
2058 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "tasksProposal.classNameId = ? AND ";
2059 private static final String _FINDER_COLUMN_C_C_CLASSPK_1 = "tasksProposal.classPK IS NULL";
2060 private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "tasksProposal.classPK = ?";
2061 private static final String _FINDER_COLUMN_C_C_CLASSPK_3 = "(tasksProposal.classPK IS NULL OR tasksProposal.classPK = ?)";
2062 private static final String _FILTER_SQL_SELECT_TASKSPROPOSAL_WHERE = "SELECT DISTINCT {tasksProposal.*} FROM TasksProposal tasksProposal WHERE ";
2063 private static final String _FILTER_SQL_COUNT_TASKSPROPOSAL_WHERE = "SELECT COUNT(DISTINCT tasksProposal.proposalId) AS COUNT_VALUE FROM TasksProposal tasksProposal WHERE ";
2064 private static final String _FILTER_COLUMN_PK = "tasksProposal.proposalId";
2065 private static final String _FILTER_COLUMN_USERID = "tasksProposal.userId";
2066 private static final String _FILTER_ENTITY_ALIAS = "tasksProposal";
2067 private static final String _ORDER_BY_ENTITY_ALIAS = "tasksProposal.";
2068 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No TasksProposal exists with the primary key ";
2069 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No TasksProposal exists with the key {";
2070 private static Log _log = LogFactoryUtil.getLog(TasksProposalPersistenceImpl.class);
2071 }