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