001
014
015 package com.liferay.portlet.dynamicdatamapping.service.persistence;
016
017 import com.liferay.portal.NoSuchModelException;
018 import com.liferay.portal.kernel.bean.BeanReference;
019 import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQuery;
021 import com.liferay.portal.kernel.dao.jdbc.MappingSqlQueryFactoryUtil;
022 import com.liferay.portal.kernel.dao.jdbc.RowMapper;
023 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025 import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
026 import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
027 import com.liferay.portal.kernel.dao.orm.FinderPath;
028 import com.liferay.portal.kernel.dao.orm.Query;
029 import com.liferay.portal.kernel.dao.orm.QueryPos;
030 import com.liferay.portal.kernel.dao.orm.QueryUtil;
031 import com.liferay.portal.kernel.dao.orm.SQLQuery;
032 import com.liferay.portal.kernel.dao.orm.Session;
033 import com.liferay.portal.kernel.exception.SystemException;
034 import com.liferay.portal.kernel.log.Log;
035 import com.liferay.portal.kernel.log.LogFactoryUtil;
036 import com.liferay.portal.kernel.util.GetterUtil;
037 import com.liferay.portal.kernel.util.InstanceFactory;
038 import com.liferay.portal.kernel.util.OrderByComparator;
039 import com.liferay.portal.kernel.util.SetUtil;
040 import com.liferay.portal.kernel.util.StringBundler;
041 import com.liferay.portal.kernel.util.StringPool;
042 import com.liferay.portal.kernel.util.StringUtil;
043 import com.liferay.portal.kernel.util.Validator;
044 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
045 import com.liferay.portal.model.CacheModel;
046 import com.liferay.portal.model.ModelListener;
047 import com.liferay.portal.security.permission.InlineSQLHelperUtil;
048 import com.liferay.portal.service.persistence.BatchSessionUtil;
049 import com.liferay.portal.service.persistence.ResourcePersistence;
050 import com.liferay.portal.service.persistence.UserPersistence;
051 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
052
053 import com.liferay.portlet.documentlibrary.service.persistence.DLFileEntryTypePersistence;
054 import com.liferay.portlet.dynamicdatamapping.NoSuchStructureException;
055 import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
056 import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl;
057 import com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl;
058
059 import java.io.Serializable;
060
061 import java.util.ArrayList;
062 import java.util.Collections;
063 import java.util.List;
064 import java.util.Set;
065
066
078 public class DDMStructurePersistenceImpl extends BasePersistenceImpl<DDMStructure>
079 implements DDMStructurePersistence {
080
085 public static final String FINDER_CLASS_NAME_ENTITY = DDMStructureImpl.class.getName();
086 public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
087 ".List1";
088 public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
089 ".List2";
090 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
091 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
092 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
093 new String[] {
094 String.class.getName(),
095
096 "java.lang.Integer", "java.lang.Integer",
097 "com.liferay.portal.kernel.util.OrderByComparator"
098 });
099 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
100 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
101 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
102 new String[] { String.class.getName() },
103 DDMStructureModelImpl.UUID_COLUMN_BITMASK);
104 public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
105 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
106 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
107 new String[] { String.class.getName() });
108 public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
109 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
110 FINDER_CLASS_NAME_ENTITY, "fetchByUUID_G",
111 new String[] { String.class.getName(), Long.class.getName() },
112 DDMStructureModelImpl.UUID_COLUMN_BITMASK |
113 DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
114 public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
115 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
116 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
117 new String[] { String.class.getName(), Long.class.getName() });
118 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
119 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
120 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByGroupId",
121 new String[] {
122 Long.class.getName(),
123
124 "java.lang.Integer", "java.lang.Integer",
125 "com.liferay.portal.kernel.util.OrderByComparator"
126 });
127 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
128 new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
129 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
130 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
131 new String[] { Long.class.getName() },
132 DDMStructureModelImpl.GROUPID_COLUMN_BITMASK);
133 public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
134 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
135 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
136 new String[] { Long.class.getName() });
137 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID =
138 new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
139 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
140 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByClassNameId",
141 new String[] {
142 Long.class.getName(),
143
144 "java.lang.Integer", "java.lang.Integer",
145 "com.liferay.portal.kernel.util.OrderByComparator"
146 });
147 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID =
148 new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
149 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
150 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByClassNameId",
151 new String[] { Long.class.getName() },
152 DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
153 public static final FinderPath FINDER_PATH_COUNT_BY_CLASSNAMEID = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
154 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
155 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByClassNameId",
156 new String[] { Long.class.getName() });
157 public static final FinderPath FINDER_PATH_FETCH_BY_G_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
158 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
159 FINDER_CLASS_NAME_ENTITY, "fetchByG_S",
160 new String[] { Long.class.getName(), String.class.getName() },
161 DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
162 DDMStructureModelImpl.STRUCTUREKEY_COLUMN_BITMASK);
163 public static final FinderPath FINDER_PATH_COUNT_BY_G_S = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
164 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
165 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_S",
166 new String[] { Long.class.getName(), String.class.getName() });
167 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
168 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
169 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_C",
170 new String[] {
171 Long.class.getName(), Long.class.getName(),
172
173 "java.lang.Integer", "java.lang.Integer",
174 "com.liferay.portal.kernel.util.OrderByComparator"
175 });
176 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
177 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
178 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_C",
179 new String[] { Long.class.getName(), Long.class.getName() },
180 DDMStructureModelImpl.COMPANYID_COLUMN_BITMASK |
181 DDMStructureModelImpl.CLASSNAMEID_COLUMN_BITMASK);
182 public static final FinderPath FINDER_PATH_COUNT_BY_C_C = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
183 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
184 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C",
185 new String[] { Long.class.getName(), Long.class.getName() });
186 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
187 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
188 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_N_D",
189 new String[] {
190 Long.class.getName(), String.class.getName(),
191 String.class.getName(),
192
193 "java.lang.Integer", "java.lang.Integer",
194 "com.liferay.portal.kernel.util.OrderByComparator"
195 });
196 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
197 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
198 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_N_D",
199 new String[] {
200 Long.class.getName(), String.class.getName(),
201 String.class.getName()
202 },
203 DDMStructureModelImpl.GROUPID_COLUMN_BITMASK |
204 DDMStructureModelImpl.NAME_COLUMN_BITMASK |
205 DDMStructureModelImpl.DESCRIPTION_COLUMN_BITMASK);
206 public static final FinderPath FINDER_PATH_COUNT_BY_G_N_D = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
207 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
208 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N_D",
209 new String[] {
210 Long.class.getName(), String.class.getName(),
211 String.class.getName()
212 });
213 public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
214 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
215 FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
216 public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
217 DDMStructureModelImpl.FINDER_CACHE_ENABLED, DDMStructureImpl.class,
218 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
219 public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
220 DDMStructureModelImpl.FINDER_CACHE_ENABLED, Long.class,
221 FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
222
223
228 public void cacheResult(DDMStructure ddmStructure) {
229 EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
230 DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
231
232 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
233 new Object[] {
234 ddmStructure.getUuid(), Long.valueOf(ddmStructure.getGroupId())
235 }, ddmStructure);
236
237 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
238 new Object[] {
239 Long.valueOf(ddmStructure.getGroupId()),
240
241 ddmStructure.getStructureKey()
242 }, ddmStructure);
243
244 ddmStructure.resetOriginalValues();
245 }
246
247
252 public void cacheResult(List<DDMStructure> ddmStructures) {
253 for (DDMStructure ddmStructure : ddmStructures) {
254 if (EntityCacheUtil.getResult(
255 DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
256 DDMStructureImpl.class, ddmStructure.getPrimaryKey()) == null) {
257 cacheResult(ddmStructure);
258 }
259 else {
260 ddmStructure.resetOriginalValues();
261 }
262 }
263 }
264
265
272 @Override
273 public void clearCache() {
274 if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
275 CacheRegistryUtil.clear(DDMStructureImpl.class.getName());
276 }
277
278 EntityCacheUtil.clearCache(DDMStructureImpl.class.getName());
279
280 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
281 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
282 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
283 }
284
285
292 @Override
293 public void clearCache(DDMStructure ddmStructure) {
294 EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
295 DDMStructureImpl.class, ddmStructure.getPrimaryKey());
296
297 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
298 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
299
300 clearUniqueFindersCache(ddmStructure);
301 }
302
303 @Override
304 public void clearCache(List<DDMStructure> ddmStructures) {
305 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
306 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
307
308 for (DDMStructure ddmStructure : ddmStructures) {
309 EntityCacheUtil.removeResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
310 DDMStructureImpl.class, ddmStructure.getPrimaryKey());
311
312 clearUniqueFindersCache(ddmStructure);
313 }
314 }
315
316 protected void cacheUniqueFindersCache(DDMStructure ddmStructure) {
317 if (ddmStructure.isNew()) {
318 Object[] args = new Object[] {
319 ddmStructure.getUuid(),
320 Long.valueOf(ddmStructure.getGroupId())
321 };
322
323 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
324 Long.valueOf(1));
325 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
326 ddmStructure);
327
328 args = new Object[] {
329 Long.valueOf(ddmStructure.getGroupId()),
330
331 ddmStructure.getStructureKey()
332 };
333
334 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, args,
335 Long.valueOf(1));
336 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S, args,
337 ddmStructure);
338 }
339 else {
340 DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
341
342 if ((ddmStructureModelImpl.getColumnBitmask() &
343 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
344 Object[] args = new Object[] {
345 ddmStructure.getUuid(),
346 Long.valueOf(ddmStructure.getGroupId())
347 };
348
349 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G, args,
350 Long.valueOf(1));
351 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G, args,
352 ddmStructure);
353 }
354
355 if ((ddmStructureModelImpl.getColumnBitmask() &
356 FINDER_PATH_FETCH_BY_G_S.getColumnBitmask()) != 0) {
357 Object[] args = new Object[] {
358 Long.valueOf(ddmStructure.getGroupId()),
359
360 ddmStructure.getStructureKey()
361 };
362
363 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, args,
364 Long.valueOf(1));
365 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S, args,
366 ddmStructure);
367 }
368 }
369 }
370
371 protected void clearUniqueFindersCache(DDMStructure ddmStructure) {
372 DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
373
374 Object[] args = new Object[] {
375 ddmStructure.getUuid(), Long.valueOf(ddmStructure.getGroupId())
376 };
377
378 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
379 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
380
381 if ((ddmStructureModelImpl.getColumnBitmask() &
382 FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
383 args = new Object[] {
384 ddmStructureModelImpl.getOriginalUuid(),
385 Long.valueOf(ddmStructureModelImpl.getOriginalGroupId())
386 };
387
388 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
389 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
390 }
391
392 args = new Object[] {
393 Long.valueOf(ddmStructure.getGroupId()),
394
395 ddmStructure.getStructureKey()
396 };
397
398 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
399 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S, args);
400
401 if ((ddmStructureModelImpl.getColumnBitmask() &
402 FINDER_PATH_FETCH_BY_G_S.getColumnBitmask()) != 0) {
403 args = new Object[] {
404 Long.valueOf(ddmStructureModelImpl.getOriginalGroupId()),
405
406 ddmStructureModelImpl.getOriginalStructureKey()
407 };
408
409 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_S, args);
410 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S, args);
411 }
412 }
413
414
420 public DDMStructure create(long structureId) {
421 DDMStructure ddmStructure = new DDMStructureImpl();
422
423 ddmStructure.setNew(true);
424 ddmStructure.setPrimaryKey(structureId);
425
426 String uuid = PortalUUIDUtil.generate();
427
428 ddmStructure.setUuid(uuid);
429
430 return ddmStructure;
431 }
432
433
441 public DDMStructure remove(long structureId)
442 throws NoSuchStructureException, SystemException {
443 return remove(Long.valueOf(structureId));
444 }
445
446
454 @Override
455 public DDMStructure remove(Serializable primaryKey)
456 throws NoSuchStructureException, SystemException {
457 Session session = null;
458
459 try {
460 session = openSession();
461
462 DDMStructure ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
463 primaryKey);
464
465 if (ddmStructure == null) {
466 if (_log.isWarnEnabled()) {
467 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
468 }
469
470 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
471 primaryKey);
472 }
473
474 return remove(ddmStructure);
475 }
476 catch (NoSuchStructureException nsee) {
477 throw nsee;
478 }
479 catch (Exception e) {
480 throw processException(e);
481 }
482 finally {
483 closeSession(session);
484 }
485 }
486
487 @Override
488 protected DDMStructure removeImpl(DDMStructure ddmStructure)
489 throws SystemException {
490 ddmStructure = toUnwrappedModel(ddmStructure);
491
492 try {
493 clearDLFileEntryTypes.clear(ddmStructure.getPrimaryKey());
494 }
495 catch (Exception e) {
496 throw processException(e);
497 }
498 finally {
499 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
500 }
501
502 Session session = null;
503
504 try {
505 session = openSession();
506
507 BatchSessionUtil.delete(session, ddmStructure);
508 }
509 catch (Exception e) {
510 throw processException(e);
511 }
512 finally {
513 closeSession(session);
514 }
515
516 clearCache(ddmStructure);
517
518 return ddmStructure;
519 }
520
521 @Override
522 public DDMStructure updateImpl(
523 com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure,
524 boolean merge) throws SystemException {
525 ddmStructure = toUnwrappedModel(ddmStructure);
526
527 boolean isNew = ddmStructure.isNew();
528
529 DDMStructureModelImpl ddmStructureModelImpl = (DDMStructureModelImpl)ddmStructure;
530
531 if (Validator.isNull(ddmStructure.getUuid())) {
532 String uuid = PortalUUIDUtil.generate();
533
534 ddmStructure.setUuid(uuid);
535 }
536
537 Session session = null;
538
539 try {
540 session = openSession();
541
542 BatchSessionUtil.update(session, ddmStructure, merge);
543
544 ddmStructure.setNew(false);
545 }
546 catch (Exception e) {
547 throw processException(e);
548 }
549 finally {
550 closeSession(session);
551 }
552
553 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
554
555 if (isNew || !DDMStructureModelImpl.COLUMN_BITMASK_ENABLED) {
556 FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
557 }
558
559 else {
560 if ((ddmStructureModelImpl.getColumnBitmask() &
561 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
562 Object[] args = new Object[] {
563 ddmStructureModelImpl.getOriginalUuid()
564 };
565
566 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
567 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
568 args);
569
570 args = new Object[] { ddmStructureModelImpl.getUuid() };
571
572 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
573 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
574 args);
575 }
576
577 if ((ddmStructureModelImpl.getColumnBitmask() &
578 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
579 Object[] args = new Object[] {
580 Long.valueOf(ddmStructureModelImpl.getOriginalGroupId())
581 };
582
583 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
584 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
585 args);
586
587 args = new Object[] {
588 Long.valueOf(ddmStructureModelImpl.getGroupId())
589 };
590
591 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
592 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
593 args);
594 }
595
596 if ((ddmStructureModelImpl.getColumnBitmask() &
597 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID.getColumnBitmask()) != 0) {
598 Object[] args = new Object[] {
599 Long.valueOf(ddmStructureModelImpl.getOriginalClassNameId())
600 };
601
602 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
603 args);
604 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
605 args);
606
607 args = new Object[] {
608 Long.valueOf(ddmStructureModelImpl.getClassNameId())
609 };
610
611 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
612 args);
613 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID,
614 args);
615 }
616
617 if ((ddmStructureModelImpl.getColumnBitmask() &
618 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C.getColumnBitmask()) != 0) {
619 Object[] args = new Object[] {
620 Long.valueOf(ddmStructureModelImpl.getOriginalCompanyId()),
621 Long.valueOf(ddmStructureModelImpl.getOriginalClassNameId())
622 };
623
624 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
625 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
626 args);
627
628 args = new Object[] {
629 Long.valueOf(ddmStructureModelImpl.getCompanyId()),
630 Long.valueOf(ddmStructureModelImpl.getClassNameId())
631 };
632
633 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_C, args);
634 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C,
635 args);
636 }
637
638 if ((ddmStructureModelImpl.getColumnBitmask() &
639 FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D.getColumnBitmask()) != 0) {
640 Object[] args = new Object[] {
641 Long.valueOf(ddmStructureModelImpl.getOriginalGroupId()),
642
643 ddmStructureModelImpl.getOriginalName(),
644
645 ddmStructureModelImpl.getOriginalDescription()
646 };
647
648 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
649 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
650 args);
651
652 args = new Object[] {
653 Long.valueOf(ddmStructureModelImpl.getGroupId()),
654
655 ddmStructureModelImpl.getName(),
656
657 ddmStructureModelImpl.getDescription()
658 };
659
660 FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N_D, args);
661 FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D,
662 args);
663 }
664 }
665
666 EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
667 DDMStructureImpl.class, ddmStructure.getPrimaryKey(), ddmStructure);
668
669 clearUniqueFindersCache(ddmStructure);
670 cacheUniqueFindersCache(ddmStructure);
671
672 return ddmStructure;
673 }
674
675 protected DDMStructure toUnwrappedModel(DDMStructure ddmStructure) {
676 if (ddmStructure instanceof DDMStructureImpl) {
677 return ddmStructure;
678 }
679
680 DDMStructureImpl ddmStructureImpl = new DDMStructureImpl();
681
682 ddmStructureImpl.setNew(ddmStructure.isNew());
683 ddmStructureImpl.setPrimaryKey(ddmStructure.getPrimaryKey());
684
685 ddmStructureImpl.setUuid(ddmStructure.getUuid());
686 ddmStructureImpl.setStructureId(ddmStructure.getStructureId());
687 ddmStructureImpl.setGroupId(ddmStructure.getGroupId());
688 ddmStructureImpl.setCompanyId(ddmStructure.getCompanyId());
689 ddmStructureImpl.setUserId(ddmStructure.getUserId());
690 ddmStructureImpl.setUserName(ddmStructure.getUserName());
691 ddmStructureImpl.setCreateDate(ddmStructure.getCreateDate());
692 ddmStructureImpl.setModifiedDate(ddmStructure.getModifiedDate());
693 ddmStructureImpl.setClassNameId(ddmStructure.getClassNameId());
694 ddmStructureImpl.setStructureKey(ddmStructure.getStructureKey());
695 ddmStructureImpl.setName(ddmStructure.getName());
696 ddmStructureImpl.setDescription(ddmStructure.getDescription());
697 ddmStructureImpl.setXsd(ddmStructure.getXsd());
698 ddmStructureImpl.setStorageType(ddmStructure.getStorageType());
699 ddmStructureImpl.setType(ddmStructure.getType());
700
701 return ddmStructureImpl;
702 }
703
704
712 @Override
713 public DDMStructure findByPrimaryKey(Serializable primaryKey)
714 throws NoSuchModelException, SystemException {
715 return findByPrimaryKey(((Long)primaryKey).longValue());
716 }
717
718
726 public DDMStructure findByPrimaryKey(long structureId)
727 throws NoSuchStructureException, SystemException {
728 DDMStructure ddmStructure = fetchByPrimaryKey(structureId);
729
730 if (ddmStructure == null) {
731 if (_log.isWarnEnabled()) {
732 _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + structureId);
733 }
734
735 throw new NoSuchStructureException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
736 structureId);
737 }
738
739 return ddmStructure;
740 }
741
742
749 @Override
750 public DDMStructure fetchByPrimaryKey(Serializable primaryKey)
751 throws SystemException {
752 return fetchByPrimaryKey(((Long)primaryKey).longValue());
753 }
754
755
762 public DDMStructure fetchByPrimaryKey(long structureId)
763 throws SystemException {
764 DDMStructure ddmStructure = (DDMStructure)EntityCacheUtil.getResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
765 DDMStructureImpl.class, structureId);
766
767 if (ddmStructure == _nullDDMStructure) {
768 return null;
769 }
770
771 if (ddmStructure == null) {
772 Session session = null;
773
774 boolean hasException = false;
775
776 try {
777 session = openSession();
778
779 ddmStructure = (DDMStructure)session.get(DDMStructureImpl.class,
780 Long.valueOf(structureId));
781 }
782 catch (Exception e) {
783 hasException = true;
784
785 throw processException(e);
786 }
787 finally {
788 if (ddmStructure != null) {
789 cacheResult(ddmStructure);
790 }
791 else if (!hasException) {
792 EntityCacheUtil.putResult(DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
793 DDMStructureImpl.class, structureId, _nullDDMStructure);
794 }
795
796 closeSession(session);
797 }
798 }
799
800 return ddmStructure;
801 }
802
803
810 public List<DDMStructure> findByUuid(String uuid) throws SystemException {
811 return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
812 }
813
814
827 public List<DDMStructure> findByUuid(String uuid, int start, int end)
828 throws SystemException {
829 return findByUuid(uuid, start, end, null);
830 }
831
832
846 public List<DDMStructure> findByUuid(String uuid, int start, int end,
847 OrderByComparator orderByComparator) throws SystemException {
848 FinderPath finderPath = null;
849 Object[] finderArgs = null;
850
851 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
852 (orderByComparator == null)) {
853 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
854 finderArgs = new Object[] { uuid };
855 }
856 else {
857 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
858 finderArgs = new Object[] { uuid, start, end, orderByComparator };
859 }
860
861 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
862 finderArgs, this);
863
864 if ((list != null) && !list.isEmpty()) {
865 for (DDMStructure ddmStructure : list) {
866 if (!Validator.equals(uuid, ddmStructure.getUuid())) {
867 list = null;
868
869 break;
870 }
871 }
872 }
873
874 if (list == null) {
875 StringBundler query = null;
876
877 if (orderByComparator != null) {
878 query = new StringBundler(3 +
879 (orderByComparator.getOrderByFields().length * 3));
880 }
881 else {
882 query = new StringBundler(2);
883 }
884
885 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
886
887 if (uuid == null) {
888 query.append(_FINDER_COLUMN_UUID_UUID_1);
889 }
890 else {
891 if (uuid.equals(StringPool.BLANK)) {
892 query.append(_FINDER_COLUMN_UUID_UUID_3);
893 }
894 else {
895 query.append(_FINDER_COLUMN_UUID_UUID_2);
896 }
897 }
898
899 if (orderByComparator != null) {
900 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
901 orderByComparator);
902 }
903
904 String sql = query.toString();
905
906 Session session = null;
907
908 try {
909 session = openSession();
910
911 Query q = session.createQuery(sql);
912
913 QueryPos qPos = QueryPos.getInstance(q);
914
915 if (uuid != null) {
916 qPos.add(uuid);
917 }
918
919 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
920 start, end);
921 }
922 catch (Exception e) {
923 throw processException(e);
924 }
925 finally {
926 if (list == null) {
927 FinderCacheUtil.removeResult(finderPath, finderArgs);
928 }
929 else {
930 cacheResult(list);
931
932 FinderCacheUtil.putResult(finderPath, finderArgs, list);
933 }
934
935 closeSession(session);
936 }
937 }
938
939 return list;
940 }
941
942
951 public DDMStructure findByUuid_First(String uuid,
952 OrderByComparator orderByComparator)
953 throws NoSuchStructureException, SystemException {
954 DDMStructure ddmStructure = fetchByUuid_First(uuid, orderByComparator);
955
956 if (ddmStructure != null) {
957 return ddmStructure;
958 }
959
960 StringBundler msg = new StringBundler(4);
961
962 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
963
964 msg.append("uuid=");
965 msg.append(uuid);
966
967 msg.append(StringPool.CLOSE_CURLY_BRACE);
968
969 throw new NoSuchStructureException(msg.toString());
970 }
971
972
980 public DDMStructure fetchByUuid_First(String uuid,
981 OrderByComparator orderByComparator) throws SystemException {
982 List<DDMStructure> list = findByUuid(uuid, 0, 1, orderByComparator);
983
984 if (!list.isEmpty()) {
985 return list.get(0);
986 }
987
988 return null;
989 }
990
991
1000 public DDMStructure findByUuid_Last(String uuid,
1001 OrderByComparator orderByComparator)
1002 throws NoSuchStructureException, SystemException {
1003 DDMStructure ddmStructure = fetchByUuid_Last(uuid, orderByComparator);
1004
1005 if (ddmStructure != null) {
1006 return ddmStructure;
1007 }
1008
1009 StringBundler msg = new StringBundler(4);
1010
1011 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1012
1013 msg.append("uuid=");
1014 msg.append(uuid);
1015
1016 msg.append(StringPool.CLOSE_CURLY_BRACE);
1017
1018 throw new NoSuchStructureException(msg.toString());
1019 }
1020
1021
1029 public DDMStructure fetchByUuid_Last(String uuid,
1030 OrderByComparator orderByComparator) throws SystemException {
1031 int count = countByUuid(uuid);
1032
1033 List<DDMStructure> list = findByUuid(uuid, count - 1, count,
1034 orderByComparator);
1035
1036 if (!list.isEmpty()) {
1037 return list.get(0);
1038 }
1039
1040 return null;
1041 }
1042
1043
1053 public DDMStructure[] findByUuid_PrevAndNext(long structureId, String uuid,
1054 OrderByComparator orderByComparator)
1055 throws NoSuchStructureException, SystemException {
1056 DDMStructure ddmStructure = findByPrimaryKey(structureId);
1057
1058 Session session = null;
1059
1060 try {
1061 session = openSession();
1062
1063 DDMStructure[] array = new DDMStructureImpl[3];
1064
1065 array[0] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
1066 orderByComparator, true);
1067
1068 array[1] = ddmStructure;
1069
1070 array[2] = getByUuid_PrevAndNext(session, ddmStructure, uuid,
1071 orderByComparator, false);
1072
1073 return array;
1074 }
1075 catch (Exception e) {
1076 throw processException(e);
1077 }
1078 finally {
1079 closeSession(session);
1080 }
1081 }
1082
1083 protected DDMStructure getByUuid_PrevAndNext(Session session,
1084 DDMStructure ddmStructure, String uuid,
1085 OrderByComparator orderByComparator, boolean previous) {
1086 StringBundler query = null;
1087
1088 if (orderByComparator != null) {
1089 query = new StringBundler(6 +
1090 (orderByComparator.getOrderByFields().length * 6));
1091 }
1092 else {
1093 query = new StringBundler(3);
1094 }
1095
1096 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1097
1098 if (uuid == null) {
1099 query.append(_FINDER_COLUMN_UUID_UUID_1);
1100 }
1101 else {
1102 if (uuid.equals(StringPool.BLANK)) {
1103 query.append(_FINDER_COLUMN_UUID_UUID_3);
1104 }
1105 else {
1106 query.append(_FINDER_COLUMN_UUID_UUID_2);
1107 }
1108 }
1109
1110 if (orderByComparator != null) {
1111 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1112
1113 if (orderByConditionFields.length > 0) {
1114 query.append(WHERE_AND);
1115 }
1116
1117 for (int i = 0; i < orderByConditionFields.length; i++) {
1118 query.append(_ORDER_BY_ENTITY_ALIAS);
1119 query.append(orderByConditionFields[i]);
1120
1121 if ((i + 1) < orderByConditionFields.length) {
1122 if (orderByComparator.isAscending() ^ previous) {
1123 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1124 }
1125 else {
1126 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1127 }
1128 }
1129 else {
1130 if (orderByComparator.isAscending() ^ previous) {
1131 query.append(WHERE_GREATER_THAN);
1132 }
1133 else {
1134 query.append(WHERE_LESSER_THAN);
1135 }
1136 }
1137 }
1138
1139 query.append(ORDER_BY_CLAUSE);
1140
1141 String[] orderByFields = orderByComparator.getOrderByFields();
1142
1143 for (int i = 0; i < orderByFields.length; i++) {
1144 query.append(_ORDER_BY_ENTITY_ALIAS);
1145 query.append(orderByFields[i]);
1146
1147 if ((i + 1) < orderByFields.length) {
1148 if (orderByComparator.isAscending() ^ previous) {
1149 query.append(ORDER_BY_ASC_HAS_NEXT);
1150 }
1151 else {
1152 query.append(ORDER_BY_DESC_HAS_NEXT);
1153 }
1154 }
1155 else {
1156 if (orderByComparator.isAscending() ^ previous) {
1157 query.append(ORDER_BY_ASC);
1158 }
1159 else {
1160 query.append(ORDER_BY_DESC);
1161 }
1162 }
1163 }
1164 }
1165
1166 String sql = query.toString();
1167
1168 Query q = session.createQuery(sql);
1169
1170 q.setFirstResult(0);
1171 q.setMaxResults(2);
1172
1173 QueryPos qPos = QueryPos.getInstance(q);
1174
1175 if (uuid != null) {
1176 qPos.add(uuid);
1177 }
1178
1179 if (orderByComparator != null) {
1180 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1181
1182 for (Object value : values) {
1183 qPos.add(value);
1184 }
1185 }
1186
1187 List<DDMStructure> list = q.list();
1188
1189 if (list.size() == 2) {
1190 return list.get(1);
1191 }
1192 else {
1193 return null;
1194 }
1195 }
1196
1197
1206 public DDMStructure findByUUID_G(String uuid, long groupId)
1207 throws NoSuchStructureException, SystemException {
1208 DDMStructure ddmStructure = fetchByUUID_G(uuid, groupId);
1209
1210 if (ddmStructure == null) {
1211 StringBundler msg = new StringBundler(6);
1212
1213 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1214
1215 msg.append("uuid=");
1216 msg.append(uuid);
1217
1218 msg.append(", groupId=");
1219 msg.append(groupId);
1220
1221 msg.append(StringPool.CLOSE_CURLY_BRACE);
1222
1223 if (_log.isWarnEnabled()) {
1224 _log.warn(msg.toString());
1225 }
1226
1227 throw new NoSuchStructureException(msg.toString());
1228 }
1229
1230 return ddmStructure;
1231 }
1232
1233
1241 public DDMStructure fetchByUUID_G(String uuid, long groupId)
1242 throws SystemException {
1243 return fetchByUUID_G(uuid, groupId, true);
1244 }
1245
1246
1255 public DDMStructure fetchByUUID_G(String uuid, long groupId,
1256 boolean retrieveFromCache) throws SystemException {
1257 Object[] finderArgs = new Object[] { uuid, groupId };
1258
1259 Object result = null;
1260
1261 if (retrieveFromCache) {
1262 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1263 finderArgs, this);
1264 }
1265
1266 if (result instanceof DDMStructure) {
1267 DDMStructure ddmStructure = (DDMStructure)result;
1268
1269 if (!Validator.equals(uuid, ddmStructure.getUuid()) ||
1270 (groupId != ddmStructure.getGroupId())) {
1271 result = null;
1272 }
1273 }
1274
1275 if (result == null) {
1276 StringBundler query = new StringBundler(3);
1277
1278 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1279
1280 if (uuid == null) {
1281 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1282 }
1283 else {
1284 if (uuid.equals(StringPool.BLANK)) {
1285 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1286 }
1287 else {
1288 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1289 }
1290 }
1291
1292 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1293
1294 String sql = query.toString();
1295
1296 Session session = null;
1297
1298 try {
1299 session = openSession();
1300
1301 Query q = session.createQuery(sql);
1302
1303 QueryPos qPos = QueryPos.getInstance(q);
1304
1305 if (uuid != null) {
1306 qPos.add(uuid);
1307 }
1308
1309 qPos.add(groupId);
1310
1311 List<DDMStructure> list = q.list();
1312
1313 result = list;
1314
1315 DDMStructure ddmStructure = null;
1316
1317 if (list.isEmpty()) {
1318 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1319 finderArgs, list);
1320 }
1321 else {
1322 ddmStructure = list.get(0);
1323
1324 cacheResult(ddmStructure);
1325
1326 if ((ddmStructure.getUuid() == null) ||
1327 !ddmStructure.getUuid().equals(uuid) ||
1328 (ddmStructure.getGroupId() != groupId)) {
1329 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1330 finderArgs, ddmStructure);
1331 }
1332 }
1333
1334 return ddmStructure;
1335 }
1336 catch (Exception e) {
1337 throw processException(e);
1338 }
1339 finally {
1340 if (result == null) {
1341 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1342 finderArgs);
1343 }
1344
1345 closeSession(session);
1346 }
1347 }
1348 else {
1349 if (result instanceof List<?>) {
1350 return null;
1351 }
1352 else {
1353 return (DDMStructure)result;
1354 }
1355 }
1356 }
1357
1358
1365 public List<DDMStructure> findByGroupId(long groupId)
1366 throws SystemException {
1367 return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1368 }
1369
1370
1383 public List<DDMStructure> findByGroupId(long groupId, int start, int end)
1384 throws SystemException {
1385 return findByGroupId(groupId, start, end, null);
1386 }
1387
1388
1402 public List<DDMStructure> findByGroupId(long groupId, int start, int end,
1403 OrderByComparator orderByComparator) throws SystemException {
1404 FinderPath finderPath = null;
1405 Object[] finderArgs = null;
1406
1407 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1408 (orderByComparator == null)) {
1409 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1410 finderArgs = new Object[] { groupId };
1411 }
1412 else {
1413 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1414 finderArgs = new Object[] { groupId, start, end, orderByComparator };
1415 }
1416
1417 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
1418 finderArgs, this);
1419
1420 if ((list != null) && !list.isEmpty()) {
1421 for (DDMStructure ddmStructure : list) {
1422 if ((groupId != ddmStructure.getGroupId())) {
1423 list = null;
1424
1425 break;
1426 }
1427 }
1428 }
1429
1430 if (list == null) {
1431 StringBundler query = null;
1432
1433 if (orderByComparator != null) {
1434 query = new StringBundler(3 +
1435 (orderByComparator.getOrderByFields().length * 3));
1436 }
1437 else {
1438 query = new StringBundler(2);
1439 }
1440
1441 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1442
1443 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1444
1445 if (orderByComparator != null) {
1446 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1447 orderByComparator);
1448 }
1449
1450 String sql = query.toString();
1451
1452 Session session = null;
1453
1454 try {
1455 session = openSession();
1456
1457 Query q = session.createQuery(sql);
1458
1459 QueryPos qPos = QueryPos.getInstance(q);
1460
1461 qPos.add(groupId);
1462
1463 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
1464 start, end);
1465 }
1466 catch (Exception e) {
1467 throw processException(e);
1468 }
1469 finally {
1470 if (list == null) {
1471 FinderCacheUtil.removeResult(finderPath, finderArgs);
1472 }
1473 else {
1474 cacheResult(list);
1475
1476 FinderCacheUtil.putResult(finderPath, finderArgs, list);
1477 }
1478
1479 closeSession(session);
1480 }
1481 }
1482
1483 return list;
1484 }
1485
1486
1495 public DDMStructure findByGroupId_First(long groupId,
1496 OrderByComparator orderByComparator)
1497 throws NoSuchStructureException, SystemException {
1498 DDMStructure ddmStructure = fetchByGroupId_First(groupId,
1499 orderByComparator);
1500
1501 if (ddmStructure != null) {
1502 return ddmStructure;
1503 }
1504
1505 StringBundler msg = new StringBundler(4);
1506
1507 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1508
1509 msg.append("groupId=");
1510 msg.append(groupId);
1511
1512 msg.append(StringPool.CLOSE_CURLY_BRACE);
1513
1514 throw new NoSuchStructureException(msg.toString());
1515 }
1516
1517
1525 public DDMStructure fetchByGroupId_First(long groupId,
1526 OrderByComparator orderByComparator) throws SystemException {
1527 List<DDMStructure> list = findByGroupId(groupId, 0, 1, orderByComparator);
1528
1529 if (!list.isEmpty()) {
1530 return list.get(0);
1531 }
1532
1533 return null;
1534 }
1535
1536
1545 public DDMStructure findByGroupId_Last(long groupId,
1546 OrderByComparator orderByComparator)
1547 throws NoSuchStructureException, SystemException {
1548 DDMStructure ddmStructure = fetchByGroupId_Last(groupId,
1549 orderByComparator);
1550
1551 if (ddmStructure != null) {
1552 return ddmStructure;
1553 }
1554
1555 StringBundler msg = new StringBundler(4);
1556
1557 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1558
1559 msg.append("groupId=");
1560 msg.append(groupId);
1561
1562 msg.append(StringPool.CLOSE_CURLY_BRACE);
1563
1564 throw new NoSuchStructureException(msg.toString());
1565 }
1566
1567
1575 public DDMStructure fetchByGroupId_Last(long groupId,
1576 OrderByComparator orderByComparator) throws SystemException {
1577 int count = countByGroupId(groupId);
1578
1579 List<DDMStructure> list = findByGroupId(groupId, count - 1, count,
1580 orderByComparator);
1581
1582 if (!list.isEmpty()) {
1583 return list.get(0);
1584 }
1585
1586 return null;
1587 }
1588
1589
1599 public DDMStructure[] findByGroupId_PrevAndNext(long structureId,
1600 long groupId, OrderByComparator orderByComparator)
1601 throws NoSuchStructureException, SystemException {
1602 DDMStructure ddmStructure = findByPrimaryKey(structureId);
1603
1604 Session session = null;
1605
1606 try {
1607 session = openSession();
1608
1609 DDMStructure[] array = new DDMStructureImpl[3];
1610
1611 array[0] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
1612 orderByComparator, true);
1613
1614 array[1] = ddmStructure;
1615
1616 array[2] = getByGroupId_PrevAndNext(session, ddmStructure, groupId,
1617 orderByComparator, false);
1618
1619 return array;
1620 }
1621 catch (Exception e) {
1622 throw processException(e);
1623 }
1624 finally {
1625 closeSession(session);
1626 }
1627 }
1628
1629 protected DDMStructure getByGroupId_PrevAndNext(Session session,
1630 DDMStructure ddmStructure, long groupId,
1631 OrderByComparator orderByComparator, boolean previous) {
1632 StringBundler query = null;
1633
1634 if (orderByComparator != null) {
1635 query = new StringBundler(6 +
1636 (orderByComparator.getOrderByFields().length * 6));
1637 }
1638 else {
1639 query = new StringBundler(3);
1640 }
1641
1642 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
1643
1644 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1645
1646 if (orderByComparator != null) {
1647 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1648
1649 if (orderByConditionFields.length > 0) {
1650 query.append(WHERE_AND);
1651 }
1652
1653 for (int i = 0; i < orderByConditionFields.length; i++) {
1654 query.append(_ORDER_BY_ENTITY_ALIAS);
1655 query.append(orderByConditionFields[i]);
1656
1657 if ((i + 1) < orderByConditionFields.length) {
1658 if (orderByComparator.isAscending() ^ previous) {
1659 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1660 }
1661 else {
1662 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1663 }
1664 }
1665 else {
1666 if (orderByComparator.isAscending() ^ previous) {
1667 query.append(WHERE_GREATER_THAN);
1668 }
1669 else {
1670 query.append(WHERE_LESSER_THAN);
1671 }
1672 }
1673 }
1674
1675 query.append(ORDER_BY_CLAUSE);
1676
1677 String[] orderByFields = orderByComparator.getOrderByFields();
1678
1679 for (int i = 0; i < orderByFields.length; i++) {
1680 query.append(_ORDER_BY_ENTITY_ALIAS);
1681 query.append(orderByFields[i]);
1682
1683 if ((i + 1) < orderByFields.length) {
1684 if (orderByComparator.isAscending() ^ previous) {
1685 query.append(ORDER_BY_ASC_HAS_NEXT);
1686 }
1687 else {
1688 query.append(ORDER_BY_DESC_HAS_NEXT);
1689 }
1690 }
1691 else {
1692 if (orderByComparator.isAscending() ^ previous) {
1693 query.append(ORDER_BY_ASC);
1694 }
1695 else {
1696 query.append(ORDER_BY_DESC);
1697 }
1698 }
1699 }
1700 }
1701
1702 String sql = query.toString();
1703
1704 Query q = session.createQuery(sql);
1705
1706 q.setFirstResult(0);
1707 q.setMaxResults(2);
1708
1709 QueryPos qPos = QueryPos.getInstance(q);
1710
1711 qPos.add(groupId);
1712
1713 if (orderByComparator != null) {
1714 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
1715
1716 for (Object value : values) {
1717 qPos.add(value);
1718 }
1719 }
1720
1721 List<DDMStructure> list = q.list();
1722
1723 if (list.size() == 2) {
1724 return list.get(1);
1725 }
1726 else {
1727 return null;
1728 }
1729 }
1730
1731
1738 public List<DDMStructure> filterFindByGroupId(long groupId)
1739 throws SystemException {
1740 return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1741 QueryUtil.ALL_POS, null);
1742 }
1743
1744
1757 public List<DDMStructure> filterFindByGroupId(long groupId, int start,
1758 int end) throws SystemException {
1759 return filterFindByGroupId(groupId, start, end, null);
1760 }
1761
1762
1776 public List<DDMStructure> filterFindByGroupId(long groupId, int start,
1777 int end, OrderByComparator orderByComparator) throws SystemException {
1778 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1779 return findByGroupId(groupId, start, end, orderByComparator);
1780 }
1781
1782 StringBundler query = null;
1783
1784 if (orderByComparator != null) {
1785 query = new StringBundler(3 +
1786 (orderByComparator.getOrderByFields().length * 3));
1787 }
1788 else {
1789 query = new StringBundler(2);
1790 }
1791
1792 if (getDB().isSupportsInlineDistinct()) {
1793 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
1794 }
1795 else {
1796 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
1797 }
1798
1799 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1800
1801 if (!getDB().isSupportsInlineDistinct()) {
1802 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
1803 }
1804
1805 if (orderByComparator != null) {
1806 if (getDB().isSupportsInlineDistinct()) {
1807 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1808 orderByComparator);
1809 }
1810 else {
1811 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1812 orderByComparator);
1813 }
1814 }
1815
1816 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1817 DDMStructure.class.getName(),
1818 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1819
1820 Session session = null;
1821
1822 try {
1823 session = openSession();
1824
1825 SQLQuery q = session.createSQLQuery(sql);
1826
1827 if (getDB().isSupportsInlineDistinct()) {
1828 q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
1829 }
1830 else {
1831 q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
1832 }
1833
1834 QueryPos qPos = QueryPos.getInstance(q);
1835
1836 qPos.add(groupId);
1837
1838 return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
1839 end);
1840 }
1841 catch (Exception e) {
1842 throw processException(e);
1843 }
1844 finally {
1845 closeSession(session);
1846 }
1847 }
1848
1849
1859 public DDMStructure[] filterFindByGroupId_PrevAndNext(long structureId,
1860 long groupId, OrderByComparator orderByComparator)
1861 throws NoSuchStructureException, SystemException {
1862 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1863 return findByGroupId_PrevAndNext(structureId, groupId,
1864 orderByComparator);
1865 }
1866
1867 DDMStructure ddmStructure = findByPrimaryKey(structureId);
1868
1869 Session session = null;
1870
1871 try {
1872 session = openSession();
1873
1874 DDMStructure[] array = new DDMStructureImpl[3];
1875
1876 array[0] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
1877 groupId, orderByComparator, true);
1878
1879 array[1] = ddmStructure;
1880
1881 array[2] = filterGetByGroupId_PrevAndNext(session, ddmStructure,
1882 groupId, orderByComparator, false);
1883
1884 return array;
1885 }
1886 catch (Exception e) {
1887 throw processException(e);
1888 }
1889 finally {
1890 closeSession(session);
1891 }
1892 }
1893
1894 protected DDMStructure filterGetByGroupId_PrevAndNext(Session session,
1895 DDMStructure ddmStructure, long groupId,
1896 OrderByComparator orderByComparator, boolean previous) {
1897 StringBundler query = null;
1898
1899 if (orderByComparator != null) {
1900 query = new StringBundler(6 +
1901 (orderByComparator.getOrderByFields().length * 6));
1902 }
1903 else {
1904 query = new StringBundler(3);
1905 }
1906
1907 if (getDB().isSupportsInlineDistinct()) {
1908 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
1909 }
1910 else {
1911 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
1912 }
1913
1914 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1915
1916 if (!getDB().isSupportsInlineDistinct()) {
1917 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
1918 }
1919
1920 if (orderByComparator != null) {
1921 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1922
1923 if (orderByConditionFields.length > 0) {
1924 query.append(WHERE_AND);
1925 }
1926
1927 for (int i = 0; i < orderByConditionFields.length; i++) {
1928 if (getDB().isSupportsInlineDistinct()) {
1929 query.append(_ORDER_BY_ENTITY_ALIAS);
1930 }
1931 else {
1932 query.append(_ORDER_BY_ENTITY_TABLE);
1933 }
1934
1935 query.append(orderByConditionFields[i]);
1936
1937 if ((i + 1) < orderByConditionFields.length) {
1938 if (orderByComparator.isAscending() ^ previous) {
1939 query.append(WHERE_GREATER_THAN_HAS_NEXT);
1940 }
1941 else {
1942 query.append(WHERE_LESSER_THAN_HAS_NEXT);
1943 }
1944 }
1945 else {
1946 if (orderByComparator.isAscending() ^ previous) {
1947 query.append(WHERE_GREATER_THAN);
1948 }
1949 else {
1950 query.append(WHERE_LESSER_THAN);
1951 }
1952 }
1953 }
1954
1955 query.append(ORDER_BY_CLAUSE);
1956
1957 String[] orderByFields = orderByComparator.getOrderByFields();
1958
1959 for (int i = 0; i < orderByFields.length; i++) {
1960 if (getDB().isSupportsInlineDistinct()) {
1961 query.append(_ORDER_BY_ENTITY_ALIAS);
1962 }
1963 else {
1964 query.append(_ORDER_BY_ENTITY_TABLE);
1965 }
1966
1967 query.append(orderByFields[i]);
1968
1969 if ((i + 1) < orderByFields.length) {
1970 if (orderByComparator.isAscending() ^ previous) {
1971 query.append(ORDER_BY_ASC_HAS_NEXT);
1972 }
1973 else {
1974 query.append(ORDER_BY_DESC_HAS_NEXT);
1975 }
1976 }
1977 else {
1978 if (orderByComparator.isAscending() ^ previous) {
1979 query.append(ORDER_BY_ASC);
1980 }
1981 else {
1982 query.append(ORDER_BY_DESC);
1983 }
1984 }
1985 }
1986 }
1987
1988 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1989 DDMStructure.class.getName(),
1990 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1991
1992 SQLQuery q = session.createSQLQuery(sql);
1993
1994 q.setFirstResult(0);
1995 q.setMaxResults(2);
1996
1997 if (getDB().isSupportsInlineDistinct()) {
1998 q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
1999 }
2000 else {
2001 q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
2002 }
2003
2004 QueryPos qPos = QueryPos.getInstance(q);
2005
2006 qPos.add(groupId);
2007
2008 if (orderByComparator != null) {
2009 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2010
2011 for (Object value : values) {
2012 qPos.add(value);
2013 }
2014 }
2015
2016 List<DDMStructure> list = q.list();
2017
2018 if (list.size() == 2) {
2019 return list.get(1);
2020 }
2021 else {
2022 return null;
2023 }
2024 }
2025
2026
2033 public List<DDMStructure> findByClassNameId(long classNameId)
2034 throws SystemException {
2035 return findByClassNameId(classNameId, QueryUtil.ALL_POS,
2036 QueryUtil.ALL_POS, null);
2037 }
2038
2039
2052 public List<DDMStructure> findByClassNameId(long classNameId, int start,
2053 int end) throws SystemException {
2054 return findByClassNameId(classNameId, start, end, null);
2055 }
2056
2057
2071 public List<DDMStructure> findByClassNameId(long classNameId, int start,
2072 int end, OrderByComparator orderByComparator) throws SystemException {
2073 FinderPath finderPath = null;
2074 Object[] finderArgs = null;
2075
2076 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2077 (orderByComparator == null)) {
2078 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CLASSNAMEID;
2079 finderArgs = new Object[] { classNameId };
2080 }
2081 else {
2082 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_CLASSNAMEID;
2083 finderArgs = new Object[] { classNameId, start, end, orderByComparator };
2084 }
2085
2086 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
2087 finderArgs, this);
2088
2089 if ((list != null) && !list.isEmpty()) {
2090 for (DDMStructure ddmStructure : list) {
2091 if ((classNameId != ddmStructure.getClassNameId())) {
2092 list = null;
2093
2094 break;
2095 }
2096 }
2097 }
2098
2099 if (list == null) {
2100 StringBundler query = null;
2101
2102 if (orderByComparator != null) {
2103 query = new StringBundler(3 +
2104 (orderByComparator.getOrderByFields().length * 3));
2105 }
2106 else {
2107 query = new StringBundler(2);
2108 }
2109
2110 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2111
2112 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
2113
2114 if (orderByComparator != null) {
2115 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2116 orderByComparator);
2117 }
2118
2119 String sql = query.toString();
2120
2121 Session session = null;
2122
2123 try {
2124 session = openSession();
2125
2126 Query q = session.createQuery(sql);
2127
2128 QueryPos qPos = QueryPos.getInstance(q);
2129
2130 qPos.add(classNameId);
2131
2132 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2133 start, end);
2134 }
2135 catch (Exception e) {
2136 throw processException(e);
2137 }
2138 finally {
2139 if (list == null) {
2140 FinderCacheUtil.removeResult(finderPath, finderArgs);
2141 }
2142 else {
2143 cacheResult(list);
2144
2145 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2146 }
2147
2148 closeSession(session);
2149 }
2150 }
2151
2152 return list;
2153 }
2154
2155
2164 public DDMStructure findByClassNameId_First(long classNameId,
2165 OrderByComparator orderByComparator)
2166 throws NoSuchStructureException, SystemException {
2167 DDMStructure ddmStructure = fetchByClassNameId_First(classNameId,
2168 orderByComparator);
2169
2170 if (ddmStructure != null) {
2171 return ddmStructure;
2172 }
2173
2174 StringBundler msg = new StringBundler(4);
2175
2176 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2177
2178 msg.append("classNameId=");
2179 msg.append(classNameId);
2180
2181 msg.append(StringPool.CLOSE_CURLY_BRACE);
2182
2183 throw new NoSuchStructureException(msg.toString());
2184 }
2185
2186
2194 public DDMStructure fetchByClassNameId_First(long classNameId,
2195 OrderByComparator orderByComparator) throws SystemException {
2196 List<DDMStructure> list = findByClassNameId(classNameId, 0, 1,
2197 orderByComparator);
2198
2199 if (!list.isEmpty()) {
2200 return list.get(0);
2201 }
2202
2203 return null;
2204 }
2205
2206
2215 public DDMStructure findByClassNameId_Last(long classNameId,
2216 OrderByComparator orderByComparator)
2217 throws NoSuchStructureException, SystemException {
2218 DDMStructure ddmStructure = fetchByClassNameId_Last(classNameId,
2219 orderByComparator);
2220
2221 if (ddmStructure != null) {
2222 return ddmStructure;
2223 }
2224
2225 StringBundler msg = new StringBundler(4);
2226
2227 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2228
2229 msg.append("classNameId=");
2230 msg.append(classNameId);
2231
2232 msg.append(StringPool.CLOSE_CURLY_BRACE);
2233
2234 throw new NoSuchStructureException(msg.toString());
2235 }
2236
2237
2245 public DDMStructure fetchByClassNameId_Last(long classNameId,
2246 OrderByComparator orderByComparator) throws SystemException {
2247 int count = countByClassNameId(classNameId);
2248
2249 List<DDMStructure> list = findByClassNameId(classNameId, count - 1,
2250 count, orderByComparator);
2251
2252 if (!list.isEmpty()) {
2253 return list.get(0);
2254 }
2255
2256 return null;
2257 }
2258
2259
2269 public DDMStructure[] findByClassNameId_PrevAndNext(long structureId,
2270 long classNameId, OrderByComparator orderByComparator)
2271 throws NoSuchStructureException, SystemException {
2272 DDMStructure ddmStructure = findByPrimaryKey(structureId);
2273
2274 Session session = null;
2275
2276 try {
2277 session = openSession();
2278
2279 DDMStructure[] array = new DDMStructureImpl[3];
2280
2281 array[0] = getByClassNameId_PrevAndNext(session, ddmStructure,
2282 classNameId, orderByComparator, true);
2283
2284 array[1] = ddmStructure;
2285
2286 array[2] = getByClassNameId_PrevAndNext(session, ddmStructure,
2287 classNameId, orderByComparator, false);
2288
2289 return array;
2290 }
2291 catch (Exception e) {
2292 throw processException(e);
2293 }
2294 finally {
2295 closeSession(session);
2296 }
2297 }
2298
2299 protected DDMStructure getByClassNameId_PrevAndNext(Session session,
2300 DDMStructure ddmStructure, long classNameId,
2301 OrderByComparator orderByComparator, boolean previous) {
2302 StringBundler query = null;
2303
2304 if (orderByComparator != null) {
2305 query = new StringBundler(6 +
2306 (orderByComparator.getOrderByFields().length * 6));
2307 }
2308 else {
2309 query = new StringBundler(3);
2310 }
2311
2312 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2313
2314 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
2315
2316 if (orderByComparator != null) {
2317 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2318
2319 if (orderByConditionFields.length > 0) {
2320 query.append(WHERE_AND);
2321 }
2322
2323 for (int i = 0; i < orderByConditionFields.length; i++) {
2324 query.append(_ORDER_BY_ENTITY_ALIAS);
2325 query.append(orderByConditionFields[i]);
2326
2327 if ((i + 1) < orderByConditionFields.length) {
2328 if (orderByComparator.isAscending() ^ previous) {
2329 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2330 }
2331 else {
2332 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2333 }
2334 }
2335 else {
2336 if (orderByComparator.isAscending() ^ previous) {
2337 query.append(WHERE_GREATER_THAN);
2338 }
2339 else {
2340 query.append(WHERE_LESSER_THAN);
2341 }
2342 }
2343 }
2344
2345 query.append(ORDER_BY_CLAUSE);
2346
2347 String[] orderByFields = orderByComparator.getOrderByFields();
2348
2349 for (int i = 0; i < orderByFields.length; i++) {
2350 query.append(_ORDER_BY_ENTITY_ALIAS);
2351 query.append(orderByFields[i]);
2352
2353 if ((i + 1) < orderByFields.length) {
2354 if (orderByComparator.isAscending() ^ previous) {
2355 query.append(ORDER_BY_ASC_HAS_NEXT);
2356 }
2357 else {
2358 query.append(ORDER_BY_DESC_HAS_NEXT);
2359 }
2360 }
2361 else {
2362 if (orderByComparator.isAscending() ^ previous) {
2363 query.append(ORDER_BY_ASC);
2364 }
2365 else {
2366 query.append(ORDER_BY_DESC);
2367 }
2368 }
2369 }
2370 }
2371
2372 String sql = query.toString();
2373
2374 Query q = session.createQuery(sql);
2375
2376 q.setFirstResult(0);
2377 q.setMaxResults(2);
2378
2379 QueryPos qPos = QueryPos.getInstance(q);
2380
2381 qPos.add(classNameId);
2382
2383 if (orderByComparator != null) {
2384 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2385
2386 for (Object value : values) {
2387 qPos.add(value);
2388 }
2389 }
2390
2391 List<DDMStructure> list = q.list();
2392
2393 if (list.size() == 2) {
2394 return list.get(1);
2395 }
2396 else {
2397 return null;
2398 }
2399 }
2400
2401
2410 public DDMStructure findByG_S(long groupId, String structureKey)
2411 throws NoSuchStructureException, SystemException {
2412 DDMStructure ddmStructure = fetchByG_S(groupId, structureKey);
2413
2414 if (ddmStructure == null) {
2415 StringBundler msg = new StringBundler(6);
2416
2417 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2418
2419 msg.append("groupId=");
2420 msg.append(groupId);
2421
2422 msg.append(", structureKey=");
2423 msg.append(structureKey);
2424
2425 msg.append(StringPool.CLOSE_CURLY_BRACE);
2426
2427 if (_log.isWarnEnabled()) {
2428 _log.warn(msg.toString());
2429 }
2430
2431 throw new NoSuchStructureException(msg.toString());
2432 }
2433
2434 return ddmStructure;
2435 }
2436
2437
2445 public DDMStructure fetchByG_S(long groupId, String structureKey)
2446 throws SystemException {
2447 return fetchByG_S(groupId, structureKey, true);
2448 }
2449
2450
2459 public DDMStructure fetchByG_S(long groupId, String structureKey,
2460 boolean retrieveFromCache) throws SystemException {
2461 Object[] finderArgs = new Object[] { groupId, structureKey };
2462
2463 Object result = null;
2464
2465 if (retrieveFromCache) {
2466 result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_S,
2467 finderArgs, this);
2468 }
2469
2470 if (result instanceof DDMStructure) {
2471 DDMStructure ddmStructure = (DDMStructure)result;
2472
2473 if ((groupId != ddmStructure.getGroupId()) ||
2474 !Validator.equals(structureKey,
2475 ddmStructure.getStructureKey())) {
2476 result = null;
2477 }
2478 }
2479
2480 if (result == null) {
2481 StringBundler query = new StringBundler(3);
2482
2483 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2484
2485 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
2486
2487 if (structureKey == null) {
2488 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_1);
2489 }
2490 else {
2491 if (structureKey.equals(StringPool.BLANK)) {
2492 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_3);
2493 }
2494 else {
2495 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_2);
2496 }
2497 }
2498
2499 String sql = query.toString();
2500
2501 Session session = null;
2502
2503 try {
2504 session = openSession();
2505
2506 Query q = session.createQuery(sql);
2507
2508 QueryPos qPos = QueryPos.getInstance(q);
2509
2510 qPos.add(groupId);
2511
2512 if (structureKey != null) {
2513 qPos.add(structureKey);
2514 }
2515
2516 List<DDMStructure> list = q.list();
2517
2518 result = list;
2519
2520 DDMStructure ddmStructure = null;
2521
2522 if (list.isEmpty()) {
2523 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
2524 finderArgs, list);
2525 }
2526 else {
2527 ddmStructure = list.get(0);
2528
2529 cacheResult(ddmStructure);
2530
2531 if ((ddmStructure.getGroupId() != groupId) ||
2532 (ddmStructure.getStructureKey() == null) ||
2533 !ddmStructure.getStructureKey().equals(structureKey)) {
2534 FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_S,
2535 finderArgs, ddmStructure);
2536 }
2537 }
2538
2539 return ddmStructure;
2540 }
2541 catch (Exception e) {
2542 throw processException(e);
2543 }
2544 finally {
2545 if (result == null) {
2546 FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_S,
2547 finderArgs);
2548 }
2549
2550 closeSession(session);
2551 }
2552 }
2553 else {
2554 if (result instanceof List<?>) {
2555 return null;
2556 }
2557 else {
2558 return (DDMStructure)result;
2559 }
2560 }
2561 }
2562
2563
2571 public List<DDMStructure> findByC_C(long companyId, long classNameId)
2572 throws SystemException {
2573 return findByC_C(companyId, classNameId, QueryUtil.ALL_POS,
2574 QueryUtil.ALL_POS, null);
2575 }
2576
2577
2591 public List<DDMStructure> findByC_C(long companyId, long classNameId,
2592 int start, int end) throws SystemException {
2593 return findByC_C(companyId, classNameId, start, end, null);
2594 }
2595
2596
2611 public List<DDMStructure> findByC_C(long companyId, long classNameId,
2612 int start, int end, OrderByComparator orderByComparator)
2613 throws SystemException {
2614 FinderPath finderPath = null;
2615 Object[] finderArgs = null;
2616
2617 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2618 (orderByComparator == null)) {
2619 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_C;
2620 finderArgs = new Object[] { companyId, classNameId };
2621 }
2622 else {
2623 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_C;
2624 finderArgs = new Object[] {
2625 companyId, classNameId,
2626
2627 start, end, orderByComparator
2628 };
2629 }
2630
2631 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
2632 finderArgs, this);
2633
2634 if ((list != null) && !list.isEmpty()) {
2635 for (DDMStructure ddmStructure : list) {
2636 if ((companyId != ddmStructure.getCompanyId()) ||
2637 (classNameId != ddmStructure.getClassNameId())) {
2638 list = null;
2639
2640 break;
2641 }
2642 }
2643 }
2644
2645 if (list == null) {
2646 StringBundler query = null;
2647
2648 if (orderByComparator != null) {
2649 query = new StringBundler(4 +
2650 (orderByComparator.getOrderByFields().length * 3));
2651 }
2652 else {
2653 query = new StringBundler(3);
2654 }
2655
2656 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2657
2658 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2659
2660 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2661
2662 if (orderByComparator != null) {
2663 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2664 orderByComparator);
2665 }
2666
2667 String sql = query.toString();
2668
2669 Session session = null;
2670
2671 try {
2672 session = openSession();
2673
2674 Query q = session.createQuery(sql);
2675
2676 QueryPos qPos = QueryPos.getInstance(q);
2677
2678 qPos.add(companyId);
2679
2680 qPos.add(classNameId);
2681
2682 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
2683 start, end);
2684 }
2685 catch (Exception e) {
2686 throw processException(e);
2687 }
2688 finally {
2689 if (list == null) {
2690 FinderCacheUtil.removeResult(finderPath, finderArgs);
2691 }
2692 else {
2693 cacheResult(list);
2694
2695 FinderCacheUtil.putResult(finderPath, finderArgs, list);
2696 }
2697
2698 closeSession(session);
2699 }
2700 }
2701
2702 return list;
2703 }
2704
2705
2715 public DDMStructure findByC_C_First(long companyId, long classNameId,
2716 OrderByComparator orderByComparator)
2717 throws NoSuchStructureException, SystemException {
2718 DDMStructure ddmStructure = fetchByC_C_First(companyId, classNameId,
2719 orderByComparator);
2720
2721 if (ddmStructure != null) {
2722 return ddmStructure;
2723 }
2724
2725 StringBundler msg = new StringBundler(6);
2726
2727 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2728
2729 msg.append("companyId=");
2730 msg.append(companyId);
2731
2732 msg.append(", classNameId=");
2733 msg.append(classNameId);
2734
2735 msg.append(StringPool.CLOSE_CURLY_BRACE);
2736
2737 throw new NoSuchStructureException(msg.toString());
2738 }
2739
2740
2749 public DDMStructure fetchByC_C_First(long companyId, long classNameId,
2750 OrderByComparator orderByComparator) throws SystemException {
2751 List<DDMStructure> list = findByC_C(companyId, classNameId, 0, 1,
2752 orderByComparator);
2753
2754 if (!list.isEmpty()) {
2755 return list.get(0);
2756 }
2757
2758 return null;
2759 }
2760
2761
2771 public DDMStructure findByC_C_Last(long companyId, long classNameId,
2772 OrderByComparator orderByComparator)
2773 throws NoSuchStructureException, SystemException {
2774 DDMStructure ddmStructure = fetchByC_C_Last(companyId, classNameId,
2775 orderByComparator);
2776
2777 if (ddmStructure != null) {
2778 return ddmStructure;
2779 }
2780
2781 StringBundler msg = new StringBundler(6);
2782
2783 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2784
2785 msg.append("companyId=");
2786 msg.append(companyId);
2787
2788 msg.append(", classNameId=");
2789 msg.append(classNameId);
2790
2791 msg.append(StringPool.CLOSE_CURLY_BRACE);
2792
2793 throw new NoSuchStructureException(msg.toString());
2794 }
2795
2796
2805 public DDMStructure fetchByC_C_Last(long companyId, long classNameId,
2806 OrderByComparator orderByComparator) throws SystemException {
2807 int count = countByC_C(companyId, classNameId);
2808
2809 List<DDMStructure> list = findByC_C(companyId, classNameId, count - 1,
2810 count, orderByComparator);
2811
2812 if (!list.isEmpty()) {
2813 return list.get(0);
2814 }
2815
2816 return null;
2817 }
2818
2819
2830 public DDMStructure[] findByC_C_PrevAndNext(long structureId,
2831 long companyId, long classNameId, OrderByComparator orderByComparator)
2832 throws NoSuchStructureException, SystemException {
2833 DDMStructure ddmStructure = findByPrimaryKey(structureId);
2834
2835 Session session = null;
2836
2837 try {
2838 session = openSession();
2839
2840 DDMStructure[] array = new DDMStructureImpl[3];
2841
2842 array[0] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
2843 classNameId, orderByComparator, true);
2844
2845 array[1] = ddmStructure;
2846
2847 array[2] = getByC_C_PrevAndNext(session, ddmStructure, companyId,
2848 classNameId, orderByComparator, false);
2849
2850 return array;
2851 }
2852 catch (Exception e) {
2853 throw processException(e);
2854 }
2855 finally {
2856 closeSession(session);
2857 }
2858 }
2859
2860 protected DDMStructure getByC_C_PrevAndNext(Session session,
2861 DDMStructure ddmStructure, long companyId, long classNameId,
2862 OrderByComparator orderByComparator, boolean previous) {
2863 StringBundler query = null;
2864
2865 if (orderByComparator != null) {
2866 query = new StringBundler(6 +
2867 (orderByComparator.getOrderByFields().length * 6));
2868 }
2869 else {
2870 query = new StringBundler(3);
2871 }
2872
2873 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
2874
2875 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
2876
2877 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
2878
2879 if (orderByComparator != null) {
2880 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2881
2882 if (orderByConditionFields.length > 0) {
2883 query.append(WHERE_AND);
2884 }
2885
2886 for (int i = 0; i < orderByConditionFields.length; i++) {
2887 query.append(_ORDER_BY_ENTITY_ALIAS);
2888 query.append(orderByConditionFields[i]);
2889
2890 if ((i + 1) < orderByConditionFields.length) {
2891 if (orderByComparator.isAscending() ^ previous) {
2892 query.append(WHERE_GREATER_THAN_HAS_NEXT);
2893 }
2894 else {
2895 query.append(WHERE_LESSER_THAN_HAS_NEXT);
2896 }
2897 }
2898 else {
2899 if (orderByComparator.isAscending() ^ previous) {
2900 query.append(WHERE_GREATER_THAN);
2901 }
2902 else {
2903 query.append(WHERE_LESSER_THAN);
2904 }
2905 }
2906 }
2907
2908 query.append(ORDER_BY_CLAUSE);
2909
2910 String[] orderByFields = orderByComparator.getOrderByFields();
2911
2912 for (int i = 0; i < orderByFields.length; i++) {
2913 query.append(_ORDER_BY_ENTITY_ALIAS);
2914 query.append(orderByFields[i]);
2915
2916 if ((i + 1) < orderByFields.length) {
2917 if (orderByComparator.isAscending() ^ previous) {
2918 query.append(ORDER_BY_ASC_HAS_NEXT);
2919 }
2920 else {
2921 query.append(ORDER_BY_DESC_HAS_NEXT);
2922 }
2923 }
2924 else {
2925 if (orderByComparator.isAscending() ^ previous) {
2926 query.append(ORDER_BY_ASC);
2927 }
2928 else {
2929 query.append(ORDER_BY_DESC);
2930 }
2931 }
2932 }
2933 }
2934
2935 String sql = query.toString();
2936
2937 Query q = session.createQuery(sql);
2938
2939 q.setFirstResult(0);
2940 q.setMaxResults(2);
2941
2942 QueryPos qPos = QueryPos.getInstance(q);
2943
2944 qPos.add(companyId);
2945
2946 qPos.add(classNameId);
2947
2948 if (orderByComparator != null) {
2949 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
2950
2951 for (Object value : values) {
2952 qPos.add(value);
2953 }
2954 }
2955
2956 List<DDMStructure> list = q.list();
2957
2958 if (list.size() == 2) {
2959 return list.get(1);
2960 }
2961 else {
2962 return null;
2963 }
2964 }
2965
2966
2975 public List<DDMStructure> findByG_N_D(long groupId, String name,
2976 String description) throws SystemException {
2977 return findByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
2978 QueryUtil.ALL_POS, null);
2979 }
2980
2981
2996 public List<DDMStructure> findByG_N_D(long groupId, String name,
2997 String description, int start, int end) throws SystemException {
2998 return findByG_N_D(groupId, name, description, start, end, null);
2999 }
3000
3001
3017 public List<DDMStructure> findByG_N_D(long groupId, String name,
3018 String description, int start, int end,
3019 OrderByComparator orderByComparator) throws SystemException {
3020 FinderPath finderPath = null;
3021 Object[] finderArgs = null;
3022
3023 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3024 (orderByComparator == null)) {
3025 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_N_D;
3026 finderArgs = new Object[] { groupId, name, description };
3027 }
3028 else {
3029 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_N_D;
3030 finderArgs = new Object[] {
3031 groupId, name, description,
3032
3033 start, end, orderByComparator
3034 };
3035 }
3036
3037 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3038 finderArgs, this);
3039
3040 if ((list != null) && !list.isEmpty()) {
3041 for (DDMStructure ddmStructure : list) {
3042 if ((groupId != ddmStructure.getGroupId()) ||
3043 !Validator.equals(name, ddmStructure.getName()) ||
3044 !Validator.equals(description,
3045 ddmStructure.getDescription())) {
3046 list = null;
3047
3048 break;
3049 }
3050 }
3051 }
3052
3053 if (list == null) {
3054 StringBundler query = null;
3055
3056 if (orderByComparator != null) {
3057 query = new StringBundler(5 +
3058 (orderByComparator.getOrderByFields().length * 3));
3059 }
3060 else {
3061 query = new StringBundler(4);
3062 }
3063
3064 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3065
3066 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
3067
3068 if (name == null) {
3069 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
3070 }
3071 else {
3072 if (name.equals(StringPool.BLANK)) {
3073 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
3074 }
3075 else {
3076 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
3077 }
3078 }
3079
3080 if (description == null) {
3081 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
3082 }
3083 else {
3084 if (description.equals(StringPool.BLANK)) {
3085 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
3086 }
3087 else {
3088 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
3089 }
3090 }
3091
3092 if (orderByComparator != null) {
3093 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3094 orderByComparator);
3095 }
3096
3097 String sql = query.toString();
3098
3099 Session session = null;
3100
3101 try {
3102 session = openSession();
3103
3104 Query q = session.createQuery(sql);
3105
3106 QueryPos qPos = QueryPos.getInstance(q);
3107
3108 qPos.add(groupId);
3109
3110 if (name != null) {
3111 qPos.add(name);
3112 }
3113
3114 if (description != null) {
3115 qPos.add(description);
3116 }
3117
3118 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3119 start, end);
3120 }
3121 catch (Exception e) {
3122 throw processException(e);
3123 }
3124 finally {
3125 if (list == null) {
3126 FinderCacheUtil.removeResult(finderPath, finderArgs);
3127 }
3128 else {
3129 cacheResult(list);
3130
3131 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3132 }
3133
3134 closeSession(session);
3135 }
3136 }
3137
3138 return list;
3139 }
3140
3141
3152 public DDMStructure findByG_N_D_First(long groupId, String name,
3153 String description, OrderByComparator orderByComparator)
3154 throws NoSuchStructureException, SystemException {
3155 DDMStructure ddmStructure = fetchByG_N_D_First(groupId, name,
3156 description, orderByComparator);
3157
3158 if (ddmStructure != null) {
3159 return ddmStructure;
3160 }
3161
3162 StringBundler msg = new StringBundler(8);
3163
3164 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3165
3166 msg.append("groupId=");
3167 msg.append(groupId);
3168
3169 msg.append(", name=");
3170 msg.append(name);
3171
3172 msg.append(", description=");
3173 msg.append(description);
3174
3175 msg.append(StringPool.CLOSE_CURLY_BRACE);
3176
3177 throw new NoSuchStructureException(msg.toString());
3178 }
3179
3180
3190 public DDMStructure fetchByG_N_D_First(long groupId, String name,
3191 String description, OrderByComparator orderByComparator)
3192 throws SystemException {
3193 List<DDMStructure> list = findByG_N_D(groupId, name, description, 0, 1,
3194 orderByComparator);
3195
3196 if (!list.isEmpty()) {
3197 return list.get(0);
3198 }
3199
3200 return null;
3201 }
3202
3203
3214 public DDMStructure findByG_N_D_Last(long groupId, String name,
3215 String description, OrderByComparator orderByComparator)
3216 throws NoSuchStructureException, SystemException {
3217 DDMStructure ddmStructure = fetchByG_N_D_Last(groupId, name,
3218 description, orderByComparator);
3219
3220 if (ddmStructure != null) {
3221 return ddmStructure;
3222 }
3223
3224 StringBundler msg = new StringBundler(8);
3225
3226 msg.append(_NO_SUCH_ENTITY_WITH_KEY);
3227
3228 msg.append("groupId=");
3229 msg.append(groupId);
3230
3231 msg.append(", name=");
3232 msg.append(name);
3233
3234 msg.append(", description=");
3235 msg.append(description);
3236
3237 msg.append(StringPool.CLOSE_CURLY_BRACE);
3238
3239 throw new NoSuchStructureException(msg.toString());
3240 }
3241
3242
3252 public DDMStructure fetchByG_N_D_Last(long groupId, String name,
3253 String description, OrderByComparator orderByComparator)
3254 throws SystemException {
3255 int count = countByG_N_D(groupId, name, description);
3256
3257 List<DDMStructure> list = findByG_N_D(groupId, name, description,
3258 count - 1, count, orderByComparator);
3259
3260 if (!list.isEmpty()) {
3261 return list.get(0);
3262 }
3263
3264 return null;
3265 }
3266
3267
3279 public DDMStructure[] findByG_N_D_PrevAndNext(long structureId,
3280 long groupId, String name, String description,
3281 OrderByComparator orderByComparator)
3282 throws NoSuchStructureException, SystemException {
3283 DDMStructure ddmStructure = findByPrimaryKey(structureId);
3284
3285 Session session = null;
3286
3287 try {
3288 session = openSession();
3289
3290 DDMStructure[] array = new DDMStructureImpl[3];
3291
3292 array[0] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
3293 name, description, orderByComparator, true);
3294
3295 array[1] = ddmStructure;
3296
3297 array[2] = getByG_N_D_PrevAndNext(session, ddmStructure, groupId,
3298 name, description, orderByComparator, false);
3299
3300 return array;
3301 }
3302 catch (Exception e) {
3303 throw processException(e);
3304 }
3305 finally {
3306 closeSession(session);
3307 }
3308 }
3309
3310 protected DDMStructure getByG_N_D_PrevAndNext(Session session,
3311 DDMStructure ddmStructure, long groupId, String name,
3312 String description, OrderByComparator orderByComparator,
3313 boolean previous) {
3314 StringBundler query = null;
3315
3316 if (orderByComparator != null) {
3317 query = new StringBundler(6 +
3318 (orderByComparator.getOrderByFields().length * 6));
3319 }
3320 else {
3321 query = new StringBundler(3);
3322 }
3323
3324 query.append(_SQL_SELECT_DDMSTRUCTURE_WHERE);
3325
3326 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
3327
3328 if (name == null) {
3329 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
3330 }
3331 else {
3332 if (name.equals(StringPool.BLANK)) {
3333 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
3334 }
3335 else {
3336 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
3337 }
3338 }
3339
3340 if (description == null) {
3341 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
3342 }
3343 else {
3344 if (description.equals(StringPool.BLANK)) {
3345 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
3346 }
3347 else {
3348 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
3349 }
3350 }
3351
3352 if (orderByComparator != null) {
3353 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3354
3355 if (orderByConditionFields.length > 0) {
3356 query.append(WHERE_AND);
3357 }
3358
3359 for (int i = 0; i < orderByConditionFields.length; i++) {
3360 query.append(_ORDER_BY_ENTITY_ALIAS);
3361 query.append(orderByConditionFields[i]);
3362
3363 if ((i + 1) < orderByConditionFields.length) {
3364 if (orderByComparator.isAscending() ^ previous) {
3365 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3366 }
3367 else {
3368 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3369 }
3370 }
3371 else {
3372 if (orderByComparator.isAscending() ^ previous) {
3373 query.append(WHERE_GREATER_THAN);
3374 }
3375 else {
3376 query.append(WHERE_LESSER_THAN);
3377 }
3378 }
3379 }
3380
3381 query.append(ORDER_BY_CLAUSE);
3382
3383 String[] orderByFields = orderByComparator.getOrderByFields();
3384
3385 for (int i = 0; i < orderByFields.length; i++) {
3386 query.append(_ORDER_BY_ENTITY_ALIAS);
3387 query.append(orderByFields[i]);
3388
3389 if ((i + 1) < orderByFields.length) {
3390 if (orderByComparator.isAscending() ^ previous) {
3391 query.append(ORDER_BY_ASC_HAS_NEXT);
3392 }
3393 else {
3394 query.append(ORDER_BY_DESC_HAS_NEXT);
3395 }
3396 }
3397 else {
3398 if (orderByComparator.isAscending() ^ previous) {
3399 query.append(ORDER_BY_ASC);
3400 }
3401 else {
3402 query.append(ORDER_BY_DESC);
3403 }
3404 }
3405 }
3406 }
3407
3408 String sql = query.toString();
3409
3410 Query q = session.createQuery(sql);
3411
3412 q.setFirstResult(0);
3413 q.setMaxResults(2);
3414
3415 QueryPos qPos = QueryPos.getInstance(q);
3416
3417 qPos.add(groupId);
3418
3419 if (name != null) {
3420 qPos.add(name);
3421 }
3422
3423 if (description != null) {
3424 qPos.add(description);
3425 }
3426
3427 if (orderByComparator != null) {
3428 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3429
3430 for (Object value : values) {
3431 qPos.add(value);
3432 }
3433 }
3434
3435 List<DDMStructure> list = q.list();
3436
3437 if (list.size() == 2) {
3438 return list.get(1);
3439 }
3440 else {
3441 return null;
3442 }
3443 }
3444
3445
3454 public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
3455 String description) throws SystemException {
3456 return filterFindByG_N_D(groupId, name, description, QueryUtil.ALL_POS,
3457 QueryUtil.ALL_POS, null);
3458 }
3459
3460
3475 public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
3476 String description, int start, int end) throws SystemException {
3477 return filterFindByG_N_D(groupId, name, description, start, end, null);
3478 }
3479
3480
3496 public List<DDMStructure> filterFindByG_N_D(long groupId, String name,
3497 String description, int start, int end,
3498 OrderByComparator orderByComparator) throws SystemException {
3499 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3500 return findByG_N_D(groupId, name, description, start, end,
3501 orderByComparator);
3502 }
3503
3504 StringBundler query = null;
3505
3506 if (orderByComparator != null) {
3507 query = new StringBundler(5 +
3508 (orderByComparator.getOrderByFields().length * 3));
3509 }
3510 else {
3511 query = new StringBundler(4);
3512 }
3513
3514 if (getDB().isSupportsInlineDistinct()) {
3515 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
3516 }
3517 else {
3518 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
3519 }
3520
3521 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
3522
3523 if (name == null) {
3524 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
3525 }
3526 else {
3527 if (name.equals(StringPool.BLANK)) {
3528 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
3529 }
3530 else {
3531 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
3532 }
3533 }
3534
3535 if (description == null) {
3536 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
3537 }
3538 else {
3539 if (description.equals(StringPool.BLANK)) {
3540 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
3541 }
3542 else {
3543 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
3544 }
3545 }
3546
3547 if (!getDB().isSupportsInlineDistinct()) {
3548 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
3549 }
3550
3551 if (orderByComparator != null) {
3552 if (getDB().isSupportsInlineDistinct()) {
3553 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3554 orderByComparator);
3555 }
3556 else {
3557 appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
3558 orderByComparator);
3559 }
3560 }
3561
3562 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3563 DDMStructure.class.getName(),
3564 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3565
3566 Session session = null;
3567
3568 try {
3569 session = openSession();
3570
3571 SQLQuery q = session.createSQLQuery(sql);
3572
3573 if (getDB().isSupportsInlineDistinct()) {
3574 q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
3575 }
3576 else {
3577 q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
3578 }
3579
3580 QueryPos qPos = QueryPos.getInstance(q);
3581
3582 qPos.add(groupId);
3583
3584 if (name != null) {
3585 qPos.add(name);
3586 }
3587
3588 if (description != null) {
3589 qPos.add(description);
3590 }
3591
3592 return (List<DDMStructure>)QueryUtil.list(q, getDialect(), start,
3593 end);
3594 }
3595 catch (Exception e) {
3596 throw processException(e);
3597 }
3598 finally {
3599 closeSession(session);
3600 }
3601 }
3602
3603
3615 public DDMStructure[] filterFindByG_N_D_PrevAndNext(long structureId,
3616 long groupId, String name, String description,
3617 OrderByComparator orderByComparator)
3618 throws NoSuchStructureException, SystemException {
3619 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
3620 return findByG_N_D_PrevAndNext(structureId, groupId, name,
3621 description, orderByComparator);
3622 }
3623
3624 DDMStructure ddmStructure = findByPrimaryKey(structureId);
3625
3626 Session session = null;
3627
3628 try {
3629 session = openSession();
3630
3631 DDMStructure[] array = new DDMStructureImpl[3];
3632
3633 array[0] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
3634 groupId, name, description, orderByComparator, true);
3635
3636 array[1] = ddmStructure;
3637
3638 array[2] = filterGetByG_N_D_PrevAndNext(session, ddmStructure,
3639 groupId, name, description, orderByComparator, false);
3640
3641 return array;
3642 }
3643 catch (Exception e) {
3644 throw processException(e);
3645 }
3646 finally {
3647 closeSession(session);
3648 }
3649 }
3650
3651 protected DDMStructure filterGetByG_N_D_PrevAndNext(Session session,
3652 DDMStructure ddmStructure, long groupId, String name,
3653 String description, OrderByComparator orderByComparator,
3654 boolean previous) {
3655 StringBundler query = null;
3656
3657 if (orderByComparator != null) {
3658 query = new StringBundler(6 +
3659 (orderByComparator.getOrderByFields().length * 6));
3660 }
3661 else {
3662 query = new StringBundler(3);
3663 }
3664
3665 if (getDB().isSupportsInlineDistinct()) {
3666 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE);
3667 }
3668 else {
3669 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1);
3670 }
3671
3672 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
3673
3674 if (name == null) {
3675 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
3676 }
3677 else {
3678 if (name.equals(StringPool.BLANK)) {
3679 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
3680 }
3681 else {
3682 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
3683 }
3684 }
3685
3686 if (description == null) {
3687 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
3688 }
3689 else {
3690 if (description.equals(StringPool.BLANK)) {
3691 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
3692 }
3693 else {
3694 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
3695 }
3696 }
3697
3698 if (!getDB().isSupportsInlineDistinct()) {
3699 query.append(_FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2);
3700 }
3701
3702 if (orderByComparator != null) {
3703 String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
3704
3705 if (orderByConditionFields.length > 0) {
3706 query.append(WHERE_AND);
3707 }
3708
3709 for (int i = 0; i < orderByConditionFields.length; i++) {
3710 if (getDB().isSupportsInlineDistinct()) {
3711 query.append(_ORDER_BY_ENTITY_ALIAS);
3712 }
3713 else {
3714 query.append(_ORDER_BY_ENTITY_TABLE);
3715 }
3716
3717 query.append(orderByConditionFields[i]);
3718
3719 if ((i + 1) < orderByConditionFields.length) {
3720 if (orderByComparator.isAscending() ^ previous) {
3721 query.append(WHERE_GREATER_THAN_HAS_NEXT);
3722 }
3723 else {
3724 query.append(WHERE_LESSER_THAN_HAS_NEXT);
3725 }
3726 }
3727 else {
3728 if (orderByComparator.isAscending() ^ previous) {
3729 query.append(WHERE_GREATER_THAN);
3730 }
3731 else {
3732 query.append(WHERE_LESSER_THAN);
3733 }
3734 }
3735 }
3736
3737 query.append(ORDER_BY_CLAUSE);
3738
3739 String[] orderByFields = orderByComparator.getOrderByFields();
3740
3741 for (int i = 0; i < orderByFields.length; i++) {
3742 if (getDB().isSupportsInlineDistinct()) {
3743 query.append(_ORDER_BY_ENTITY_ALIAS);
3744 }
3745 else {
3746 query.append(_ORDER_BY_ENTITY_TABLE);
3747 }
3748
3749 query.append(orderByFields[i]);
3750
3751 if ((i + 1) < orderByFields.length) {
3752 if (orderByComparator.isAscending() ^ previous) {
3753 query.append(ORDER_BY_ASC_HAS_NEXT);
3754 }
3755 else {
3756 query.append(ORDER_BY_DESC_HAS_NEXT);
3757 }
3758 }
3759 else {
3760 if (orderByComparator.isAscending() ^ previous) {
3761 query.append(ORDER_BY_ASC);
3762 }
3763 else {
3764 query.append(ORDER_BY_DESC);
3765 }
3766 }
3767 }
3768 }
3769
3770 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
3771 DDMStructure.class.getName(),
3772 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
3773
3774 SQLQuery q = session.createSQLQuery(sql);
3775
3776 q.setFirstResult(0);
3777 q.setMaxResults(2);
3778
3779 if (getDB().isSupportsInlineDistinct()) {
3780 q.addEntity(_FILTER_ENTITY_ALIAS, DDMStructureImpl.class);
3781 }
3782 else {
3783 q.addEntity(_FILTER_ENTITY_TABLE, DDMStructureImpl.class);
3784 }
3785
3786 QueryPos qPos = QueryPos.getInstance(q);
3787
3788 qPos.add(groupId);
3789
3790 if (name != null) {
3791 qPos.add(name);
3792 }
3793
3794 if (description != null) {
3795 qPos.add(description);
3796 }
3797
3798 if (orderByComparator != null) {
3799 Object[] values = orderByComparator.getOrderByConditionValues(ddmStructure);
3800
3801 for (Object value : values) {
3802 qPos.add(value);
3803 }
3804 }
3805
3806 List<DDMStructure> list = q.list();
3807
3808 if (list.size() == 2) {
3809 return list.get(1);
3810 }
3811 else {
3812 return null;
3813 }
3814 }
3815
3816
3822 public List<DDMStructure> findAll() throws SystemException {
3823 return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3824 }
3825
3826
3838 public List<DDMStructure> findAll(int start, int end)
3839 throws SystemException {
3840 return findAll(start, end, null);
3841 }
3842
3843
3856 public List<DDMStructure> findAll(int start, int end,
3857 OrderByComparator orderByComparator) throws SystemException {
3858 FinderPath finderPath = null;
3859 Object[] finderArgs = new Object[] { start, end, orderByComparator };
3860
3861 if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3862 (orderByComparator == null)) {
3863 finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3864 finderArgs = FINDER_ARGS_EMPTY;
3865 }
3866 else {
3867 finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3868 finderArgs = new Object[] { start, end, orderByComparator };
3869 }
3870
3871 List<DDMStructure> list = (List<DDMStructure>)FinderCacheUtil.getResult(finderPath,
3872 finderArgs, this);
3873
3874 if (list == null) {
3875 StringBundler query = null;
3876 String sql = null;
3877
3878 if (orderByComparator != null) {
3879 query = new StringBundler(2 +
3880 (orderByComparator.getOrderByFields().length * 3));
3881
3882 query.append(_SQL_SELECT_DDMSTRUCTURE);
3883
3884 appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3885 orderByComparator);
3886
3887 sql = query.toString();
3888 }
3889 else {
3890 sql = _SQL_SELECT_DDMSTRUCTURE;
3891 }
3892
3893 Session session = null;
3894
3895 try {
3896 session = openSession();
3897
3898 Query q = session.createQuery(sql);
3899
3900 if (orderByComparator == null) {
3901 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3902 start, end, false);
3903
3904 Collections.sort(list);
3905 }
3906 else {
3907 list = (List<DDMStructure>)QueryUtil.list(q, getDialect(),
3908 start, end);
3909 }
3910 }
3911 catch (Exception e) {
3912 throw processException(e);
3913 }
3914 finally {
3915 if (list == null) {
3916 FinderCacheUtil.removeResult(finderPath, finderArgs);
3917 }
3918 else {
3919 cacheResult(list);
3920
3921 FinderCacheUtil.putResult(finderPath, finderArgs, list);
3922 }
3923
3924 closeSession(session);
3925 }
3926 }
3927
3928 return list;
3929 }
3930
3931
3937 public void removeByUuid(String uuid) throws SystemException {
3938 for (DDMStructure ddmStructure : findByUuid(uuid)) {
3939 remove(ddmStructure);
3940 }
3941 }
3942
3943
3951 public DDMStructure removeByUUID_G(String uuid, long groupId)
3952 throws NoSuchStructureException, SystemException {
3953 DDMStructure ddmStructure = findByUUID_G(uuid, groupId);
3954
3955 return remove(ddmStructure);
3956 }
3957
3958
3964 public void removeByGroupId(long groupId) throws SystemException {
3965 for (DDMStructure ddmStructure : findByGroupId(groupId)) {
3966 remove(ddmStructure);
3967 }
3968 }
3969
3970
3976 public void removeByClassNameId(long classNameId) throws SystemException {
3977 for (DDMStructure ddmStructure : findByClassNameId(classNameId)) {
3978 remove(ddmStructure);
3979 }
3980 }
3981
3982
3990 public DDMStructure removeByG_S(long groupId, String structureKey)
3991 throws NoSuchStructureException, SystemException {
3992 DDMStructure ddmStructure = findByG_S(groupId, structureKey);
3993
3994 return remove(ddmStructure);
3995 }
3996
3997
4004 public void removeByC_C(long companyId, long classNameId)
4005 throws SystemException {
4006 for (DDMStructure ddmStructure : findByC_C(companyId, classNameId)) {
4007 remove(ddmStructure);
4008 }
4009 }
4010
4011
4019 public void removeByG_N_D(long groupId, String name, String description)
4020 throws SystemException {
4021 for (DDMStructure ddmStructure : findByG_N_D(groupId, name, description)) {
4022 remove(ddmStructure);
4023 }
4024 }
4025
4026
4031 public void removeAll() throws SystemException {
4032 for (DDMStructure ddmStructure : findAll()) {
4033 remove(ddmStructure);
4034 }
4035 }
4036
4037
4044 public int countByUuid(String uuid) throws SystemException {
4045 Object[] finderArgs = new Object[] { uuid };
4046
4047 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
4048 finderArgs, this);
4049
4050 if (count == null) {
4051 StringBundler query = new StringBundler(2);
4052
4053 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4054
4055 if (uuid == null) {
4056 query.append(_FINDER_COLUMN_UUID_UUID_1);
4057 }
4058 else {
4059 if (uuid.equals(StringPool.BLANK)) {
4060 query.append(_FINDER_COLUMN_UUID_UUID_3);
4061 }
4062 else {
4063 query.append(_FINDER_COLUMN_UUID_UUID_2);
4064 }
4065 }
4066
4067 String sql = query.toString();
4068
4069 Session session = null;
4070
4071 try {
4072 session = openSession();
4073
4074 Query q = session.createQuery(sql);
4075
4076 QueryPos qPos = QueryPos.getInstance(q);
4077
4078 if (uuid != null) {
4079 qPos.add(uuid);
4080 }
4081
4082 count = (Long)q.uniqueResult();
4083 }
4084 catch (Exception e) {
4085 throw processException(e);
4086 }
4087 finally {
4088 if (count == null) {
4089 count = Long.valueOf(0);
4090 }
4091
4092 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
4093 finderArgs, count);
4094
4095 closeSession(session);
4096 }
4097 }
4098
4099 return count.intValue();
4100 }
4101
4102
4110 public int countByUUID_G(String uuid, long groupId)
4111 throws SystemException {
4112 Object[] finderArgs = new Object[] { uuid, groupId };
4113
4114 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
4115 finderArgs, this);
4116
4117 if (count == null) {
4118 StringBundler query = new StringBundler(3);
4119
4120 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4121
4122 if (uuid == null) {
4123 query.append(_FINDER_COLUMN_UUID_G_UUID_1);
4124 }
4125 else {
4126 if (uuid.equals(StringPool.BLANK)) {
4127 query.append(_FINDER_COLUMN_UUID_G_UUID_3);
4128 }
4129 else {
4130 query.append(_FINDER_COLUMN_UUID_G_UUID_2);
4131 }
4132 }
4133
4134 query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
4135
4136 String sql = query.toString();
4137
4138 Session session = null;
4139
4140 try {
4141 session = openSession();
4142
4143 Query q = session.createQuery(sql);
4144
4145 QueryPos qPos = QueryPos.getInstance(q);
4146
4147 if (uuid != null) {
4148 qPos.add(uuid);
4149 }
4150
4151 qPos.add(groupId);
4152
4153 count = (Long)q.uniqueResult();
4154 }
4155 catch (Exception e) {
4156 throw processException(e);
4157 }
4158 finally {
4159 if (count == null) {
4160 count = Long.valueOf(0);
4161 }
4162
4163 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
4164 finderArgs, count);
4165
4166 closeSession(session);
4167 }
4168 }
4169
4170 return count.intValue();
4171 }
4172
4173
4180 public int countByGroupId(long groupId) throws SystemException {
4181 Object[] finderArgs = new Object[] { groupId };
4182
4183 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
4184 finderArgs, this);
4185
4186 if (count == null) {
4187 StringBundler query = new StringBundler(2);
4188
4189 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4190
4191 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4192
4193 String sql = query.toString();
4194
4195 Session session = null;
4196
4197 try {
4198 session = openSession();
4199
4200 Query q = session.createQuery(sql);
4201
4202 QueryPos qPos = QueryPos.getInstance(q);
4203
4204 qPos.add(groupId);
4205
4206 count = (Long)q.uniqueResult();
4207 }
4208 catch (Exception e) {
4209 throw processException(e);
4210 }
4211 finally {
4212 if (count == null) {
4213 count = Long.valueOf(0);
4214 }
4215
4216 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
4217 finderArgs, count);
4218
4219 closeSession(session);
4220 }
4221 }
4222
4223 return count.intValue();
4224 }
4225
4226
4233 public int filterCountByGroupId(long groupId) throws SystemException {
4234 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4235 return countByGroupId(groupId);
4236 }
4237
4238 StringBundler query = new StringBundler(2);
4239
4240 query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
4241
4242 query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
4243
4244 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4245 DDMStructure.class.getName(),
4246 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4247
4248 Session session = null;
4249
4250 try {
4251 session = openSession();
4252
4253 SQLQuery q = session.createSQLQuery(sql);
4254
4255 q.addScalar(COUNT_COLUMN_NAME,
4256 com.liferay.portal.kernel.dao.orm.Type.LONG);
4257
4258 QueryPos qPos = QueryPos.getInstance(q);
4259
4260 qPos.add(groupId);
4261
4262 Long count = (Long)q.uniqueResult();
4263
4264 return count.intValue();
4265 }
4266 catch (Exception e) {
4267 throw processException(e);
4268 }
4269 finally {
4270 closeSession(session);
4271 }
4272 }
4273
4274
4281 public int countByClassNameId(long classNameId) throws SystemException {
4282 Object[] finderArgs = new Object[] { classNameId };
4283
4284 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
4285 finderArgs, this);
4286
4287 if (count == null) {
4288 StringBundler query = new StringBundler(2);
4289
4290 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4291
4292 query.append(_FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2);
4293
4294 String sql = query.toString();
4295
4296 Session session = null;
4297
4298 try {
4299 session = openSession();
4300
4301 Query q = session.createQuery(sql);
4302
4303 QueryPos qPos = QueryPos.getInstance(q);
4304
4305 qPos.add(classNameId);
4306
4307 count = (Long)q.uniqueResult();
4308 }
4309 catch (Exception e) {
4310 throw processException(e);
4311 }
4312 finally {
4313 if (count == null) {
4314 count = Long.valueOf(0);
4315 }
4316
4317 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_CLASSNAMEID,
4318 finderArgs, count);
4319
4320 closeSession(session);
4321 }
4322 }
4323
4324 return count.intValue();
4325 }
4326
4327
4335 public int countByG_S(long groupId, String structureKey)
4336 throws SystemException {
4337 Object[] finderArgs = new Object[] { groupId, structureKey };
4338
4339 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_S,
4340 finderArgs, this);
4341
4342 if (count == null) {
4343 StringBundler query = new StringBundler(3);
4344
4345 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4346
4347 query.append(_FINDER_COLUMN_G_S_GROUPID_2);
4348
4349 if (structureKey == null) {
4350 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_1);
4351 }
4352 else {
4353 if (structureKey.equals(StringPool.BLANK)) {
4354 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_3);
4355 }
4356 else {
4357 query.append(_FINDER_COLUMN_G_S_STRUCTUREKEY_2);
4358 }
4359 }
4360
4361 String sql = query.toString();
4362
4363 Session session = null;
4364
4365 try {
4366 session = openSession();
4367
4368 Query q = session.createQuery(sql);
4369
4370 QueryPos qPos = QueryPos.getInstance(q);
4371
4372 qPos.add(groupId);
4373
4374 if (structureKey != null) {
4375 qPos.add(structureKey);
4376 }
4377
4378 count = (Long)q.uniqueResult();
4379 }
4380 catch (Exception e) {
4381 throw processException(e);
4382 }
4383 finally {
4384 if (count == null) {
4385 count = Long.valueOf(0);
4386 }
4387
4388 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_S, finderArgs,
4389 count);
4390
4391 closeSession(session);
4392 }
4393 }
4394
4395 return count.intValue();
4396 }
4397
4398
4406 public int countByC_C(long companyId, long classNameId)
4407 throws SystemException {
4408 Object[] finderArgs = new Object[] { companyId, classNameId };
4409
4410 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_C,
4411 finderArgs, this);
4412
4413 if (count == null) {
4414 StringBundler query = new StringBundler(3);
4415
4416 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4417
4418 query.append(_FINDER_COLUMN_C_C_COMPANYID_2);
4419
4420 query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2);
4421
4422 String sql = query.toString();
4423
4424 Session session = null;
4425
4426 try {
4427 session = openSession();
4428
4429 Query q = session.createQuery(sql);
4430
4431 QueryPos qPos = QueryPos.getInstance(q);
4432
4433 qPos.add(companyId);
4434
4435 qPos.add(classNameId);
4436
4437 count = (Long)q.uniqueResult();
4438 }
4439 catch (Exception e) {
4440 throw processException(e);
4441 }
4442 finally {
4443 if (count == null) {
4444 count = Long.valueOf(0);
4445 }
4446
4447 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_C, finderArgs,
4448 count);
4449
4450 closeSession(session);
4451 }
4452 }
4453
4454 return count.intValue();
4455 }
4456
4457
4466 public int countByG_N_D(long groupId, String name, String description)
4467 throws SystemException {
4468 Object[] finderArgs = new Object[] { groupId, name, description };
4469
4470 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N_D,
4471 finderArgs, this);
4472
4473 if (count == null) {
4474 StringBundler query = new StringBundler(4);
4475
4476 query.append(_SQL_COUNT_DDMSTRUCTURE_WHERE);
4477
4478 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
4479
4480 if (name == null) {
4481 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
4482 }
4483 else {
4484 if (name.equals(StringPool.BLANK)) {
4485 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
4486 }
4487 else {
4488 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
4489 }
4490 }
4491
4492 if (description == null) {
4493 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
4494 }
4495 else {
4496 if (description.equals(StringPool.BLANK)) {
4497 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
4498 }
4499 else {
4500 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
4501 }
4502 }
4503
4504 String sql = query.toString();
4505
4506 Session session = null;
4507
4508 try {
4509 session = openSession();
4510
4511 Query q = session.createQuery(sql);
4512
4513 QueryPos qPos = QueryPos.getInstance(q);
4514
4515 qPos.add(groupId);
4516
4517 if (name != null) {
4518 qPos.add(name);
4519 }
4520
4521 if (description != null) {
4522 qPos.add(description);
4523 }
4524
4525 count = (Long)q.uniqueResult();
4526 }
4527 catch (Exception e) {
4528 throw processException(e);
4529 }
4530 finally {
4531 if (count == null) {
4532 count = Long.valueOf(0);
4533 }
4534
4535 FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N_D,
4536 finderArgs, count);
4537
4538 closeSession(session);
4539 }
4540 }
4541
4542 return count.intValue();
4543 }
4544
4545
4554 public int filterCountByG_N_D(long groupId, String name, String description)
4555 throws SystemException {
4556 if (!InlineSQLHelperUtil.isEnabled(groupId)) {
4557 return countByG_N_D(groupId, name, description);
4558 }
4559
4560 StringBundler query = new StringBundler(4);
4561
4562 query.append(_FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE);
4563
4564 query.append(_FINDER_COLUMN_G_N_D_GROUPID_2);
4565
4566 if (name == null) {
4567 query.append(_FINDER_COLUMN_G_N_D_NAME_1);
4568 }
4569 else {
4570 if (name.equals(StringPool.BLANK)) {
4571 query.append(_FINDER_COLUMN_G_N_D_NAME_3);
4572 }
4573 else {
4574 query.append(_FINDER_COLUMN_G_N_D_NAME_2);
4575 }
4576 }
4577
4578 if (description == null) {
4579 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_1);
4580 }
4581 else {
4582 if (description.equals(StringPool.BLANK)) {
4583 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_3);
4584 }
4585 else {
4586 query.append(_FINDER_COLUMN_G_N_D_DESCRIPTION_2);
4587 }
4588 }
4589
4590 String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
4591 DDMStructure.class.getName(),
4592 _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
4593
4594 Session session = null;
4595
4596 try {
4597 session = openSession();
4598
4599 SQLQuery q = session.createSQLQuery(sql);
4600
4601 q.addScalar(COUNT_COLUMN_NAME,
4602 com.liferay.portal.kernel.dao.orm.Type.LONG);
4603
4604 QueryPos qPos = QueryPos.getInstance(q);
4605
4606 qPos.add(groupId);
4607
4608 if (name != null) {
4609 qPos.add(name);
4610 }
4611
4612 if (description != null) {
4613 qPos.add(description);
4614 }
4615
4616 Long count = (Long)q.uniqueResult();
4617
4618 return count.intValue();
4619 }
4620 catch (Exception e) {
4621 throw processException(e);
4622 }
4623 finally {
4624 closeSession(session);
4625 }
4626 }
4627
4628
4634 public int countAll() throws SystemException {
4635 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
4636 FINDER_ARGS_EMPTY, this);
4637
4638 if (count == null) {
4639 Session session = null;
4640
4641 try {
4642 session = openSession();
4643
4644 Query q = session.createQuery(_SQL_COUNT_DDMSTRUCTURE);
4645
4646 count = (Long)q.uniqueResult();
4647 }
4648 catch (Exception e) {
4649 throw processException(e);
4650 }
4651 finally {
4652 if (count == null) {
4653 count = Long.valueOf(0);
4654 }
4655
4656 FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
4657 FINDER_ARGS_EMPTY, count);
4658
4659 closeSession(session);
4660 }
4661 }
4662
4663 return count.intValue();
4664 }
4665
4666
4673 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
4674 long pk) throws SystemException {
4675 return getDLFileEntryTypes(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
4676 }
4677
4678
4691 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
4692 long pk, int start, int end) throws SystemException {
4693 return getDLFileEntryTypes(pk, start, end, null);
4694 }
4695
4696 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
4697 DDMStructureModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
4698 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class,
4699 DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
4700 "getDLFileEntryTypes",
4701 new String[] {
4702 Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
4703 "com.liferay.portal.kernel.util.OrderByComparator"
4704 });
4705
4706 static {
4707 FINDER_PATH_GET_DLFILEENTRYTYPES.setCacheKeyGeneratorCacheName(null);
4708 }
4709
4710
4724 public List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> getDLFileEntryTypes(
4725 long pk, int start, int end, OrderByComparator orderByComparator)
4726 throws SystemException {
4727 Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
4728
4729 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
4730 finderArgs, this);
4731
4732 if (list == null) {
4733 Session session = null;
4734
4735 try {
4736 session = openSession();
4737
4738 String sql = null;
4739
4740 if (orderByComparator != null) {
4741 sql = _SQL_GETDLFILEENTRYTYPES.concat(ORDER_BY_CLAUSE)
4742 .concat(orderByComparator.getOrderBy());
4743 }
4744 else {
4745 sql = _SQL_GETDLFILEENTRYTYPES;
4746 }
4747
4748 SQLQuery q = session.createSQLQuery(sql);
4749
4750 q.addEntity("DLFileEntryType",
4751 com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl.class);
4752
4753 QueryPos qPos = QueryPos.getInstance(q);
4754
4755 qPos.add(pk);
4756
4757 list = (List<com.liferay.portlet.documentlibrary.model.DLFileEntryType>)QueryUtil.list(q,
4758 getDialect(), start, end);
4759 }
4760 catch (Exception e) {
4761 throw processException(e);
4762 }
4763 finally {
4764 if (list == null) {
4765 FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
4766 finderArgs);
4767 }
4768 else {
4769 dlFileEntryTypePersistence.cacheResult(list);
4770
4771 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES,
4772 finderArgs, list);
4773 }
4774
4775 closeSession(session);
4776 }
4777 }
4778
4779 return list;
4780 }
4781
4782 public static final FinderPath FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
4783 DDMStructureModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
4784 Long.class,
4785 DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
4786 "getDLFileEntryTypesSize", new String[] { Long.class.getName() });
4787
4788 static {
4789 FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE.setCacheKeyGeneratorCacheName(null);
4790 }
4791
4792
4799 public int getDLFileEntryTypesSize(long pk) throws SystemException {
4800 Object[] finderArgs = new Object[] { pk };
4801
4802 Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
4803 finderArgs, this);
4804
4805 if (count == null) {
4806 Session session = null;
4807
4808 try {
4809 session = openSession();
4810
4811 SQLQuery q = session.createSQLQuery(_SQL_GETDLFILEENTRYTYPESSIZE);
4812
4813 q.addScalar(COUNT_COLUMN_NAME,
4814 com.liferay.portal.kernel.dao.orm.Type.LONG);
4815
4816 QueryPos qPos = QueryPos.getInstance(q);
4817
4818 qPos.add(pk);
4819
4820 count = (Long)q.uniqueResult();
4821 }
4822 catch (Exception e) {
4823 throw processException(e);
4824 }
4825 finally {
4826 if (count == null) {
4827 count = Long.valueOf(0);
4828 }
4829
4830 FinderCacheUtil.putResult(FINDER_PATH_GET_DLFILEENTRYTYPES_SIZE,
4831 finderArgs, count);
4832
4833 closeSession(session);
4834 }
4835 }
4836
4837 return count.intValue();
4838 }
4839
4840 public static final FinderPath FINDER_PATH_CONTAINS_DLFILEENTRYTYPE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
4841 DDMStructureModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
4842 Boolean.class,
4843 DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
4844 "containsDLFileEntryType",
4845 new String[] { Long.class.getName(), Long.class.getName() });
4846
4847
4855 public boolean containsDLFileEntryType(long pk, long dlFileEntryTypePK)
4856 throws SystemException {
4857 Object[] finderArgs = new Object[] { pk, dlFileEntryTypePK };
4858
4859 Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
4860 finderArgs, this);
4861
4862 if (value == null) {
4863 try {
4864 value = Boolean.valueOf(containsDLFileEntryType.contains(pk,
4865 dlFileEntryTypePK));
4866 }
4867 catch (Exception e) {
4868 throw processException(e);
4869 }
4870 finally {
4871 if (value == null) {
4872 value = Boolean.FALSE;
4873 }
4874
4875 FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFILEENTRYTYPE,
4876 finderArgs, value);
4877 }
4878 }
4879
4880 return value.booleanValue();
4881 }
4882
4883
4890 public boolean containsDLFileEntryTypes(long pk) throws SystemException {
4891 if (getDLFileEntryTypesSize(pk) > 0) {
4892 return true;
4893 }
4894 else {
4895 return false;
4896 }
4897 }
4898
4899
4906 public void addDLFileEntryType(long pk, long dlFileEntryTypePK)
4907 throws SystemException {
4908 try {
4909 addDLFileEntryType.add(pk, dlFileEntryTypePK);
4910 }
4911 catch (Exception e) {
4912 throw processException(e);
4913 }
4914 finally {
4915 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
4916 }
4917 }
4918
4919
4926 public void addDLFileEntryType(long pk,
4927 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
4928 throws SystemException {
4929 try {
4930 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
4931 }
4932 catch (Exception e) {
4933 throw processException(e);
4934 }
4935 finally {
4936 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
4937 }
4938 }
4939
4940
4947 public void addDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
4948 throws SystemException {
4949 try {
4950 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
4951 addDLFileEntryType.add(pk, dlFileEntryTypePK);
4952 }
4953 }
4954 catch (Exception e) {
4955 throw processException(e);
4956 }
4957 finally {
4958 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
4959 }
4960 }
4961
4962
4969 public void addDLFileEntryTypes(long pk,
4970 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
4971 throws SystemException {
4972 try {
4973 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
4974 addDLFileEntryType.add(pk, dlFileEntryType.getPrimaryKey());
4975 }
4976 }
4977 catch (Exception e) {
4978 throw processException(e);
4979 }
4980 finally {
4981 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
4982 }
4983 }
4984
4985
4991 public void clearDLFileEntryTypes(long pk) throws SystemException {
4992 try {
4993 clearDLFileEntryTypes.clear(pk);
4994 }
4995 catch (Exception e) {
4996 throw processException(e);
4997 }
4998 finally {
4999 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5000 }
5001 }
5002
5003
5010 public void removeDLFileEntryType(long pk, long dlFileEntryTypePK)
5011 throws SystemException {
5012 try {
5013 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5014 }
5015 catch (Exception e) {
5016 throw processException(e);
5017 }
5018 finally {
5019 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5020 }
5021 }
5022
5023
5030 public void removeDLFileEntryType(long pk,
5031 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType)
5032 throws SystemException {
5033 try {
5034 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
5035 }
5036 catch (Exception e) {
5037 throw processException(e);
5038 }
5039 finally {
5040 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5041 }
5042 }
5043
5044
5051 public void removeDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5052 throws SystemException {
5053 try {
5054 for (long dlFileEntryTypePK : dlFileEntryTypePKs) {
5055 removeDLFileEntryType.remove(pk, dlFileEntryTypePK);
5056 }
5057 }
5058 catch (Exception e) {
5059 throw processException(e);
5060 }
5061 finally {
5062 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5063 }
5064 }
5065
5066
5073 public void removeDLFileEntryTypes(long pk,
5074 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5075 throws SystemException {
5076 try {
5077 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5078 removeDLFileEntryType.remove(pk, dlFileEntryType.getPrimaryKey());
5079 }
5080 }
5081 catch (Exception e) {
5082 throw processException(e);
5083 }
5084 finally {
5085 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5086 }
5087 }
5088
5089
5096 public void setDLFileEntryTypes(long pk, long[] dlFileEntryTypePKs)
5097 throws SystemException {
5098 try {
5099 Set<Long> dlFileEntryTypePKSet = SetUtil.fromArray(dlFileEntryTypePKs);
5100
5101 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
5102 getDLFileEntryTypes(pk);
5103
5104 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5105 if (!dlFileEntryTypePKSet.remove(
5106 dlFileEntryType.getPrimaryKey())) {
5107 removeDLFileEntryType.remove(pk,
5108 dlFileEntryType.getPrimaryKey());
5109 }
5110 }
5111
5112 for (Long dlFileEntryTypePK : dlFileEntryTypePKSet) {
5113 addDLFileEntryType.add(pk, dlFileEntryTypePK);
5114 }
5115 }
5116 catch (Exception e) {
5117 throw processException(e);
5118 }
5119 finally {
5120 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5121 }
5122 }
5123
5124
5131 public void setDLFileEntryTypes(long pk,
5132 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes)
5133 throws SystemException {
5134 try {
5135 long[] dlFileEntryTypePKs = new long[dlFileEntryTypes.size()];
5136
5137 for (int i = 0; i < dlFileEntryTypes.size(); i++) {
5138 com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType =
5139 dlFileEntryTypes.get(i);
5140
5141 dlFileEntryTypePKs[i] = dlFileEntryType.getPrimaryKey();
5142 }
5143
5144 setDLFileEntryTypes(pk, dlFileEntryTypePKs);
5145 }
5146 catch (Exception e) {
5147 throw processException(e);
5148 }
5149 finally {
5150 FinderCacheUtil.clearCache(DDMStructureModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
5151 }
5152 }
5153
5154
5157 public void afterPropertiesSet() {
5158 String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
5159 com.liferay.portal.util.PropsUtil.get(
5160 "value.object.listener.com.liferay.portlet.dynamicdatamapping.model.DDMStructure")));
5161
5162 if (listenerClassNames.length > 0) {
5163 try {
5164 List<ModelListener<DDMStructure>> listenersList = new ArrayList<ModelListener<DDMStructure>>();
5165
5166 for (String listenerClassName : listenerClassNames) {
5167 Class<?> clazz = getClass();
5168
5169 listenersList.add((ModelListener<DDMStructure>)InstanceFactory.newInstance(
5170 clazz.getClassLoader(), listenerClassName));
5171 }
5172
5173 listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
5174 }
5175 catch (Exception e) {
5176 _log.error(e);
5177 }
5178 }
5179
5180 containsDLFileEntryType = new ContainsDLFileEntryType();
5181
5182 addDLFileEntryType = new AddDLFileEntryType();
5183 clearDLFileEntryTypes = new ClearDLFileEntryTypes();
5184 removeDLFileEntryType = new RemoveDLFileEntryType();
5185 }
5186
5187 public void destroy() {
5188 EntityCacheUtil.removeCache(DDMStructureImpl.class.getName());
5189 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
5190 FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
5191 }
5192
5193 @BeanReference(type = DDMContentPersistence.class)
5194 protected DDMContentPersistence ddmContentPersistence;
5195 @BeanReference(type = DDMStorageLinkPersistence.class)
5196 protected DDMStorageLinkPersistence ddmStorageLinkPersistence;
5197 @BeanReference(type = DDMStructurePersistence.class)
5198 protected DDMStructurePersistence ddmStructurePersistence;
5199 @BeanReference(type = DDMStructureLinkPersistence.class)
5200 protected DDMStructureLinkPersistence ddmStructureLinkPersistence;
5201 @BeanReference(type = DDMTemplatePersistence.class)
5202 protected DDMTemplatePersistence ddmTemplatePersistence;
5203 @BeanReference(type = ResourcePersistence.class)
5204 protected ResourcePersistence resourcePersistence;
5205 @BeanReference(type = UserPersistence.class)
5206 protected UserPersistence userPersistence;
5207 @BeanReference(type = DLFileEntryTypePersistence.class)
5208 protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
5209 protected ContainsDLFileEntryType containsDLFileEntryType;
5210 protected AddDLFileEntryType addDLFileEntryType;
5211 protected ClearDLFileEntryTypes clearDLFileEntryTypes;
5212 protected RemoveDLFileEntryType removeDLFileEntryType;
5213
5214 protected class ContainsDLFileEntryType {
5215 protected ContainsDLFileEntryType() {
5216 _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
5217 _SQL_CONTAINSDLFILEENTRYTYPE,
5218 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
5219 RowMapper.COUNT);
5220 }
5221
5222 protected boolean contains(long structureId, long fileEntryTypeId) {
5223 List<Integer> results = _mappingSqlQuery.execute(new Object[] {
5224 new Long(structureId), new Long(fileEntryTypeId)
5225 });
5226
5227 if (results.size() > 0) {
5228 Integer count = results.get(0);
5229
5230 if (count.intValue() > 0) {
5231 return true;
5232 }
5233 }
5234
5235 return false;
5236 }
5237
5238 private MappingSqlQuery<Integer> _mappingSqlQuery;
5239 }
5240
5241 protected class AddDLFileEntryType {
5242 protected AddDLFileEntryType() {
5243 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5244 "INSERT INTO DLFileEntryTypes_DDMStructures (structureId, fileEntryTypeId) VALUES (?, ?)",
5245 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5246 }
5247
5248 protected void add(long structureId, long fileEntryTypeId)
5249 throws SystemException {
5250 if (!containsDLFileEntryType.contains(structureId, fileEntryTypeId)) {
5251 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
5252 dlFileEntryTypePersistence.getListeners();
5253
5254 for (ModelListener<DDMStructure> listener : listeners) {
5255 listener.onBeforeAddAssociation(structureId,
5256 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5257 fileEntryTypeId);
5258 }
5259
5260 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5261 listener.onBeforeAddAssociation(fileEntryTypeId,
5262 DDMStructure.class.getName(), structureId);
5263 }
5264
5265 _sqlUpdate.update(new Object[] {
5266 new Long(structureId), new Long(fileEntryTypeId)
5267 });
5268
5269 for (ModelListener<DDMStructure> listener : listeners) {
5270 listener.onAfterAddAssociation(structureId,
5271 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5272 fileEntryTypeId);
5273 }
5274
5275 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5276 listener.onAfterAddAssociation(fileEntryTypeId,
5277 DDMStructure.class.getName(), structureId);
5278 }
5279 }
5280 }
5281
5282 private SqlUpdate _sqlUpdate;
5283 }
5284
5285 protected class ClearDLFileEntryTypes {
5286 protected ClearDLFileEntryTypes() {
5287 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5288 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE structureId = ?",
5289 new int[] { java.sql.Types.BIGINT });
5290 }
5291
5292 protected void clear(long structureId) throws SystemException {
5293 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
5294 dlFileEntryTypePersistence.getListeners();
5295
5296 List<com.liferay.portlet.documentlibrary.model.DLFileEntryType> dlFileEntryTypes =
5297 null;
5298
5299 if ((listeners.length > 0) ||
5300 (dlFileEntryTypeListeners.length > 0)) {
5301 dlFileEntryTypes = getDLFileEntryTypes(structureId);
5302
5303 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5304 for (ModelListener<DDMStructure> listener : listeners) {
5305 listener.onBeforeRemoveAssociation(structureId,
5306 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5307 dlFileEntryType.getPrimaryKey());
5308 }
5309
5310 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5311 listener.onBeforeRemoveAssociation(dlFileEntryType.getPrimaryKey(),
5312 DDMStructure.class.getName(), structureId);
5313 }
5314 }
5315 }
5316
5317 _sqlUpdate.update(new Object[] { new Long(structureId) });
5318
5319 if ((listeners.length > 0) ||
5320 (dlFileEntryTypeListeners.length > 0)) {
5321 for (com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
5322 for (ModelListener<DDMStructure> listener : listeners) {
5323 listener.onAfterRemoveAssociation(structureId,
5324 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5325 dlFileEntryType.getPrimaryKey());
5326 }
5327
5328 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5329 listener.onAfterRemoveAssociation(dlFileEntryType.getPrimaryKey(),
5330 DDMStructure.class.getName(), structureId);
5331 }
5332 }
5333 }
5334 }
5335
5336 private SqlUpdate _sqlUpdate;
5337 }
5338
5339 protected class RemoveDLFileEntryType {
5340 protected RemoveDLFileEntryType() {
5341 _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
5342 "DELETE FROM DLFileEntryTypes_DDMStructures WHERE structureId = ? AND fileEntryTypeId = ?",
5343 new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
5344 }
5345
5346 protected void remove(long structureId, long fileEntryTypeId)
5347 throws SystemException {
5348 if (containsDLFileEntryType.contains(structureId, fileEntryTypeId)) {
5349 ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType>[] dlFileEntryTypeListeners =
5350 dlFileEntryTypePersistence.getListeners();
5351
5352 for (ModelListener<DDMStructure> listener : listeners) {
5353 listener.onBeforeRemoveAssociation(structureId,
5354 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5355 fileEntryTypeId);
5356 }
5357
5358 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5359 listener.onBeforeRemoveAssociation(fileEntryTypeId,
5360 DDMStructure.class.getName(), structureId);
5361 }
5362
5363 _sqlUpdate.update(new Object[] {
5364 new Long(structureId), new Long(fileEntryTypeId)
5365 });
5366
5367 for (ModelListener<DDMStructure> listener : listeners) {
5368 listener.onAfterRemoveAssociation(structureId,
5369 com.liferay.portlet.documentlibrary.model.DLFileEntryType.class.getName(),
5370 fileEntryTypeId);
5371 }
5372
5373 for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFileEntryType> listener : dlFileEntryTypeListeners) {
5374 listener.onAfterRemoveAssociation(fileEntryTypeId,
5375 DDMStructure.class.getName(), structureId);
5376 }
5377 }
5378 }
5379
5380 private SqlUpdate _sqlUpdate;
5381 }
5382
5383 private static final String _SQL_SELECT_DDMSTRUCTURE = "SELECT ddmStructure FROM DDMStructure ddmStructure";
5384 private static final String _SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT ddmStructure FROM DDMStructure ddmStructure WHERE ";
5385 private static final String _SQL_COUNT_DDMSTRUCTURE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure";
5386 private static final String _SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(ddmStructure) FROM DDMStructure ddmStructure WHERE ";
5387 private static final String _SQL_GETDLFILEENTRYTYPES = "SELECT {DLFileEntryType.*} FROM DLFileEntryType INNER JOIN DLFileEntryTypes_DDMStructures ON (DLFileEntryTypes_DDMStructures.fileEntryTypeId = DLFileEntryType.fileEntryTypeId) WHERE (DLFileEntryTypes_DDMStructures.structureId = ?)";
5388 private static final String _SQL_GETDLFILEENTRYTYPESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE structureId = ?";
5389 private static final String _SQL_CONTAINSDLFILEENTRYTYPE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE structureId = ? AND fileEntryTypeId = ?";
5390 private static final String _FINDER_COLUMN_UUID_UUID_1 = "ddmStructure.uuid IS NULL";
5391 private static final String _FINDER_COLUMN_UUID_UUID_2 = "ddmStructure.uuid = ?";
5392 private static final String _FINDER_COLUMN_UUID_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = ?)";
5393 private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "ddmStructure.uuid IS NULL AND ";
5394 private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "ddmStructure.uuid = ? AND ";
5395 private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(ddmStructure.uuid IS NULL OR ddmStructure.uuid = ?) AND ";
5396 private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "ddmStructure.groupId = ?";
5397 private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "ddmStructure.groupId = ?";
5398 private static final String _FINDER_COLUMN_CLASSNAMEID_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
5399 private static final String _FINDER_COLUMN_G_S_GROUPID_2 = "ddmStructure.groupId = ? AND ";
5400 private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_1 = "ddmStructure.structureKey IS NULL";
5401 private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_2 = "ddmStructure.structureKey = ?";
5402 private static final String _FINDER_COLUMN_G_S_STRUCTUREKEY_3 = "(ddmStructure.structureKey IS NULL OR ddmStructure.structureKey = ?)";
5403 private static final String _FINDER_COLUMN_C_C_COMPANYID_2 = "ddmStructure.companyId = ? AND ";
5404 private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "ddmStructure.classNameId = ?";
5405 private static final String _FINDER_COLUMN_G_N_D_GROUPID_2 = "ddmStructure.groupId = ? AND ";
5406 private static final String _FINDER_COLUMN_G_N_D_NAME_1 = "ddmStructure.name IS NULL AND ";
5407 private static final String _FINDER_COLUMN_G_N_D_NAME_2 = "ddmStructure.name = ? AND ";
5408 private static final String _FINDER_COLUMN_G_N_D_NAME_3 = "(ddmStructure.name IS NULL OR ddmStructure.name = ?) AND ";
5409 private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_1 = "ddmStructure.description IS NULL";
5410 private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_2 = "ddmStructure.description = ?";
5411 private static final String _FINDER_COLUMN_G_N_D_DESCRIPTION_3 = "(ddmStructure.description IS NULL OR ddmStructure.description = ?)";
5412 private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "ddmStructure.structureId";
5413 private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_WHERE = "SELECT DISTINCT {ddmStructure.*} FROM DDMStructure ddmStructure WHERE ";
5414 private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_1 =
5415 "SELECT {DDMStructure.*} FROM (SELECT DISTINCT ddmStructure.structureId FROM DDMStructure ddmStructure WHERE ";
5416 private static final String _FILTER_SQL_SELECT_DDMSTRUCTURE_NO_INLINE_DISTINCT_WHERE_2 =
5417 ") TEMP_TABLE INNER JOIN DDMStructure ON TEMP_TABLE.structureId = DDMStructure.structureId";
5418 private static final String _FILTER_SQL_COUNT_DDMSTRUCTURE_WHERE = "SELECT COUNT(DISTINCT ddmStructure.structureId) AS COUNT_VALUE FROM DDMStructure ddmStructure WHERE ";
5419 private static final String _FILTER_ENTITY_ALIAS = "ddmStructure";
5420 private static final String _FILTER_ENTITY_TABLE = "DDMStructure";
5421 private static final String _ORDER_BY_ENTITY_ALIAS = "ddmStructure.";
5422 private static final String _ORDER_BY_ENTITY_TABLE = "DDMStructure.";
5423 private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DDMStructure exists with the primary key ";
5424 private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DDMStructure exists with the key {";
5425 private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
5426 private static Log _log = LogFactoryUtil.getLog(DDMStructurePersistenceImpl.class);
5427 private static DDMStructure _nullDDMStructure = new DDMStructureImpl() {
5428 @Override
5429 public Object clone() {
5430 return this;
5431 }
5432
5433 @Override
5434 public CacheModel<DDMStructure> toCacheModel() {
5435 return _nullDDMStructureCacheModel;
5436 }
5437 };
5438
5439 private static CacheModel<DDMStructure> _nullDDMStructureCacheModel = new CacheModel<DDMStructure>() {
5440 public DDMStructure toEntityModel() {
5441 return _nullDDMStructure;
5442 }
5443 };
5444 }