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