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