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