1
22
23 package com.liferay.portal.service.persistence;
24
25 import com.liferay.portal.NoSuchPluginSettingException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.annotation.BeanReference;
28 import com.liferay.portal.kernel.cache.CacheRegistry;
29 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
30 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
31 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
32 import com.liferay.portal.kernel.dao.orm.FinderPath;
33 import com.liferay.portal.kernel.dao.orm.Query;
34 import com.liferay.portal.kernel.dao.orm.QueryPos;
35 import com.liferay.portal.kernel.dao.orm.QueryUtil;
36 import com.liferay.portal.kernel.dao.orm.Session;
37 import com.liferay.portal.kernel.log.Log;
38 import com.liferay.portal.kernel.log.LogFactoryUtil;
39 import com.liferay.portal.kernel.util.GetterUtil;
40 import com.liferay.portal.kernel.util.OrderByComparator;
41 import com.liferay.portal.kernel.util.StringPool;
42 import com.liferay.portal.kernel.util.StringUtil;
43 import com.liferay.portal.kernel.util.Validator;
44 import com.liferay.portal.model.ModelListener;
45 import com.liferay.portal.model.PluginSetting;
46 import com.liferay.portal.model.impl.PluginSettingImpl;
47 import com.liferay.portal.model.impl.PluginSettingModelImpl;
48 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
49
50 import java.util.ArrayList;
51 import java.util.Collections;
52 import java.util.List;
53
54
60 public class PluginSettingPersistenceImpl extends BasePersistenceImpl
61 implements PluginSettingPersistence {
62 public static final String FINDER_CLASS_NAME_ENTITY = PluginSettingImpl.class.getName();
63 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
64 ".List";
65 public static final FinderPath FINDER_PATH_FIND_BY_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
66 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
67 FINDER_CLASS_NAME_LIST, "findByCompanyId",
68 new String[] { Long.class.getName() });
69 public static final FinderPath FINDER_PATH_FIND_BY_OBC_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
70 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
71 FINDER_CLASS_NAME_LIST, "findByCompanyId",
72 new String[] {
73 Long.class.getName(),
74
75 "java.lang.Integer", "java.lang.Integer",
76 "com.liferay.portal.kernel.util.OrderByComparator"
77 });
78 public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
79 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
80 FINDER_CLASS_NAME_LIST, "countByCompanyId",
81 new String[] { Long.class.getName() });
82 public static final FinderPath FINDER_PATH_FETCH_BY_C_I_T = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
83 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
84 FINDER_CLASS_NAME_ENTITY, "fetchByC_I_T",
85 new String[] {
86 Long.class.getName(), String.class.getName(),
87 String.class.getName()
88 });
89 public static final FinderPath FINDER_PATH_COUNT_BY_C_I_T = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
90 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
91 FINDER_CLASS_NAME_LIST, "countByC_I_T",
92 new String[] {
93 Long.class.getName(), String.class.getName(),
94 String.class.getName()
95 });
96 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
97 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
98 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
99 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
100 PluginSettingModelImpl.FINDER_CACHE_ENABLED,
101 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
102
103 public void cacheResult(PluginSetting pluginSetting) {
104 EntityCacheUtil.putResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
105 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
106 pluginSetting);
107
108 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
109 new Object[] {
110 new Long(pluginSetting.getCompanyId()),
111
112 pluginSetting.getPluginId(),
113
114 pluginSetting.getPluginType()
115 }, pluginSetting);
116 }
117
118 public void cacheResult(List<PluginSetting> pluginSettings) {
119 for (PluginSetting pluginSetting : pluginSettings) {
120 if (EntityCacheUtil.getResult(
121 PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
122 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
123 this) == null) {
124 cacheResult(pluginSetting);
125 }
126 }
127 }
128
129 public void clearCache() {
130 CacheRegistry.clear(PluginSettingImpl.class.getName());
131 EntityCacheUtil.clearCache(PluginSettingImpl.class.getName());
132 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
133 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
134 }
135
136 public PluginSetting create(long pluginSettingId) {
137 PluginSetting pluginSetting = new PluginSettingImpl();
138
139 pluginSetting.setNew(true);
140 pluginSetting.setPrimaryKey(pluginSettingId);
141
142 return pluginSetting;
143 }
144
145 public PluginSetting remove(long pluginSettingId)
146 throws NoSuchPluginSettingException, SystemException {
147 Session session = null;
148
149 try {
150 session = openSession();
151
152 PluginSetting pluginSetting = (PluginSetting)session.get(PluginSettingImpl.class,
153 new Long(pluginSettingId));
154
155 if (pluginSetting == null) {
156 if (_log.isWarnEnabled()) {
157 _log.warn("No PluginSetting exists with the primary key " +
158 pluginSettingId);
159 }
160
161 throw new NoSuchPluginSettingException(
162 "No PluginSetting exists with the primary key " +
163 pluginSettingId);
164 }
165
166 return remove(pluginSetting);
167 }
168 catch (NoSuchPluginSettingException nsee) {
169 throw nsee;
170 }
171 catch (Exception e) {
172 throw processException(e);
173 }
174 finally {
175 closeSession(session);
176 }
177 }
178
179 public PluginSetting remove(PluginSetting pluginSetting)
180 throws SystemException {
181 for (ModelListener<PluginSetting> listener : listeners) {
182 listener.onBeforeRemove(pluginSetting);
183 }
184
185 pluginSetting = removeImpl(pluginSetting);
186
187 for (ModelListener<PluginSetting> listener : listeners) {
188 listener.onAfterRemove(pluginSetting);
189 }
190
191 return pluginSetting;
192 }
193
194 protected PluginSetting removeImpl(PluginSetting pluginSetting)
195 throws SystemException {
196 Session session = null;
197
198 try {
199 session = openSession();
200
201 if (pluginSetting.isCachedModel() || BatchSessionUtil.isEnabled()) {
202 Object staleObject = session.get(PluginSettingImpl.class,
203 pluginSetting.getPrimaryKeyObj());
204
205 if (staleObject != null) {
206 session.evict(staleObject);
207 }
208 }
209
210 session.delete(pluginSetting);
211
212 session.flush();
213 }
214 catch (Exception e) {
215 throw processException(e);
216 }
217 finally {
218 closeSession(session);
219 }
220
221 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
222
223 PluginSettingModelImpl pluginSettingModelImpl = (PluginSettingModelImpl)pluginSetting;
224
225 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_I_T,
226 new Object[] {
227 new Long(pluginSettingModelImpl.getOriginalCompanyId()),
228
229 pluginSettingModelImpl.getOriginalPluginId(),
230
231 pluginSettingModelImpl.getOriginalPluginType()
232 });
233
234 EntityCacheUtil.removeResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
235 PluginSettingImpl.class, pluginSetting.getPrimaryKey());
236
237 return pluginSetting;
238 }
239
240
243 public PluginSetting update(PluginSetting pluginSetting)
244 throws SystemException {
245 if (_log.isWarnEnabled()) {
246 _log.warn(
247 "Using the deprecated update(PluginSetting pluginSetting) method. Use update(PluginSetting pluginSetting, boolean merge) instead.");
248 }
249
250 return update(pluginSetting, false);
251 }
252
253
266 public PluginSetting update(PluginSetting pluginSetting, boolean merge)
267 throws SystemException {
268 boolean isNew = pluginSetting.isNew();
269
270 for (ModelListener<PluginSetting> listener : listeners) {
271 if (isNew) {
272 listener.onBeforeCreate(pluginSetting);
273 }
274 else {
275 listener.onBeforeUpdate(pluginSetting);
276 }
277 }
278
279 pluginSetting = updateImpl(pluginSetting, merge);
280
281 for (ModelListener<PluginSetting> listener : listeners) {
282 if (isNew) {
283 listener.onAfterCreate(pluginSetting);
284 }
285 else {
286 listener.onAfterUpdate(pluginSetting);
287 }
288 }
289
290 return pluginSetting;
291 }
292
293 public PluginSetting updateImpl(
294 com.liferay.portal.model.PluginSetting pluginSetting, boolean merge)
295 throws SystemException {
296 boolean isNew = pluginSetting.isNew();
297
298 PluginSettingModelImpl pluginSettingModelImpl = (PluginSettingModelImpl)pluginSetting;
299
300 Session session = null;
301
302 try {
303 session = openSession();
304
305 BatchSessionUtil.update(session, pluginSetting, merge);
306
307 pluginSetting.setNew(false);
308 }
309 catch (Exception e) {
310 throw processException(e);
311 }
312 finally {
313 closeSession(session);
314 }
315
316 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
317
318 EntityCacheUtil.putResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
319 PluginSettingImpl.class, pluginSetting.getPrimaryKey(),
320 pluginSetting);
321
322 if (!isNew &&
323 ((pluginSetting.getCompanyId() != pluginSettingModelImpl.getOriginalCompanyId()) ||
324 !Validator.equals(pluginSetting.getPluginId(),
325 pluginSettingModelImpl.getOriginalPluginId()) ||
326 !Validator.equals(pluginSetting.getPluginType(),
327 pluginSettingModelImpl.getOriginalPluginType()))) {
328 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_I_T,
329 new Object[] {
330 new Long(pluginSettingModelImpl.getOriginalCompanyId()),
331
332 pluginSettingModelImpl.getOriginalPluginId(),
333
334 pluginSettingModelImpl.getOriginalPluginType()
335 });
336 }
337
338 if (isNew ||
339 ((pluginSetting.getCompanyId() != pluginSettingModelImpl.getOriginalCompanyId()) ||
340 !Validator.equals(pluginSetting.getPluginId(),
341 pluginSettingModelImpl.getOriginalPluginId()) ||
342 !Validator.equals(pluginSetting.getPluginType(),
343 pluginSettingModelImpl.getOriginalPluginType()))) {
344 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
345 new Object[] {
346 new Long(pluginSetting.getCompanyId()),
347
348 pluginSetting.getPluginId(),
349
350 pluginSetting.getPluginType()
351 }, pluginSetting);
352 }
353
354 return pluginSetting;
355 }
356
357 public PluginSetting findByPrimaryKey(long pluginSettingId)
358 throws NoSuchPluginSettingException, SystemException {
359 PluginSetting pluginSetting = fetchByPrimaryKey(pluginSettingId);
360
361 if (pluginSetting == null) {
362 if (_log.isWarnEnabled()) {
363 _log.warn("No PluginSetting exists with the primary key " +
364 pluginSettingId);
365 }
366
367 throw new NoSuchPluginSettingException(
368 "No PluginSetting exists with the primary key " +
369 pluginSettingId);
370 }
371
372 return pluginSetting;
373 }
374
375 public PluginSetting fetchByPrimaryKey(long pluginSettingId)
376 throws SystemException {
377 PluginSetting pluginSetting = (PluginSetting)EntityCacheUtil.getResult(PluginSettingModelImpl.ENTITY_CACHE_ENABLED,
378 PluginSettingImpl.class, pluginSettingId, this);
379
380 if (pluginSetting == null) {
381 Session session = null;
382
383 try {
384 session = openSession();
385
386 pluginSetting = (PluginSetting)session.get(PluginSettingImpl.class,
387 new Long(pluginSettingId));
388 }
389 catch (Exception e) {
390 throw processException(e);
391 }
392 finally {
393 if (pluginSetting != null) {
394 cacheResult(pluginSetting);
395 }
396
397 closeSession(session);
398 }
399 }
400
401 return pluginSetting;
402 }
403
404 public List<PluginSetting> findByCompanyId(long companyId)
405 throws SystemException {
406 Object[] finderArgs = new Object[] { new Long(companyId) };
407
408 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_COMPANYID,
409 finderArgs, this);
410
411 if (list == null) {
412 Session session = null;
413
414 try {
415 session = openSession();
416
417 StringBuilder query = new StringBuilder();
418
419 query.append(
420 "FROM com.liferay.portal.model.PluginSetting WHERE ");
421
422 query.append("companyId = ?");
423
424 query.append(" ");
425
426 Query q = session.createQuery(query.toString());
427
428 QueryPos qPos = QueryPos.getInstance(q);
429
430 qPos.add(companyId);
431
432 list = q.list();
433 }
434 catch (Exception e) {
435 throw processException(e);
436 }
437 finally {
438 if (list == null) {
439 list = new ArrayList<PluginSetting>();
440 }
441
442 cacheResult(list);
443
444 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_COMPANYID,
445 finderArgs, list);
446
447 closeSession(session);
448 }
449 }
450
451 return list;
452 }
453
454 public List<PluginSetting> findByCompanyId(long companyId, int start,
455 int end) throws SystemException {
456 return findByCompanyId(companyId, start, end, null);
457 }
458
459 public List<PluginSetting> findByCompanyId(long companyId, int start,
460 int end, OrderByComparator obc) throws SystemException {
461 Object[] finderArgs = new Object[] {
462 new Long(companyId),
463
464 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
465 };
466
467 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
468 finderArgs, this);
469
470 if (list == null) {
471 Session session = null;
472
473 try {
474 session = openSession();
475
476 StringBuilder query = new StringBuilder();
477
478 query.append(
479 "FROM com.liferay.portal.model.PluginSetting WHERE ");
480
481 query.append("companyId = ?");
482
483 query.append(" ");
484
485 if (obc != null) {
486 query.append("ORDER BY ");
487 query.append(obc.getOrderBy());
488 }
489
490 Query q = session.createQuery(query.toString());
491
492 QueryPos qPos = QueryPos.getInstance(q);
493
494 qPos.add(companyId);
495
496 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
497 start, end);
498 }
499 catch (Exception e) {
500 throw processException(e);
501 }
502 finally {
503 if (list == null) {
504 list = new ArrayList<PluginSetting>();
505 }
506
507 cacheResult(list);
508
509 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_OBC_COMPANYID,
510 finderArgs, list);
511
512 closeSession(session);
513 }
514 }
515
516 return list;
517 }
518
519 public PluginSetting findByCompanyId_First(long companyId,
520 OrderByComparator obc)
521 throws NoSuchPluginSettingException, SystemException {
522 List<PluginSetting> list = findByCompanyId(companyId, 0, 1, obc);
523
524 if (list.isEmpty()) {
525 StringBuilder msg = new StringBuilder();
526
527 msg.append("No PluginSetting exists with the key {");
528
529 msg.append("companyId=" + companyId);
530
531 msg.append(StringPool.CLOSE_CURLY_BRACE);
532
533 throw new NoSuchPluginSettingException(msg.toString());
534 }
535 else {
536 return list.get(0);
537 }
538 }
539
540 public PluginSetting findByCompanyId_Last(long companyId,
541 OrderByComparator obc)
542 throws NoSuchPluginSettingException, SystemException {
543 int count = countByCompanyId(companyId);
544
545 List<PluginSetting> list = findByCompanyId(companyId, count - 1, count,
546 obc);
547
548 if (list.isEmpty()) {
549 StringBuilder msg = new StringBuilder();
550
551 msg.append("No PluginSetting exists with the key {");
552
553 msg.append("companyId=" + companyId);
554
555 msg.append(StringPool.CLOSE_CURLY_BRACE);
556
557 throw new NoSuchPluginSettingException(msg.toString());
558 }
559 else {
560 return list.get(0);
561 }
562 }
563
564 public PluginSetting[] findByCompanyId_PrevAndNext(long pluginSettingId,
565 long companyId, OrderByComparator obc)
566 throws NoSuchPluginSettingException, SystemException {
567 PluginSetting pluginSetting = findByPrimaryKey(pluginSettingId);
568
569 int count = countByCompanyId(companyId);
570
571 Session session = null;
572
573 try {
574 session = openSession();
575
576 StringBuilder query = new StringBuilder();
577
578 query.append("FROM com.liferay.portal.model.PluginSetting WHERE ");
579
580 query.append("companyId = ?");
581
582 query.append(" ");
583
584 if (obc != null) {
585 query.append("ORDER BY ");
586 query.append(obc.getOrderBy());
587 }
588
589 Query q = session.createQuery(query.toString());
590
591 QueryPos qPos = QueryPos.getInstance(q);
592
593 qPos.add(companyId);
594
595 Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
596 pluginSetting);
597
598 PluginSetting[] array = new PluginSettingImpl[3];
599
600 array[0] = (PluginSetting)objArray[0];
601 array[1] = (PluginSetting)objArray[1];
602 array[2] = (PluginSetting)objArray[2];
603
604 return array;
605 }
606 catch (Exception e) {
607 throw processException(e);
608 }
609 finally {
610 closeSession(session);
611 }
612 }
613
614 public PluginSetting findByC_I_T(long companyId, String pluginId,
615 String pluginType) throws NoSuchPluginSettingException, SystemException {
616 PluginSetting pluginSetting = fetchByC_I_T(companyId, pluginId,
617 pluginType);
618
619 if (pluginSetting == null) {
620 StringBuilder msg = new StringBuilder();
621
622 msg.append("No PluginSetting exists with the key {");
623
624 msg.append("companyId=" + companyId);
625
626 msg.append(", ");
627 msg.append("pluginId=" + pluginId);
628
629 msg.append(", ");
630 msg.append("pluginType=" + pluginType);
631
632 msg.append(StringPool.CLOSE_CURLY_BRACE);
633
634 if (_log.isWarnEnabled()) {
635 _log.warn(msg.toString());
636 }
637
638 throw new NoSuchPluginSettingException(msg.toString());
639 }
640
641 return pluginSetting;
642 }
643
644 public PluginSetting fetchByC_I_T(long companyId, String pluginId,
645 String pluginType) throws SystemException {
646 return fetchByC_I_T(companyId, pluginId, pluginType, true);
647 }
648
649 public PluginSetting fetchByC_I_T(long companyId, String pluginId,
650 String pluginType, boolean retrieveFromCache) throws SystemException {
651 Object[] finderArgs = new Object[] {
652 new Long(companyId),
653
654 pluginId,
655
656 pluginType
657 };
658
659 Object result = null;
660
661 if (retrieveFromCache) {
662 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_I_T,
663 finderArgs, this);
664 }
665
666 if (result == null) {
667 Session session = null;
668
669 try {
670 session = openSession();
671
672 StringBuilder query = new StringBuilder();
673
674 query.append(
675 "FROM com.liferay.portal.model.PluginSetting WHERE ");
676
677 query.append("companyId = ?");
678
679 query.append(" AND ");
680
681 if (pluginId == null) {
682 query.append("pluginId IS NULL");
683 }
684 else {
685 query.append("pluginId = ?");
686 }
687
688 query.append(" AND ");
689
690 if (pluginType == null) {
691 query.append("pluginType IS NULL");
692 }
693 else {
694 query.append("pluginType = ?");
695 }
696
697 query.append(" ");
698
699 Query q = session.createQuery(query.toString());
700
701 QueryPos qPos = QueryPos.getInstance(q);
702
703 qPos.add(companyId);
704
705 if (pluginId != null) {
706 qPos.add(pluginId);
707 }
708
709 if (pluginType != null) {
710 qPos.add(pluginType);
711 }
712
713 List<PluginSetting> list = q.list();
714
715 result = list;
716
717 PluginSetting pluginSetting = null;
718
719 if (list.isEmpty()) {
720 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
721 finderArgs, list);
722 }
723 else {
724 pluginSetting = list.get(0);
725
726 cacheResult(pluginSetting);
727
728 if ((pluginSetting.getCompanyId() != companyId) ||
729 (pluginSetting.getPluginId() == null) ||
730 !pluginSetting.getPluginId().equals(pluginId) ||
731 (pluginSetting.getPluginType() == null) ||
732 !pluginSetting.getPluginType().equals(pluginType)) {
733 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
734 finderArgs, pluginSetting);
735 }
736 }
737
738 return pluginSetting;
739 }
740 catch (Exception e) {
741 throw processException(e);
742 }
743 finally {
744 if (result == null) {
745 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_I_T,
746 finderArgs, new ArrayList<PluginSetting>());
747 }
748
749 closeSession(session);
750 }
751 }
752 else {
753 if (result instanceof List) {
754 return null;
755 }
756 else {
757 return (PluginSetting)result;
758 }
759 }
760 }
761
762 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
763 throws SystemException {
764 Session session = null;
765
766 try {
767 session = openSession();
768
769 dynamicQuery.compile(session);
770
771 return dynamicQuery.list();
772 }
773 catch (Exception e) {
774 throw processException(e);
775 }
776 finally {
777 closeSession(session);
778 }
779 }
780
781 public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
782 int start, int end) throws SystemException {
783 Session session = null;
784
785 try {
786 session = openSession();
787
788 dynamicQuery.setLimit(start, end);
789
790 dynamicQuery.compile(session);
791
792 return dynamicQuery.list();
793 }
794 catch (Exception e) {
795 throw processException(e);
796 }
797 finally {
798 closeSession(session);
799 }
800 }
801
802 public List<PluginSetting> findAll() throws SystemException {
803 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
804 }
805
806 public List<PluginSetting> findAll(int start, int end)
807 throws SystemException {
808 return findAll(start, end, null);
809 }
810
811 public List<PluginSetting> findAll(int start, int end, OrderByComparator obc)
812 throws SystemException {
813 Object[] finderArgs = new Object[] {
814 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
815 };
816
817 List<PluginSetting> list = (List<PluginSetting>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
818 finderArgs, this);
819
820 if (list == null) {
821 Session session = null;
822
823 try {
824 session = openSession();
825
826 StringBuilder query = new StringBuilder();
827
828 query.append("FROM com.liferay.portal.model.PluginSetting ");
829
830 if (obc != null) {
831 query.append("ORDER BY ");
832 query.append(obc.getOrderBy());
833 }
834
835 Query q = session.createQuery(query.toString());
836
837 if (obc == null) {
838 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
839 start, end, false);
840
841 Collections.sort(list);
842 }
843 else {
844 list = (List<PluginSetting>)QueryUtil.list(q, getDialect(),
845 start, end);
846 }
847 }
848 catch (Exception e) {
849 throw processException(e);
850 }
851 finally {
852 if (list == null) {
853 list = new ArrayList<PluginSetting>();
854 }
855
856 cacheResult(list);
857
858 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
859
860 closeSession(session);
861 }
862 }
863
864 return list;
865 }
866
867 public void removeByCompanyId(long companyId) throws SystemException {
868 for (PluginSetting pluginSetting : findByCompanyId(companyId)) {
869 remove(pluginSetting);
870 }
871 }
872
873 public void removeByC_I_T(long companyId, String pluginId, String pluginType)
874 throws NoSuchPluginSettingException, SystemException {
875 PluginSetting pluginSetting = findByC_I_T(companyId, pluginId,
876 pluginType);
877
878 remove(pluginSetting);
879 }
880
881 public void removeAll() throws SystemException {
882 for (PluginSetting pluginSetting : findAll()) {
883 remove(pluginSetting);
884 }
885 }
886
887 public int countByCompanyId(long companyId) throws SystemException {
888 Object[] finderArgs = new Object[] { new Long(companyId) };
889
890 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
891 finderArgs, this);
892
893 if (count == null) {
894 Session session = null;
895
896 try {
897 session = openSession();
898
899 StringBuilder query = new StringBuilder();
900
901 query.append("SELECT COUNT(*) ");
902 query.append(
903 "FROM com.liferay.portal.model.PluginSetting WHERE ");
904
905 query.append("companyId = ?");
906
907 query.append(" ");
908
909 Query q = session.createQuery(query.toString());
910
911 QueryPos qPos = QueryPos.getInstance(q);
912
913 qPos.add(companyId);
914
915 count = (Long)q.uniqueResult();
916 }
917 catch (Exception e) {
918 throw processException(e);
919 }
920 finally {
921 if (count == null) {
922 count = Long.valueOf(0);
923 }
924
925 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
926 finderArgs, count);
927
928 closeSession(session);
929 }
930 }
931
932 return count.intValue();
933 }
934
935 public int countByC_I_T(long companyId, String pluginId, String pluginType)
936 throws SystemException {
937 Object[] finderArgs = new Object[] {
938 new Long(companyId),
939
940 pluginId,
941
942 pluginType
943 };
944
945 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_I_T,
946 finderArgs, this);
947
948 if (count == null) {
949 Session session = null;
950
951 try {
952 session = openSession();
953
954 StringBuilder query = new StringBuilder();
955
956 query.append("SELECT COUNT(*) ");
957 query.append(
958 "FROM com.liferay.portal.model.PluginSetting WHERE ");
959
960 query.append("companyId = ?");
961
962 query.append(" AND ");
963
964 if (pluginId == null) {
965 query.append("pluginId IS NULL");
966 }
967 else {
968 query.append("pluginId = ?");
969 }
970
971 query.append(" AND ");
972
973 if (pluginType == null) {
974 query.append("pluginType IS NULL");
975 }
976 else {
977 query.append("pluginType = ?");
978 }
979
980 query.append(" ");
981
982 Query q = session.createQuery(query.toString());
983
984 QueryPos qPos = QueryPos.getInstance(q);
985
986 qPos.add(companyId);
987
988 if (pluginId != null) {
989 qPos.add(pluginId);
990 }
991
992 if (pluginType != null) {
993 qPos.add(pluginType);
994 }
995
996 count = (Long)q.uniqueResult();
997 }
998 catch (Exception e) {
999 throw processException(e);
1000 }
1001 finally {
1002 if (count == null) {
1003 count = Long.valueOf(0);
1004 }
1005
1006 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_I_T,
1007 finderArgs, count);
1008
1009 closeSession(session);
1010 }
1011 }
1012
1013 return count.intValue();
1014 }
1015
1016 public int countAll() throws SystemException {
1017 Object[] finderArgs = new Object[0];
1018
1019 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
1020 finderArgs, this);
1021
1022 if (count == null) {
1023 Session session = null;
1024
1025 try {
1026 session = openSession();
1027
1028 Query q = session.createQuery(
1029 "SELECT COUNT(*) FROM com.liferay.portal.model.PluginSetting");
1030
1031 count = (Long)q.uniqueResult();
1032 }
1033 catch (Exception e) {
1034 throw processException(e);
1035 }
1036 finally {
1037 if (count == null) {
1038 count = Long.valueOf(0);
1039 }
1040
1041 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
1042 count);
1043
1044 closeSession(session);
1045 }
1046 }
1047
1048 return count.intValue();
1049 }
1050
1051 public void afterPropertiesSet() {
1052 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1053 com.liferay.portal.util.PropsUtil.get(
1054 "value.object.listener.com.liferay.portal.model.PluginSetting")));
1055
1056 if (listenerClassNames.length > 0) {
1057 try {
1058 List<ModelListener<PluginSetting>> listenersList = new ArrayList<ModelListener<PluginSetting>>();
1059
1060 for (String listenerClassName : listenerClassNames) {
1061 listenersList.add((ModelListener<PluginSetting>)Class.forName(
1062 listenerClassName).newInstance());
1063 }
1064
1065 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
1066 }
1067 catch (Exception e) {
1068 _log.error(e);
1069 }
1070 }
1071 }
1072
1073 @BeanReference(name = "com.liferay.portal.service.persistence.AccountPersistence.impl")
1074 protected com.liferay.portal.service.persistence.AccountPersistence accountPersistence;
1075 @BeanReference(name = "com.liferay.portal.service.persistence.AddressPersistence.impl")
1076 protected com.liferay.portal.service.persistence.AddressPersistence addressPersistence;
1077 @BeanReference(name = "com.liferay.portal.service.persistence.BrowserTrackerPersistence.impl")
1078 protected com.liferay.portal.service.persistence.BrowserTrackerPersistence browserTrackerPersistence;
1079 @BeanReference(name = "com.liferay.portal.service.persistence.ClassNamePersistence.impl")
1080 protected com.liferay.portal.service.persistence.ClassNamePersistence classNamePersistence;
1081 @BeanReference(name = "com.liferay.portal.service.persistence.CompanyPersistence.impl")
1082 protected com.liferay.portal.service.persistence.CompanyPersistence companyPersistence;
1083 @BeanReference(name = "com.liferay.portal.service.persistence.ContactPersistence.impl")
1084 protected com.liferay.portal.service.persistence.ContactPersistence contactPersistence;
1085 @BeanReference(name = "com.liferay.portal.service.persistence.CountryPersistence.impl")
1086 protected com.liferay.portal.service.persistence.CountryPersistence countryPersistence;
1087 @BeanReference(name = "com.liferay.portal.service.persistence.EmailAddressPersistence.impl")
1088 protected com.liferay.portal.service.persistence.EmailAddressPersistence emailAddressPersistence;
1089 @BeanReference(name = "com.liferay.portal.service.persistence.GroupPersistence.impl")
1090 protected com.liferay.portal.service.persistence.GroupPersistence groupPersistence;
1091 @BeanReference(name = "com.liferay.portal.service.persistence.ImagePersistence.impl")
1092 protected com.liferay.portal.service.persistence.ImagePersistence imagePersistence;
1093 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutPersistence.impl")
1094 protected com.liferay.portal.service.persistence.LayoutPersistence layoutPersistence;
1095 @BeanReference(name = "com.liferay.portal.service.persistence.LayoutSetPersistence.impl")
1096 protected com.liferay.portal.service.persistence.LayoutSetPersistence layoutSetPersistence;
1097 @BeanReference(name = "com.liferay.portal.service.persistence.ListTypePersistence.impl")
1098 protected com.liferay.portal.service.persistence.ListTypePersistence listTypePersistence;
1099 @BeanReference(name = "com.liferay.portal.service.persistence.MembershipRequestPersistence.impl")
1100 protected com.liferay.portal.service.persistence.MembershipRequestPersistence membershipRequestPersistence;
1101 @BeanReference(name = "com.liferay.portal.service.persistence.OrganizationPersistence.impl")
1102 protected com.liferay.portal.service.persistence.OrganizationPersistence organizationPersistence;
1103 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupPermissionPersistence.impl")
1104 protected com.liferay.portal.service.persistence.OrgGroupPermissionPersistence orgGroupPermissionPersistence;
1105 @BeanReference(name = "com.liferay.portal.service.persistence.OrgGroupRolePersistence.impl")
1106 protected com.liferay.portal.service.persistence.OrgGroupRolePersistence orgGroupRolePersistence;
1107 @BeanReference(name = "com.liferay.portal.service.persistence.OrgLaborPersistence.impl")
1108 protected com.liferay.portal.service.persistence.OrgLaborPersistence orgLaborPersistence;
1109 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyPersistence.impl")
1110 protected com.liferay.portal.service.persistence.PasswordPolicyPersistence passwordPolicyPersistence;
1111 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordPolicyRelPersistence.impl")
1112 protected com.liferay.portal.service.persistence.PasswordPolicyRelPersistence passwordPolicyRelPersistence;
1113 @BeanReference(name = "com.liferay.portal.service.persistence.PasswordTrackerPersistence.impl")
1114 protected com.liferay.portal.service.persistence.PasswordTrackerPersistence passwordTrackerPersistence;
1115 @BeanReference(name = "com.liferay.portal.service.persistence.PermissionPersistence.impl")
1116 protected com.liferay.portal.service.persistence.PermissionPersistence permissionPersistence;
1117 @BeanReference(name = "com.liferay.portal.service.persistence.PhonePersistence.impl")
1118 protected com.liferay.portal.service.persistence.PhonePersistence phonePersistence;
1119 @BeanReference(name = "com.liferay.portal.service.persistence.PluginSettingPersistence.impl")
1120 protected com.liferay.portal.service.persistence.PluginSettingPersistence pluginSettingPersistence;
1121 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPersistence.impl")
1122 protected com.liferay.portal.service.persistence.PortletPersistence portletPersistence;
1123 @BeanReference(name = "com.liferay.portal.service.persistence.PortletItemPersistence.impl")
1124 protected com.liferay.portal.service.persistence.PortletItemPersistence portletItemPersistence;
1125 @BeanReference(name = "com.liferay.portal.service.persistence.PortletPreferencesPersistence.impl")
1126 protected com.liferay.portal.service.persistence.PortletPreferencesPersistence portletPreferencesPersistence;
1127 @BeanReference(name = "com.liferay.portal.service.persistence.RegionPersistence.impl")
1128 protected com.liferay.portal.service.persistence.RegionPersistence regionPersistence;
1129 @BeanReference(name = "com.liferay.portal.service.persistence.ReleasePersistence.impl")
1130 protected com.liferay.portal.service.persistence.ReleasePersistence releasePersistence;
1131 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePersistence.impl")
1132 protected com.liferay.portal.service.persistence.ResourcePersistence resourcePersistence;
1133 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceActionPersistence.impl")
1134 protected com.liferay.portal.service.persistence.ResourceActionPersistence resourceActionPersistence;
1135 @BeanReference(name = "com.liferay.portal.service.persistence.ResourceCodePersistence.impl")
1136 protected com.liferay.portal.service.persistence.ResourceCodePersistence resourceCodePersistence;
1137 @BeanReference(name = "com.liferay.portal.service.persistence.ResourcePermissionPersistence.impl")
1138 protected com.liferay.portal.service.persistence.ResourcePermissionPersistence resourcePermissionPersistence;
1139 @BeanReference(name = "com.liferay.portal.service.persistence.RolePersistence.impl")
1140 protected com.liferay.portal.service.persistence.RolePersistence rolePersistence;
1141 @BeanReference(name = "com.liferay.portal.service.persistence.ServiceComponentPersistence.impl")
1142 protected com.liferay.portal.service.persistence.ServiceComponentPersistence serviceComponentPersistence;
1143 @BeanReference(name = "com.liferay.portal.service.persistence.ShardPersistence.impl")
1144 protected com.liferay.portal.service.persistence.ShardPersistence shardPersistence;
1145 @BeanReference(name = "com.liferay.portal.service.persistence.SubscriptionPersistence.impl")
1146 protected com.liferay.portal.service.persistence.SubscriptionPersistence subscriptionPersistence;
1147 @BeanReference(name = "com.liferay.portal.service.persistence.UserPersistence.impl")
1148 protected com.liferay.portal.service.persistence.UserPersistence userPersistence;
1149 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupPersistence.impl")
1150 protected com.liferay.portal.service.persistence.UserGroupPersistence userGroupPersistence;
1151 @BeanReference(name = "com.liferay.portal.service.persistence.UserGroupRolePersistence.impl")
1152 protected com.liferay.portal.service.persistence.UserGroupRolePersistence userGroupRolePersistence;
1153 @BeanReference(name = "com.liferay.portal.service.persistence.UserIdMapperPersistence.impl")
1154 protected com.liferay.portal.service.persistence.UserIdMapperPersistence userIdMapperPersistence;
1155 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPersistence.impl")
1156 protected com.liferay.portal.service.persistence.UserTrackerPersistence userTrackerPersistence;
1157 @BeanReference(name = "com.liferay.portal.service.persistence.UserTrackerPathPersistence.impl")
1158 protected com.liferay.portal.service.persistence.UserTrackerPathPersistence userTrackerPathPersistence;
1159 @BeanReference(name = "com.liferay.portal.service.persistence.WebDAVPropsPersistence.impl")
1160 protected com.liferay.portal.service.persistence.WebDAVPropsPersistence webDAVPropsPersistence;
1161 @BeanReference(name = "com.liferay.portal.service.persistence.WebsitePersistence.impl")
1162 protected com.liferay.portal.service.persistence.WebsitePersistence websitePersistence;
1163 private static Log _log = LogFactoryUtil.getLog(PluginSettingPersistenceImpl.class);
1164}