1
22
23 package com.liferay.portlet.tasks.service.persistence;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
27 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
28 import com.liferay.portal.kernel.dao.orm.Query;
29 import com.liferay.portal.kernel.dao.orm.QueryPos;
30 import com.liferay.portal.kernel.dao.orm.QueryUtil;
31 import com.liferay.portal.kernel.dao.orm.Session;
32 import com.liferay.portal.kernel.log.Log;
33 import com.liferay.portal.kernel.log.LogFactoryUtil;
34 import com.liferay.portal.kernel.util.GetterUtil;
35 import com.liferay.portal.kernel.util.OrderByComparator;
36 import com.liferay.portal.kernel.util.StringPool;
37 import com.liferay.portal.kernel.util.StringUtil;
38 import com.liferay.portal.model.ModelListener;
39 import com.liferay.portal.service.persistence.BatchSessionUtil;
40 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
41
42 import com.liferay.portlet.tasks.NoSuchProposalException;
43 import com.liferay.portlet.tasks.model.TasksProposal;
44 import com.liferay.portlet.tasks.model.impl.TasksProposalImpl;
45 import com.liferay.portlet.tasks.model.impl.TasksProposalModelImpl;
46
47 import java.util.ArrayList;
48 import java.util.Collections;
49 import java.util.Iterator;
50 import java.util.List;
51
52
58 public class TasksProposalPersistenceImpl extends BasePersistenceImpl
59 implements TasksProposalPersistence {
60 public TasksProposal create(long proposalId) {
61 TasksProposal tasksProposal = new TasksProposalImpl();
62
63 tasksProposal.setNew(true);
64 tasksProposal.setPrimaryKey(proposalId);
65
66 return tasksProposal;
67 }
68
69 public TasksProposal remove(long proposalId)
70 throws NoSuchProposalException, SystemException {
71 Session session = null;
72
73 try {
74 session = openSession();
75
76 TasksProposal tasksProposal = (TasksProposal)session.get(TasksProposalImpl.class,
77 new Long(proposalId));
78
79 if (tasksProposal == null) {
80 if (_log.isWarnEnabled()) {
81 _log.warn("No TasksProposal exists with the primary key " +
82 proposalId);
83 }
84
85 throw new NoSuchProposalException(
86 "No TasksProposal exists with the primary key " +
87 proposalId);
88 }
89
90 return remove(tasksProposal);
91 }
92 catch (NoSuchProposalException nsee) {
93 throw nsee;
94 }
95 catch (Exception e) {
96 throw processException(e);
97 }
98 finally {
99 closeSession(session);
100 }
101 }
102
103 public TasksProposal remove(TasksProposal tasksProposal)
104 throws SystemException {
105 for (ModelListener listener : listeners) {
106 listener.onBeforeRemove(tasksProposal);
107 }
108
109 tasksProposal = removeImpl(tasksProposal);
110
111 for (ModelListener listener : listeners) {
112 listener.onAfterRemove(tasksProposal);
113 }
114
115 return tasksProposal;
116 }
117
118 protected TasksProposal removeImpl(TasksProposal tasksProposal)
119 throws SystemException {
120 Session session = null;
121
122 try {
123 session = openSession();
124
125 if (BatchSessionUtil.isEnabled()) {
126 Object staleObject = session.get(TasksProposalImpl.class,
127 tasksProposal.getPrimaryKeyObj());
128
129 if (staleObject != null) {
130 session.evict(staleObject);
131 }
132 }
133
134 session.delete(tasksProposal);
135
136 session.flush();
137
138 return tasksProposal;
139 }
140 catch (Exception e) {
141 throw processException(e);
142 }
143 finally {
144 closeSession(session);
145
146 FinderCacheUtil.clearCache(TasksProposal.class.getName());
147 }
148 }
149
150
153 public TasksProposal update(TasksProposal tasksProposal)
154 throws SystemException {
155 if (_log.isWarnEnabled()) {
156 _log.warn(
157 "Using the deprecated update(TasksProposal tasksProposal) method. Use update(TasksProposal tasksProposal, boolean merge) instead.");
158 }
159
160 return update(tasksProposal, false);
161 }
162
163
176 public TasksProposal update(TasksProposal tasksProposal, boolean merge)
177 throws SystemException {
178 boolean isNew = tasksProposal.isNew();
179
180 for (ModelListener listener : listeners) {
181 if (isNew) {
182 listener.onBeforeCreate(tasksProposal);
183 }
184 else {
185 listener.onBeforeUpdate(tasksProposal);
186 }
187 }
188
189 tasksProposal = updateImpl(tasksProposal, merge);
190
191 for (ModelListener listener : listeners) {
192 if (isNew) {
193 listener.onAfterCreate(tasksProposal);
194 }
195 else {
196 listener.onAfterUpdate(tasksProposal);
197 }
198 }
199
200 return tasksProposal;
201 }
202
203 public TasksProposal updateImpl(
204 com.liferay.portlet.tasks.model.TasksProposal tasksProposal,
205 boolean merge) throws SystemException {
206 Session session = null;
207
208 try {
209 session = openSession();
210
211 BatchSessionUtil.update(session, tasksProposal, merge);
212
213 tasksProposal.setNew(false);
214
215 return tasksProposal;
216 }
217 catch (Exception e) {
218 throw processException(e);
219 }
220 finally {
221 closeSession(session);
222
223 FinderCacheUtil.clearCache(TasksProposal.class.getName());
224 }
225 }
226
227 public TasksProposal findByPrimaryKey(long proposalId)
228 throws NoSuchProposalException, SystemException {
229 TasksProposal tasksProposal = fetchByPrimaryKey(proposalId);
230
231 if (tasksProposal == null) {
232 if (_log.isWarnEnabled()) {
233 _log.warn("No TasksProposal exists with the primary key " +
234 proposalId);
235 }
236
237 throw new NoSuchProposalException(
238 "No TasksProposal exists with the primary key " + proposalId);
239 }
240
241 return tasksProposal;
242 }
243
244 public TasksProposal fetchByPrimaryKey(long proposalId)
245 throws SystemException {
246 Session session = null;
247
248 try {
249 session = openSession();
250
251 return (TasksProposal)session.get(TasksProposalImpl.class,
252 new Long(proposalId));
253 }
254 catch (Exception e) {
255 throw processException(e);
256 }
257 finally {
258 closeSession(session);
259 }
260 }
261
262 public List<TasksProposal> findByGroupId(long groupId)
263 throws SystemException {
264 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
265 String finderClassName = TasksProposal.class.getName();
266 String finderMethodName = "findByGroupId";
267 String[] finderParams = new String[] { Long.class.getName() };
268 Object[] finderArgs = new Object[] { new Long(groupId) };
269
270 Object result = null;
271
272 if (finderClassNameCacheEnabled) {
273 result = FinderCacheUtil.getResult(finderClassName,
274 finderMethodName, finderParams, finderArgs, this);
275 }
276
277 if (result == null) {
278 Session session = null;
279
280 try {
281 session = openSession();
282
283 StringBuilder query = new StringBuilder();
284
285 query.append(
286 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
287
288 query.append("groupId = ?");
289
290 query.append(" ");
291
292 query.append("ORDER BY ");
293
294 query.append("dueDate ASC, ");
295 query.append("createDate ASC");
296
297 Query q = session.createQuery(query.toString());
298
299 QueryPos qPos = QueryPos.getInstance(q);
300
301 qPos.add(groupId);
302
303 List<TasksProposal> list = q.list();
304
305 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
306 finderClassName, finderMethodName, finderParams,
307 finderArgs, list);
308
309 return list;
310 }
311 catch (Exception e) {
312 throw processException(e);
313 }
314 finally {
315 closeSession(session);
316 }
317 }
318 else {
319 return (List<TasksProposal>)result;
320 }
321 }
322
323 public List<TasksProposal> findByGroupId(long groupId, int start, int end)
324 throws SystemException {
325 return findByGroupId(groupId, start, end, null);
326 }
327
328 public List<TasksProposal> findByGroupId(long groupId, int start, int end,
329 OrderByComparator obc) throws SystemException {
330 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
331 String finderClassName = TasksProposal.class.getName();
332 String finderMethodName = "findByGroupId";
333 String[] finderParams = new String[] {
334 Long.class.getName(),
335
336 "java.lang.Integer", "java.lang.Integer",
337 "com.liferay.portal.kernel.util.OrderByComparator"
338 };
339 Object[] finderArgs = new Object[] {
340 new Long(groupId),
341
342 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
343 };
344
345 Object result = null;
346
347 if (finderClassNameCacheEnabled) {
348 result = FinderCacheUtil.getResult(finderClassName,
349 finderMethodName, finderParams, finderArgs, this);
350 }
351
352 if (result == null) {
353 Session session = null;
354
355 try {
356 session = openSession();
357
358 StringBuilder query = new StringBuilder();
359
360 query.append(
361 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
362
363 query.append("groupId = ?");
364
365 query.append(" ");
366
367 if (obc != null) {
368 query.append("ORDER BY ");
369 query.append(obc.getOrderBy());
370 }
371
372 else {
373 query.append("ORDER BY ");
374
375 query.append("dueDate ASC, ");
376 query.append("createDate ASC");
377 }
378
379 Query q = session.createQuery(query.toString());
380
381 QueryPos qPos = QueryPos.getInstance(q);
382
383 qPos.add(groupId);
384
385 List<TasksProposal> list = (List<TasksProposal>)QueryUtil.list(q,
386 getDialect(), start, end);
387
388 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
389 finderClassName, finderMethodName, finderParams,
390 finderArgs, list);
391
392 return list;
393 }
394 catch (Exception e) {
395 throw processException(e);
396 }
397 finally {
398 closeSession(session);
399 }
400 }
401 else {
402 return (List<TasksProposal>)result;
403 }
404 }
405
406 public TasksProposal findByGroupId_First(long groupId, OrderByComparator obc)
407 throws NoSuchProposalException, SystemException {
408 List<TasksProposal> list = findByGroupId(groupId, 0, 1, obc);
409
410 if (list.size() == 0) {
411 StringBuilder msg = new StringBuilder();
412
413 msg.append("No TasksProposal exists with the key {");
414
415 msg.append("groupId=" + groupId);
416
417 msg.append(StringPool.CLOSE_CURLY_BRACE);
418
419 throw new NoSuchProposalException(msg.toString());
420 }
421 else {
422 return list.get(0);
423 }
424 }
425
426 public TasksProposal findByGroupId_Last(long groupId, OrderByComparator obc)
427 throws NoSuchProposalException, SystemException {
428 int count = countByGroupId(groupId);
429
430 List<TasksProposal> list = findByGroupId(groupId, count - 1, count, obc);
431
432 if (list.size() == 0) {
433 StringBuilder msg = new StringBuilder();
434
435 msg.append("No TasksProposal exists with the key {");
436
437 msg.append("groupId=" + groupId);
438
439 msg.append(StringPool.CLOSE_CURLY_BRACE);
440
441 throw new NoSuchProposalException(msg.toString());
442 }
443 else {
444 return list.get(0);
445 }
446 }
447
448 public TasksProposal[] findByGroupId_PrevAndNext(long proposalId,
449 long groupId, OrderByComparator obc)
450 throws NoSuchProposalException, SystemException {
451 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
452
453 int count = countByGroupId(groupId);
454
455 Session session = null;
456
457 try {
458 session = openSession();
459
460 StringBuilder query = new StringBuilder();
461
462 query.append(
463 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
464
465 query.append("groupId = ?");
466
467 query.append(" ");
468
469 if (obc != null) {
470 query.append("ORDER BY ");
471 query.append(obc.getOrderBy());
472 }
473
474 else {
475 query.append("ORDER BY ");
476
477 query.append("dueDate ASC, ");
478 query.append("createDate ASC");
479 }
480
481 Query q = session.createQuery(query.toString());
482
483 QueryPos qPos = QueryPos.getInstance(q);
484
485 qPos.add(groupId);
486
487 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
488 tasksProposal);
489
490 TasksProposal[] array = new TasksProposalImpl[3];
491
492 array[0] = (TasksProposal)objArray[0];
493 array[1] = (TasksProposal)objArray[1];
494 array[2] = (TasksProposal)objArray[2];
495
496 return array;
497 }
498 catch (Exception e) {
499 throw processException(e);
500 }
501 finally {
502 closeSession(session);
503 }
504 }
505
506 public List<TasksProposal> findByG_U(long groupId, long userId)
507 throws SystemException {
508 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
509 String finderClassName = TasksProposal.class.getName();
510 String finderMethodName = "findByG_U";
511 String[] finderParams = new String[] {
512 Long.class.getName(), Long.class.getName()
513 };
514 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
515
516 Object result = null;
517
518 if (finderClassNameCacheEnabled) {
519 result = FinderCacheUtil.getResult(finderClassName,
520 finderMethodName, finderParams, finderArgs, this);
521 }
522
523 if (result == null) {
524 Session session = null;
525
526 try {
527 session = openSession();
528
529 StringBuilder query = new StringBuilder();
530
531 query.append(
532 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
533
534 query.append("groupId = ?");
535
536 query.append(" AND ");
537
538 query.append("userId = ?");
539
540 query.append(" ");
541
542 query.append("ORDER BY ");
543
544 query.append("dueDate ASC, ");
545 query.append("createDate ASC");
546
547 Query q = session.createQuery(query.toString());
548
549 QueryPos qPos = QueryPos.getInstance(q);
550
551 qPos.add(groupId);
552
553 qPos.add(userId);
554
555 List<TasksProposal> list = q.list();
556
557 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
558 finderClassName, finderMethodName, finderParams,
559 finderArgs, list);
560
561 return list;
562 }
563 catch (Exception e) {
564 throw processException(e);
565 }
566 finally {
567 closeSession(session);
568 }
569 }
570 else {
571 return (List<TasksProposal>)result;
572 }
573 }
574
575 public List<TasksProposal> findByG_U(long groupId, long userId, int start,
576 int end) throws SystemException {
577 return findByG_U(groupId, userId, start, end, null);
578 }
579
580 public List<TasksProposal> findByG_U(long groupId, long userId, int start,
581 int end, OrderByComparator obc) throws SystemException {
582 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
583 String finderClassName = TasksProposal.class.getName();
584 String finderMethodName = "findByG_U";
585 String[] finderParams = new String[] {
586 Long.class.getName(), Long.class.getName(),
587
588 "java.lang.Integer", "java.lang.Integer",
589 "com.liferay.portal.kernel.util.OrderByComparator"
590 };
591 Object[] finderArgs = new Object[] {
592 new Long(groupId), new Long(userId),
593
594 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
595 };
596
597 Object result = null;
598
599 if (finderClassNameCacheEnabled) {
600 result = FinderCacheUtil.getResult(finderClassName,
601 finderMethodName, finderParams, finderArgs, this);
602 }
603
604 if (result == null) {
605 Session session = null;
606
607 try {
608 session = openSession();
609
610 StringBuilder query = new StringBuilder();
611
612 query.append(
613 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
614
615 query.append("groupId = ?");
616
617 query.append(" AND ");
618
619 query.append("userId = ?");
620
621 query.append(" ");
622
623 if (obc != null) {
624 query.append("ORDER BY ");
625 query.append(obc.getOrderBy());
626 }
627
628 else {
629 query.append("ORDER BY ");
630
631 query.append("dueDate ASC, ");
632 query.append("createDate ASC");
633 }
634
635 Query q = session.createQuery(query.toString());
636
637 QueryPos qPos = QueryPos.getInstance(q);
638
639 qPos.add(groupId);
640
641 qPos.add(userId);
642
643 List<TasksProposal> list = (List<TasksProposal>)QueryUtil.list(q,
644 getDialect(), start, end);
645
646 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
647 finderClassName, finderMethodName, finderParams,
648 finderArgs, list);
649
650 return list;
651 }
652 catch (Exception e) {
653 throw processException(e);
654 }
655 finally {
656 closeSession(session);
657 }
658 }
659 else {
660 return (List<TasksProposal>)result;
661 }
662 }
663
664 public TasksProposal findByG_U_First(long groupId, long userId,
665 OrderByComparator obc) throws NoSuchProposalException, SystemException {
666 List<TasksProposal> list = findByG_U(groupId, userId, 0, 1, obc);
667
668 if (list.size() == 0) {
669 StringBuilder msg = new StringBuilder();
670
671 msg.append("No TasksProposal exists with the key {");
672
673 msg.append("groupId=" + groupId);
674
675 msg.append(", ");
676 msg.append("userId=" + userId);
677
678 msg.append(StringPool.CLOSE_CURLY_BRACE);
679
680 throw new NoSuchProposalException(msg.toString());
681 }
682 else {
683 return list.get(0);
684 }
685 }
686
687 public TasksProposal findByG_U_Last(long groupId, long userId,
688 OrderByComparator obc) throws NoSuchProposalException, SystemException {
689 int count = countByG_U(groupId, userId);
690
691 List<TasksProposal> list = findByG_U(groupId, userId, count - 1, count,
692 obc);
693
694 if (list.size() == 0) {
695 StringBuilder msg = new StringBuilder();
696
697 msg.append("No TasksProposal exists with the key {");
698
699 msg.append("groupId=" + groupId);
700
701 msg.append(", ");
702 msg.append("userId=" + userId);
703
704 msg.append(StringPool.CLOSE_CURLY_BRACE);
705
706 throw new NoSuchProposalException(msg.toString());
707 }
708 else {
709 return list.get(0);
710 }
711 }
712
713 public TasksProposal[] findByG_U_PrevAndNext(long proposalId, long groupId,
714 long userId, OrderByComparator obc)
715 throws NoSuchProposalException, SystemException {
716 TasksProposal tasksProposal = findByPrimaryKey(proposalId);
717
718 int count = countByG_U(groupId, userId);
719
720 Session session = null;
721
722 try {
723 session = openSession();
724
725 StringBuilder query = new StringBuilder();
726
727 query.append(
728 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
729
730 query.append("groupId = ?");
731
732 query.append(" AND ");
733
734 query.append("userId = ?");
735
736 query.append(" ");
737
738 if (obc != null) {
739 query.append("ORDER BY ");
740 query.append(obc.getOrderBy());
741 }
742
743 else {
744 query.append("ORDER BY ");
745
746 query.append("dueDate ASC, ");
747 query.append("createDate ASC");
748 }
749
750 Query q = session.createQuery(query.toString());
751
752 QueryPos qPos = QueryPos.getInstance(q);
753
754 qPos.add(groupId);
755
756 qPos.add(userId);
757
758 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
759 tasksProposal);
760
761 TasksProposal[] array = new TasksProposalImpl[3];
762
763 array[0] = (TasksProposal)objArray[0];
764 array[1] = (TasksProposal)objArray[1];
765 array[2] = (TasksProposal)objArray[2];
766
767 return array;
768 }
769 catch (Exception e) {
770 throw processException(e);
771 }
772 finally {
773 closeSession(session);
774 }
775 }
776
777 public TasksProposal findByC_C(long classNameId, String classPK)
778 throws NoSuchProposalException, SystemException {
779 TasksProposal tasksProposal = fetchByC_C(classNameId, classPK);
780
781 if (tasksProposal == null) {
782 StringBuilder msg = new StringBuilder();
783
784 msg.append("No TasksProposal exists with the key {");
785
786 msg.append("classNameId=" + classNameId);
787
788 msg.append(", ");
789 msg.append("classPK=" + classPK);
790
791 msg.append(StringPool.CLOSE_CURLY_BRACE);
792
793 if (_log.isWarnEnabled()) {
794 _log.warn(msg.toString());
795 }
796
797 throw new NoSuchProposalException(msg.toString());
798 }
799
800 return tasksProposal;
801 }
802
803 public TasksProposal fetchByC_C(long classNameId, String classPK)
804 throws SystemException {
805 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
806 String finderClassName = TasksProposal.class.getName();
807 String finderMethodName = "fetchByC_C";
808 String[] finderParams = new String[] {
809 Long.class.getName(), String.class.getName()
810 };
811 Object[] finderArgs = new Object[] { new Long(classNameId), classPK };
812
813 Object result = null;
814
815 if (finderClassNameCacheEnabled) {
816 result = FinderCacheUtil.getResult(finderClassName,
817 finderMethodName, finderParams, finderArgs, this);
818 }
819
820 if (result == null) {
821 Session session = null;
822
823 try {
824 session = openSession();
825
826 StringBuilder query = new StringBuilder();
827
828 query.append(
829 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
830
831 query.append("classNameId = ?");
832
833 query.append(" AND ");
834
835 if (classPK == null) {
836 query.append("classPK IS NULL");
837 }
838 else {
839 query.append("classPK = ?");
840 }
841
842 query.append(" ");
843
844 query.append("ORDER BY ");
845
846 query.append("dueDate ASC, ");
847 query.append("createDate ASC");
848
849 Query q = session.createQuery(query.toString());
850
851 QueryPos qPos = QueryPos.getInstance(q);
852
853 qPos.add(classNameId);
854
855 if (classPK != null) {
856 qPos.add(classPK);
857 }
858
859 List<TasksProposal> list = q.list();
860
861 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
862 finderClassName, finderMethodName, finderParams,
863 finderArgs, list);
864
865 if (list.size() == 0) {
866 return null;
867 }
868 else {
869 return list.get(0);
870 }
871 }
872 catch (Exception e) {
873 throw processException(e);
874 }
875 finally {
876 closeSession(session);
877 }
878 }
879 else {
880 List<TasksProposal> list = (List<TasksProposal>)result;
881
882 if (list.size() == 0) {
883 return null;
884 }
885 else {
886 return list.get(0);
887 }
888 }
889 }
890
891 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
892 throws SystemException {
893 Session session = null;
894
895 try {
896 session = openSession();
897
898 dynamicQuery.compile(session);
899
900 return dynamicQuery.list();
901 }
902 catch (Exception e) {
903 throw processException(e);
904 }
905 finally {
906 closeSession(session);
907 }
908 }
909
910 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
911 int start, int end) throws SystemException {
912 Session session = null;
913
914 try {
915 session = openSession();
916
917 dynamicQuery.setLimit(start, end);
918
919 dynamicQuery.compile(session);
920
921 return dynamicQuery.list();
922 }
923 catch (Exception e) {
924 throw processException(e);
925 }
926 finally {
927 closeSession(session);
928 }
929 }
930
931 public List<TasksProposal> findAll() throws SystemException {
932 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
933 }
934
935 public List<TasksProposal> findAll(int start, int end)
936 throws SystemException {
937 return findAll(start, end, null);
938 }
939
940 public List<TasksProposal> findAll(int start, int end, OrderByComparator obc)
941 throws SystemException {
942 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
943 String finderClassName = TasksProposal.class.getName();
944 String finderMethodName = "findAll";
945 String[] finderParams = new String[] {
946 "java.lang.Integer", "java.lang.Integer",
947 "com.liferay.portal.kernel.util.OrderByComparator"
948 };
949 Object[] finderArgs = new Object[] {
950 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
951 };
952
953 Object result = null;
954
955 if (finderClassNameCacheEnabled) {
956 result = FinderCacheUtil.getResult(finderClassName,
957 finderMethodName, finderParams, finderArgs, this);
958 }
959
960 if (result == null) {
961 Session session = null;
962
963 try {
964 session = openSession();
965
966 StringBuilder query = new StringBuilder();
967
968 query.append(
969 "FROM com.liferay.portlet.tasks.model.TasksProposal ");
970
971 if (obc != null) {
972 query.append("ORDER BY ");
973 query.append(obc.getOrderBy());
974 }
975
976 else {
977 query.append("ORDER BY ");
978
979 query.append("dueDate ASC, ");
980 query.append("createDate ASC");
981 }
982
983 Query q = session.createQuery(query.toString());
984
985 List<TasksProposal> list = null;
986
987 if (obc == null) {
988 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
989 start, end, false);
990
991 Collections.sort(list);
992 }
993 else {
994 list = (List<TasksProposal>)QueryUtil.list(q, getDialect(),
995 start, end);
996 }
997
998 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
999 finderClassName, finderMethodName, finderParams,
1000 finderArgs, list);
1001
1002 return list;
1003 }
1004 catch (Exception e) {
1005 throw processException(e);
1006 }
1007 finally {
1008 closeSession(session);
1009 }
1010 }
1011 else {
1012 return (List<TasksProposal>)result;
1013 }
1014 }
1015
1016 public void removeByGroupId(long groupId) throws SystemException {
1017 for (TasksProposal tasksProposal : findByGroupId(groupId)) {
1018 remove(tasksProposal);
1019 }
1020 }
1021
1022 public void removeByG_U(long groupId, long userId)
1023 throws SystemException {
1024 for (TasksProposal tasksProposal : findByG_U(groupId, userId)) {
1025 remove(tasksProposal);
1026 }
1027 }
1028
1029 public void removeByC_C(long classNameId, String classPK)
1030 throws NoSuchProposalException, SystemException {
1031 TasksProposal tasksProposal = findByC_C(classNameId, classPK);
1032
1033 remove(tasksProposal);
1034 }
1035
1036 public void removeAll() throws SystemException {
1037 for (TasksProposal tasksProposal : findAll()) {
1038 remove(tasksProposal);
1039 }
1040 }
1041
1042 public int countByGroupId(long groupId) throws SystemException {
1043 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1044 String finderClassName = TasksProposal.class.getName();
1045 String finderMethodName = "countByGroupId";
1046 String[] finderParams = new String[] { Long.class.getName() };
1047 Object[] finderArgs = new Object[] { new Long(groupId) };
1048
1049 Object result = null;
1050
1051 if (finderClassNameCacheEnabled) {
1052 result = FinderCacheUtil.getResult(finderClassName,
1053 finderMethodName, finderParams, finderArgs, this);
1054 }
1055
1056 if (result == null) {
1057 Session session = null;
1058
1059 try {
1060 session = openSession();
1061
1062 StringBuilder query = new StringBuilder();
1063
1064 query.append("SELECT COUNT(*) ");
1065 query.append(
1066 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1067
1068 query.append("groupId = ?");
1069
1070 query.append(" ");
1071
1072 Query q = session.createQuery(query.toString());
1073
1074 QueryPos qPos = QueryPos.getInstance(q);
1075
1076 qPos.add(groupId);
1077
1078 Long count = null;
1079
1080 Iterator<Long> itr = q.list().iterator();
1081
1082 if (itr.hasNext()) {
1083 count = itr.next();
1084 }
1085
1086 if (count == null) {
1087 count = new Long(0);
1088 }
1089
1090 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1091 finderClassName, finderMethodName, finderParams,
1092 finderArgs, count);
1093
1094 return count.intValue();
1095 }
1096 catch (Exception e) {
1097 throw processException(e);
1098 }
1099 finally {
1100 closeSession(session);
1101 }
1102 }
1103 else {
1104 return ((Long)result).intValue();
1105 }
1106 }
1107
1108 public int countByG_U(long groupId, long userId) throws SystemException {
1109 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1110 String finderClassName = TasksProposal.class.getName();
1111 String finderMethodName = "countByG_U";
1112 String[] finderParams = new String[] {
1113 Long.class.getName(), Long.class.getName()
1114 };
1115 Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1116
1117 Object result = null;
1118
1119 if (finderClassNameCacheEnabled) {
1120 result = FinderCacheUtil.getResult(finderClassName,
1121 finderMethodName, finderParams, finderArgs, this);
1122 }
1123
1124 if (result == null) {
1125 Session session = null;
1126
1127 try {
1128 session = openSession();
1129
1130 StringBuilder query = new StringBuilder();
1131
1132 query.append("SELECT COUNT(*) ");
1133 query.append(
1134 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1135
1136 query.append("groupId = ?");
1137
1138 query.append(" AND ");
1139
1140 query.append("userId = ?");
1141
1142 query.append(" ");
1143
1144 Query q = session.createQuery(query.toString());
1145
1146 QueryPos qPos = QueryPos.getInstance(q);
1147
1148 qPos.add(groupId);
1149
1150 qPos.add(userId);
1151
1152 Long count = null;
1153
1154 Iterator<Long> itr = q.list().iterator();
1155
1156 if (itr.hasNext()) {
1157 count = itr.next();
1158 }
1159
1160 if (count == null) {
1161 count = new Long(0);
1162 }
1163
1164 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1165 finderClassName, finderMethodName, finderParams,
1166 finderArgs, count);
1167
1168 return count.intValue();
1169 }
1170 catch (Exception e) {
1171 throw processException(e);
1172 }
1173 finally {
1174 closeSession(session);
1175 }
1176 }
1177 else {
1178 return ((Long)result).intValue();
1179 }
1180 }
1181
1182 public int countByC_C(long classNameId, String classPK)
1183 throws SystemException {
1184 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1185 String finderClassName = TasksProposal.class.getName();
1186 String finderMethodName = "countByC_C";
1187 String[] finderParams = new String[] {
1188 Long.class.getName(), String.class.getName()
1189 };
1190 Object[] finderArgs = new Object[] { new Long(classNameId), classPK };
1191
1192 Object result = null;
1193
1194 if (finderClassNameCacheEnabled) {
1195 result = FinderCacheUtil.getResult(finderClassName,
1196 finderMethodName, finderParams, finderArgs, this);
1197 }
1198
1199 if (result == null) {
1200 Session session = null;
1201
1202 try {
1203 session = openSession();
1204
1205 StringBuilder query = new StringBuilder();
1206
1207 query.append("SELECT COUNT(*) ");
1208 query.append(
1209 "FROM com.liferay.portlet.tasks.model.TasksProposal WHERE ");
1210
1211 query.append("classNameId = ?");
1212
1213 query.append(" AND ");
1214
1215 if (classPK == null) {
1216 query.append("classPK IS NULL");
1217 }
1218 else {
1219 query.append("classPK = ?");
1220 }
1221
1222 query.append(" ");
1223
1224 Query q = session.createQuery(query.toString());
1225
1226 QueryPos qPos = QueryPos.getInstance(q);
1227
1228 qPos.add(classNameId);
1229
1230 if (classPK != null) {
1231 qPos.add(classPK);
1232 }
1233
1234 Long count = null;
1235
1236 Iterator<Long> itr = q.list().iterator();
1237
1238 if (itr.hasNext()) {
1239 count = itr.next();
1240 }
1241
1242 if (count == null) {
1243 count = new Long(0);
1244 }
1245
1246 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1247 finderClassName, finderMethodName, finderParams,
1248 finderArgs, count);
1249
1250 return count.intValue();
1251 }
1252 catch (Exception e) {
1253 throw processException(e);
1254 }
1255 finally {
1256 closeSession(session);
1257 }
1258 }
1259 else {
1260 return ((Long)result).intValue();
1261 }
1262 }
1263
1264 public int countAll() throws SystemException {
1265 boolean finderClassNameCacheEnabled = TasksProposalModelImpl.CACHE_ENABLED;
1266 String finderClassName = TasksProposal.class.getName();
1267 String finderMethodName = "countAll";
1268 String[] finderParams = new String[] { };
1269 Object[] finderArgs = new Object[] { };
1270
1271 Object result = null;
1272
1273 if (finderClassNameCacheEnabled) {
1274 result = FinderCacheUtil.getResult(finderClassName,
1275 finderMethodName, finderParams, finderArgs, this);
1276 }
1277
1278 if (result == null) {
1279 Session session = null;
1280
1281 try {
1282 session = openSession();
1283
1284 Query q = session.createQuery(
1285 "SELECT COUNT(*) FROM com.liferay.portlet.tasks.model.TasksProposal");
1286
1287 Long count = null;
1288
1289 Iterator<Long> itr = q.list().iterator();
1290
1291 if (itr.hasNext()) {
1292 count = itr.next();
1293 }
1294
1295 if (count == null) {
1296 count = new Long(0);
1297 }
1298
1299 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1300 finderClassName, finderMethodName, finderParams,
1301 finderArgs, count);
1302
1303 return count.intValue();
1304 }
1305 catch (Exception e) {
1306 throw processException(e);
1307 }
1308 finally {
1309 closeSession(session);
1310 }
1311 }
1312 else {
1313 return ((Long)result).intValue();
1314 }
1315 }
1316
1317 public void afterPropertiesSet() {
1318 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1319 com.liferay.portal.util.PropsUtil.get(
1320 "value.object.listener.com.liferay.portlet.tasks.model.TasksProposal")));
1321
1322 if (listenerClassNames.length > 0) {
1323 try {
1324 List<ModelListener> listenersList = new ArrayList<ModelListener>();
1325
1326 for (String listenerClassName : listenerClassNames) {
1327 listenersList.add((ModelListener)Class.forName(
1328 listenerClassName).newInstance());
1329 }
1330
1331 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1332 }
1333 catch (Exception e) {
1334 _log.error(e);
1335 }
1336 }
1337 }
1338
1339 private static Log _log = LogFactoryUtil.getLog(TasksProposalPersistenceImpl.class);
1340}