001
014
015 package com.liferay.portlet.journal.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.annotation.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022 import com.liferay.portal.kernel.dao.orm.FinderPath;
023 import com.liferay.portal.kernel.dao.orm.Query;
024 import com.liferay.portal.kernel.dao.orm.QueryPos;
025 import com.liferay.portal.kernel.dao.orm.QueryUtil;
026 import com.liferay.portal.kernel.dao.orm.SQLQuery;
027 import com.liferay.portal.kernel.dao.orm.Session;
028 import com.liferay.portal.kernel.exception.SystemException;
029 import com.liferay.portal.kernel.log.Log;
030 import com.liferay.portal.kernel.log.LogFactoryUtil;
031 import com.liferay.portal.kernel.util.GetterUtil;
032 import com.liferay.portal.kernel.util.InstanceFactory;
033 import com.liferay.portal.kernel.util.OrderByComparator;
034 import com.liferay.portal.kernel.util.StringBundler;
035 import com.liferay.portal.kernel.util.StringPool;
036 import com.liferay.portal.kernel.util.StringUtil;
037 import com.liferay.portal.kernel.util.Validator;
038 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
039 import com.liferay.portal.model.ModelListener;
040 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
041 import com.liferay.portal.service.persistence.BatchSessionUtil;
042 import com.liferay.portal.service.persistence.ResourcePersistence;
043 import com.liferay.portal.service.persistence.UserPersistence;
044 import com.liferay.portal.service.persistence.WebDAVPropsPersistence;
045 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
046
047 import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
048 import com.liferay.portlet.journal.NoSuchStructureException;
049 import com.liferay.portlet.journal.model.JournalStructure;
050 import com.liferay.portlet.journal.model.impl.JournalStructureImpl;
051 import com.liferay.portlet.journal.model.impl.JournalStructureModelImpl;
052
053 import java.io.Serializable;
054
055 import java.util.ArrayList;
056 import java.util.Collections;
057 import java.util.List;
058
059
075 public class JournalStructurePersistenceImpl extends BasePersistenceImpl<JournalStructure>
076 implements JournalStructurePersistence {
077 public static final String FINDER_CLASS_NAME_ENTITY = JournalStructureImpl.class.getName();
078 public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
079 ".List";
080 public static final FinderPath FINDER_PATH_FIND_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
081 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
082 FINDER_CLASS_NAME_LIST, "findByUuid",
083 new String[] {
084 String.class.getName(),
085
086 "java.lang.Integer", "java.lang.Integer",
087 "com.liferay.portal.kernel.util.OrderByComparator"
088 });
089 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
090 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
091 FINDER_CLASS_NAME_LIST, "countByUuid",
092 new String[] { String.class.getName() });
093 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
094 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
095 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
096 new String[] { String.class.getName(), Long.class.getName() });
097 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
098 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
099 FINDER_CLASS_NAME_LIST, "countByUUID_G",
100 new String[] { String.class.getName(), Long.class.getName() });
101 public static final FinderPath FINDER_PATH_FIND_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
102 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
103 FINDER_CLASS_NAME_LIST, "findByGroupId",
104 new String[] {
105 Long.class.getName(),
106
107 "java.lang.Integer", "java.lang.Integer",
108 "com.liferay.portal.kernel.util.OrderByComparator"
109 });
110 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
111 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
112 FINDER_CLASS_NAME_LIST, "countByGroupId",
113 new String[] { Long.class.getName() });
114 public static final FinderPath FINDER_PATH_FIND_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
115 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
116 FINDER_CLASS_NAME_LIST, "findByStructureId",
117 new String[] {
118 String.class.getName(),
119
120 "java.lang.Integer", "java.lang.Integer",
121 "com.liferay.portal.kernel.util.OrderByComparator"
122 });
123 public static final FinderPath FINDER_PATH_COUNT_BY_STRUCTUREID = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
124 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
125 FINDER_CLASS_NAME_LIST, "countByStructureId",
126 new String[] { String.class.getName() });
127 public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
128 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
129 FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
130 new String[] { Long.class.getName(), String.class.getName() });
131 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
132 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
133 FINDER_CLASS_NAME_LIST, "countByG_S",
134 new String[] { Long.class.getName(), String.class.getName() });
135 public static final FinderPath FINDER_PATH_FIND_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
136 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
137 FINDER_CLASS_NAME_LIST, "findByG_P",
138 new String[] {
139 Long.class.getName(), String.class.getName(),
140
141 "java.lang.Integer", "java.lang.Integer",
142 "com.liferay.portal.kernel.util.OrderByComparator"
143 });
144 public static final FinderPath FINDER_PATH_COUNT_BY_G_P = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
145 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
146 FINDER_CLASS_NAME_LIST, "countByG_P",
147 new String[] { Long.class.getName(), String.class.getName() });
148 public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
149 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
150 FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
151 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
152 JournalStructureModelImpl.FINDER_CACHE_ENABLED,
153 FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
154
155
160 public void cacheResult(JournalStructure journalStructure) {
161 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
162 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
163 journalStructure);
164
165 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
166 new Object[] {
167 journalStructure.getUuid(),
168 new Long(journalStructure.getGroupId())
169 }, journalStructure);
170
171 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
172 new Object[] {
173 new Long(journalStructure.getGroupId()),
174
175 journalStructure.getStructureId()
176 }, journalStructure);
177 }
178
179
184 public void cacheResult(List<JournalStructure> journalStructures) {
185 for (JournalStructure journalStructure : journalStructures) {
186 if (EntityCacheUtil.getResult(
187 JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
188 JournalStructureImpl.class,
189 journalStructure.getPrimaryKey(), this) == null) {
190 cacheResult(journalStructure);
191 }
192 }
193 }
194
195
202 public void clearCache() {
203 CacheRegistryUtil.clear(JournalStructureImpl.class.getName());
204 EntityCacheUtil.clearCache(JournalStructureImpl.class.getName());
205 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
206 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
207 }
208
209
216 public void clearCache(JournalStructure journalStructure) {
217 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
218 JournalStructureImpl.class, journalStructure.getPrimaryKey());
219
220 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
221 new Object[] {
222 journalStructure.getUuid(),
223 new Long(journalStructure.getGroupId())
224 });
225
226 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
227 new Object[] {
228 new Long(journalStructure.getGroupId()),
229
230 journalStructure.getStructureId()
231 });
232 }
233
234
240 public JournalStructure create(long id) {
241 JournalStructure journalStructure = new JournalStructureImpl();
242
243 journalStructure.setNew(true);
244 journalStructure.setPrimaryKey(id);
245
246 String uuid = PortalUUIDUtil.generate();
247
248 journalStructure.setUuid(uuid);
249
250 return journalStructure;
251 }
252
253
261 public JournalStructure remove(Serializable primaryKey)
262 throws NoSuchModelException, SystemException {
263 return remove(((Long)primaryKey).longValue());
264 }
265
266
274 public JournalStructure remove(long id)
275 throws NoSuchStructureException, SystemException {
276 Session session = null;
277
278 try {
279 session = openSession();
280
281 JournalStructure journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
282 new Long(id));
283
284 if (journalStructure == null) {
285 if (_log.isWarnEnabled()) {
286 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
287 }
288
289 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
290 id);
291 }
292
293 return remove(journalStructure);
294 }
295 catch (NoSuchStructureException nsee) {
296 throw nsee;
297 }
298 catch (Exception e) {
299 throw processException(e);
300 }
301 finally {
302 closeSession(session);
303 }
304 }
305
306 protected JournalStructure removeImpl(JournalStructure journalStructure)
307 throws SystemException {
308 journalStructure = toUnwrappedModel(journalStructure);
309
310 Session session = null;
311
312 try {
313 session = openSession();
314
315 if (journalStructure.isCachedModel() ||
316 BatchSessionUtil.isEnabled()) {
317 Object staleObject = session.get(JournalStructureImpl.class,
318 journalStructure.getPrimaryKeyObj());
319
320 if (staleObject != null) {
321 session.evict(staleObject);
322 }
323 }
324
325 session.delete(journalStructure);
326
327 session.flush();
328 }
329 catch (Exception e) {
330 throw processException(e);
331 }
332 finally {
333 closeSession(session);
334 }
335
336 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
337
338 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
339
340 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
341 new Object[] {
342 journalStructureModelImpl.getOriginalUuid(),
343 new Long(journalStructureModelImpl.getOriginalGroupId())
344 });
345
346 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
347 new Object[] {
348 new Long(journalStructureModelImpl.getOriginalGroupId()),
349
350 journalStructureModelImpl.getOriginalStructureId()
351 });
352
353 EntityCacheUtil.removeResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
354 JournalStructureImpl.class, journalStructure.getPrimaryKey());
355
356 return journalStructure;
357 }
358
359 public JournalStructure updateImpl(
360 com.liferay.portlet.journal.model.JournalStructure journalStructure,
361 boolean merge) throws SystemException {
362 journalStructure = toUnwrappedModel(journalStructure);
363
364 boolean isNew = journalStructure.isNew();
365
366 JournalStructureModelImpl journalStructureModelImpl = (JournalStructureModelImpl)journalStructure;
367
368 if (Validator.isNull(journalStructure.getUuid())) {
369 String uuid = PortalUUIDUtil.generate();
370
371 journalStructure.setUuid(uuid);
372 }
373
374 Session session = null;
375
376 try {
377 session = openSession();
378
379 BatchSessionUtil.update(session, journalStructure, merge);
380
381 journalStructure.setNew(false);
382 }
383 catch (Exception e) {
384 throw processException(e);
385 }
386 finally {
387 closeSession(session);
388 }
389
390 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
391
392 EntityCacheUtil.putResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
393 JournalStructureImpl.class, journalStructure.getPrimaryKey(),
394 journalStructure);
395
396 if (!isNew &&
397 (!Validator.equals(journalStructure.getUuid(),
398 journalStructureModelImpl.getOriginalUuid()) ||
399 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
400 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
401 new Object[] {
402 journalStructureModelImpl.getOriginalUuid(),
403 new Long(journalStructureModelImpl.getOriginalGroupId())
404 });
405 }
406
407 if (isNew ||
408 (!Validator.equals(journalStructure.getUuid(),
409 journalStructureModelImpl.getOriginalUuid()) ||
410 (journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()))) {
411 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
412 new Object[] {
413 journalStructure.getUuid(),
414 new Long(journalStructure.getGroupId())
415 }, journalStructure);
416 }
417
418 if (!isNew &&
419 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
420 !Validator.equals(journalStructure.getStructureId(),
421 journalStructureModelImpl.getOriginalStructureId()))) {
422 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
423 new Object[] {
424 new Long(journalStructureModelImpl.getOriginalGroupId()),
425
426 journalStructureModelImpl.getOriginalStructureId()
427 });
428 }
429
430 if (isNew ||
431 ((journalStructure.getGroupId() != journalStructureModelImpl.getOriginalGroupId()) ||
432 !Validator.equals(journalStructure.getStructureId(),
433 journalStructureModelImpl.getOriginalStructureId()))) {
434 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
435 new Object[] {
436 new Long(journalStructure.getGroupId()),
437
438 journalStructure.getStructureId()
439 }, journalStructure);
440 }
441
442 return journalStructure;
443 }
444
445 protected JournalStructure toUnwrappedModel(
446 JournalStructure journalStructure) {
447 if (journalStructure instanceof JournalStructureImpl) {
448 return journalStructure;
449 }
450
451 JournalStructureImpl journalStructureImpl = new JournalStructureImpl();
452
453 journalStructureImpl.setNew(journalStructure.isNew());
454 journalStructureImpl.setPrimaryKey(journalStructure.getPrimaryKey());
455
456 journalStructureImpl.setUuid(journalStructure.getUuid());
457 journalStructureImpl.setId(journalStructure.getId());
458 journalStructureImpl.setGroupId(journalStructure.getGroupId());
459 journalStructureImpl.setCompanyId(journalStructure.getCompanyId());
460 journalStructureImpl.setUserId(journalStructure.getUserId());
461 journalStructureImpl.setUserName(journalStructure.getUserName());
462 journalStructureImpl.setCreateDate(journalStructure.getCreateDate());
463 journalStructureImpl.setModifiedDate(journalStructure.getModifiedDate());
464 journalStructureImpl.setStructureId(journalStructure.getStructureId());
465 journalStructureImpl.setParentStructureId(journalStructure.getParentStructureId());
466 journalStructureImpl.setName(journalStructure.getName());
467 journalStructureImpl.setDescription(journalStructure.getDescription());
468 journalStructureImpl.setXsd(journalStructure.getXsd());
469
470 return journalStructureImpl;
471 }
472
473
481 public JournalStructure findByPrimaryKey(Serializable primaryKey)
482 throws NoSuchModelException, SystemException {
483 return findByPrimaryKey(((Long)primaryKey).longValue());
484 }
485
486
494 public JournalStructure findByPrimaryKey(long id)
495 throws NoSuchStructureException, SystemException {
496 JournalStructure journalStructure = fetchByPrimaryKey(id);
497
498 if (journalStructure == null) {
499 if (_log.isWarnEnabled()) {
500 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + id);
501 }
502
503 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
504 id);
505 }
506
507 return journalStructure;
508 }
509
510
517 public JournalStructure fetchByPrimaryKey(Serializable primaryKey)
518 throws SystemException {
519 return fetchByPrimaryKey(((Long)primaryKey).longValue());
520 }
521
522
529 public JournalStructure fetchByPrimaryKey(long id)
530 throws SystemException {
531 JournalStructure journalStructure = (JournalStructure)EntityCacheUtil.getResult(JournalStructureModelImpl.ENTITY_CACHE_ENABLED,
532 JournalStructureImpl.class, id, this);
533
534 if (journalStructure == null) {
535 Session session = null;
536
537 try {
538 session = openSession();
539
540 journalStructure = (JournalStructure)session.get(JournalStructureImpl.class,
541 new Long(id));
542 }
543 catch (Exception e) {
544 throw processException(e);
545 }
546 finally {
547 if (journalStructure != null) {
548 cacheResult(journalStructure);
549 }
550
551 closeSession(session);
552 }
553 }
554
555 return journalStructure;
556 }
557
558
565 public List<JournalStructure> findByUuid(String uuid)
566 throws SystemException {
567 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
568 }
569
570
583 public List<JournalStructure> findByUuid(String uuid, int start, int end)
584 throws SystemException {
585 return findByUuid(uuid, start, end, null);
586 }
587
588
602 public List<JournalStructure> findByUuid(String uuid, int start, int end,
603 OrderByComparator orderByComparator) throws SystemException {
604 Object[] finderArgs = new Object[] {
605 uuid,
606
607 String.valueOf(start), String.valueOf(end),
608 String.valueOf(orderByComparator)
609 };
610
611 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_UUID,
612 finderArgs, this);
613
614 if (list == null) {
615 Session session = null;
616
617 try {
618 session = openSession();
619
620 StringBundler query = null;
621
622 if (orderByComparator != null) {
623 query = new StringBundler(3 +
624 (orderByComparator.getOrderByFields().length * 3));
625 }
626 else {
627 query = new StringBundler(3);
628 }
629
630 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
631
632 if (uuid == null) {
633 query.append(_FINDER_COLUMN_UUID_UUID_1);
634 }
635 else {
636 if (uuid.equals(StringPool.BLANK)) {
637 query.append(_FINDER_COLUMN_UUID_UUID_3);
638 }
639 else {
640 query.append(_FINDER_COLUMN_UUID_UUID_2);
641 }
642 }
643
644 if (orderByComparator != null) {
645 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
646 orderByComparator);
647 }
648
649 else {
650 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
651 }
652
653 String sql = query.toString();
654
655 Query q = session.createQuery(sql);
656
657 QueryPos qPos = QueryPos.getInstance(q);
658
659 if (uuid != null) {
660 qPos.add(uuid);
661 }
662
663 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
664 start, end);
665 }
666 catch (Exception e) {
667 throw processException(e);
668 }
669 finally {
670 if (list == null) {
671 list = new ArrayList<JournalStructure>();
672 }
673
674 cacheResult(list);
675
676 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_UUID, finderArgs,
677 list);
678
679 closeSession(session);
680 }
681 }
682
683 return list;
684 }
685
686
699 public JournalStructure findByUuid_First(String uuid,
700 OrderByComparator orderByComparator)
701 throws NoSuchStructureException, SystemException {
702 List<JournalStructure> list = findByUuid(uuid, 0, 1, orderByComparator);
703
704 if (list.isEmpty()) {
705 StringBundler msg = new StringBundler(4);
706
707 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
708
709 msg.append("uuid=");
710 msg.append(uuid);
711
712 msg.append(StringPool.CLOSE_CURLY_BRACE);
713
714 throw new NoSuchStructureException(msg.toString());
715 }
716 else {
717 return list.get(0);
718 }
719 }
720
721
734 public JournalStructure findByUuid_Last(String uuid,
735 OrderByComparator orderByComparator)
736 throws NoSuchStructureException, SystemException {
737 int count = countByUuid(uuid);
738
739 List<JournalStructure> list = findByUuid(uuid, count - 1, count,
740 orderByComparator);
741
742 if (list.isEmpty()) {
743 StringBundler msg = new StringBundler(4);
744
745 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
746
747 msg.append("uuid=");
748 msg.append(uuid);
749
750 msg.append(StringPool.CLOSE_CURLY_BRACE);
751
752 throw new NoSuchStructureException(msg.toString());
753 }
754 else {
755 return list.get(0);
756 }
757 }
758
759
773 public JournalStructure[] findByUuid_PrevAndNext(long id, String uuid,
774 OrderByComparator orderByComparator)
775 throws NoSuchStructureException, SystemException {
776 JournalStructure journalStructure = findByPrimaryKey(id);
777
778 Session session = null;
779
780 try {
781 session = openSession();
782
783 JournalStructure[] array = new JournalStructureImpl[3];
784
785 array[0] = getByUuid_PrevAndNext(session, journalStructure, uuid,
786 orderByComparator, true);
787
788 array[1] = journalStructure;
789
790 array[2] = getByUuid_PrevAndNext(session, journalStructure, uuid,
791 orderByComparator, false);
792
793 return array;
794 }
795 catch (Exception e) {
796 throw processException(e);
797 }
798 finally {
799 closeSession(session);
800 }
801 }
802
803 protected JournalStructure getByUuid_PrevAndNext(Session session,
804 JournalStructure journalStructure, String uuid,
805 OrderByComparator orderByComparator, boolean previous) {
806 StringBundler query = null;
807
808 if (orderByComparator != null) {
809 query = new StringBundler(6 +
810 (orderByComparator.getOrderByFields().length * 6));
811 }
812 else {
813 query = new StringBundler(3);
814 }
815
816 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
817
818 if (uuid == null) {
819 query.append(_FINDER_COLUMN_UUID_UUID_1);
820 }
821 else {
822 if (uuid.equals(StringPool.BLANK)) {
823 query.append(_FINDER_COLUMN_UUID_UUID_3);
824 }
825 else {
826 query.append(_FINDER_COLUMN_UUID_UUID_2);
827 }
828 }
829
830 if (orderByComparator != null) {
831 String[] orderByFields = orderByComparator.getOrderByFields();
832
833 if (orderByFields.length > 0) {
834 query.append(WHERE_AND);
835 }
836
837 for (int i = 0; i < orderByFields.length; i++) {
838 query.append(_ORDER_BY_ENTITY_ALIAS);
839 query.append(orderByFields[i]);
840
841 if ((i + 1) < orderByFields.length) {
842 if (orderByComparator.isAscending() ^ previous) {
843 query.append(WHERE_GREATER_THAN_HAS_NEXT);
844 }
845 else {
846 query.append(WHERE_LESSER_THAN_HAS_NEXT);
847 }
848 }
849 else {
850 if (orderByComparator.isAscending() ^ previous) {
851 query.append(WHERE_GREATER_THAN);
852 }
853 else {
854 query.append(WHERE_LESSER_THAN);
855 }
856 }
857 }
858
859 query.append(ORDER_BY_CLAUSE);
860
861 for (int i = 0; i < orderByFields.length; i++) {
862 query.append(_ORDER_BY_ENTITY_ALIAS);
863 query.append(orderByFields[i]);
864
865 if ((i + 1) < orderByFields.length) {
866 if (orderByComparator.isAscending() ^ previous) {
867 query.append(ORDER_BY_ASC_HAS_NEXT);
868 }
869 else {
870 query.append(ORDER_BY_DESC_HAS_NEXT);
871 }
872 }
873 else {
874 if (orderByComparator.isAscending() ^ previous) {
875 query.append(ORDER_BY_ASC);
876 }
877 else {
878 query.append(ORDER_BY_DESC);
879 }
880 }
881 }
882 }
883
884 else {
885 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
886 }
887
888 String sql = query.toString();
889
890 Query q = session.createQuery(sql);
891
892 q.setFirstResult(0);
893 q.setMaxResults(2);
894
895 QueryPos qPos = QueryPos.getInstance(q);
896
897 if (uuid != null) {
898 qPos.add(uuid);
899 }
900
901 if (orderByComparator != null) {
902 Object[] values = orderByComparator.getOrderByValues(journalStructure);
903
904 for (Object value : values) {
905 qPos.add(value);
906 }
907 }
908
909 List<JournalStructure> list = q.list();
910
911 if (list.size() == 2) {
912 return list.get(1);
913 }
914 else {
915 return null;
916 }
917 }
918
919
928 public JournalStructure findByUUID_G(String uuid, long groupId)
929 throws NoSuchStructureException, SystemException {
930 JournalStructure journalStructure = fetchByUUID_G(uuid, groupId);
931
932 if (journalStructure == null) {
933 StringBundler msg = new StringBundler(6);
934
935 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
936
937 msg.append("uuid=");
938 msg.append(uuid);
939
940 msg.append(", groupId=");
941 msg.append(groupId);
942
943 msg.append(StringPool.CLOSE_CURLY_BRACE);
944
945 if (_log.isWarnEnabled()) {
946 _log.warn(msg.toString());
947 }
948
949 throw new NoSuchStructureException(msg.toString());
950 }
951
952 return journalStructure;
953 }
954
955
963 public JournalStructure fetchByUUID_G(String uuid, long groupId)
964 throws SystemException {
965 return fetchByUUID_G(uuid, groupId, true);
966 }
967
968
976 public JournalStructure fetchByUUID_G(String uuid, long groupId,
977 boolean retrieveFromCache) throws SystemException {
978 Object[] finderArgs = new Object[] { uuid, groupId };
979
980 Object result = null;
981
982 if (retrieveFromCache) {
983 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
984 finderArgs, this);
985 }
986
987 if (result == null) {
988 Session session = null;
989
990 try {
991 session = openSession();
992
993 StringBundler query = new StringBundler(4);
994
995 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
996
997 if (uuid == null) {
998 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
999 }
1000 else {
1001 if (uuid.equals(StringPool.BLANK)) {
1002 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1003 }
1004 else {
1005 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1006 }
1007 }
1008
1009 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1010
1011 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1012
1013 String sql = query.toString();
1014
1015 Query q = session.createQuery(sql);
1016
1017 QueryPos qPos = QueryPos.getInstance(q);
1018
1019 if (uuid != null) {
1020 qPos.add(uuid);
1021 }
1022
1023 qPos.add(groupId);
1024
1025 List<JournalStructure> list = q.list();
1026
1027 result = list;
1028
1029 JournalStructure journalStructure = null;
1030
1031 if (list.isEmpty()) {
1032 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1033 finderArgs, list);
1034 }
1035 else {
1036 journalStructure = list.get(0);
1037
1038 cacheResult(journalStructure);
1039
1040 if ((journalStructure.getUuid() == null) ||
1041 !journalStructure.getUuid().equals(uuid) ||
1042 (journalStructure.getGroupId() != groupId)) {
1043 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1044 finderArgs, journalStructure);
1045 }
1046 }
1047
1048 return journalStructure;
1049 }
1050 catch (Exception e) {
1051 throw processException(e);
1052 }
1053 finally {
1054 if (result == null) {
1055 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1056 finderArgs, new ArrayList<JournalStructure>());
1057 }
1058
1059 closeSession(session);
1060 }
1061 }
1062 else {
1063 if (result instanceof List<?>) {
1064 return null;
1065 }
1066 else {
1067 return (JournalStructure)result;
1068 }
1069 }
1070 }
1071
1072
1079 public List<JournalStructure> findByGroupId(long groupId)
1080 throws SystemException {
1081 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1082 }
1083
1084
1097 public List<JournalStructure> findByGroupId(long groupId, int start, int end)
1098 throws SystemException {
1099 return findByGroupId(groupId, start, end, null);
1100 }
1101
1102
1116 public List<JournalStructure> findByGroupId(long groupId, int start,
1117 int end, OrderByComparator orderByComparator) throws SystemException {
1118 Object[] finderArgs = new Object[] {
1119 groupId,
1120
1121 String.valueOf(start), String.valueOf(end),
1122 String.valueOf(orderByComparator)
1123 };
1124
1125 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_GROUPID,
1126 finderArgs, this);
1127
1128 if (list == null) {
1129 Session session = null;
1130
1131 try {
1132 session = openSession();
1133
1134 StringBundler query = null;
1135
1136 if (orderByComparator != null) {
1137 query = new StringBundler(3 +
1138 (orderByComparator.getOrderByFields().length * 3));
1139 }
1140 else {
1141 query = new StringBundler(3);
1142 }
1143
1144 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1145
1146 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1147
1148 if (orderByComparator != null) {
1149 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1150 orderByComparator);
1151 }
1152
1153 else {
1154 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1155 }
1156
1157 String sql = query.toString();
1158
1159 Query q = session.createQuery(sql);
1160
1161 QueryPos qPos = QueryPos.getInstance(q);
1162
1163 qPos.add(groupId);
1164
1165 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1166 start, end);
1167 }
1168 catch (Exception e) {
1169 throw processException(e);
1170 }
1171 finally {
1172 if (list == null) {
1173 list = new ArrayList<JournalStructure>();
1174 }
1175
1176 cacheResult(list);
1177
1178 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_GROUPID,
1179 finderArgs, list);
1180
1181 closeSession(session);
1182 }
1183 }
1184
1185 return list;
1186 }
1187
1188
1201 public JournalStructure findByGroupId_First(long groupId,
1202 OrderByComparator orderByComparator)
1203 throws NoSuchStructureException, SystemException {
1204 List<JournalStructure> list = findByGroupId(groupId, 0, 1,
1205 orderByComparator);
1206
1207 if (list.isEmpty()) {
1208 StringBundler msg = new StringBundler(4);
1209
1210 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1211
1212 msg.append("groupId=");
1213 msg.append(groupId);
1214
1215 msg.append(StringPool.CLOSE_CURLY_BRACE);
1216
1217 throw new NoSuchStructureException(msg.toString());
1218 }
1219 else {
1220 return list.get(0);
1221 }
1222 }
1223
1224
1237 public JournalStructure findByGroupId_Last(long groupId,
1238 OrderByComparator orderByComparator)
1239 throws NoSuchStructureException, SystemException {
1240 int count = countByGroupId(groupId);
1241
1242 List<JournalStructure> list = findByGroupId(groupId, count - 1, count,
1243 orderByComparator);
1244
1245 if (list.isEmpty()) {
1246 StringBundler msg = new StringBundler(4);
1247
1248 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1249
1250 msg.append("groupId=");
1251 msg.append(groupId);
1252
1253 msg.append(StringPool.CLOSE_CURLY_BRACE);
1254
1255 throw new NoSuchStructureException(msg.toString());
1256 }
1257 else {
1258 return list.get(0);
1259 }
1260 }
1261
1262
1276 public JournalStructure[] findByGroupId_PrevAndNext(long id, long groupId,
1277 OrderByComparator orderByComparator)
1278 throws NoSuchStructureException, SystemException {
1279 JournalStructure journalStructure = findByPrimaryKey(id);
1280
1281 Session session = null;
1282
1283 try {
1284 session = openSession();
1285
1286 JournalStructure[] array = new JournalStructureImpl[3];
1287
1288 array[0] = getByGroupId_PrevAndNext(session, journalStructure,
1289 groupId, orderByComparator, true);
1290
1291 array[1] = journalStructure;
1292
1293 array[2] = getByGroupId_PrevAndNext(session, journalStructure,
1294 groupId, orderByComparator, false);
1295
1296 return array;
1297 }
1298 catch (Exception e) {
1299 throw processException(e);
1300 }
1301 finally {
1302 closeSession(session);
1303 }
1304 }
1305
1306 protected JournalStructure getByGroupId_PrevAndNext(Session session,
1307 JournalStructure journalStructure, long groupId,
1308 OrderByComparator orderByComparator, boolean previous) {
1309 StringBundler query = null;
1310
1311 if (orderByComparator != null) {
1312 query = new StringBundler(6 +
1313 (orderByComparator.getOrderByFields().length * 6));
1314 }
1315 else {
1316 query = new StringBundler(3);
1317 }
1318
1319 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1320
1321 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1322
1323 if (orderByComparator != null) {
1324 String[] orderByFields = orderByComparator.getOrderByFields();
1325
1326 if (orderByFields.length > 0) {
1327 query.append(WHERE_AND);
1328 }
1329
1330 for (int i = 0; i < orderByFields.length; i++) {
1331 query.append(_ORDER_BY_ENTITY_ALIAS);
1332 query.append(orderByFields[i]);
1333
1334 if ((i + 1) < orderByFields.length) {
1335 if (orderByComparator.isAscending() ^ previous) {
1336 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1337 }
1338 else {
1339 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1340 }
1341 }
1342 else {
1343 if (orderByComparator.isAscending() ^ previous) {
1344 query.append(WHERE_GREATER_THAN);
1345 }
1346 else {
1347 query.append(WHERE_LESSER_THAN);
1348 }
1349 }
1350 }
1351
1352 query.append(ORDER_BY_CLAUSE);
1353
1354 for (int i = 0; i < orderByFields.length; i++) {
1355 query.append(_ORDER_BY_ENTITY_ALIAS);
1356 query.append(orderByFields[i]);
1357
1358 if ((i + 1) < orderByFields.length) {
1359 if (orderByComparator.isAscending() ^ previous) {
1360 query.append(ORDER_BY_ASC_HAS_NEXT);
1361 }
1362 else {
1363 query.append(ORDER_BY_DESC_HAS_NEXT);
1364 }
1365 }
1366 else {
1367 if (orderByComparator.isAscending() ^ previous) {
1368 query.append(ORDER_BY_ASC);
1369 }
1370 else {
1371 query.append(ORDER_BY_DESC);
1372 }
1373 }
1374 }
1375 }
1376
1377 else {
1378 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1379 }
1380
1381 String sql = query.toString();
1382
1383 Query q = session.createQuery(sql);
1384
1385 q.setFirstResult(0);
1386 q.setMaxResults(2);
1387
1388 QueryPos qPos = QueryPos.getInstance(q);
1389
1390 qPos.add(groupId);
1391
1392 if (orderByComparator != null) {
1393 Object[] values = orderByComparator.getOrderByValues(journalStructure);
1394
1395 for (Object value : values) {
1396 qPos.add(value);
1397 }
1398 }
1399
1400 List<JournalStructure> list = q.list();
1401
1402 if (list.size() == 2) {
1403 return list.get(1);
1404 }
1405 else {
1406 return null;
1407 }
1408 }
1409
1410
1417 public List<JournalStructure> filterFindByGroupId(long groupId)
1418 throws SystemException {
1419 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1420 QueryUtil.ALL_POS, null);
1421 }
1422
1423
1436 public List<JournalStructure> filterFindByGroupId(long groupId, int start,
1437 int end) throws SystemException {
1438 return filterFindByGroupId(groupId, start, end, null);
1439 }
1440
1441
1455 public List<JournalStructure> filterFindByGroupId(long groupId, int start,
1456 int end, OrderByComparator orderByComparator) throws SystemException {
1457 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1458 return findByGroupId(groupId, start, end, orderByComparator);
1459 }
1460
1461 Session session = null;
1462
1463 try {
1464 session = openSession();
1465
1466 StringBundler query = null;
1467
1468 if (orderByComparator != null) {
1469 query = new StringBundler(3 +
1470 (orderByComparator.getOrderByFields().length * 3));
1471 }
1472 else {
1473 query = new StringBundler(3);
1474 }
1475
1476 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1477
1478 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1479
1480 if (orderByComparator != null) {
1481 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1482 orderByComparator);
1483 }
1484
1485 else {
1486 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1487 }
1488
1489 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1490 JournalStructure.class.getName(), _FILTER_COLUMN_PK,
1491 _FILTER_COLUMN_USERID, groupId);
1492
1493 SQLQuery q = session.createSQLQuery(sql);
1494
1495 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
1496
1497 QueryPos qPos = QueryPos.getInstance(q);
1498
1499 qPos.add(groupId);
1500
1501 return (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1502 start, end);
1503 }
1504 catch (Exception e) {
1505 throw processException(e);
1506 }
1507 finally {
1508 closeSession(session);
1509 }
1510 }
1511
1512
1519 public List<JournalStructure> findByStructureId(String structureId)
1520 throws SystemException {
1521 return findByStructureId(structureId, QueryUtil.ALL_POS,
1522 QueryUtil.ALL_POS, null);
1523 }
1524
1525
1538 public List<JournalStructure> findByStructureId(String structureId,
1539 int start, int end) throws SystemException {
1540 return findByStructureId(structureId, start, end, null);
1541 }
1542
1543
1557 public List<JournalStructure> findByStructureId(String structureId,
1558 int start, int end, OrderByComparator orderByComparator)
1559 throws SystemException {
1560 Object[] finderArgs = new Object[] {
1561 structureId,
1562
1563 String.valueOf(start), String.valueOf(end),
1564 String.valueOf(orderByComparator)
1565 };
1566
1567 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1568 finderArgs, this);
1569
1570 if (list == null) {
1571 Session session = null;
1572
1573 try {
1574 session = openSession();
1575
1576 StringBundler query = null;
1577
1578 if (orderByComparator != null) {
1579 query = new StringBundler(3 +
1580 (orderByComparator.getOrderByFields().length * 3));
1581 }
1582 else {
1583 query = new StringBundler(3);
1584 }
1585
1586 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1587
1588 if (structureId == null) {
1589 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
1590 }
1591 else {
1592 if (structureId.equals(StringPool.BLANK)) {
1593 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
1594 }
1595 else {
1596 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1597 }
1598 }
1599
1600 if (orderByComparator != null) {
1601 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1602 orderByComparator);
1603 }
1604
1605 else {
1606 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1607 }
1608
1609 String sql = query.toString();
1610
1611 Query q = session.createQuery(sql);
1612
1613 QueryPos qPos = QueryPos.getInstance(q);
1614
1615 if (structureId != null) {
1616 qPos.add(structureId);
1617 }
1618
1619 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
1620 start, end);
1621 }
1622 catch (Exception e) {
1623 throw processException(e);
1624 }
1625 finally {
1626 if (list == null) {
1627 list = new ArrayList<JournalStructure>();
1628 }
1629
1630 cacheResult(list);
1631
1632 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_STRUCTUREID,
1633 finderArgs, list);
1634
1635 closeSession(session);
1636 }
1637 }
1638
1639 return list;
1640 }
1641
1642
1655 public JournalStructure findByStructureId_First(String structureId,
1656 OrderByComparator orderByComparator)
1657 throws NoSuchStructureException, SystemException {
1658 List<JournalStructure> list = findByStructureId(structureId, 0, 1,
1659 orderByComparator);
1660
1661 if (list.isEmpty()) {
1662 StringBundler msg = new StringBundler(4);
1663
1664 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1665
1666 msg.append("structureId=");
1667 msg.append(structureId);
1668
1669 msg.append(StringPool.CLOSE_CURLY_BRACE);
1670
1671 throw new NoSuchStructureException(msg.toString());
1672 }
1673 else {
1674 return list.get(0);
1675 }
1676 }
1677
1678
1691 public JournalStructure findByStructureId_Last(String structureId,
1692 OrderByComparator orderByComparator)
1693 throws NoSuchStructureException, SystemException {
1694 int count = countByStructureId(structureId);
1695
1696 List<JournalStructure> list = findByStructureId(structureId, count - 1,
1697 count, orderByComparator);
1698
1699 if (list.isEmpty()) {
1700 StringBundler msg = new StringBundler(4);
1701
1702 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1703
1704 msg.append("structureId=");
1705 msg.append(structureId);
1706
1707 msg.append(StringPool.CLOSE_CURLY_BRACE);
1708
1709 throw new NoSuchStructureException(msg.toString());
1710 }
1711 else {
1712 return list.get(0);
1713 }
1714 }
1715
1716
1730 public JournalStructure[] findByStructureId_PrevAndNext(long id,
1731 String structureId, OrderByComparator orderByComparator)
1732 throws NoSuchStructureException, SystemException {
1733 JournalStructure journalStructure = findByPrimaryKey(id);
1734
1735 Session session = null;
1736
1737 try {
1738 session = openSession();
1739
1740 JournalStructure[] array = new JournalStructureImpl[3];
1741
1742 array[0] = getByStructureId_PrevAndNext(session, journalStructure,
1743 structureId, orderByComparator, true);
1744
1745 array[1] = journalStructure;
1746
1747 array[2] = getByStructureId_PrevAndNext(session, journalStructure,
1748 structureId, orderByComparator, false);
1749
1750 return array;
1751 }
1752 catch (Exception e) {
1753 throw processException(e);
1754 }
1755 finally {
1756 closeSession(session);
1757 }
1758 }
1759
1760 protected JournalStructure getByStructureId_PrevAndNext(Session session,
1761 JournalStructure journalStructure, String structureId,
1762 OrderByComparator orderByComparator, boolean previous) {
1763 StringBundler query = null;
1764
1765 if (orderByComparator != null) {
1766 query = new StringBundler(6 +
1767 (orderByComparator.getOrderByFields().length * 6));
1768 }
1769 else {
1770 query = new StringBundler(3);
1771 }
1772
1773 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1774
1775 if (structureId == null) {
1776 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
1777 }
1778 else {
1779 if (structureId.equals(StringPool.BLANK)) {
1780 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
1781 }
1782 else {
1783 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
1784 }
1785 }
1786
1787 if (orderByComparator != null) {
1788 String[] orderByFields = orderByComparator.getOrderByFields();
1789
1790 if (orderByFields.length > 0) {
1791 query.append(WHERE_AND);
1792 }
1793
1794 for (int i = 0; i < orderByFields.length; i++) {
1795 query.append(_ORDER_BY_ENTITY_ALIAS);
1796 query.append(orderByFields[i]);
1797
1798 if ((i + 1) < orderByFields.length) {
1799 if (orderByComparator.isAscending() ^ previous) {
1800 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1801 }
1802 else {
1803 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1804 }
1805 }
1806 else {
1807 if (orderByComparator.isAscending() ^ previous) {
1808 query.append(WHERE_GREATER_THAN);
1809 }
1810 else {
1811 query.append(WHERE_LESSER_THAN);
1812 }
1813 }
1814 }
1815
1816 query.append(ORDER_BY_CLAUSE);
1817
1818 for (int i = 0; i < orderByFields.length; i++) {
1819 query.append(_ORDER_BY_ENTITY_ALIAS);
1820 query.append(orderByFields[i]);
1821
1822 if ((i + 1) < orderByFields.length) {
1823 if (orderByComparator.isAscending() ^ previous) {
1824 query.append(ORDER_BY_ASC_HAS_NEXT);
1825 }
1826 else {
1827 query.append(ORDER_BY_DESC_HAS_NEXT);
1828 }
1829 }
1830 else {
1831 if (orderByComparator.isAscending() ^ previous) {
1832 query.append(ORDER_BY_ASC);
1833 }
1834 else {
1835 query.append(ORDER_BY_DESC);
1836 }
1837 }
1838 }
1839 }
1840
1841 else {
1842 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1843 }
1844
1845 String sql = query.toString();
1846
1847 Query q = session.createQuery(sql);
1848
1849 q.setFirstResult(0);
1850 q.setMaxResults(2);
1851
1852 QueryPos qPos = QueryPos.getInstance(q);
1853
1854 if (structureId != null) {
1855 qPos.add(structureId);
1856 }
1857
1858 if (orderByComparator != null) {
1859 Object[] values = orderByComparator.getOrderByValues(journalStructure);
1860
1861 for (Object value : values) {
1862 qPos.add(value);
1863 }
1864 }
1865
1866 List<JournalStructure> list = q.list();
1867
1868 if (list.size() == 2) {
1869 return list.get(1);
1870 }
1871 else {
1872 return null;
1873 }
1874 }
1875
1876
1885 public JournalStructure findByG_S(long groupId, String structureId)
1886 throws NoSuchStructureException, SystemException {
1887 JournalStructure journalStructure = fetchByG_S(groupId, structureId);
1888
1889 if (journalStructure == null) {
1890 StringBundler msg = new StringBundler(6);
1891
1892 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1893
1894 msg.append("groupId=");
1895 msg.append(groupId);
1896
1897 msg.append(", structureId=");
1898 msg.append(structureId);
1899
1900 msg.append(StringPool.CLOSE_CURLY_BRACE);
1901
1902 if (_log.isWarnEnabled()) {
1903 _log.warn(msg.toString());
1904 }
1905
1906 throw new NoSuchStructureException(msg.toString());
1907 }
1908
1909 return journalStructure;
1910 }
1911
1912
1920 public JournalStructure fetchByG_S(long groupId, String structureId)
1921 throws SystemException {
1922 return fetchByG_S(groupId, structureId, true);
1923 }
1924
1925
1933 public JournalStructure fetchByG_S(long groupId, String structureId,
1934 boolean retrieveFromCache) throws SystemException {
1935 Object[] finderArgs = new Object[] { groupId, structureId };
1936
1937 Object result = null;
1938
1939 if (retrieveFromCache) {
1940 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
1941 finderArgs, this);
1942 }
1943
1944 if (result == null) {
1945 Session session = null;
1946
1947 try {
1948 session = openSession();
1949
1950 StringBundler query = new StringBundler(4);
1951
1952 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
1953
1954 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
1955
1956 if (structureId == null) {
1957 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
1958 }
1959 else {
1960 if (structureId.equals(StringPool.BLANK)) {
1961 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
1962 }
1963 else {
1964 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
1965 }
1966 }
1967
1968 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
1969
1970 String sql = query.toString();
1971
1972 Query q = session.createQuery(sql);
1973
1974 QueryPos qPos = QueryPos.getInstance(q);
1975
1976 qPos.add(groupId);
1977
1978 if (structureId != null) {
1979 qPos.add(structureId);
1980 }
1981
1982 List<JournalStructure> list = q.list();
1983
1984 result = list;
1985
1986 JournalStructure journalStructure = null;
1987
1988 if (list.isEmpty()) {
1989 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
1990 finderArgs, list);
1991 }
1992 else {
1993 journalStructure = list.get(0);
1994
1995 cacheResult(journalStructure);
1996
1997 if ((journalStructure.getGroupId() != groupId) ||
1998 (journalStructure.getStructureId() == null) ||
1999 !journalStructure.getStructureId()
2000 .equals(structureId)) {
2001 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
2002 finderArgs, journalStructure);
2003 }
2004 }
2005
2006 return journalStructure;
2007 }
2008 catch (Exception e) {
2009 throw processException(e);
2010 }
2011 finally {
2012 if (result == null) {
2013 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
2014 finderArgs, new ArrayList<JournalStructure>());
2015 }
2016
2017 closeSession(session);
2018 }
2019 }
2020 else {
2021 if (result instanceof List<?>) {
2022 return null;
2023 }
2024 else {
2025 return (JournalStructure)result;
2026 }
2027 }
2028 }
2029
2030
2038 public List<JournalStructure> findByG_P(long groupId,
2039 String parentStructureId) throws SystemException {
2040 return findByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
2041 QueryUtil.ALL_POS, null);
2042 }
2043
2044
2058 public List<JournalStructure> findByG_P(long groupId,
2059 String parentStructureId, int start, int end) throws SystemException {
2060 return findByG_P(groupId, parentStructureId, start, end, null);
2061 }
2062
2063
2078 public List<JournalStructure> findByG_P(long groupId,
2079 String parentStructureId, int start, int end,
2080 OrderByComparator orderByComparator) throws SystemException {
2081 Object[] finderArgs = new Object[] {
2082 groupId, parentStructureId,
2083
2084 String.valueOf(start), String.valueOf(end),
2085 String.valueOf(orderByComparator)
2086 };
2087
2088 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_G_P,
2089 finderArgs, this);
2090
2091 if (list == null) {
2092 Session session = null;
2093
2094 try {
2095 session = openSession();
2096
2097 StringBundler query = null;
2098
2099 if (orderByComparator != null) {
2100 query = new StringBundler(4 +
2101 (orderByComparator.getOrderByFields().length * 3));
2102 }
2103 else {
2104 query = new StringBundler(4);
2105 }
2106
2107 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2108
2109 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2110
2111 if (parentStructureId == null) {
2112 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
2113 }
2114 else {
2115 if (parentStructureId.equals(StringPool.BLANK)) {
2116 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
2117 }
2118 else {
2119 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
2120 }
2121 }
2122
2123 if (orderByComparator != null) {
2124 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2125 orderByComparator);
2126 }
2127
2128 else {
2129 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2130 }
2131
2132 String sql = query.toString();
2133
2134 Query q = session.createQuery(sql);
2135
2136 QueryPos qPos = QueryPos.getInstance(q);
2137
2138 qPos.add(groupId);
2139
2140 if (parentStructureId != null) {
2141 qPos.add(parentStructureId);
2142 }
2143
2144 list = (List<JournalStructure>)QueryUtil.list(q, getDialect(),
2145 start, end);
2146 }
2147 catch (Exception e) {
2148 throw processException(e);
2149 }
2150 finally {
2151 if (list == null) {
2152 list = new ArrayList<JournalStructure>();
2153 }
2154
2155 cacheResult(list);
2156
2157 FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_G_P, finderArgs,
2158 list);
2159
2160 closeSession(session);
2161 }
2162 }
2163
2164 return list;
2165 }
2166
2167
2181 public JournalStructure findByG_P_First(long groupId,
2182 String parentStructureId, OrderByComparator orderByComparator)
2183 throws NoSuchStructureException, SystemException {
2184 List<JournalStructure> list = findByG_P(groupId, parentStructureId, 0,
2185 1, orderByComparator);
2186
2187 if (list.isEmpty()) {
2188 StringBundler msg = new StringBundler(6);
2189
2190 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2191
2192 msg.append("groupId=");
2193 msg.append(groupId);
2194
2195 msg.append(", parentStructureId=");
2196 msg.append(parentStructureId);
2197
2198 msg.append(StringPool.CLOSE_CURLY_BRACE);
2199
2200 throw new NoSuchStructureException(msg.toString());
2201 }
2202 else {
2203 return list.get(0);
2204 }
2205 }
2206
2207
2221 public JournalStructure findByG_P_Last(long groupId,
2222 String parentStructureId, OrderByComparator orderByComparator)
2223 throws NoSuchStructureException, SystemException {
2224 int count = countByG_P(groupId, parentStructureId);
2225
2226 List<JournalStructure> list = findByG_P(groupId, parentStructureId,
2227 count - 1, count, orderByComparator);
2228
2229 if (list.isEmpty()) {
2230 StringBundler msg = new StringBundler(6);
2231
2232 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2233
2234 msg.append("groupId=");
2235 msg.append(groupId);
2236
2237 msg.append(", parentStructureId=");
2238 msg.append(parentStructureId);
2239
2240 msg.append(StringPool.CLOSE_CURLY_BRACE);
2241
2242 throw new NoSuchStructureException(msg.toString());
2243 }
2244 else {
2245 return list.get(0);
2246 }
2247 }
2248
2249
2264 public JournalStructure[] findByG_P_PrevAndNext(long id, long groupId,
2265 String parentStructureId, OrderByComparator orderByComparator)
2266 throws NoSuchStructureException, SystemException {
2267 JournalStructure journalStructure = findByPrimaryKey(id);
2268
2269 Session session = null;
2270
2271 try {
2272 session = openSession();
2273
2274 JournalStructure[] array = new JournalStructureImpl[3];
2275
2276 array[0] = getByG_P_PrevAndNext(session, journalStructure, groupId,
2277 parentStructureId, orderByComparator, true);
2278
2279 array[1] = journalStructure;
2280
2281 array[2] = getByG_P_PrevAndNext(session, journalStructure, groupId,
2282 parentStructureId, orderByComparator, false);
2283
2284 return array;
2285 }
2286 catch (Exception e) {
2287 throw processException(e);
2288 }
2289 finally {
2290 closeSession(session);
2291 }
2292 }
2293
2294 protected JournalStructure getByG_P_PrevAndNext(Session session,
2295 JournalStructure journalStructure, long groupId,
2296 String parentStructureId, OrderByComparator orderByComparator,
2297 boolean previous) {
2298 StringBundler query = null;
2299
2300 if (orderByComparator != null) {
2301 query = new StringBundler(6 +
2302 (orderByComparator.getOrderByFields().length * 6));
2303 }
2304 else {
2305 query = new StringBundler(3);
2306 }
2307
2308 query.append(_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2309
2310 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2311
2312 if (parentStructureId == null) {
2313 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
2314 }
2315 else {
2316 if (parentStructureId.equals(StringPool.BLANK)) {
2317 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
2318 }
2319 else {
2320 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
2321 }
2322 }
2323
2324 if (orderByComparator != null) {
2325 String[] orderByFields = orderByComparator.getOrderByFields();
2326
2327 if (orderByFields.length > 0) {
2328 query.append(WHERE_AND);
2329 }
2330
2331 for (int i = 0; i < orderByFields.length; i++) {
2332 query.append(_ORDER_BY_ENTITY_ALIAS);
2333 query.append(orderByFields[i]);
2334
2335 if ((i + 1) < orderByFields.length) {
2336 if (orderByComparator.isAscending() ^ previous) {
2337 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2338 }
2339 else {
2340 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2341 }
2342 }
2343 else {
2344 if (orderByComparator.isAscending() ^ previous) {
2345 query.append(WHERE_GREATER_THAN);
2346 }
2347 else {
2348 query.append(WHERE_LESSER_THAN);
2349 }
2350 }
2351 }
2352
2353 query.append(ORDER_BY_CLAUSE);
2354
2355 for (int i = 0; i < orderByFields.length; i++) {
2356 query.append(_ORDER_BY_ENTITY_ALIAS);
2357 query.append(orderByFields[i]);
2358
2359 if ((i + 1) < orderByFields.length) {
2360 if (orderByComparator.isAscending() ^ previous) {
2361 query.append(ORDER_BY_ASC_HAS_NEXT);
2362 }
2363 else {
2364 query.append(ORDER_BY_DESC_HAS_NEXT);
2365 }
2366 }
2367 else {
2368 if (orderByComparator.isAscending() ^ previous) {
2369 query.append(ORDER_BY_ASC);
2370 }
2371 else {
2372 query.append(ORDER_BY_DESC);
2373 }
2374 }
2375 }
2376 }
2377
2378 else {
2379 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2380 }
2381
2382 String sql = query.toString();
2383
2384 Query q = session.createQuery(sql);
2385
2386 q.setFirstResult(0);
2387 q.setMaxResults(2);
2388
2389 QueryPos qPos = QueryPos.getInstance(q);
2390
2391 qPos.add(groupId);
2392
2393 if (parentStructureId != null) {
2394 qPos.add(parentStructureId);
2395 }
2396
2397 if (orderByComparator != null) {
2398 Object[] values = orderByComparator.getOrderByValues(journalStructure);
2399
2400 for (Object value : values) {
2401 qPos.add(value);
2402 }
2403 }
2404
2405 List<JournalStructure> list = q.list();
2406
2407 if (list.size() == 2) {
2408 return list.get(1);
2409 }
2410 else {
2411 return null;
2412 }
2413 }
2414
2415
2423 public List<JournalStructure> filterFindByG_P(long groupId,
2424 String parentStructureId) throws SystemException {
2425 return filterFindByG_P(groupId, parentStructureId, QueryUtil.ALL_POS,
2426 QueryUtil.ALL_POS, null);
2427 }
2428
2429
2443 public List<JournalStructure> filterFindByG_P(long groupId,
2444 String parentStructureId, int start, int end) throws SystemException {
2445 return filterFindByG_P(groupId, parentStructureId, start, end, null);
2446 }
2447
2448
2463 public List<JournalStructure> filterFindByG_P(long groupId,
2464 String parentStructureId, int start, int end,
2465 OrderByComparator orderByComparator) throws SystemException {
2466 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2467 return findByG_P(groupId, parentStructureId, start, end,
2468 orderByComparator);
2469 }
2470
2471 Session session = null;
2472
2473 try {
2474 session = openSession();
2475
2476 StringBundler query = null;
2477
2478 if (orderByComparator != null) {
2479 query = new StringBundler(4 +
2480 (orderByComparator.getOrderByFields().length * 3));
2481 }
2482 else {
2483 query = new StringBundler(4);
2484 }
2485
2486 query.append(_FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE);
2487
2488 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
2489
2490 if (parentStructureId == null) {
2491 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
2492 }
2493 else {
2494 if (parentStructureId.equals(StringPool.BLANK)) {
2495 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
2496 }
2497 else {
2498 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
2499 }
2500 }
2501
2502 if (orderByComparator != null) {
2503 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2504 orderByComparator);
2505 }
2506
2507 else {
2508 query.append(JournalStructureModelImpl.ORDER_BY_JPQL);
2509 }
2510
2511 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2512 JournalStructure.class.getName(), _FILTER_COLUMN_PK,
2513 _FILTER_COLUMN_USERID, groupId);
2514
2515 SQLQuery q = session.createSQLQuery(sql);
2516
2517 q.addEntity(_FILTER_ENTITY_ALIAS, JournalStructureImpl.class);
2518
2519 QueryPos qPos = QueryPos.getInstance(q);
2520
2521 qPos.add(groupId);
2522
2523 if (parentStructureId != null) {
2524 qPos.add(parentStructureId);
2525 }
2526
2527 return (List<JournalStructure>)QueryUtil.list(q, getDialect(),
2528 start, end);
2529 }
2530 catch (Exception e) {
2531 throw processException(e);
2532 }
2533 finally {
2534 closeSession(session);
2535 }
2536 }
2537
2538
2544 public List<JournalStructure> findAll() throws SystemException {
2545 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2546 }
2547
2548
2560 public List<JournalStructure> findAll(int start, int end)
2561 throws SystemException {
2562 return findAll(start, end, null);
2563 }
2564
2565
2578 public List<JournalStructure> findAll(int start, int end,
2579 OrderByComparator orderByComparator) throws SystemException {
2580 Object[] finderArgs = new Object[] {
2581 String.valueOf(start), String.valueOf(end),
2582 String.valueOf(orderByComparator)
2583 };
2584
2585 List<JournalStructure> list = (List<JournalStructure>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2586 finderArgs, this);
2587
2588 if (list == null) {
2589 Session session = null;
2590
2591 try {
2592 session = openSession();
2593
2594 StringBundler query = null;
2595 String sql = null;
2596
2597 if (orderByComparator != null) {
2598 query = new StringBundler(2 +
2599 (orderByComparator.getOrderByFields().length * 3));
2600
2601 query.append(_SQL_SELECT_JOURNALSTRUCTURE);
2602
2603 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2604 orderByComparator);
2605
2606 sql = query.toString();
2607 }
2608 else {
2609 sql = _SQL_SELECT_JOURNALSTRUCTURE.concat(JournalStructureModelImpl.ORDER_BY_JPQL);
2610 }
2611
2612 Query q = session.createQuery(sql);
2613
2614 if (orderByComparator == null) {
2615 list = (List<JournalStructure>)QueryUtil.list(q,
2616 getDialect(), start, end, false);
2617
2618 Collections.sort(list);
2619 }
2620 else {
2621 list = (List<JournalStructure>)QueryUtil.list(q,
2622 getDialect(), start, end);
2623 }
2624 }
2625 catch (Exception e) {
2626 throw processException(e);
2627 }
2628 finally {
2629 if (list == null) {
2630 list = new ArrayList<JournalStructure>();
2631 }
2632
2633 cacheResult(list);
2634
2635 FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2636
2637 closeSession(session);
2638 }
2639 }
2640
2641 return list;
2642 }
2643
2644
2650 public void removeByUuid(String uuid) throws SystemException {
2651 for (JournalStructure journalStructure : findByUuid(uuid)) {
2652 remove(journalStructure);
2653 }
2654 }
2655
2656
2663 public void removeByUUID_G(String uuid, long groupId)
2664 throws NoSuchStructureException, SystemException {
2665 JournalStructure journalStructure = findByUUID_G(uuid, groupId);
2666
2667 remove(journalStructure);
2668 }
2669
2670
2676 public void removeByGroupId(long groupId) throws SystemException {
2677 for (JournalStructure journalStructure : findByGroupId(groupId)) {
2678 remove(journalStructure);
2679 }
2680 }
2681
2682
2688 public void removeByStructureId(String structureId)
2689 throws SystemException {
2690 for (JournalStructure journalStructure : findByStructureId(structureId)) {
2691 remove(journalStructure);
2692 }
2693 }
2694
2695
2702 public void removeByG_S(long groupId, String structureId)
2703 throws NoSuchStructureException, SystemException {
2704 JournalStructure journalStructure = findByG_S(groupId, structureId);
2705
2706 remove(journalStructure);
2707 }
2708
2709
2716 public void removeByG_P(long groupId, String parentStructureId)
2717 throws SystemException {
2718 for (JournalStructure journalStructure : findByG_P(groupId,
2719 parentStructureId)) {
2720 remove(journalStructure);
2721 }
2722 }
2723
2724
2729 public void removeAll() throws SystemException {
2730 for (JournalStructure journalStructure : findAll()) {
2731 remove(journalStructure);
2732 }
2733 }
2734
2735
2742 public int countByUuid(String uuid) throws SystemException {
2743 Object[] finderArgs = new Object[] { uuid };
2744
2745 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2746 finderArgs, this);
2747
2748 if (count == null) {
2749 Session session = null;
2750
2751 try {
2752 session = openSession();
2753
2754 StringBundler query = new StringBundler(2);
2755
2756 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2757
2758 if (uuid == null) {
2759 query.append(_FINDER_COLUMN_UUID_UUID_1);
2760 }
2761 else {
2762 if (uuid.equals(StringPool.BLANK)) {
2763 query.append(_FINDER_COLUMN_UUID_UUID_3);
2764 }
2765 else {
2766 query.append(_FINDER_COLUMN_UUID_UUID_2);
2767 }
2768 }
2769
2770 String sql = query.toString();
2771
2772 Query q = session.createQuery(sql);
2773
2774 QueryPos qPos = QueryPos.getInstance(q);
2775
2776 if (uuid != null) {
2777 qPos.add(uuid);
2778 }
2779
2780 count = (Long)q.uniqueResult();
2781 }
2782 catch (Exception e) {
2783 throw processException(e);
2784 }
2785 finally {
2786 if (count == null) {
2787 count = Long.valueOf(0);
2788 }
2789
2790 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2791 finderArgs, count);
2792
2793 closeSession(session);
2794 }
2795 }
2796
2797 return count.intValue();
2798 }
2799
2800
2808 public int countByUUID_G(String uuid, long groupId)
2809 throws SystemException {
2810 Object[] finderArgs = new Object[] { uuid, groupId };
2811
2812 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2813 finderArgs, this);
2814
2815 if (count == null) {
2816 Session session = null;
2817
2818 try {
2819 session = openSession();
2820
2821 StringBundler query = new StringBundler(3);
2822
2823 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2824
2825 if (uuid == null) {
2826 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2827 }
2828 else {
2829 if (uuid.equals(StringPool.BLANK)) {
2830 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2831 }
2832 else {
2833 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2834 }
2835 }
2836
2837 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2838
2839 String sql = query.toString();
2840
2841 Query q = session.createQuery(sql);
2842
2843 QueryPos qPos = QueryPos.getInstance(q);
2844
2845 if (uuid != null) {
2846 qPos.add(uuid);
2847 }
2848
2849 qPos.add(groupId);
2850
2851 count = (Long)q.uniqueResult();
2852 }
2853 catch (Exception e) {
2854 throw processException(e);
2855 }
2856 finally {
2857 if (count == null) {
2858 count = Long.valueOf(0);
2859 }
2860
2861 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2862 finderArgs, count);
2863
2864 closeSession(session);
2865 }
2866 }
2867
2868 return count.intValue();
2869 }
2870
2871
2878 public int countByGroupId(long groupId) throws SystemException {
2879 Object[] finderArgs = new Object[] { groupId };
2880
2881 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2882 finderArgs, this);
2883
2884 if (count == null) {
2885 Session session = null;
2886
2887 try {
2888 session = openSession();
2889
2890 StringBundler query = new StringBundler(2);
2891
2892 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2893
2894 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2895
2896 String sql = query.toString();
2897
2898 Query q = session.createQuery(sql);
2899
2900 QueryPos qPos = QueryPos.getInstance(q);
2901
2902 qPos.add(groupId);
2903
2904 count = (Long)q.uniqueResult();
2905 }
2906 catch (Exception e) {
2907 throw processException(e);
2908 }
2909 finally {
2910 if (count == null) {
2911 count = Long.valueOf(0);
2912 }
2913
2914 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2915 finderArgs, count);
2916
2917 closeSession(session);
2918 }
2919 }
2920
2921 return count.intValue();
2922 }
2923
2924
2931 public int filterCountByGroupId(long groupId) throws SystemException {
2932 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2933 return countByGroupId(groupId);
2934 }
2935
2936 Session session = null;
2937
2938 try {
2939 session = openSession();
2940
2941 StringBundler query = new StringBundler(2);
2942
2943 query.append(_FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2944
2945 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2946
2947 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2948 JournalStructure.class.getName(), _FILTER_COLUMN_PK,
2949 _FILTER_COLUMN_USERID, groupId);
2950
2951 SQLQuery q = session.createSQLQuery(sql);
2952
2953 q.addScalar(COUNT_COLUMN_NAME,
2954 com.liferay.portal.kernel.dao.orm.Type.LONG);
2955
2956 QueryPos qPos = QueryPos.getInstance(q);
2957
2958 qPos.add(groupId);
2959
2960 Long count = (Long)q.uniqueResult();
2961
2962 return count.intValue();
2963 }
2964 catch (Exception e) {
2965 throw processException(e);
2966 }
2967 finally {
2968 closeSession(session);
2969 }
2970 }
2971
2972
2979 public int countByStructureId(String structureId) throws SystemException {
2980 Object[] finderArgs = new Object[] { structureId };
2981
2982 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
2983 finderArgs, this);
2984
2985 if (count == null) {
2986 Session session = null;
2987
2988 try {
2989 session = openSession();
2990
2991 StringBundler query = new StringBundler(2);
2992
2993 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
2994
2995 if (structureId == null) {
2996 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1);
2997 }
2998 else {
2999 if (structureId.equals(StringPool.BLANK)) {
3000 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3);
3001 }
3002 else {
3003 query.append(_FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2);
3004 }
3005 }
3006
3007 String sql = query.toString();
3008
3009 Query q = session.createQuery(sql);
3010
3011 QueryPos qPos = QueryPos.getInstance(q);
3012
3013 if (structureId != null) {
3014 qPos.add(structureId);
3015 }
3016
3017 count = (Long)q.uniqueResult();
3018 }
3019 catch (Exception e) {
3020 throw processException(e);
3021 }
3022 finally {
3023 if (count == null) {
3024 count = Long.valueOf(0);
3025 }
3026
3027 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STRUCTUREID,
3028 finderArgs, count);
3029
3030 closeSession(session);
3031 }
3032 }
3033
3034 return count.intValue();
3035 }
3036
3037
3045 public int countByG_S(long groupId, String structureId)
3046 throws SystemException {
3047 Object[] finderArgs = new Object[] { groupId, structureId };
3048
3049 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
3050 finderArgs, this);
3051
3052 if (count == null) {
3053 Session session = null;
3054
3055 try {
3056 session = openSession();
3057
3058 StringBundler query = new StringBundler(3);
3059
3060 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
3061
3062 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3063
3064 if (structureId == null) {
3065 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
3066 }
3067 else {
3068 if (structureId.equals(StringPool.BLANK)) {
3069 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
3070 }
3071 else {
3072 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
3073 }
3074 }
3075
3076 String sql = query.toString();
3077
3078 Query q = session.createQuery(sql);
3079
3080 QueryPos qPos = QueryPos.getInstance(q);
3081
3082 qPos.add(groupId);
3083
3084 if (structureId != null) {
3085 qPos.add(structureId);
3086 }
3087
3088 count = (Long)q.uniqueResult();
3089 }
3090 catch (Exception e) {
3091 throw processException(e);
3092 }
3093 finally {
3094 if (count == null) {
3095 count = Long.valueOf(0);
3096 }
3097
3098 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
3099 count);
3100
3101 closeSession(session);
3102 }
3103 }
3104
3105 return count.intValue();
3106 }
3107
3108
3116 public int filterCountByG_S(long groupId, String structureId)
3117 throws SystemException {
3118 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3119 return countByG_S(groupId, structureId);
3120 }
3121
3122 Session session = null;
3123
3124 try {
3125 session = openSession();
3126
3127 StringBundler query = new StringBundler(3);
3128
3129 query.append(_FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
3130
3131 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
3132
3133 if (structureId == null) {
3134 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_1);
3135 }
3136 else {
3137 if (structureId.equals(StringPool.BLANK)) {
3138 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_3);
3139 }
3140 else {
3141 query.append(_FINDER_COLUMN_G_S_STRUCTUREID_2);
3142 }
3143 }
3144
3145 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3146 JournalStructure.class.getName(), _FILTER_COLUMN_PK,
3147 _FILTER_COLUMN_USERID, groupId);
3148
3149 SQLQuery q = session.createSQLQuery(sql);
3150
3151 q.addScalar(COUNT_COLUMN_NAME,
3152 com.liferay.portal.kernel.dao.orm.Type.LONG);
3153
3154 QueryPos qPos = QueryPos.getInstance(q);
3155
3156 qPos.add(groupId);
3157
3158 if (structureId != null) {
3159 qPos.add(structureId);
3160 }
3161
3162 Long count = (Long)q.uniqueResult();
3163
3164 return count.intValue();
3165 }
3166 catch (Exception e) {
3167 throw processException(e);
3168 }
3169 finally {
3170 closeSession(session);
3171 }
3172 }
3173
3174
3182 public int countByG_P(long groupId, String parentStructureId)
3183 throws SystemException {
3184 Object[] finderArgs = new Object[] { groupId, parentStructureId };
3185
3186 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_P,
3187 finderArgs, this);
3188
3189 if (count == null) {
3190 Session session = null;
3191
3192 try {
3193 session = openSession();
3194
3195 StringBundler query = new StringBundler(3);
3196
3197 query.append(_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
3198
3199 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3200
3201 if (parentStructureId == null) {
3202 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3203 }
3204 else {
3205 if (parentStructureId.equals(StringPool.BLANK)) {
3206 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3207 }
3208 else {
3209 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3210 }
3211 }
3212
3213 String sql = query.toString();
3214
3215 Query q = session.createQuery(sql);
3216
3217 QueryPos qPos = QueryPos.getInstance(q);
3218
3219 qPos.add(groupId);
3220
3221 if (parentStructureId != null) {
3222 qPos.add(parentStructureId);
3223 }
3224
3225 count = (Long)q.uniqueResult();
3226 }
3227 catch (Exception e) {
3228 throw processException(e);
3229 }
3230 finally {
3231 if (count == null) {
3232 count = Long.valueOf(0);
3233 }
3234
3235 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_P, finderArgs,
3236 count);
3237
3238 closeSession(session);
3239 }
3240 }
3241
3242 return count.intValue();
3243 }
3244
3245
3253 public int filterCountByG_P(long groupId, String parentStructureId)
3254 throws SystemException {
3255 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3256 return countByG_P(groupId, parentStructureId);
3257 }
3258
3259 Session session = null;
3260
3261 try {
3262 session = openSession();
3263
3264 StringBundler query = new StringBundler(3);
3265
3266 query.append(_FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE);
3267
3268 query.append(_FINDER_COLUMN_G_P_GROUPID_2);
3269
3270 if (parentStructureId == null) {
3271 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1);
3272 }
3273 else {
3274 if (parentStructureId.equals(StringPool.BLANK)) {
3275 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3);
3276 }
3277 else {
3278 query.append(_FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2);
3279 }
3280 }
3281
3282 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3283 JournalStructure.class.getName(), _FILTER_COLUMN_PK,
3284 _FILTER_COLUMN_USERID, groupId);
3285
3286 SQLQuery q = session.createSQLQuery(sql);
3287
3288 q.addScalar(COUNT_COLUMN_NAME,
3289 com.liferay.portal.kernel.dao.orm.Type.LONG);
3290
3291 QueryPos qPos = QueryPos.getInstance(q);
3292
3293 qPos.add(groupId);
3294
3295 if (parentStructureId != null) {
3296 qPos.add(parentStructureId);
3297 }
3298
3299 Long count = (Long)q.uniqueResult();
3300
3301 return count.intValue();
3302 }
3303 catch (Exception e) {
3304 throw processException(e);
3305 }
3306 finally {
3307 closeSession(session);
3308 }
3309 }
3310
3311
3317 public int countAll() throws SystemException {
3318 Object[] finderArgs = new Object[0];
3319
3320 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3321 finderArgs, this);
3322
3323 if (count == null) {
3324 Session session = null;
3325
3326 try {
3327 session = openSession();
3328
3329 Query q = session.createQuery(_SQL_COUNT_JOURNALSTRUCTURE);
3330
3331 count = (Long)q.uniqueResult();
3332 }
3333 catch (Exception e) {
3334 throw processException(e);
3335 }
3336 finally {
3337 if (count == null) {
3338 count = Long.valueOf(0);
3339 }
3340
3341 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3342 count);
3343
3344 closeSession(session);
3345 }
3346 }
3347
3348 return count.intValue();
3349 }
3350
3351
3354 public void afterPropertiesSet() {
3355 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3356 com.liferay.portal.util.PropsUtil.get(
3357 "value.object.listener.com.liferay.portlet.journal.model.JournalStructure")));
3358
3359 if (listenerClassNames.length > 0) {
3360 try {
3361 List<ModelListener<JournalStructure>> listenersList = new ArrayList<ModelListener<JournalStructure>>();
3362
3363 for (String listenerClassName : listenerClassNames) {
3364 listenersList.add((ModelListener<JournalStructure>)InstanceFactory.newInstance(
3365 listenerClassName));
3366 }
3367
3368 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3369 }
3370 catch (Exception e) {
3371 _log.error(e);
3372 }
3373 }
3374 }
3375
3376 @BeanReference(type = JournalArticlePersistence.class)
3377 protected JournalArticlePersistence journalArticlePersistence;
3378 @BeanReference(type = JournalArticleImagePersistence.class)
3379 protected JournalArticleImagePersistence journalArticleImagePersistence;
3380 @BeanReference(type = JournalArticleResourcePersistence.class)
3381 protected JournalArticleResourcePersistence journalArticleResourcePersistence;
3382 @BeanReference(type = JournalContentSearchPersistence.class)
3383 protected JournalContentSearchPersistence journalContentSearchPersistence;
3384 @BeanReference(type = JournalFeedPersistence.class)
3385 protected JournalFeedPersistence journalFeedPersistence;
3386 @BeanReference(type = JournalStructurePersistence.class)
3387 protected JournalStructurePersistence journalStructurePersistence;
3388 @BeanReference(type = JournalTemplatePersistence.class)
3389 protected JournalTemplatePersistence journalTemplatePersistence;
3390 @BeanReference(type = ResourcePersistence.class)
3391 protected ResourcePersistence resourcePersistence;
3392 @BeanReference(type = UserPersistence.class)
3393 protected UserPersistence userPersistence;
3394 @BeanReference(type = WebDAVPropsPersistence.class)
3395 protected WebDAVPropsPersistence webDAVPropsPersistence;
3396 @BeanReference(type = ExpandoValuePersistence.class)
3397 protected ExpandoValuePersistence expandoValuePersistence;
3398 private static final String _SQL_SELECT_JOURNALSTRUCTURE = "SELECT journalStructure FROM JournalStructure journalStructure";
3399 private static final String _SQL_SELECT_JOURNALSTRUCTURE_WHERE = "SELECT journalStructure FROM JournalStructure journalStructure WHERE ";
3400 private static final String _SQL_COUNT_JOURNALSTRUCTURE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure";
3401 private static final String _SQL_COUNT_JOURNALSTRUCTURE_WHERE = "SELECT COUNT(journalStructure) FROM JournalStructure journalStructure WHERE ";
3402 private static final String _FINDER_COLUMN_UUID_UUID_1 = "journalStructure.uuid IS NULL";
3403 private static final String _FINDER_COLUMN_UUID_UUID_2 = "journalStructure.uuid = ?";
3404 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?)";
3405 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "journalStructure.uuid IS NULL AND ";
3406 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "journalStructure.uuid = ? AND ";
3407 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(journalStructure.uuid IS NULL OR journalStructure.uuid = ?) AND ";
3408 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "journalStructure.groupId = ?";
3409 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "journalStructure.groupId = ?";
3410 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
3411 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_2 = "journalStructure.structureId = ?";
3412 private static final String _FINDER_COLUMN_STRUCTUREID_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
3413 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "journalStructure.groupId = ? AND ";
3414 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_1 = "journalStructure.structureId IS NULL";
3415 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_2 = "journalStructure.structureId = ?";
3416 private static final String _FINDER_COLUMN_G_S_STRUCTUREID_3 = "(journalStructure.structureId IS NULL OR journalStructure.structureId = ?)";
3417 private static final String _FINDER_COLUMN_G_P_GROUPID_2 = "journalStructure.groupId = ? AND ";
3418 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_1 = "journalStructure.parentStructureId IS NULL";
3419 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_2 = "journalStructure.parentStructureId = ?";
3420 private static final String _FINDER_COLUMN_G_P_PARENTSTRUCTUREID_3 = "(journalStructure.parentStructureId IS NULL OR journalStructure.parentStructureId = ?)";
3421 private static final String _FILTER_SQL_SELECT_JOURNALSTRUCTURE_WHERE = "SELECT DISTINCT {journalStructure.*} FROM JournalStructure journalStructure WHERE ";
3422 private static final String _FILTER_SQL_COUNT_JOURNALSTRUCTURE_WHERE = "SELECT COUNT(DISTINCT journalStructure.id) AS COUNT_VALUE FROM JournalStructure journalStructure WHERE ";
3423 private static final String _FILTER_COLUMN_PK = "journalStructure.id";
3424 private static final String _FILTER_COLUMN_USERID = "journalStructure.userId";
3425 private static final String _FILTER_ENTITY_ALIAS = "journalStructure";
3426 private static final String _ORDER_BY_ENTITY_ALIAS = "journalStructure.";
3427 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No JournalStructure exists with the primary key ";
3428 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No JournalStructure exists with the key {";
3429 private static Log _log = LogFactoryUtil.getLog(JournalStructurePersistenceImpl.class);
3430 }