001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.documentlibrary.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.ArrayUtil;
037    import com.liferay.portal.kernel.util.GetterUtil;
038    import com.liferay.portal.kernel.util.InstanceFactory;
039    import com.liferay.portal.kernel.util.OrderByComparator;
040    import com.liferay.portal.kernel.util.SetUtil;
041    import com.liferay.portal.kernel.util.StringBundler;
042    import com.liferay.portal.kernel.util.StringPool;
043    import com.liferay.portal.kernel.util.StringUtil;
044    import com.liferay.portal.kernel.util.Validator;
045    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
046    import com.liferay.portal.model.CacheModel;
047    import com.liferay.portal.model.ModelListener;
048    import com.liferay.portal.security.permission.InlineSQLHelperUtil;
049    import com.liferay.portal.service.persistence.BatchSessionUtil;
050    import com.liferay.portal.service.persistence.ResourcePersistence;
051    import com.liferay.portal.service.persistence.UserPersistence;
052    import com.liferay.portal.service.persistence.WorkflowDefinitionLinkPersistence;
053    import com.liferay.portal.service.persistence.WorkflowInstanceLinkPersistence;
054    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
055    
056    import com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException;
057    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
058    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeImpl;
059    import com.liferay.portlet.documentlibrary.model.impl.DLFileEntryTypeModelImpl;
060    import com.liferay.portlet.dynamicdatamapping.service.persistence.DDMStructurePersistence;
061    
062    import java.io.Serializable;
063    
064    import java.util.ArrayList;
065    import java.util.Collections;
066    import java.util.List;
067    import java.util.Set;
068    
069    /**
070     * The persistence implementation for the document library file entry type service.
071     *
072     * <p>
073     * Caching information and settings can be found in <code>portal.properties</code>
074     * </p>
075     *
076     * @author Brian Wing Shun Chan
077     * @see DLFileEntryTypePersistence
078     * @see DLFileEntryTypeUtil
079     * @generated
080     */
081    public class DLFileEntryTypePersistenceImpl extends BasePersistenceImpl<DLFileEntryType>
082            implements DLFileEntryTypePersistence {
083            /*
084             * NOTE FOR DEVELOPERS:
085             *
086             * Never modify or reference this class directly. Always use {@link DLFileEntryTypeUtil} to access the document library file entry type persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
087             */
088            public static final String FINDER_CLASS_NAME_ENTITY = DLFileEntryTypeImpl.class.getName();
089            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
090                    ".List1";
091            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
092                    ".List2";
093            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
094                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
095                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
096                            "findByUuid",
097                            new String[] {
098                                    String.class.getName(),
099                                    
100                            "java.lang.Integer", "java.lang.Integer",
101                                    "com.liferay.portal.kernel.util.OrderByComparator"
102                            });
103            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
104                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
105                            DLFileEntryTypeImpl.class,
106                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
107                            new String[] { String.class.getName() },
108                            DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK);
109            public static final FinderPath FINDER_PATH_COUNT_BY_UUID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
110                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
112                            new String[] { String.class.getName() });
113            public static final FinderPath FINDER_PATH_FETCH_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
114                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
115                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY,
116                            "fetchByUUID_G",
117                            new String[] { String.class.getName(), Long.class.getName() },
118                            DLFileEntryTypeModelImpl.UUID_COLUMN_BITMASK |
119                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
120            public static final FinderPath FINDER_PATH_COUNT_BY_UUID_G = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
121                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
122                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUUID_G",
123                            new String[] { String.class.getName(), Long.class.getName() });
124            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
125                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
126                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
127                            "findByGroupId",
128                            new String[] {
129                                    Long.class.getName(),
130                                    
131                            "java.lang.Integer", "java.lang.Integer",
132                                    "com.liferay.portal.kernel.util.OrderByComparator"
133                            });
134            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID =
135                    new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
136                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
137                            DLFileEntryTypeImpl.class,
138                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByGroupId",
139                            new String[] { Long.class.getName() },
140                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK);
141            public static final FinderPath FINDER_PATH_COUNT_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
142                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
143                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByGroupId",
144                            new String[] { Long.class.getName() });
145            public static final FinderPath FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
146                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
147                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "countByGroupId",
148                            new String[] { Long.class.getName() });
149            public static final FinderPath FINDER_PATH_FETCH_BY_G_N = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
150                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
151                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByG_N",
152                            new String[] { Long.class.getName(), String.class.getName() },
153                            DLFileEntryTypeModelImpl.GROUPID_COLUMN_BITMASK |
154                            DLFileEntryTypeModelImpl.NAME_COLUMN_BITMASK);
155            public static final FinderPath FINDER_PATH_COUNT_BY_G_N = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_N",
158                            new String[] { Long.class.getName(), String.class.getName() });
159            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
160                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
161                            DLFileEntryTypeImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
162                            "findAll", new String[0]);
163            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
164                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED,
165                            DLFileEntryTypeImpl.class,
166                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
167            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
168                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED, Long.class,
169                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
170    
171            /**
172             * Caches the document library file entry type in the entity cache if it is enabled.
173             *
174             * @param dlFileEntryType the document library file entry type
175             */
176            public void cacheResult(DLFileEntryType dlFileEntryType) {
177                    EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
178                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
179                            dlFileEntryType);
180    
181                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
182                            new Object[] {
183                                    dlFileEntryType.getUuid(),
184                                    Long.valueOf(dlFileEntryType.getGroupId())
185                            }, dlFileEntryType);
186    
187                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
188                            new Object[] {
189                                    Long.valueOf(dlFileEntryType.getGroupId()),
190                                    
191                            dlFileEntryType.getName()
192                            }, dlFileEntryType);
193    
194                    dlFileEntryType.resetOriginalValues();
195            }
196    
197            /**
198             * Caches the document library file entry types in the entity cache if it is enabled.
199             *
200             * @param dlFileEntryTypes the document library file entry types
201             */
202            public void cacheResult(List<DLFileEntryType> dlFileEntryTypes) {
203                    for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
204                            if (EntityCacheUtil.getResult(
205                                                    DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
206                                                    DLFileEntryTypeImpl.class,
207                                                    dlFileEntryType.getPrimaryKey()) == null) {
208                                    cacheResult(dlFileEntryType);
209                            }
210                            else {
211                                    dlFileEntryType.resetOriginalValues();
212                            }
213                    }
214            }
215    
216            /**
217             * Clears the cache for all document library file entry types.
218             *
219             * <p>
220             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
221             * </p>
222             */
223            @Override
224            public void clearCache() {
225                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
226                            CacheRegistryUtil.clear(DLFileEntryTypeImpl.class.getName());
227                    }
228    
229                    EntityCacheUtil.clearCache(DLFileEntryTypeImpl.class.getName());
230    
231                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
232                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
234            }
235    
236            /**
237             * Clears the cache for the document library file entry type.
238             *
239             * <p>
240             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
241             * </p>
242             */
243            @Override
244            public void clearCache(DLFileEntryType dlFileEntryType) {
245                    EntityCacheUtil.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
246                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
247    
248                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
249                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
250    
251                    clearUniqueFindersCache(dlFileEntryType);
252            }
253    
254            @Override
255            public void clearCache(List<DLFileEntryType> dlFileEntryTypes) {
256                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258    
259                    for (DLFileEntryType dlFileEntryType : dlFileEntryTypes) {
260                            EntityCacheUtil.removeResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
261                                    DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey());
262    
263                            clearUniqueFindersCache(dlFileEntryType);
264                    }
265            }
266    
267            protected void clearUniqueFindersCache(DLFileEntryType dlFileEntryType) {
268                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
269                            new Object[] {
270                                    dlFileEntryType.getUuid(),
271                                    Long.valueOf(dlFileEntryType.getGroupId())
272                            });
273    
274                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
275                            new Object[] {
276                                    Long.valueOf(dlFileEntryType.getGroupId()),
277                                    
278                            dlFileEntryType.getName()
279                            });
280            }
281    
282            /**
283             * Creates a new document library file entry type with the primary key. Does not add the document library file entry type to the database.
284             *
285             * @param fileEntryTypeId the primary key for the new document library file entry type
286             * @return the new document library file entry type
287             */
288            public DLFileEntryType create(long fileEntryTypeId) {
289                    DLFileEntryType dlFileEntryType = new DLFileEntryTypeImpl();
290    
291                    dlFileEntryType.setNew(true);
292                    dlFileEntryType.setPrimaryKey(fileEntryTypeId);
293    
294                    String uuid = PortalUUIDUtil.generate();
295    
296                    dlFileEntryType.setUuid(uuid);
297    
298                    return dlFileEntryType;
299            }
300    
301            /**
302             * Removes the document library file entry type with the primary key from the database. Also notifies the appropriate model listeners.
303             *
304             * @param fileEntryTypeId the primary key of the document library file entry type
305             * @return the document library file entry type that was removed
306             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
307             * @throws SystemException if a system exception occurred
308             */
309            public DLFileEntryType remove(long fileEntryTypeId)
310                    throws NoSuchFileEntryTypeException, SystemException {
311                    return remove(Long.valueOf(fileEntryTypeId));
312            }
313    
314            /**
315             * Removes the document library file entry type with the primary key from the database. Also notifies the appropriate model listeners.
316             *
317             * @param primaryKey the primary key of the document library file entry type
318             * @return the document library file entry type that was removed
319             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
320             * @throws SystemException if a system exception occurred
321             */
322            @Override
323            public DLFileEntryType remove(Serializable primaryKey)
324                    throws NoSuchFileEntryTypeException, SystemException {
325                    Session session = null;
326    
327                    try {
328                            session = openSession();
329    
330                            DLFileEntryType dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
331                                            primaryKey);
332    
333                            if (dlFileEntryType == null) {
334                                    if (_log.isWarnEnabled()) {
335                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
336                                    }
337    
338                                    throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
339                                            primaryKey);
340                            }
341    
342                            return remove(dlFileEntryType);
343                    }
344                    catch (NoSuchFileEntryTypeException nsee) {
345                            throw nsee;
346                    }
347                    catch (Exception e) {
348                            throw processException(e);
349                    }
350                    finally {
351                            closeSession(session);
352                    }
353            }
354    
355            @Override
356            protected DLFileEntryType removeImpl(DLFileEntryType dlFileEntryType)
357                    throws SystemException {
358                    dlFileEntryType = toUnwrappedModel(dlFileEntryType);
359    
360                    try {
361                            clearDLFolders.clear(dlFileEntryType.getPrimaryKey());
362                    }
363                    catch (Exception e) {
364                            throw processException(e);
365                    }
366                    finally {
367                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
368                    }
369    
370                    try {
371                            clearDDMStructures.clear(dlFileEntryType.getPrimaryKey());
372                    }
373                    catch (Exception e) {
374                            throw processException(e);
375                    }
376                    finally {
377                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
378                    }
379    
380                    Session session = null;
381    
382                    try {
383                            session = openSession();
384    
385                            BatchSessionUtil.delete(session, dlFileEntryType);
386                    }
387                    catch (Exception e) {
388                            throw processException(e);
389                    }
390                    finally {
391                            closeSession(session);
392                    }
393    
394                    clearCache(dlFileEntryType);
395    
396                    return dlFileEntryType;
397            }
398    
399            @Override
400            public DLFileEntryType updateImpl(
401                    com.liferay.portlet.documentlibrary.model.DLFileEntryType dlFileEntryType,
402                    boolean merge) throws SystemException {
403                    dlFileEntryType = toUnwrappedModel(dlFileEntryType);
404    
405                    boolean isNew = dlFileEntryType.isNew();
406    
407                    DLFileEntryTypeModelImpl dlFileEntryTypeModelImpl = (DLFileEntryTypeModelImpl)dlFileEntryType;
408    
409                    if (Validator.isNull(dlFileEntryType.getUuid())) {
410                            String uuid = PortalUUIDUtil.generate();
411    
412                            dlFileEntryType.setUuid(uuid);
413                    }
414    
415                    Session session = null;
416    
417                    try {
418                            session = openSession();
419    
420                            BatchSessionUtil.update(session, dlFileEntryType, merge);
421    
422                            dlFileEntryType.setNew(false);
423                    }
424                    catch (Exception e) {
425                            throw processException(e);
426                    }
427                    finally {
428                            closeSession(session);
429                    }
430    
431                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
432    
433                    if (isNew || !DLFileEntryTypeModelImpl.COLUMN_BITMASK_ENABLED) {
434                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
435                    }
436    
437                    else {
438                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
439                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID.getColumnBitmask()) != 0) {
440                                    Object[] args = new Object[] {
441                                                    dlFileEntryTypeModelImpl.getOriginalUuid()
442                                            };
443    
444                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
445                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
446                                            args);
447    
448                                    args = new Object[] { dlFileEntryTypeModelImpl.getUuid() };
449    
450                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID, args);
451                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID,
452                                            args);
453                            }
454    
455                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
456                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID.getColumnBitmask()) != 0) {
457                                    Object[] args = new Object[] {
458                                                    Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
459                                            };
460    
461                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
462                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
463                                            args);
464    
465                                    args = new Object[] {
466                                                    Long.valueOf(dlFileEntryTypeModelImpl.getGroupId())
467                                            };
468    
469                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_GROUPID, args);
470                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID,
471                                            args);
472                            }
473                    }
474    
475                    EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
476                            DLFileEntryTypeImpl.class, dlFileEntryType.getPrimaryKey(),
477                            dlFileEntryType);
478    
479                    if (isNew) {
480                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
481                                    new Object[] {
482                                            dlFileEntryType.getUuid(),
483                                            Long.valueOf(dlFileEntryType.getGroupId())
484                                    }, dlFileEntryType);
485    
486                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
487                                    new Object[] {
488                                            Long.valueOf(dlFileEntryType.getGroupId()),
489                                            
490                                    dlFileEntryType.getName()
491                                    }, dlFileEntryType);
492                    }
493                    else {
494                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
495                                            FINDER_PATH_FETCH_BY_UUID_G.getColumnBitmask()) != 0) {
496                                    Object[] args = new Object[] {
497                                                    dlFileEntryTypeModelImpl.getOriginalUuid(),
498                                                    Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId())
499                                            };
500    
501                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_UUID_G, args);
502    
503                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G, args);
504    
505                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
506                                            new Object[] {
507                                                    dlFileEntryType.getUuid(),
508                                                    Long.valueOf(dlFileEntryType.getGroupId())
509                                            }, dlFileEntryType);
510                            }
511    
512                            if ((dlFileEntryTypeModelImpl.getColumnBitmask() &
513                                            FINDER_PATH_FETCH_BY_G_N.getColumnBitmask()) != 0) {
514                                    Object[] args = new Object[] {
515                                                    Long.valueOf(dlFileEntryTypeModelImpl.getOriginalGroupId()),
516                                                    
517                                                    dlFileEntryTypeModelImpl.getOriginalName()
518                                            };
519    
520                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_N, args);
521    
522                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N, args);
523    
524                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
525                                            new Object[] {
526                                                    Long.valueOf(dlFileEntryType.getGroupId()),
527                                                    
528                                            dlFileEntryType.getName()
529                                            }, dlFileEntryType);
530                            }
531                    }
532    
533                    return dlFileEntryType;
534            }
535    
536            protected DLFileEntryType toUnwrappedModel(DLFileEntryType dlFileEntryType) {
537                    if (dlFileEntryType instanceof DLFileEntryTypeImpl) {
538                            return dlFileEntryType;
539                    }
540    
541                    DLFileEntryTypeImpl dlFileEntryTypeImpl = new DLFileEntryTypeImpl();
542    
543                    dlFileEntryTypeImpl.setNew(dlFileEntryType.isNew());
544                    dlFileEntryTypeImpl.setPrimaryKey(dlFileEntryType.getPrimaryKey());
545    
546                    dlFileEntryTypeImpl.setUuid(dlFileEntryType.getUuid());
547                    dlFileEntryTypeImpl.setFileEntryTypeId(dlFileEntryType.getFileEntryTypeId());
548                    dlFileEntryTypeImpl.setGroupId(dlFileEntryType.getGroupId());
549                    dlFileEntryTypeImpl.setCompanyId(dlFileEntryType.getCompanyId());
550                    dlFileEntryTypeImpl.setUserId(dlFileEntryType.getUserId());
551                    dlFileEntryTypeImpl.setUserName(dlFileEntryType.getUserName());
552                    dlFileEntryTypeImpl.setCreateDate(dlFileEntryType.getCreateDate());
553                    dlFileEntryTypeImpl.setModifiedDate(dlFileEntryType.getModifiedDate());
554                    dlFileEntryTypeImpl.setName(dlFileEntryType.getName());
555                    dlFileEntryTypeImpl.setDescription(dlFileEntryType.getDescription());
556    
557                    return dlFileEntryTypeImpl;
558            }
559    
560            /**
561             * Returns the document library file entry type with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
562             *
563             * @param primaryKey the primary key of the document library file entry type
564             * @return the document library file entry type
565             * @throws com.liferay.portal.NoSuchModelException if a document library file entry type with the primary key could not be found
566             * @throws SystemException if a system exception occurred
567             */
568            @Override
569            public DLFileEntryType findByPrimaryKey(Serializable primaryKey)
570                    throws NoSuchModelException, SystemException {
571                    return findByPrimaryKey(((Long)primaryKey).longValue());
572            }
573    
574            /**
575             * Returns the document library file entry type with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException} if it could not be found.
576             *
577             * @param fileEntryTypeId the primary key of the document library file entry type
578             * @return the document library file entry type
579             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
580             * @throws SystemException if a system exception occurred
581             */
582            public DLFileEntryType findByPrimaryKey(long fileEntryTypeId)
583                    throws NoSuchFileEntryTypeException, SystemException {
584                    DLFileEntryType dlFileEntryType = fetchByPrimaryKey(fileEntryTypeId);
585    
586                    if (dlFileEntryType == null) {
587                            if (_log.isWarnEnabled()) {
588                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileEntryTypeId);
589                            }
590    
591                            throw new NoSuchFileEntryTypeException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
592                                    fileEntryTypeId);
593                    }
594    
595                    return dlFileEntryType;
596            }
597    
598            /**
599             * Returns the document library file entry type with the primary key or returns <code>null</code> if it could not be found.
600             *
601             * @param primaryKey the primary key of the document library file entry type
602             * @return the document library file entry type, or <code>null</code> if a document library file entry type with the primary key could not be found
603             * @throws SystemException if a system exception occurred
604             */
605            @Override
606            public DLFileEntryType fetchByPrimaryKey(Serializable primaryKey)
607                    throws SystemException {
608                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
609            }
610    
611            /**
612             * Returns the document library file entry type with the primary key or returns <code>null</code> if it could not be found.
613             *
614             * @param fileEntryTypeId the primary key of the document library file entry type
615             * @return the document library file entry type, or <code>null</code> if a document library file entry type with the primary key could not be found
616             * @throws SystemException if a system exception occurred
617             */
618            public DLFileEntryType fetchByPrimaryKey(long fileEntryTypeId)
619                    throws SystemException {
620                    DLFileEntryType dlFileEntryType = (DLFileEntryType)EntityCacheUtil.getResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
621                                    DLFileEntryTypeImpl.class, fileEntryTypeId);
622    
623                    if (dlFileEntryType == _nullDLFileEntryType) {
624                            return null;
625                    }
626    
627                    if (dlFileEntryType == null) {
628                            Session session = null;
629    
630                            boolean hasException = false;
631    
632                            try {
633                                    session = openSession();
634    
635                                    dlFileEntryType = (DLFileEntryType)session.get(DLFileEntryTypeImpl.class,
636                                                    Long.valueOf(fileEntryTypeId));
637                            }
638                            catch (Exception e) {
639                                    hasException = true;
640    
641                                    throw processException(e);
642                            }
643                            finally {
644                                    if (dlFileEntryType != null) {
645                                            cacheResult(dlFileEntryType);
646                                    }
647                                    else if (!hasException) {
648                                            EntityCacheUtil.putResult(DLFileEntryTypeModelImpl.ENTITY_CACHE_ENABLED,
649                                                    DLFileEntryTypeImpl.class, fileEntryTypeId,
650                                                    _nullDLFileEntryType);
651                                    }
652    
653                                    closeSession(session);
654                            }
655                    }
656    
657                    return dlFileEntryType;
658            }
659    
660            /**
661             * Returns all the document library file entry types where uuid = &#63;.
662             *
663             * @param uuid the uuid
664             * @return the matching document library file entry types
665             * @throws SystemException if a system exception occurred
666             */
667            public List<DLFileEntryType> findByUuid(String uuid)
668                    throws SystemException {
669                    return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
670            }
671    
672            /**
673             * Returns a range of all the document library file entry types where uuid = &#63;.
674             *
675             * <p>
676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
677             * </p>
678             *
679             * @param uuid the uuid
680             * @param start the lower bound of the range of document library file entry types
681             * @param end the upper bound of the range of document library file entry types (not inclusive)
682             * @return the range of matching document library file entry types
683             * @throws SystemException if a system exception occurred
684             */
685            public List<DLFileEntryType> findByUuid(String uuid, int start, int end)
686                    throws SystemException {
687                    return findByUuid(uuid, start, end, null);
688            }
689    
690            /**
691             * Returns an ordered range of all the document library file entry types where uuid = &#63;.
692             *
693             * <p>
694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
695             * </p>
696             *
697             * @param uuid the uuid
698             * @param start the lower bound of the range of document library file entry types
699             * @param end the upper bound of the range of document library file entry types (not inclusive)
700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
701             * @return the ordered range of matching document library file entry types
702             * @throws SystemException if a system exception occurred
703             */
704            public List<DLFileEntryType> findByUuid(String uuid, int start, int end,
705                    OrderByComparator orderByComparator) throws SystemException {
706                    FinderPath finderPath = null;
707                    Object[] finderArgs = null;
708    
709                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
710                                    (orderByComparator == null)) {
711                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_UUID;
712                            finderArgs = new Object[] { uuid };
713                    }
714                    else {
715                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_UUID;
716                            finderArgs = new Object[] { uuid, start, end, orderByComparator };
717                    }
718    
719                    List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
720                                    finderArgs, this);
721    
722                    if ((list != null) && !list.isEmpty()) {
723                            for (DLFileEntryType dlFileEntryType : list) {
724                                    if (!Validator.equals(uuid, dlFileEntryType.getUuid())) {
725                                            list = null;
726    
727                                            break;
728                                    }
729                            }
730                    }
731    
732                    if (list == null) {
733                            StringBundler query = null;
734    
735                            if (orderByComparator != null) {
736                                    query = new StringBundler(3 +
737                                                    (orderByComparator.getOrderByFields().length * 3));
738                            }
739                            else {
740                                    query = new StringBundler(2);
741                            }
742    
743                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
744    
745                            if (uuid == null) {
746                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
747                            }
748                            else {
749                                    if (uuid.equals(StringPool.BLANK)) {
750                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
751                                    }
752                                    else {
753                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
754                                    }
755                            }
756    
757                            if (orderByComparator != null) {
758                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
759                                            orderByComparator);
760                            }
761    
762                            String sql = query.toString();
763    
764                            Session session = null;
765    
766                            try {
767                                    session = openSession();
768    
769                                    Query q = session.createQuery(sql);
770    
771                                    QueryPos qPos = QueryPos.getInstance(q);
772    
773                                    if (uuid != null) {
774                                            qPos.add(uuid);
775                                    }
776    
777                                    list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
778                                                    start, end);
779                            }
780                            catch (Exception e) {
781                                    throw processException(e);
782                            }
783                            finally {
784                                    if (list == null) {
785                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
786                                    }
787                                    else {
788                                            cacheResult(list);
789    
790                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
791                                    }
792    
793                                    closeSession(session);
794                            }
795                    }
796    
797                    return list;
798            }
799    
800            /**
801             * Returns the first document library file entry type in the ordered set where uuid = &#63;.
802             *
803             * @param uuid the uuid
804             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
805             * @return the first matching document library file entry type
806             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
807             * @throws SystemException if a system exception occurred
808             */
809            public DLFileEntryType findByUuid_First(String uuid,
810                    OrderByComparator orderByComparator)
811                    throws NoSuchFileEntryTypeException, SystemException {
812                    DLFileEntryType dlFileEntryType = fetchByUuid_First(uuid,
813                                    orderByComparator);
814    
815                    if (dlFileEntryType != null) {
816                            return dlFileEntryType;
817                    }
818    
819                    StringBundler msg = new StringBundler(4);
820    
821                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
822    
823                    msg.append("uuid=");
824                    msg.append(uuid);
825    
826                    msg.append(StringPool.CLOSE_CURLY_BRACE);
827    
828                    throw new NoSuchFileEntryTypeException(msg.toString());
829            }
830    
831            /**
832             * Returns the first document library file entry type in the ordered set where uuid = &#63;.
833             *
834             * @param uuid the uuid
835             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
836             * @return the first matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
837             * @throws SystemException if a system exception occurred
838             */
839            public DLFileEntryType fetchByUuid_First(String uuid,
840                    OrderByComparator orderByComparator) throws SystemException {
841                    List<DLFileEntryType> list = findByUuid(uuid, 0, 1, orderByComparator);
842    
843                    if (!list.isEmpty()) {
844                            return list.get(0);
845                    }
846    
847                    return null;
848            }
849    
850            /**
851             * Returns the last document library file entry type in the ordered set where uuid = &#63;.
852             *
853             * @param uuid the uuid
854             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
855             * @return the last matching document library file entry type
856             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
857             * @throws SystemException if a system exception occurred
858             */
859            public DLFileEntryType findByUuid_Last(String uuid,
860                    OrderByComparator orderByComparator)
861                    throws NoSuchFileEntryTypeException, SystemException {
862                    DLFileEntryType dlFileEntryType = fetchByUuid_Last(uuid,
863                                    orderByComparator);
864    
865                    if (dlFileEntryType != null) {
866                            return dlFileEntryType;
867                    }
868    
869                    StringBundler msg = new StringBundler(4);
870    
871                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
872    
873                    msg.append("uuid=");
874                    msg.append(uuid);
875    
876                    msg.append(StringPool.CLOSE_CURLY_BRACE);
877    
878                    throw new NoSuchFileEntryTypeException(msg.toString());
879            }
880    
881            /**
882             * Returns the last document library file entry type in the ordered set where uuid = &#63;.
883             *
884             * @param uuid the uuid
885             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
886             * @return the last matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
887             * @throws SystemException if a system exception occurred
888             */
889            public DLFileEntryType fetchByUuid_Last(String uuid,
890                    OrderByComparator orderByComparator) throws SystemException {
891                    int count = countByUuid(uuid);
892    
893                    List<DLFileEntryType> list = findByUuid(uuid, count - 1, count,
894                                    orderByComparator);
895    
896                    if (!list.isEmpty()) {
897                            return list.get(0);
898                    }
899    
900                    return null;
901            }
902    
903            /**
904             * Returns the document library file entry types before and after the current document library file entry type in the ordered set where uuid = &#63;.
905             *
906             * @param fileEntryTypeId the primary key of the current document library file entry type
907             * @param uuid the uuid
908             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
909             * @return the previous, current, and next document library file entry type
910             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
911             * @throws SystemException if a system exception occurred
912             */
913            public DLFileEntryType[] findByUuid_PrevAndNext(long fileEntryTypeId,
914                    String uuid, OrderByComparator orderByComparator)
915                    throws NoSuchFileEntryTypeException, SystemException {
916                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
917    
918                    Session session = null;
919    
920                    try {
921                            session = openSession();
922    
923                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
924    
925                            array[0] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
926                                            orderByComparator, true);
927    
928                            array[1] = dlFileEntryType;
929    
930                            array[2] = getByUuid_PrevAndNext(session, dlFileEntryType, uuid,
931                                            orderByComparator, false);
932    
933                            return array;
934                    }
935                    catch (Exception e) {
936                            throw processException(e);
937                    }
938                    finally {
939                            closeSession(session);
940                    }
941            }
942    
943            protected DLFileEntryType getByUuid_PrevAndNext(Session session,
944                    DLFileEntryType dlFileEntryType, String uuid,
945                    OrderByComparator orderByComparator, boolean previous) {
946                    StringBundler query = null;
947    
948                    if (orderByComparator != null) {
949                            query = new StringBundler(6 +
950                                            (orderByComparator.getOrderByFields().length * 6));
951                    }
952                    else {
953                            query = new StringBundler(3);
954                    }
955    
956                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
957    
958                    if (uuid == null) {
959                            query.append(_FINDER_COLUMN_UUID_UUID_1);
960                    }
961                    else {
962                            if (uuid.equals(StringPool.BLANK)) {
963                                    query.append(_FINDER_COLUMN_UUID_UUID_3);
964                            }
965                            else {
966                                    query.append(_FINDER_COLUMN_UUID_UUID_2);
967                            }
968                    }
969    
970                    if (orderByComparator != null) {
971                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
972    
973                            if (orderByConditionFields.length > 0) {
974                                    query.append(WHERE_AND);
975                            }
976    
977                            for (int i = 0; i < orderByConditionFields.length; i++) {
978                                    query.append(_ORDER_BY_ENTITY_ALIAS);
979                                    query.append(orderByConditionFields[i]);
980    
981                                    if ((i + 1) < orderByConditionFields.length) {
982                                            if (orderByComparator.isAscending() ^ previous) {
983                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
984                                            }
985                                            else {
986                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
987                                            }
988                                    }
989                                    else {
990                                            if (orderByComparator.isAscending() ^ previous) {
991                                                    query.append(WHERE_GREATER_THAN);
992                                            }
993                                            else {
994                                                    query.append(WHERE_LESSER_THAN);
995                                            }
996                                    }
997                            }
998    
999                            query.append(ORDER_BY_CLAUSE);
1000    
1001                            String[] orderByFields = orderByComparator.getOrderByFields();
1002    
1003                            for (int i = 0; i < orderByFields.length; i++) {
1004                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1005                                    query.append(orderByFields[i]);
1006    
1007                                    if ((i + 1) < orderByFields.length) {
1008                                            if (orderByComparator.isAscending() ^ previous) {
1009                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1010                                            }
1011                                            else {
1012                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1013                                            }
1014                                    }
1015                                    else {
1016                                            if (orderByComparator.isAscending() ^ previous) {
1017                                                    query.append(ORDER_BY_ASC);
1018                                            }
1019                                            else {
1020                                                    query.append(ORDER_BY_DESC);
1021                                            }
1022                                    }
1023                            }
1024                    }
1025    
1026                    String sql = query.toString();
1027    
1028                    Query q = session.createQuery(sql);
1029    
1030                    q.setFirstResult(0);
1031                    q.setMaxResults(2);
1032    
1033                    QueryPos qPos = QueryPos.getInstance(q);
1034    
1035                    if (uuid != null) {
1036                            qPos.add(uuid);
1037                    }
1038    
1039                    if (orderByComparator != null) {
1040                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1041    
1042                            for (Object value : values) {
1043                                    qPos.add(value);
1044                            }
1045                    }
1046    
1047                    List<DLFileEntryType> list = q.list();
1048    
1049                    if (list.size() == 2) {
1050                            return list.get(1);
1051                    }
1052                    else {
1053                            return null;
1054                    }
1055            }
1056    
1057            /**
1058             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException} if it could not be found.
1059             *
1060             * @param uuid the uuid
1061             * @param groupId the group ID
1062             * @return the matching document library file entry type
1063             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1064             * @throws SystemException if a system exception occurred
1065             */
1066            public DLFileEntryType findByUUID_G(String uuid, long groupId)
1067                    throws NoSuchFileEntryTypeException, SystemException {
1068                    DLFileEntryType dlFileEntryType = fetchByUUID_G(uuid, groupId);
1069    
1070                    if (dlFileEntryType == null) {
1071                            StringBundler msg = new StringBundler(6);
1072    
1073                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1074    
1075                            msg.append("uuid=");
1076                            msg.append(uuid);
1077    
1078                            msg.append(", groupId=");
1079                            msg.append(groupId);
1080    
1081                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1082    
1083                            if (_log.isWarnEnabled()) {
1084                                    _log.warn(msg.toString());
1085                            }
1086    
1087                            throw new NoSuchFileEntryTypeException(msg.toString());
1088                    }
1089    
1090                    return dlFileEntryType;
1091            }
1092    
1093            /**
1094             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1095             *
1096             * @param uuid the uuid
1097             * @param groupId the group ID
1098             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1099             * @throws SystemException if a system exception occurred
1100             */
1101            public DLFileEntryType fetchByUUID_G(String uuid, long groupId)
1102                    throws SystemException {
1103                    return fetchByUUID_G(uuid, groupId, true);
1104            }
1105    
1106            /**
1107             * Returns the document library file entry type where uuid = &#63; and groupId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1108             *
1109             * @param uuid the uuid
1110             * @param groupId the group ID
1111             * @param retrieveFromCache whether to use the finder cache
1112             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1113             * @throws SystemException if a system exception occurred
1114             */
1115            public DLFileEntryType fetchByUUID_G(String uuid, long groupId,
1116                    boolean retrieveFromCache) throws SystemException {
1117                    Object[] finderArgs = new Object[] { uuid, groupId };
1118    
1119                    Object result = null;
1120    
1121                    if (retrieveFromCache) {
1122                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_UUID_G,
1123                                            finderArgs, this);
1124                    }
1125    
1126                    if (result instanceof DLFileEntryType) {
1127                            DLFileEntryType dlFileEntryType = (DLFileEntryType)result;
1128    
1129                            if (!Validator.equals(uuid, dlFileEntryType.getUuid()) ||
1130                                            (groupId != dlFileEntryType.getGroupId())) {
1131                                    result = null;
1132                            }
1133                    }
1134    
1135                    if (result == null) {
1136                            StringBundler query = new StringBundler(3);
1137    
1138                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1139    
1140                            if (uuid == null) {
1141                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
1142                            }
1143                            else {
1144                                    if (uuid.equals(StringPool.BLANK)) {
1145                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
1146                                    }
1147                                    else {
1148                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
1149                                    }
1150                            }
1151    
1152                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
1153    
1154                            String sql = query.toString();
1155    
1156                            Session session = null;
1157    
1158                            try {
1159                                    session = openSession();
1160    
1161                                    Query q = session.createQuery(sql);
1162    
1163                                    QueryPos qPos = QueryPos.getInstance(q);
1164    
1165                                    if (uuid != null) {
1166                                            qPos.add(uuid);
1167                                    }
1168    
1169                                    qPos.add(groupId);
1170    
1171                                    List<DLFileEntryType> list = q.list();
1172    
1173                                    result = list;
1174    
1175                                    DLFileEntryType dlFileEntryType = null;
1176    
1177                                    if (list.isEmpty()) {
1178                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1179                                                    finderArgs, list);
1180                                    }
1181                                    else {
1182                                            dlFileEntryType = list.get(0);
1183    
1184                                            cacheResult(dlFileEntryType);
1185    
1186                                            if ((dlFileEntryType.getUuid() == null) ||
1187                                                            !dlFileEntryType.getUuid().equals(uuid) ||
1188                                                            (dlFileEntryType.getGroupId() != groupId)) {
1189                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_UUID_G,
1190                                                            finderArgs, dlFileEntryType);
1191                                            }
1192                                    }
1193    
1194                                    return dlFileEntryType;
1195                            }
1196                            catch (Exception e) {
1197                                    throw processException(e);
1198                            }
1199                            finally {
1200                                    if (result == null) {
1201                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_UUID_G,
1202                                                    finderArgs);
1203                                    }
1204    
1205                                    closeSession(session);
1206                            }
1207                    }
1208                    else {
1209                            if (result instanceof List<?>) {
1210                                    return null;
1211                            }
1212                            else {
1213                                    return (DLFileEntryType)result;
1214                            }
1215                    }
1216            }
1217    
1218            /**
1219             * Returns all the document library file entry types where groupId = &#63;.
1220             *
1221             * @param groupId the group ID
1222             * @return the matching document library file entry types
1223             * @throws SystemException if a system exception occurred
1224             */
1225            public List<DLFileEntryType> findByGroupId(long groupId)
1226                    throws SystemException {
1227                    return findByGroupId(groupId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1228            }
1229    
1230            /**
1231             * Returns a range of all the document library file entry types where groupId = &#63;.
1232             *
1233             * <p>
1234             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1235             * </p>
1236             *
1237             * @param groupId the group ID
1238             * @param start the lower bound of the range of document library file entry types
1239             * @param end the upper bound of the range of document library file entry types (not inclusive)
1240             * @return the range of matching document library file entry types
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public List<DLFileEntryType> findByGroupId(long groupId, int start, int end)
1244                    throws SystemException {
1245                    return findByGroupId(groupId, start, end, null);
1246            }
1247    
1248            /**
1249             * Returns an ordered range of all the document library file entry types where groupId = &#63;.
1250             *
1251             * <p>
1252             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1253             * </p>
1254             *
1255             * @param groupId the group ID
1256             * @param start the lower bound of the range of document library file entry types
1257             * @param end the upper bound of the range of document library file entry types (not inclusive)
1258             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1259             * @return the ordered range of matching document library file entry types
1260             * @throws SystemException if a system exception occurred
1261             */
1262            public List<DLFileEntryType> findByGroupId(long groupId, int start,
1263                    int end, OrderByComparator orderByComparator) throws SystemException {
1264                    FinderPath finderPath = null;
1265                    Object[] finderArgs = null;
1266    
1267                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1268                                    (orderByComparator == null)) {
1269                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_GROUPID;
1270                            finderArgs = new Object[] { groupId };
1271                    }
1272                    else {
1273                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1274                            finderArgs = new Object[] { groupId, start, end, orderByComparator };
1275                    }
1276    
1277                    List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1278                                    finderArgs, this);
1279    
1280                    if ((list != null) && !list.isEmpty()) {
1281                            for (DLFileEntryType dlFileEntryType : list) {
1282                                    if ((groupId != dlFileEntryType.getGroupId())) {
1283                                            list = null;
1284    
1285                                            break;
1286                                    }
1287                            }
1288                    }
1289    
1290                    if (list == null) {
1291                            StringBundler query = null;
1292    
1293                            if (orderByComparator != null) {
1294                                    query = new StringBundler(3 +
1295                                                    (orderByComparator.getOrderByFields().length * 3));
1296                            }
1297                            else {
1298                                    query = new StringBundler(2);
1299                            }
1300    
1301                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1302    
1303                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1304    
1305                            if (orderByComparator != null) {
1306                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1307                                            orderByComparator);
1308                            }
1309    
1310                            String sql = query.toString();
1311    
1312                            Session session = null;
1313    
1314                            try {
1315                                    session = openSession();
1316    
1317                                    Query q = session.createQuery(sql);
1318    
1319                                    QueryPos qPos = QueryPos.getInstance(q);
1320    
1321                                    qPos.add(groupId);
1322    
1323                                    list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1324                                                    start, end);
1325                            }
1326                            catch (Exception e) {
1327                                    throw processException(e);
1328                            }
1329                            finally {
1330                                    if (list == null) {
1331                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1332                                    }
1333                                    else {
1334                                            cacheResult(list);
1335    
1336                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1337                                    }
1338    
1339                                    closeSession(session);
1340                            }
1341                    }
1342    
1343                    return list;
1344            }
1345    
1346            /**
1347             * Returns the first document library file entry type in the ordered set where groupId = &#63;.
1348             *
1349             * @param groupId the group ID
1350             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1351             * @return the first matching document library file entry type
1352             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1353             * @throws SystemException if a system exception occurred
1354             */
1355            public DLFileEntryType findByGroupId_First(long groupId,
1356                    OrderByComparator orderByComparator)
1357                    throws NoSuchFileEntryTypeException, SystemException {
1358                    DLFileEntryType dlFileEntryType = fetchByGroupId_First(groupId,
1359                                    orderByComparator);
1360    
1361                    if (dlFileEntryType != null) {
1362                            return dlFileEntryType;
1363                    }
1364    
1365                    StringBundler msg = new StringBundler(4);
1366    
1367                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1368    
1369                    msg.append("groupId=");
1370                    msg.append(groupId);
1371    
1372                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1373    
1374                    throw new NoSuchFileEntryTypeException(msg.toString());
1375            }
1376    
1377            /**
1378             * Returns the first document library file entry type in the ordered set where groupId = &#63;.
1379             *
1380             * @param groupId the group ID
1381             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1382             * @return the first matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1383             * @throws SystemException if a system exception occurred
1384             */
1385            public DLFileEntryType fetchByGroupId_First(long groupId,
1386                    OrderByComparator orderByComparator) throws SystemException {
1387                    List<DLFileEntryType> list = findByGroupId(groupId, 0, 1,
1388                                    orderByComparator);
1389    
1390                    if (!list.isEmpty()) {
1391                            return list.get(0);
1392                    }
1393    
1394                    return null;
1395            }
1396    
1397            /**
1398             * Returns the last document library file entry type in the ordered set where groupId = &#63;.
1399             *
1400             * @param groupId the group ID
1401             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1402             * @return the last matching document library file entry type
1403             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
1404             * @throws SystemException if a system exception occurred
1405             */
1406            public DLFileEntryType findByGroupId_Last(long groupId,
1407                    OrderByComparator orderByComparator)
1408                    throws NoSuchFileEntryTypeException, SystemException {
1409                    DLFileEntryType dlFileEntryType = fetchByGroupId_Last(groupId,
1410                                    orderByComparator);
1411    
1412                    if (dlFileEntryType != null) {
1413                            return dlFileEntryType;
1414                    }
1415    
1416                    StringBundler msg = new StringBundler(4);
1417    
1418                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1419    
1420                    msg.append("groupId=");
1421                    msg.append(groupId);
1422    
1423                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1424    
1425                    throw new NoSuchFileEntryTypeException(msg.toString());
1426            }
1427    
1428            /**
1429             * Returns the last document library file entry type in the ordered set where groupId = &#63;.
1430             *
1431             * @param groupId the group ID
1432             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1433             * @return the last matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
1434             * @throws SystemException if a system exception occurred
1435             */
1436            public DLFileEntryType fetchByGroupId_Last(long groupId,
1437                    OrderByComparator orderByComparator) throws SystemException {
1438                    int count = countByGroupId(groupId);
1439    
1440                    List<DLFileEntryType> list = findByGroupId(groupId, count - 1, count,
1441                                    orderByComparator);
1442    
1443                    if (!list.isEmpty()) {
1444                            return list.get(0);
1445                    }
1446    
1447                    return null;
1448            }
1449    
1450            /**
1451             * Returns the document library file entry types before and after the current document library file entry type in the ordered set where groupId = &#63;.
1452             *
1453             * @param fileEntryTypeId the primary key of the current document library file entry type
1454             * @param groupId the group ID
1455             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1456             * @return the previous, current, and next document library file entry type
1457             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
1458             * @throws SystemException if a system exception occurred
1459             */
1460            public DLFileEntryType[] findByGroupId_PrevAndNext(long fileEntryTypeId,
1461                    long groupId, OrderByComparator orderByComparator)
1462                    throws NoSuchFileEntryTypeException, SystemException {
1463                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1464    
1465                    Session session = null;
1466    
1467                    try {
1468                            session = openSession();
1469    
1470                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1471    
1472                            array[0] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1473                                            groupId, orderByComparator, true);
1474    
1475                            array[1] = dlFileEntryType;
1476    
1477                            array[2] = getByGroupId_PrevAndNext(session, dlFileEntryType,
1478                                            groupId, orderByComparator, false);
1479    
1480                            return array;
1481                    }
1482                    catch (Exception e) {
1483                            throw processException(e);
1484                    }
1485                    finally {
1486                            closeSession(session);
1487                    }
1488            }
1489    
1490            protected DLFileEntryType getByGroupId_PrevAndNext(Session session,
1491                    DLFileEntryType dlFileEntryType, long groupId,
1492                    OrderByComparator orderByComparator, boolean previous) {
1493                    StringBundler query = null;
1494    
1495                    if (orderByComparator != null) {
1496                            query = new StringBundler(6 +
1497                                            (orderByComparator.getOrderByFields().length * 6));
1498                    }
1499                    else {
1500                            query = new StringBundler(3);
1501                    }
1502    
1503                    query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1504    
1505                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1506    
1507                    if (orderByComparator != null) {
1508                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1509    
1510                            if (orderByConditionFields.length > 0) {
1511                                    query.append(WHERE_AND);
1512                            }
1513    
1514                            for (int i = 0; i < orderByConditionFields.length; i++) {
1515                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1516                                    query.append(orderByConditionFields[i]);
1517    
1518                                    if ((i + 1) < orderByConditionFields.length) {
1519                                            if (orderByComparator.isAscending() ^ previous) {
1520                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1521                                            }
1522                                            else {
1523                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1524                                            }
1525                                    }
1526                                    else {
1527                                            if (orderByComparator.isAscending() ^ previous) {
1528                                                    query.append(WHERE_GREATER_THAN);
1529                                            }
1530                                            else {
1531                                                    query.append(WHERE_LESSER_THAN);
1532                                            }
1533                                    }
1534                            }
1535    
1536                            query.append(ORDER_BY_CLAUSE);
1537    
1538                            String[] orderByFields = orderByComparator.getOrderByFields();
1539    
1540                            for (int i = 0; i < orderByFields.length; i++) {
1541                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1542                                    query.append(orderByFields[i]);
1543    
1544                                    if ((i + 1) < orderByFields.length) {
1545                                            if (orderByComparator.isAscending() ^ previous) {
1546                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1547                                            }
1548                                            else {
1549                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1550                                            }
1551                                    }
1552                                    else {
1553                                            if (orderByComparator.isAscending() ^ previous) {
1554                                                    query.append(ORDER_BY_ASC);
1555                                            }
1556                                            else {
1557                                                    query.append(ORDER_BY_DESC);
1558                                            }
1559                                    }
1560                            }
1561                    }
1562    
1563                    String sql = query.toString();
1564    
1565                    Query q = session.createQuery(sql);
1566    
1567                    q.setFirstResult(0);
1568                    q.setMaxResults(2);
1569    
1570                    QueryPos qPos = QueryPos.getInstance(q);
1571    
1572                    qPos.add(groupId);
1573    
1574                    if (orderByComparator != null) {
1575                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
1576    
1577                            for (Object value : values) {
1578                                    qPos.add(value);
1579                            }
1580                    }
1581    
1582                    List<DLFileEntryType> list = q.list();
1583    
1584                    if (list.size() == 2) {
1585                            return list.get(1);
1586                    }
1587                    else {
1588                            return null;
1589                    }
1590            }
1591    
1592            /**
1593             * Returns all the document library file entry types where groupId = any &#63;.
1594             *
1595             * <p>
1596             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1597             * </p>
1598             *
1599             * @param groupIds the group IDs
1600             * @return the matching document library file entry types
1601             * @throws SystemException if a system exception occurred
1602             */
1603            public List<DLFileEntryType> findByGroupId(long[] groupIds)
1604                    throws SystemException {
1605                    return findByGroupId(groupIds, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1606                            null);
1607            }
1608    
1609            /**
1610             * Returns a range of all the document library file entry types where groupId = any &#63;.
1611             *
1612             * <p>
1613             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1614             * </p>
1615             *
1616             * @param groupIds the group IDs
1617             * @param start the lower bound of the range of document library file entry types
1618             * @param end the upper bound of the range of document library file entry types (not inclusive)
1619             * @return the range of matching document library file entry types
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1623                    int end) throws SystemException {
1624                    return findByGroupId(groupIds, start, end, null);
1625            }
1626    
1627            /**
1628             * Returns an ordered range of all the document library file entry types where groupId = any &#63;.
1629             *
1630             * <p>
1631             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1632             * </p>
1633             *
1634             * @param groupIds the group IDs
1635             * @param start the lower bound of the range of document library file entry types
1636             * @param end the upper bound of the range of document library file entry types (not inclusive)
1637             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1638             * @return the ordered range of matching document library file entry types
1639             * @throws SystemException if a system exception occurred
1640             */
1641            public List<DLFileEntryType> findByGroupId(long[] groupIds, int start,
1642                    int end, OrderByComparator orderByComparator) throws SystemException {
1643                    FinderPath finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_GROUPID;
1644                    Object[] finderArgs = null;
1645    
1646                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1647                                    (orderByComparator == null)) {
1648                            finderArgs = new Object[] { StringUtil.merge(groupIds) };
1649                    }
1650                    else {
1651                            finderArgs = new Object[] {
1652                                            StringUtil.merge(groupIds),
1653                                            
1654                                            start, end, orderByComparator
1655                                    };
1656                    }
1657    
1658                    List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
1659                                    finderArgs, this);
1660    
1661                    if ((list != null) && !list.isEmpty()) {
1662                            for (DLFileEntryType dlFileEntryType : list) {
1663                                    if (!ArrayUtil.contains(groupIds, dlFileEntryType.getGroupId())) {
1664                                            list = null;
1665    
1666                                            break;
1667                                    }
1668                            }
1669                    }
1670    
1671                    if (list == null) {
1672                            StringBundler query = new StringBundler();
1673    
1674                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1675    
1676                            boolean conjunctionable = false;
1677    
1678                            if ((groupIds == null) || (groupIds.length > 0)) {
1679                                    if (conjunctionable) {
1680                                            query.append(WHERE_AND);
1681                                    }
1682    
1683                                    query.append(StringPool.OPEN_PARENTHESIS);
1684    
1685                                    for (int i = 0; i < groupIds.length; i++) {
1686                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
1687    
1688                                            if ((i + 1) < groupIds.length) {
1689                                                    query.append(WHERE_OR);
1690                                            }
1691                                    }
1692    
1693                                    query.append(StringPool.CLOSE_PARENTHESIS);
1694    
1695                                    conjunctionable = true;
1696                            }
1697    
1698                            if (orderByComparator != null) {
1699                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1700                                            orderByComparator);
1701                            }
1702    
1703                            String sql = query.toString();
1704    
1705                            Session session = null;
1706    
1707                            try {
1708                                    session = openSession();
1709    
1710                                    Query q = session.createQuery(sql);
1711    
1712                                    QueryPos qPos = QueryPos.getInstance(q);
1713    
1714                                    if (groupIds != null) {
1715                                            qPos.add(groupIds);
1716                                    }
1717    
1718                                    list = (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1719                                                    start, end);
1720                            }
1721                            catch (Exception e) {
1722                                    throw processException(e);
1723                            }
1724                            finally {
1725                                    if (list == null) {
1726                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1727                                    }
1728                                    else {
1729                                            cacheResult(list);
1730    
1731                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1732                                    }
1733    
1734                                    closeSession(session);
1735                            }
1736                    }
1737    
1738                    return list;
1739            }
1740    
1741            /**
1742             * Returns all the document library file entry types that the user has permission to view where groupId = &#63;.
1743             *
1744             * @param groupId the group ID
1745             * @return the matching document library file entry types that the user has permission to view
1746             * @throws SystemException if a system exception occurred
1747             */
1748            public List<DLFileEntryType> filterFindByGroupId(long groupId)
1749                    throws SystemException {
1750                    return filterFindByGroupId(groupId, QueryUtil.ALL_POS,
1751                            QueryUtil.ALL_POS, null);
1752            }
1753    
1754            /**
1755             * Returns a range of all the document library file entry types that the user has permission to view where groupId = &#63;.
1756             *
1757             * <p>
1758             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1759             * </p>
1760             *
1761             * @param groupId the group ID
1762             * @param start the lower bound of the range of document library file entry types
1763             * @param end the upper bound of the range of document library file entry types (not inclusive)
1764             * @return the range of matching document library file entry types that the user has permission to view
1765             * @throws SystemException if a system exception occurred
1766             */
1767            public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1768                    int end) throws SystemException {
1769                    return filterFindByGroupId(groupId, start, end, null);
1770            }
1771    
1772            /**
1773             * Returns an ordered range of all the document library file entry types that the user has permissions to view where groupId = &#63;.
1774             *
1775             * <p>
1776             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
1777             * </p>
1778             *
1779             * @param groupId the group ID
1780             * @param start the lower bound of the range of document library file entry types
1781             * @param end the upper bound of the range of document library file entry types (not inclusive)
1782             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1783             * @return the ordered range of matching document library file entry types that the user has permission to view
1784             * @throws SystemException if a system exception occurred
1785             */
1786            public List<DLFileEntryType> filterFindByGroupId(long groupId, int start,
1787                    int end, OrderByComparator orderByComparator) throws SystemException {
1788                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1789                            return findByGroupId(groupId, start, end, orderByComparator);
1790                    }
1791    
1792                    StringBundler query = null;
1793    
1794                    if (orderByComparator != null) {
1795                            query = new StringBundler(3 +
1796                                            (orderByComparator.getOrderByFields().length * 3));
1797                    }
1798                    else {
1799                            query = new StringBundler(2);
1800                    }
1801    
1802                    if (getDB().isSupportsInlineDistinct()) {
1803                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1804                    }
1805                    else {
1806                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1807                    }
1808    
1809                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1810    
1811                    if (!getDB().isSupportsInlineDistinct()) {
1812                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1813                    }
1814    
1815                    if (orderByComparator != null) {
1816                            if (getDB().isSupportsInlineDistinct()) {
1817                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1818                                            orderByComparator);
1819                            }
1820                            else {
1821                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
1822                                            orderByComparator);
1823                            }
1824                    }
1825    
1826                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1827                                    DLFileEntryType.class.getName(),
1828                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
1829    
1830                    Session session = null;
1831    
1832                    try {
1833                            session = openSession();
1834    
1835                            SQLQuery q = session.createSQLQuery(sql);
1836    
1837                            if (getDB().isSupportsInlineDistinct()) {
1838                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
1839                            }
1840                            else {
1841                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
1842                            }
1843    
1844                            QueryPos qPos = QueryPos.getInstance(q);
1845    
1846                            qPos.add(groupId);
1847    
1848                            return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
1849                                    start, end);
1850                    }
1851                    catch (Exception e) {
1852                            throw processException(e);
1853                    }
1854                    finally {
1855                            closeSession(session);
1856                    }
1857            }
1858    
1859            /**
1860             * Returns the document library file entry types before and after the current document library file entry type in the ordered set of document library file entry types that the user has permission to view where groupId = &#63;.
1861             *
1862             * @param fileEntryTypeId the primary key of the current document library file entry type
1863             * @param groupId the group ID
1864             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1865             * @return the previous, current, and next document library file entry type
1866             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a document library file entry type with the primary key could not be found
1867             * @throws SystemException if a system exception occurred
1868             */
1869            public DLFileEntryType[] filterFindByGroupId_PrevAndNext(
1870                    long fileEntryTypeId, long groupId, OrderByComparator orderByComparator)
1871                    throws NoSuchFileEntryTypeException, SystemException {
1872                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
1873                            return findByGroupId_PrevAndNext(fileEntryTypeId, groupId,
1874                                    orderByComparator);
1875                    }
1876    
1877                    DLFileEntryType dlFileEntryType = findByPrimaryKey(fileEntryTypeId);
1878    
1879                    Session session = null;
1880    
1881                    try {
1882                            session = openSession();
1883    
1884                            DLFileEntryType[] array = new DLFileEntryTypeImpl[3];
1885    
1886                            array[0] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1887                                            groupId, orderByComparator, true);
1888    
1889                            array[1] = dlFileEntryType;
1890    
1891                            array[2] = filterGetByGroupId_PrevAndNext(session, dlFileEntryType,
1892                                            groupId, orderByComparator, false);
1893    
1894                            return array;
1895                    }
1896                    catch (Exception e) {
1897                            throw processException(e);
1898                    }
1899                    finally {
1900                            closeSession(session);
1901                    }
1902            }
1903    
1904            protected DLFileEntryType filterGetByGroupId_PrevAndNext(Session session,
1905                    DLFileEntryType dlFileEntryType, long groupId,
1906                    OrderByComparator orderByComparator, boolean previous) {
1907                    StringBundler query = null;
1908    
1909                    if (orderByComparator != null) {
1910                            query = new StringBundler(6 +
1911                                            (orderByComparator.getOrderByFields().length * 6));
1912                    }
1913                    else {
1914                            query = new StringBundler(3);
1915                    }
1916    
1917                    if (getDB().isSupportsInlineDistinct()) {
1918                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
1919                    }
1920                    else {
1921                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
1922                    }
1923    
1924                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
1925    
1926                    if (!getDB().isSupportsInlineDistinct()) {
1927                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
1928                    }
1929    
1930                    if (orderByComparator != null) {
1931                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1932    
1933                            if (orderByConditionFields.length > 0) {
1934                                    query.append(WHERE_AND);
1935                            }
1936    
1937                            for (int i = 0; i < orderByConditionFields.length; i++) {
1938                                    if (getDB().isSupportsInlineDistinct()) {
1939                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1940                                    }
1941                                    else {
1942                                            query.append(_ORDER_BY_ENTITY_TABLE);
1943                                    }
1944    
1945                                    query.append(orderByConditionFields[i]);
1946    
1947                                    if ((i + 1) < orderByConditionFields.length) {
1948                                            if (orderByComparator.isAscending() ^ previous) {
1949                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1950                                            }
1951                                            else {
1952                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1953                                            }
1954                                    }
1955                                    else {
1956                                            if (orderByComparator.isAscending() ^ previous) {
1957                                                    query.append(WHERE_GREATER_THAN);
1958                                            }
1959                                            else {
1960                                                    query.append(WHERE_LESSER_THAN);
1961                                            }
1962                                    }
1963                            }
1964    
1965                            query.append(ORDER_BY_CLAUSE);
1966    
1967                            String[] orderByFields = orderByComparator.getOrderByFields();
1968    
1969                            for (int i = 0; i < orderByFields.length; i++) {
1970                                    if (getDB().isSupportsInlineDistinct()) {
1971                                            query.append(_ORDER_BY_ENTITY_ALIAS);
1972                                    }
1973                                    else {
1974                                            query.append(_ORDER_BY_ENTITY_TABLE);
1975                                    }
1976    
1977                                    query.append(orderByFields[i]);
1978    
1979                                    if ((i + 1) < orderByFields.length) {
1980                                            if (orderByComparator.isAscending() ^ previous) {
1981                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1982                                            }
1983                                            else {
1984                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1985                                            }
1986                                    }
1987                                    else {
1988                                            if (orderByComparator.isAscending() ^ previous) {
1989                                                    query.append(ORDER_BY_ASC);
1990                                            }
1991                                            else {
1992                                                    query.append(ORDER_BY_DESC);
1993                                            }
1994                                    }
1995                            }
1996                    }
1997    
1998                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
1999                                    DLFileEntryType.class.getName(),
2000                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2001    
2002                    SQLQuery q = session.createSQLQuery(sql);
2003    
2004                    q.setFirstResult(0);
2005                    q.setMaxResults(2);
2006    
2007                    if (getDB().isSupportsInlineDistinct()) {
2008                            q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2009                    }
2010                    else {
2011                            q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2012                    }
2013    
2014                    QueryPos qPos = QueryPos.getInstance(q);
2015    
2016                    qPos.add(groupId);
2017    
2018                    if (orderByComparator != null) {
2019                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileEntryType);
2020    
2021                            for (Object value : values) {
2022                                    qPos.add(value);
2023                            }
2024                    }
2025    
2026                    List<DLFileEntryType> list = q.list();
2027    
2028                    if (list.size() == 2) {
2029                            return list.get(1);
2030                    }
2031                    else {
2032                            return null;
2033                    }
2034            }
2035    
2036            /**
2037             * Returns all the document library file entry types that the user has permission to view where groupId = any &#63;.
2038             *
2039             * @param groupIds the group IDs
2040             * @return the matching document library file entry types that the user has permission to view
2041             * @throws SystemException if a system exception occurred
2042             */
2043            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds)
2044                    throws SystemException {
2045                    return filterFindByGroupId(groupIds, QueryUtil.ALL_POS,
2046                            QueryUtil.ALL_POS, null);
2047            }
2048    
2049            /**
2050             * Returns a range of all the document library file entry types that the user has permission to view where groupId = any &#63;.
2051             *
2052             * <p>
2053             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2054             * </p>
2055             *
2056             * @param groupIds the group IDs
2057             * @param start the lower bound of the range of document library file entry types
2058             * @param end the upper bound of the range of document library file entry types (not inclusive)
2059             * @return the range of matching document library file entry types that the user has permission to view
2060             * @throws SystemException if a system exception occurred
2061             */
2062            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
2063                    int start, int end) throws SystemException {
2064                    return filterFindByGroupId(groupIds, start, end, null);
2065            }
2066    
2067            /**
2068             * Returns an ordered range of all the document library file entry types that the user has permission to view where groupId = any &#63;.
2069             *
2070             * <p>
2071             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2072             * </p>
2073             *
2074             * @param groupIds the group IDs
2075             * @param start the lower bound of the range of document library file entry types
2076             * @param end the upper bound of the range of document library file entry types (not inclusive)
2077             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2078             * @return the ordered range of matching document library file entry types that the user has permission to view
2079             * @throws SystemException if a system exception occurred
2080             */
2081            public List<DLFileEntryType> filterFindByGroupId(long[] groupIds,
2082                    int start, int end, OrderByComparator orderByComparator)
2083                    throws SystemException {
2084                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2085                            return findByGroupId(groupIds, start, end, orderByComparator);
2086                    }
2087    
2088                    StringBundler query = new StringBundler();
2089    
2090                    if (getDB().isSupportsInlineDistinct()) {
2091                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2092                    }
2093                    else {
2094                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1);
2095                    }
2096    
2097                    boolean conjunctionable = false;
2098    
2099                    if ((groupIds == null) || (groupIds.length > 0)) {
2100                            if (conjunctionable) {
2101                                    query.append(WHERE_AND);
2102                            }
2103    
2104                            query.append(StringPool.OPEN_PARENTHESIS);
2105    
2106                            for (int i = 0; i < groupIds.length; i++) {
2107                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2108    
2109                                    if ((i + 1) < groupIds.length) {
2110                                            query.append(WHERE_OR);
2111                                    }
2112                            }
2113    
2114                            query.append(StringPool.CLOSE_PARENTHESIS);
2115    
2116                            conjunctionable = true;
2117                    }
2118    
2119                    if (!getDB().isSupportsInlineDistinct()) {
2120                            query.append(_FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2);
2121                    }
2122    
2123                    if (orderByComparator != null) {
2124                            if (getDB().isSupportsInlineDistinct()) {
2125                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2126                                            orderByComparator);
2127                            }
2128                            else {
2129                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE,
2130                                            orderByComparator);
2131                            }
2132                    }
2133    
2134                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2135                                    DLFileEntryType.class.getName(),
2136                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2137    
2138                    Session session = null;
2139    
2140                    try {
2141                            session = openSession();
2142    
2143                            SQLQuery q = session.createSQLQuery(sql);
2144    
2145                            if (getDB().isSupportsInlineDistinct()) {
2146                                    q.addEntity(_FILTER_ENTITY_ALIAS, DLFileEntryTypeImpl.class);
2147                            }
2148                            else {
2149                                    q.addEntity(_FILTER_ENTITY_TABLE, DLFileEntryTypeImpl.class);
2150                            }
2151    
2152                            QueryPos qPos = QueryPos.getInstance(q);
2153    
2154                            if (groupIds != null) {
2155                                    qPos.add(groupIds);
2156                            }
2157    
2158                            return (List<DLFileEntryType>)QueryUtil.list(q, getDialect(),
2159                                    start, end);
2160                    }
2161                    catch (Exception e) {
2162                            throw processException(e);
2163                    }
2164                    finally {
2165                            closeSession(session);
2166                    }
2167            }
2168    
2169            /**
2170             * Returns the document library file entry type where groupId = &#63; and name = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException} if it could not be found.
2171             *
2172             * @param groupId the group ID
2173             * @param name the name
2174             * @return the matching document library file entry type
2175             * @throws com.liferay.portlet.documentlibrary.NoSuchFileEntryTypeException if a matching document library file entry type could not be found
2176             * @throws SystemException if a system exception occurred
2177             */
2178            public DLFileEntryType findByG_N(long groupId, String name)
2179                    throws NoSuchFileEntryTypeException, SystemException {
2180                    DLFileEntryType dlFileEntryType = fetchByG_N(groupId, name);
2181    
2182                    if (dlFileEntryType == null) {
2183                            StringBundler msg = new StringBundler(6);
2184    
2185                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2186    
2187                            msg.append("groupId=");
2188                            msg.append(groupId);
2189    
2190                            msg.append(", name=");
2191                            msg.append(name);
2192    
2193                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2194    
2195                            if (_log.isWarnEnabled()) {
2196                                    _log.warn(msg.toString());
2197                            }
2198    
2199                            throw new NoSuchFileEntryTypeException(msg.toString());
2200                    }
2201    
2202                    return dlFileEntryType;
2203            }
2204    
2205            /**
2206             * Returns the document library file entry type where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2207             *
2208             * @param groupId the group ID
2209             * @param name the name
2210             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
2211             * @throws SystemException if a system exception occurred
2212             */
2213            public DLFileEntryType fetchByG_N(long groupId, String name)
2214                    throws SystemException {
2215                    return fetchByG_N(groupId, name, true);
2216            }
2217    
2218            /**
2219             * Returns the document library file entry type where groupId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2220             *
2221             * @param groupId the group ID
2222             * @param name the name
2223             * @param retrieveFromCache whether to use the finder cache
2224             * @return the matching document library file entry type, or <code>null</code> if a matching document library file entry type could not be found
2225             * @throws SystemException if a system exception occurred
2226             */
2227            public DLFileEntryType fetchByG_N(long groupId, String name,
2228                    boolean retrieveFromCache) throws SystemException {
2229                    Object[] finderArgs = new Object[] { groupId, name };
2230    
2231                    Object result = null;
2232    
2233                    if (retrieveFromCache) {
2234                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_N,
2235                                            finderArgs, this);
2236                    }
2237    
2238                    if (result instanceof DLFileEntryType) {
2239                            DLFileEntryType dlFileEntryType = (DLFileEntryType)result;
2240    
2241                            if ((groupId != dlFileEntryType.getGroupId()) ||
2242                                            !Validator.equals(name, dlFileEntryType.getName())) {
2243                                    result = null;
2244                            }
2245                    }
2246    
2247                    if (result == null) {
2248                            StringBundler query = new StringBundler(3);
2249    
2250                            query.append(_SQL_SELECT_DLFILEENTRYTYPE_WHERE);
2251    
2252                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2253    
2254                            if (name == null) {
2255                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
2256                            }
2257                            else {
2258                                    if (name.equals(StringPool.BLANK)) {
2259                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
2260                                    }
2261                                    else {
2262                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
2263                                    }
2264                            }
2265    
2266                            String sql = query.toString();
2267    
2268                            Session session = null;
2269    
2270                            try {
2271                                    session = openSession();
2272    
2273                                    Query q = session.createQuery(sql);
2274    
2275                                    QueryPos qPos = QueryPos.getInstance(q);
2276    
2277                                    qPos.add(groupId);
2278    
2279                                    if (name != null) {
2280                                            qPos.add(name);
2281                                    }
2282    
2283                                    List<DLFileEntryType> list = q.list();
2284    
2285                                    result = list;
2286    
2287                                    DLFileEntryType dlFileEntryType = null;
2288    
2289                                    if (list.isEmpty()) {
2290                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2291                                                    finderArgs, list);
2292                                    }
2293                                    else {
2294                                            dlFileEntryType = list.get(0);
2295    
2296                                            cacheResult(dlFileEntryType);
2297    
2298                                            if ((dlFileEntryType.getGroupId() != groupId) ||
2299                                                            (dlFileEntryType.getName() == null) ||
2300                                                            !dlFileEntryType.getName().equals(name)) {
2301                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_N,
2302                                                            finderArgs, dlFileEntryType);
2303                                            }
2304                                    }
2305    
2306                                    return dlFileEntryType;
2307                            }
2308                            catch (Exception e) {
2309                                    throw processException(e);
2310                            }
2311                            finally {
2312                                    if (result == null) {
2313                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_N,
2314                                                    finderArgs);
2315                                    }
2316    
2317                                    closeSession(session);
2318                            }
2319                    }
2320                    else {
2321                            if (result instanceof List<?>) {
2322                                    return null;
2323                            }
2324                            else {
2325                                    return (DLFileEntryType)result;
2326                            }
2327                    }
2328            }
2329    
2330            /**
2331             * Returns all the document library file entry types.
2332             *
2333             * @return the document library file entry types
2334             * @throws SystemException if a system exception occurred
2335             */
2336            public List<DLFileEntryType> findAll() throws SystemException {
2337                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2338            }
2339    
2340            /**
2341             * Returns a range of all the document library file entry types.
2342             *
2343             * <p>
2344             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2345             * </p>
2346             *
2347             * @param start the lower bound of the range of document library file entry types
2348             * @param end the upper bound of the range of document library file entry types (not inclusive)
2349             * @return the range of document library file entry types
2350             * @throws SystemException if a system exception occurred
2351             */
2352            public List<DLFileEntryType> findAll(int start, int end)
2353                    throws SystemException {
2354                    return findAll(start, end, null);
2355            }
2356    
2357            /**
2358             * Returns an ordered range of all the document library file entry types.
2359             *
2360             * <p>
2361             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
2362             * </p>
2363             *
2364             * @param start the lower bound of the range of document library file entry types
2365             * @param end the upper bound of the range of document library file entry types (not inclusive)
2366             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2367             * @return the ordered range of document library file entry types
2368             * @throws SystemException if a system exception occurred
2369             */
2370            public List<DLFileEntryType> findAll(int start, int end,
2371                    OrderByComparator orderByComparator) throws SystemException {
2372                    FinderPath finderPath = null;
2373                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2374    
2375                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2376                                    (orderByComparator == null)) {
2377                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2378                            finderArgs = FINDER_ARGS_EMPTY;
2379                    }
2380                    else {
2381                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2382                            finderArgs = new Object[] { start, end, orderByComparator };
2383                    }
2384    
2385                    List<DLFileEntryType> list = (List<DLFileEntryType>)FinderCacheUtil.getResult(finderPath,
2386                                    finderArgs, this);
2387    
2388                    if (list == null) {
2389                            StringBundler query = null;
2390                            String sql = null;
2391    
2392                            if (orderByComparator != null) {
2393                                    query = new StringBundler(2 +
2394                                                    (orderByComparator.getOrderByFields().length * 3));
2395    
2396                                    query.append(_SQL_SELECT_DLFILEENTRYTYPE);
2397    
2398                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2399                                            orderByComparator);
2400    
2401                                    sql = query.toString();
2402                            }
2403                            else {
2404                                    sql = _SQL_SELECT_DLFILEENTRYTYPE;
2405                            }
2406    
2407                            Session session = null;
2408    
2409                            try {
2410                                    session = openSession();
2411    
2412                                    Query q = session.createQuery(sql);
2413    
2414                                    if (orderByComparator == null) {
2415                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
2416                                                            getDialect(), start, end, false);
2417    
2418                                            Collections.sort(list);
2419                                    }
2420                                    else {
2421                                            list = (List<DLFileEntryType>)QueryUtil.list(q,
2422                                                            getDialect(), start, end);
2423                                    }
2424                            }
2425                            catch (Exception e) {
2426                                    throw processException(e);
2427                            }
2428                            finally {
2429                                    if (list == null) {
2430                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2431                                    }
2432                                    else {
2433                                            cacheResult(list);
2434    
2435                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2436                                    }
2437    
2438                                    closeSession(session);
2439                            }
2440                    }
2441    
2442                    return list;
2443            }
2444    
2445            /**
2446             * Removes all the document library file entry types where uuid = &#63; from the database.
2447             *
2448             * @param uuid the uuid
2449             * @throws SystemException if a system exception occurred
2450             */
2451            public void removeByUuid(String uuid) throws SystemException {
2452                    for (DLFileEntryType dlFileEntryType : findByUuid(uuid)) {
2453                            remove(dlFileEntryType);
2454                    }
2455            }
2456    
2457            /**
2458             * Removes the document library file entry type where uuid = &#63; and groupId = &#63; from the database.
2459             *
2460             * @param uuid the uuid
2461             * @param groupId the group ID
2462             * @return the document library file entry type that was removed
2463             * @throws SystemException if a system exception occurred
2464             */
2465            public DLFileEntryType removeByUUID_G(String uuid, long groupId)
2466                    throws NoSuchFileEntryTypeException, SystemException {
2467                    DLFileEntryType dlFileEntryType = findByUUID_G(uuid, groupId);
2468    
2469                    return remove(dlFileEntryType);
2470            }
2471    
2472            /**
2473             * Removes all the document library file entry types where groupId = &#63; from the database.
2474             *
2475             * @param groupId the group ID
2476             * @throws SystemException if a system exception occurred
2477             */
2478            public void removeByGroupId(long groupId) throws SystemException {
2479                    for (DLFileEntryType dlFileEntryType : findByGroupId(groupId)) {
2480                            remove(dlFileEntryType);
2481                    }
2482            }
2483    
2484            /**
2485             * Removes the document library file entry type where groupId = &#63; and name = &#63; from the database.
2486             *
2487             * @param groupId the group ID
2488             * @param name the name
2489             * @return the document library file entry type that was removed
2490             * @throws SystemException if a system exception occurred
2491             */
2492            public DLFileEntryType removeByG_N(long groupId, String name)
2493                    throws NoSuchFileEntryTypeException, SystemException {
2494                    DLFileEntryType dlFileEntryType = findByG_N(groupId, name);
2495    
2496                    return remove(dlFileEntryType);
2497            }
2498    
2499            /**
2500             * Removes all the document library file entry types from the database.
2501             *
2502             * @throws SystemException if a system exception occurred
2503             */
2504            public void removeAll() throws SystemException {
2505                    for (DLFileEntryType dlFileEntryType : findAll()) {
2506                            remove(dlFileEntryType);
2507                    }
2508            }
2509    
2510            /**
2511             * Returns the number of document library file entry types where uuid = &#63;.
2512             *
2513             * @param uuid the uuid
2514             * @return the number of matching document library file entry types
2515             * @throws SystemException if a system exception occurred
2516             */
2517            public int countByUuid(String uuid) throws SystemException {
2518                    Object[] finderArgs = new Object[] { uuid };
2519    
2520                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID,
2521                                    finderArgs, this);
2522    
2523                    if (count == null) {
2524                            StringBundler query = new StringBundler(2);
2525    
2526                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2527    
2528                            if (uuid == null) {
2529                                    query.append(_FINDER_COLUMN_UUID_UUID_1);
2530                            }
2531                            else {
2532                                    if (uuid.equals(StringPool.BLANK)) {
2533                                            query.append(_FINDER_COLUMN_UUID_UUID_3);
2534                                    }
2535                                    else {
2536                                            query.append(_FINDER_COLUMN_UUID_UUID_2);
2537                                    }
2538                            }
2539    
2540                            String sql = query.toString();
2541    
2542                            Session session = null;
2543    
2544                            try {
2545                                    session = openSession();
2546    
2547                                    Query q = session.createQuery(sql);
2548    
2549                                    QueryPos qPos = QueryPos.getInstance(q);
2550    
2551                                    if (uuid != null) {
2552                                            qPos.add(uuid);
2553                                    }
2554    
2555                                    count = (Long)q.uniqueResult();
2556                            }
2557                            catch (Exception e) {
2558                                    throw processException(e);
2559                            }
2560                            finally {
2561                                    if (count == null) {
2562                                            count = Long.valueOf(0);
2563                                    }
2564    
2565                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID,
2566                                            finderArgs, count);
2567    
2568                                    closeSession(session);
2569                            }
2570                    }
2571    
2572                    return count.intValue();
2573            }
2574    
2575            /**
2576             * Returns the number of document library file entry types where uuid = &#63; and groupId = &#63;.
2577             *
2578             * @param uuid the uuid
2579             * @param groupId the group ID
2580             * @return the number of matching document library file entry types
2581             * @throws SystemException if a system exception occurred
2582             */
2583            public int countByUUID_G(String uuid, long groupId)
2584                    throws SystemException {
2585                    Object[] finderArgs = new Object[] { uuid, groupId };
2586    
2587                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_UUID_G,
2588                                    finderArgs, this);
2589    
2590                    if (count == null) {
2591                            StringBundler query = new StringBundler(3);
2592    
2593                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2594    
2595                            if (uuid == null) {
2596                                    query.append(_FINDER_COLUMN_UUID_G_UUID_1);
2597                            }
2598                            else {
2599                                    if (uuid.equals(StringPool.BLANK)) {
2600                                            query.append(_FINDER_COLUMN_UUID_G_UUID_3);
2601                                    }
2602                                    else {
2603                                            query.append(_FINDER_COLUMN_UUID_G_UUID_2);
2604                                    }
2605                            }
2606    
2607                            query.append(_FINDER_COLUMN_UUID_G_GROUPID_2);
2608    
2609                            String sql = query.toString();
2610    
2611                            Session session = null;
2612    
2613                            try {
2614                                    session = openSession();
2615    
2616                                    Query q = session.createQuery(sql);
2617    
2618                                    QueryPos qPos = QueryPos.getInstance(q);
2619    
2620                                    if (uuid != null) {
2621                                            qPos.add(uuid);
2622                                    }
2623    
2624                                    qPos.add(groupId);
2625    
2626                                    count = (Long)q.uniqueResult();
2627                            }
2628                            catch (Exception e) {
2629                                    throw processException(e);
2630                            }
2631                            finally {
2632                                    if (count == null) {
2633                                            count = Long.valueOf(0);
2634                                    }
2635    
2636                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_UUID_G,
2637                                            finderArgs, count);
2638    
2639                                    closeSession(session);
2640                            }
2641                    }
2642    
2643                    return count.intValue();
2644            }
2645    
2646            /**
2647             * Returns the number of document library file entry types where groupId = &#63;.
2648             *
2649             * @param groupId the group ID
2650             * @return the number of matching document library file entry types
2651             * @throws SystemException if a system exception occurred
2652             */
2653            public int countByGroupId(long groupId) throws SystemException {
2654                    Object[] finderArgs = new Object[] { groupId };
2655    
2656                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_GROUPID,
2657                                    finderArgs, this);
2658    
2659                    if (count == null) {
2660                            StringBundler query = new StringBundler(2);
2661    
2662                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2663    
2664                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2665    
2666                            String sql = query.toString();
2667    
2668                            Session session = null;
2669    
2670                            try {
2671                                    session = openSession();
2672    
2673                                    Query q = session.createQuery(sql);
2674    
2675                                    QueryPos qPos = QueryPos.getInstance(q);
2676    
2677                                    qPos.add(groupId);
2678    
2679                                    count = (Long)q.uniqueResult();
2680                            }
2681                            catch (Exception e) {
2682                                    throw processException(e);
2683                            }
2684                            finally {
2685                                    if (count == null) {
2686                                            count = Long.valueOf(0);
2687                                    }
2688    
2689                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_GROUPID,
2690                                            finderArgs, count);
2691    
2692                                    closeSession(session);
2693                            }
2694                    }
2695    
2696                    return count.intValue();
2697            }
2698    
2699            /**
2700             * Returns the number of document library file entry types where groupId = any &#63;.
2701             *
2702             * @param groupIds the group IDs
2703             * @return the number of matching document library file entry types
2704             * @throws SystemException if a system exception occurred
2705             */
2706            public int countByGroupId(long[] groupIds) throws SystemException {
2707                    Object[] finderArgs = new Object[] { StringUtil.merge(groupIds) };
2708    
2709                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2710                                    finderArgs, this);
2711    
2712                    if (count == null) {
2713                            StringBundler query = new StringBundler();
2714    
2715                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2716    
2717                            boolean conjunctionable = false;
2718    
2719                            if ((groupIds == null) || (groupIds.length > 0)) {
2720                                    if (conjunctionable) {
2721                                            query.append(WHERE_AND);
2722                                    }
2723    
2724                                    query.append(StringPool.OPEN_PARENTHESIS);
2725    
2726                                    for (int i = 0; i < groupIds.length; i++) {
2727                                            query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2728    
2729                                            if ((i + 1) < groupIds.length) {
2730                                                    query.append(WHERE_OR);
2731                                            }
2732                                    }
2733    
2734                                    query.append(StringPool.CLOSE_PARENTHESIS);
2735    
2736                                    conjunctionable = true;
2737                            }
2738    
2739                            String sql = query.toString();
2740    
2741                            Session session = null;
2742    
2743                            try {
2744                                    session = openSession();
2745    
2746                                    Query q = session.createQuery(sql);
2747    
2748                                    QueryPos qPos = QueryPos.getInstance(q);
2749    
2750                                    if (groupIds != null) {
2751                                            qPos.add(groupIds);
2752                                    }
2753    
2754                                    count = (Long)q.uniqueResult();
2755                            }
2756                            catch (Exception e) {
2757                                    throw processException(e);
2758                            }
2759                            finally {
2760                                    if (count == null) {
2761                                            count = Long.valueOf(0);
2762                                    }
2763    
2764                                    FinderCacheUtil.putResult(FINDER_PATH_WITH_PAGINATION_COUNT_BY_GROUPID,
2765                                            finderArgs, count);
2766    
2767                                    closeSession(session);
2768                            }
2769                    }
2770    
2771                    return count.intValue();
2772            }
2773    
2774            /**
2775             * Returns the number of document library file entry types that the user has permission to view where groupId = &#63;.
2776             *
2777             * @param groupId the group ID
2778             * @return the number of matching document library file entry types that the user has permission to view
2779             * @throws SystemException if a system exception occurred
2780             */
2781            public int filterCountByGroupId(long groupId) throws SystemException {
2782                    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
2783                            return countByGroupId(groupId);
2784                    }
2785    
2786                    StringBundler query = new StringBundler(2);
2787    
2788                    query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2789    
2790                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
2791    
2792                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2793                                    DLFileEntryType.class.getName(),
2794                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
2795    
2796                    Session session = null;
2797    
2798                    try {
2799                            session = openSession();
2800    
2801                            SQLQuery q = session.createSQLQuery(sql);
2802    
2803                            q.addScalar(COUNT_COLUMN_NAME,
2804                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2805    
2806                            QueryPos qPos = QueryPos.getInstance(q);
2807    
2808                            qPos.add(groupId);
2809    
2810                            Long count = (Long)q.uniqueResult();
2811    
2812                            return count.intValue();
2813                    }
2814                    catch (Exception e) {
2815                            throw processException(e);
2816                    }
2817                    finally {
2818                            closeSession(session);
2819                    }
2820            }
2821    
2822            /**
2823             * Returns the number of document library file entry types that the user has permission to view where groupId = any &#63;.
2824             *
2825             * @param groupIds the group IDs
2826             * @return the number of matching document library file entry types that the user has permission to view
2827             * @throws SystemException if a system exception occurred
2828             */
2829            public int filterCountByGroupId(long[] groupIds) throws SystemException {
2830                    if (!InlineSQLHelperUtil.isEnabled(groupIds)) {
2831                            return countByGroupId(groupIds);
2832                    }
2833    
2834                    StringBundler query = new StringBundler();
2835    
2836                    query.append(_FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2837    
2838                    boolean conjunctionable = false;
2839    
2840                    if ((groupIds == null) || (groupIds.length > 0)) {
2841                            if (conjunctionable) {
2842                                    query.append(WHERE_AND);
2843                            }
2844    
2845                            query.append(StringPool.OPEN_PARENTHESIS);
2846    
2847                            for (int i = 0; i < groupIds.length; i++) {
2848                                    query.append(_FINDER_COLUMN_GROUPID_GROUPID_5);
2849    
2850                                    if ((i + 1) < groupIds.length) {
2851                                            query.append(WHERE_OR);
2852                                    }
2853                            }
2854    
2855                            query.append(StringPool.CLOSE_PARENTHESIS);
2856    
2857                            conjunctionable = true;
2858                    }
2859    
2860                    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
2861                                    DLFileEntryType.class.getName(),
2862                                    _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupIds);
2863    
2864                    Session session = null;
2865    
2866                    try {
2867                            session = openSession();
2868    
2869                            SQLQuery q = session.createSQLQuery(sql);
2870    
2871                            q.addScalar(COUNT_COLUMN_NAME,
2872                                    com.liferay.portal.kernel.dao.orm.Type.LONG);
2873    
2874                            QueryPos qPos = QueryPos.getInstance(q);
2875    
2876                            if (groupIds != null) {
2877                                    qPos.add(groupIds);
2878                            }
2879    
2880                            Long count = (Long)q.uniqueResult();
2881    
2882                            return count.intValue();
2883                    }
2884                    catch (Exception e) {
2885                            throw processException(e);
2886                    }
2887                    finally {
2888                            closeSession(session);
2889                    }
2890            }
2891    
2892            /**
2893             * Returns the number of document library file entry types where groupId = &#63; and name = &#63;.
2894             *
2895             * @param groupId the group ID
2896             * @param name the name
2897             * @return the number of matching document library file entry types
2898             * @throws SystemException if a system exception occurred
2899             */
2900            public int countByG_N(long groupId, String name) throws SystemException {
2901                    Object[] finderArgs = new Object[] { groupId, name };
2902    
2903                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_N,
2904                                    finderArgs, this);
2905    
2906                    if (count == null) {
2907                            StringBundler query = new StringBundler(3);
2908    
2909                            query.append(_SQL_COUNT_DLFILEENTRYTYPE_WHERE);
2910    
2911                            query.append(_FINDER_COLUMN_G_N_GROUPID_2);
2912    
2913                            if (name == null) {
2914                                    query.append(_FINDER_COLUMN_G_N_NAME_1);
2915                            }
2916                            else {
2917                                    if (name.equals(StringPool.BLANK)) {
2918                                            query.append(_FINDER_COLUMN_G_N_NAME_3);
2919                                    }
2920                                    else {
2921                                            query.append(_FINDER_COLUMN_G_N_NAME_2);
2922                                    }
2923                            }
2924    
2925                            String sql = query.toString();
2926    
2927                            Session session = null;
2928    
2929                            try {
2930                                    session = openSession();
2931    
2932                                    Query q = session.createQuery(sql);
2933    
2934                                    QueryPos qPos = QueryPos.getInstance(q);
2935    
2936                                    qPos.add(groupId);
2937    
2938                                    if (name != null) {
2939                                            qPos.add(name);
2940                                    }
2941    
2942                                    count = (Long)q.uniqueResult();
2943                            }
2944                            catch (Exception e) {
2945                                    throw processException(e);
2946                            }
2947                            finally {
2948                                    if (count == null) {
2949                                            count = Long.valueOf(0);
2950                                    }
2951    
2952                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_N, finderArgs,
2953                                            count);
2954    
2955                                    closeSession(session);
2956                            }
2957                    }
2958    
2959                    return count.intValue();
2960            }
2961    
2962            /**
2963             * Returns the number of document library file entry types.
2964             *
2965             * @return the number of document library file entry types
2966             * @throws SystemException if a system exception occurred
2967             */
2968            public int countAll() throws SystemException {
2969                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2970                                    FINDER_ARGS_EMPTY, this);
2971    
2972                    if (count == null) {
2973                            Session session = null;
2974    
2975                            try {
2976                                    session = openSession();
2977    
2978                                    Query q = session.createQuery(_SQL_COUNT_DLFILEENTRYTYPE);
2979    
2980                                    count = (Long)q.uniqueResult();
2981                            }
2982                            catch (Exception e) {
2983                                    throw processException(e);
2984                            }
2985                            finally {
2986                                    if (count == null) {
2987                                            count = Long.valueOf(0);
2988                                    }
2989    
2990                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2991                                            FINDER_ARGS_EMPTY, count);
2992    
2993                                    closeSession(session);
2994                            }
2995                    }
2996    
2997                    return count.intValue();
2998            }
2999    
3000            /**
3001             * Returns all the document library folders associated with the document library file entry type.
3002             *
3003             * @param pk the primary key of the document library file entry type
3004             * @return the document library folders associated with the document library file entry type
3005             * @throws SystemException if a system exception occurred
3006             */
3007            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3008                    long pk) throws SystemException {
3009                    return getDLFolders(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3010            }
3011    
3012            /**
3013             * Returns a range of all the document library folders associated with the document library file entry type.
3014             *
3015             * <p>
3016             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3017             * </p>
3018             *
3019             * @param pk the primary key of the document library file entry type
3020             * @param start the lower bound of the range of document library file entry types
3021             * @param end the upper bound of the range of document library file entry types (not inclusive)
3022             * @return the range of document library folders associated with the document library file entry type
3023             * @throws SystemException if a system exception occurred
3024             */
3025            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3026                    long pk, int start, int end) throws SystemException {
3027                    return getDLFolders(pk, start, end, null);
3028            }
3029    
3030            public static final FinderPath FINDER_PATH_GET_DLFOLDERS = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3031                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3032                            com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class,
3033                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3034                            "getDLFolders",
3035                            new String[] {
3036                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3037                                    "com.liferay.portal.kernel.util.OrderByComparator"
3038                            });
3039    
3040            static {
3041                    FINDER_PATH_GET_DLFOLDERS.setCacheKeyGeneratorCacheName(null);
3042            }
3043    
3044            /**
3045             * Returns an ordered range of all the document library folders associated with the document library file entry type.
3046             *
3047             * <p>
3048             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3049             * </p>
3050             *
3051             * @param pk the primary key of the document library file entry type
3052             * @param start the lower bound of the range of document library file entry types
3053             * @param end the upper bound of the range of document library file entry types (not inclusive)
3054             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3055             * @return the ordered range of document library folders associated with the document library file entry type
3056             * @throws SystemException if a system exception occurred
3057             */
3058            public List<com.liferay.portlet.documentlibrary.model.DLFolder> getDLFolders(
3059                    long pk, int start, int end, OrderByComparator orderByComparator)
3060                    throws SystemException {
3061                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3062    
3063                    List<com.liferay.portlet.documentlibrary.model.DLFolder> list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS,
3064                                    finderArgs, this);
3065    
3066                    if (list == null) {
3067                            Session session = null;
3068    
3069                            try {
3070                                    session = openSession();
3071    
3072                                    String sql = null;
3073    
3074                                    if (orderByComparator != null) {
3075                                            sql = _SQL_GETDLFOLDERS.concat(ORDER_BY_CLAUSE)
3076                                                                                       .concat(orderByComparator.getOrderBy());
3077                                    }
3078                                    else {
3079                                            sql = _SQL_GETDLFOLDERS.concat(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ORDER_BY_SQL);
3080                                    }
3081    
3082                                    SQLQuery q = session.createSQLQuery(sql);
3083    
3084                                    q.addEntity("DLFolder",
3085                                            com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl.class);
3086    
3087                                    QueryPos qPos = QueryPos.getInstance(q);
3088    
3089                                    qPos.add(pk);
3090    
3091                                    list = (List<com.liferay.portlet.documentlibrary.model.DLFolder>)QueryUtil.list(q,
3092                                                    getDialect(), start, end);
3093                            }
3094                            catch (Exception e) {
3095                                    throw processException(e);
3096                            }
3097                            finally {
3098                                    if (list == null) {
3099                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_DLFOLDERS,
3100                                                    finderArgs);
3101                                    }
3102                                    else {
3103                                            dlFolderPersistence.cacheResult(list);
3104    
3105                                            FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS,
3106                                                    finderArgs, list);
3107                                    }
3108    
3109                                    closeSession(session);
3110                            }
3111                    }
3112    
3113                    return list;
3114            }
3115    
3116            public static final FinderPath FINDER_PATH_GET_DLFOLDERS_SIZE = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3117                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3118                            Long.class,
3119                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3120                            "getDLFoldersSize", new String[] { Long.class.getName() });
3121    
3122            static {
3123                    FINDER_PATH_GET_DLFOLDERS_SIZE.setCacheKeyGeneratorCacheName(null);
3124            }
3125    
3126            /**
3127             * Returns the number of document library folders associated with the document library file entry type.
3128             *
3129             * @param pk the primary key of the document library file entry type
3130             * @return the number of document library folders associated with the document library file entry type
3131             * @throws SystemException if a system exception occurred
3132             */
3133            public int getDLFoldersSize(long pk) throws SystemException {
3134                    Object[] finderArgs = new Object[] { pk };
3135    
3136                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3137                                    finderArgs, this);
3138    
3139                    if (count == null) {
3140                            Session session = null;
3141    
3142                            try {
3143                                    session = openSession();
3144    
3145                                    SQLQuery q = session.createSQLQuery(_SQL_GETDLFOLDERSSIZE);
3146    
3147                                    q.addScalar(COUNT_COLUMN_NAME,
3148                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3149    
3150                                    QueryPos qPos = QueryPos.getInstance(q);
3151    
3152                                    qPos.add(pk);
3153    
3154                                    count = (Long)q.uniqueResult();
3155                            }
3156                            catch (Exception e) {
3157                                    throw processException(e);
3158                            }
3159                            finally {
3160                                    if (count == null) {
3161                                            count = Long.valueOf(0);
3162                                    }
3163    
3164                                    FinderCacheUtil.putResult(FINDER_PATH_GET_DLFOLDERS_SIZE,
3165                                            finderArgs, count);
3166    
3167                                    closeSession(session);
3168                            }
3169                    }
3170    
3171                    return count.intValue();
3172            }
3173    
3174            public static final FinderPath FINDER_PATH_CONTAINS_DLFOLDER = new FinderPath(com.liferay.portlet.documentlibrary.model.impl.DLFolderModelImpl.ENTITY_CACHE_ENABLED,
3175                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DLFOLDERS,
3176                            Boolean.class,
3177                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME,
3178                            "containsDLFolder",
3179                            new String[] { Long.class.getName(), Long.class.getName() });
3180    
3181            /**
3182             * Returns <code>true</code> if the document library folder is associated with the document library file entry type.
3183             *
3184             * @param pk the primary key of the document library file entry type
3185             * @param dlFolderPK the primary key of the document library folder
3186             * @return <code>true</code> if the document library folder is associated with the document library file entry type; <code>false</code> otherwise
3187             * @throws SystemException if a system exception occurred
3188             */
3189            public boolean containsDLFolder(long pk, long dlFolderPK)
3190                    throws SystemException {
3191                    Object[] finderArgs = new Object[] { pk, dlFolderPK };
3192    
3193                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DLFOLDER,
3194                                    finderArgs, this);
3195    
3196                    if (value == null) {
3197                            try {
3198                                    value = Boolean.valueOf(containsDLFolder.contains(pk, dlFolderPK));
3199                            }
3200                            catch (Exception e) {
3201                                    throw processException(e);
3202                            }
3203                            finally {
3204                                    if (value == null) {
3205                                            value = Boolean.FALSE;
3206                                    }
3207    
3208                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DLFOLDER,
3209                                            finderArgs, value);
3210                            }
3211                    }
3212    
3213                    return value.booleanValue();
3214            }
3215    
3216            /**
3217             * Returns <code>true</code> if the document library file entry type has any document library folders associated with it.
3218             *
3219             * @param pk the primary key of the document library file entry type to check for associations with document library folders
3220             * @return <code>true</code> if the document library file entry type has any document library folders associated with it; <code>false</code> otherwise
3221             * @throws SystemException if a system exception occurred
3222             */
3223            public boolean containsDLFolders(long pk) throws SystemException {
3224                    if (getDLFoldersSize(pk) > 0) {
3225                            return true;
3226                    }
3227                    else {
3228                            return false;
3229                    }
3230            }
3231    
3232            /**
3233             * Adds an association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3234             *
3235             * @param pk the primary key of the document library file entry type
3236             * @param dlFolderPK the primary key of the document library folder
3237             * @throws SystemException if a system exception occurred
3238             */
3239            public void addDLFolder(long pk, long dlFolderPK) throws SystemException {
3240                    try {
3241                            addDLFolder.add(pk, dlFolderPK);
3242                    }
3243                    catch (Exception e) {
3244                            throw processException(e);
3245                    }
3246                    finally {
3247                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3248                    }
3249            }
3250    
3251            /**
3252             * Adds an association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3253             *
3254             * @param pk the primary key of the document library file entry type
3255             * @param dlFolder the document library folder
3256             * @throws SystemException if a system exception occurred
3257             */
3258            public void addDLFolder(long pk,
3259                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3260                    throws SystemException {
3261                    try {
3262                            addDLFolder.add(pk, dlFolder.getPrimaryKey());
3263                    }
3264                    catch (Exception e) {
3265                            throw processException(e);
3266                    }
3267                    finally {
3268                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3269                    }
3270            }
3271    
3272            /**
3273             * Adds an association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3274             *
3275             * @param pk the primary key of the document library file entry type
3276             * @param dlFolderPKs the primary keys of the document library folders
3277             * @throws SystemException if a system exception occurred
3278             */
3279            public void addDLFolders(long pk, long[] dlFolderPKs)
3280                    throws SystemException {
3281                    try {
3282                            for (long dlFolderPK : dlFolderPKs) {
3283                                    addDLFolder.add(pk, dlFolderPK);
3284                            }
3285                    }
3286                    catch (Exception e) {
3287                            throw processException(e);
3288                    }
3289                    finally {
3290                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3291                    }
3292            }
3293    
3294            /**
3295             * Adds an association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3296             *
3297             * @param pk the primary key of the document library file entry type
3298             * @param dlFolders the document library folders
3299             * @throws SystemException if a system exception occurred
3300             */
3301            public void addDLFolders(long pk,
3302                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3303                    throws SystemException {
3304                    try {
3305                            for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3306                                    addDLFolder.add(pk, dlFolder.getPrimaryKey());
3307                            }
3308                    }
3309                    catch (Exception e) {
3310                            throw processException(e);
3311                    }
3312                    finally {
3313                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3314                    }
3315            }
3316    
3317            /**
3318             * Clears all associations between the document library file entry type and its document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3319             *
3320             * @param pk the primary key of the document library file entry type to clear the associated document library folders from
3321             * @throws SystemException if a system exception occurred
3322             */
3323            public void clearDLFolders(long pk) throws SystemException {
3324                    try {
3325                            clearDLFolders.clear(pk);
3326                    }
3327                    catch (Exception e) {
3328                            throw processException(e);
3329                    }
3330                    finally {
3331                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3332                    }
3333            }
3334    
3335            /**
3336             * Removes the association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3337             *
3338             * @param pk the primary key of the document library file entry type
3339             * @param dlFolderPK the primary key of the document library folder
3340             * @throws SystemException if a system exception occurred
3341             */
3342            public void removeDLFolder(long pk, long dlFolderPK)
3343                    throws SystemException {
3344                    try {
3345                            removeDLFolder.remove(pk, dlFolderPK);
3346                    }
3347                    catch (Exception e) {
3348                            throw processException(e);
3349                    }
3350                    finally {
3351                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3352                    }
3353            }
3354    
3355            /**
3356             * Removes the association between the document library file entry type and the document library folder. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3357             *
3358             * @param pk the primary key of the document library file entry type
3359             * @param dlFolder the document library folder
3360             * @throws SystemException if a system exception occurred
3361             */
3362            public void removeDLFolder(long pk,
3363                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder)
3364                    throws SystemException {
3365                    try {
3366                            removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3367                    }
3368                    catch (Exception e) {
3369                            throw processException(e);
3370                    }
3371                    finally {
3372                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3373                    }
3374            }
3375    
3376            /**
3377             * Removes the association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3378             *
3379             * @param pk the primary key of the document library file entry type
3380             * @param dlFolderPKs the primary keys of the document library folders
3381             * @throws SystemException if a system exception occurred
3382             */
3383            public void removeDLFolders(long pk, long[] dlFolderPKs)
3384                    throws SystemException {
3385                    try {
3386                            for (long dlFolderPK : dlFolderPKs) {
3387                                    removeDLFolder.remove(pk, dlFolderPK);
3388                            }
3389                    }
3390                    catch (Exception e) {
3391                            throw processException(e);
3392                    }
3393                    finally {
3394                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3395                    }
3396            }
3397    
3398            /**
3399             * Removes the association between the document library file entry type and the document library folders. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3400             *
3401             * @param pk the primary key of the document library file entry type
3402             * @param dlFolders the document library folders
3403             * @throws SystemException if a system exception occurred
3404             */
3405            public void removeDLFolders(long pk,
3406                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3407                    throws SystemException {
3408                    try {
3409                            for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3410                                    removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3411                            }
3412                    }
3413                    catch (Exception e) {
3414                            throw processException(e);
3415                    }
3416                    finally {
3417                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3418                    }
3419            }
3420    
3421            /**
3422             * Sets the document library folders associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3423             *
3424             * @param pk the primary key of the document library file entry type
3425             * @param dlFolderPKs the primary keys of the document library folders to be associated with the document library file entry type
3426             * @throws SystemException if a system exception occurred
3427             */
3428            public void setDLFolders(long pk, long[] dlFolderPKs)
3429                    throws SystemException {
3430                    try {
3431                            Set<Long> dlFolderPKSet = SetUtil.fromArray(dlFolderPKs);
3432    
3433                            List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = getDLFolders(pk);
3434    
3435                            for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
3436                                    if (!dlFolderPKSet.remove(dlFolder.getPrimaryKey())) {
3437                                            removeDLFolder.remove(pk, dlFolder.getPrimaryKey());
3438                                    }
3439                            }
3440    
3441                            for (Long dlFolderPK : dlFolderPKSet) {
3442                                    addDLFolder.add(pk, dlFolderPK);
3443                            }
3444                    }
3445                    catch (Exception e) {
3446                            throw processException(e);
3447                    }
3448                    finally {
3449                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3450                    }
3451            }
3452    
3453            /**
3454             * Sets the document library folders associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3455             *
3456             * @param pk the primary key of the document library file entry type
3457             * @param dlFolders the document library folders to be associated with the document library file entry type
3458             * @throws SystemException if a system exception occurred
3459             */
3460            public void setDLFolders(long pk,
3461                    List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders)
3462                    throws SystemException {
3463                    try {
3464                            long[] dlFolderPKs = new long[dlFolders.size()];
3465    
3466                            for (int i = 0; i < dlFolders.size(); i++) {
3467                                    com.liferay.portlet.documentlibrary.model.DLFolder dlFolder = dlFolders.get(i);
3468    
3469                                    dlFolderPKs[i] = dlFolder.getPrimaryKey();
3470                            }
3471    
3472                            setDLFolders(pk, dlFolderPKs);
3473                    }
3474                    catch (Exception e) {
3475                            throw processException(e);
3476                    }
3477                    finally {
3478                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DLFOLDERS_NAME);
3479                    }
3480            }
3481    
3482            /**
3483             * Returns all the d d m structures associated with the document library file entry type.
3484             *
3485             * @param pk the primary key of the document library file entry type
3486             * @return the d d m structures associated with the document library file entry type
3487             * @throws SystemException if a system exception occurred
3488             */
3489            public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3490                    long pk) throws SystemException {
3491                    return getDDMStructures(pk, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
3492            }
3493    
3494            /**
3495             * Returns a range of all the d d m structures associated with the document library file entry type.
3496             *
3497             * <p>
3498             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3499             * </p>
3500             *
3501             * @param pk the primary key of the document library file entry type
3502             * @param start the lower bound of the range of document library file entry types
3503             * @param end the upper bound of the range of document library file entry types (not inclusive)
3504             * @return the range of d d m structures associated with the document library file entry type
3505             * @throws SystemException if a system exception occurred
3506             */
3507            public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3508                    long pk, int start, int end) throws SystemException {
3509                    return getDDMStructures(pk, start, end, null);
3510            }
3511    
3512            public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3513                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3514                            com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class,
3515                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3516                            "getDDMStructures",
3517                            new String[] {
3518                                    Long.class.getName(), "java.lang.Integer", "java.lang.Integer",
3519                                    "com.liferay.portal.kernel.util.OrderByComparator"
3520                            });
3521    
3522            static {
3523                    FINDER_PATH_GET_DDMSTRUCTURES.setCacheKeyGeneratorCacheName(null);
3524            }
3525    
3526            /**
3527             * Returns an ordered range of all the d d m structures associated with the document library file entry type.
3528             *
3529             * <p>
3530             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
3531             * </p>
3532             *
3533             * @param pk the primary key of the document library file entry type
3534             * @param start the lower bound of the range of document library file entry types
3535             * @param end the upper bound of the range of document library file entry types (not inclusive)
3536             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3537             * @return the ordered range of d d m structures associated with the document library file entry type
3538             * @throws SystemException if a system exception occurred
3539             */
3540            public List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> getDDMStructures(
3541                    long pk, int start, int end, OrderByComparator orderByComparator)
3542                    throws SystemException {
3543                    Object[] finderArgs = new Object[] { pk, start, end, orderByComparator };
3544    
3545                    List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES,
3546                                    finderArgs, this);
3547    
3548                    if (list == null) {
3549                            Session session = null;
3550    
3551                            try {
3552                                    session = openSession();
3553    
3554                                    String sql = null;
3555    
3556                                    if (orderByComparator != null) {
3557                                            sql = _SQL_GETDDMSTRUCTURES.concat(ORDER_BY_CLAUSE)
3558                                                                                               .concat(orderByComparator.getOrderBy());
3559                                    }
3560                                    else {
3561                                            sql = _SQL_GETDDMSTRUCTURES;
3562                                    }
3563    
3564                                    SQLQuery q = session.createSQLQuery(sql);
3565    
3566                                    q.addEntity("DDMStructure",
3567                                            com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureImpl.class);
3568    
3569                                    QueryPos qPos = QueryPos.getInstance(q);
3570    
3571                                    qPos.add(pk);
3572    
3573                                    list = (List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>)QueryUtil.list(q,
3574                                                    getDialect(), start, end);
3575                            }
3576                            catch (Exception e) {
3577                                    throw processException(e);
3578                            }
3579                            finally {
3580                                    if (list == null) {
3581                                            FinderCacheUtil.removeResult(FINDER_PATH_GET_DDMSTRUCTURES,
3582                                                    finderArgs);
3583                                    }
3584                                    else {
3585                                            ddmStructurePersistence.cacheResult(list);
3586    
3587                                            FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES,
3588                                                    finderArgs, list);
3589                                    }
3590    
3591                                    closeSession(session);
3592                            }
3593                    }
3594    
3595                    return list;
3596            }
3597    
3598            public static final FinderPath FINDER_PATH_GET_DDMSTRUCTURES_SIZE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3599                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3600                            Long.class,
3601                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3602                            "getDDMStructuresSize", new String[] { Long.class.getName() });
3603    
3604            static {
3605                    FINDER_PATH_GET_DDMSTRUCTURES_SIZE.setCacheKeyGeneratorCacheName(null);
3606            }
3607    
3608            /**
3609             * Returns the number of d d m structures associated with the document library file entry type.
3610             *
3611             * @param pk the primary key of the document library file entry type
3612             * @return the number of d d m structures associated with the document library file entry type
3613             * @throws SystemException if a system exception occurred
3614             */
3615            public int getDDMStructuresSize(long pk) throws SystemException {
3616                    Object[] finderArgs = new Object[] { pk };
3617    
3618                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3619                                    finderArgs, this);
3620    
3621                    if (count == null) {
3622                            Session session = null;
3623    
3624                            try {
3625                                    session = openSession();
3626    
3627                                    SQLQuery q = session.createSQLQuery(_SQL_GETDDMSTRUCTURESSIZE);
3628    
3629                                    q.addScalar(COUNT_COLUMN_NAME,
3630                                            com.liferay.portal.kernel.dao.orm.Type.LONG);
3631    
3632                                    QueryPos qPos = QueryPos.getInstance(q);
3633    
3634                                    qPos.add(pk);
3635    
3636                                    count = (Long)q.uniqueResult();
3637                            }
3638                            catch (Exception e) {
3639                                    throw processException(e);
3640                            }
3641                            finally {
3642                                    if (count == null) {
3643                                            count = Long.valueOf(0);
3644                                    }
3645    
3646                                    FinderCacheUtil.putResult(FINDER_PATH_GET_DDMSTRUCTURES_SIZE,
3647                                            finderArgs, count);
3648    
3649                                    closeSession(session);
3650                            }
3651                    }
3652    
3653                    return count.intValue();
3654            }
3655    
3656            public static final FinderPath FINDER_PATH_CONTAINS_DDMSTRUCTURE = new FinderPath(com.liferay.portlet.dynamicdatamapping.model.impl.DDMStructureModelImpl.ENTITY_CACHE_ENABLED,
3657                            DLFileEntryTypeModelImpl.FINDER_CACHE_ENABLED_DLFILEENTRYTYPES_DDMSTRUCTURES,
3658                            Boolean.class,
3659                            DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME,
3660                            "containsDDMStructure",
3661                            new String[] { Long.class.getName(), Long.class.getName() });
3662    
3663            /**
3664             * Returns <code>true</code> if the d d m structure is associated with the document library file entry type.
3665             *
3666             * @param pk the primary key of the document library file entry type
3667             * @param ddmStructurePK the primary key of the d d m structure
3668             * @return <code>true</code> if the d d m structure is associated with the document library file entry type; <code>false</code> otherwise
3669             * @throws SystemException if a system exception occurred
3670             */
3671            public boolean containsDDMStructure(long pk, long ddmStructurePK)
3672                    throws SystemException {
3673                    Object[] finderArgs = new Object[] { pk, ddmStructurePK };
3674    
3675                    Boolean value = (Boolean)FinderCacheUtil.getResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3676                                    finderArgs, this);
3677    
3678                    if (value == null) {
3679                            try {
3680                                    value = Boolean.valueOf(containsDDMStructure.contains(pk,
3681                                                            ddmStructurePK));
3682                            }
3683                            catch (Exception e) {
3684                                    throw processException(e);
3685                            }
3686                            finally {
3687                                    if (value == null) {
3688                                            value = Boolean.FALSE;
3689                                    }
3690    
3691                                    FinderCacheUtil.putResult(FINDER_PATH_CONTAINS_DDMSTRUCTURE,
3692                                            finderArgs, value);
3693                            }
3694                    }
3695    
3696                    return value.booleanValue();
3697            }
3698    
3699            /**
3700             * Returns <code>true</code> if the document library file entry type has any d d m structures associated with it.
3701             *
3702             * @param pk the primary key of the document library file entry type to check for associations with d d m structures
3703             * @return <code>true</code> if the document library file entry type has any d d m structures associated with it; <code>false</code> otherwise
3704             * @throws SystemException if a system exception occurred
3705             */
3706            public boolean containsDDMStructures(long pk) throws SystemException {
3707                    if (getDDMStructuresSize(pk) > 0) {
3708                            return true;
3709                    }
3710                    else {
3711                            return false;
3712                    }
3713            }
3714    
3715            /**
3716             * Adds an association between the document library file entry type and the d d m structure. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3717             *
3718             * @param pk the primary key of the document library file entry type
3719             * @param ddmStructurePK the primary key of the d d m structure
3720             * @throws SystemException if a system exception occurred
3721             */
3722            public void addDDMStructure(long pk, long ddmStructurePK)
3723                    throws SystemException {
3724                    try {
3725                            addDDMStructure.add(pk, ddmStructurePK);
3726                    }
3727                    catch (Exception e) {
3728                            throw processException(e);
3729                    }
3730                    finally {
3731                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3732                    }
3733            }
3734    
3735            /**
3736             * Adds an association between the document library file entry type and the d d m structure. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3737             *
3738             * @param pk the primary key of the document library file entry type
3739             * @param ddmStructure the d d m structure
3740             * @throws SystemException if a system exception occurred
3741             */
3742            public void addDDMStructure(long pk,
3743                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3744                    throws SystemException {
3745                    try {
3746                            addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3747                    }
3748                    catch (Exception e) {
3749                            throw processException(e);
3750                    }
3751                    finally {
3752                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3753                    }
3754            }
3755    
3756            /**
3757             * Adds an association between the document library file entry type and the d d m structures. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3758             *
3759             * @param pk the primary key of the document library file entry type
3760             * @param ddmStructurePKs the primary keys of the d d m structures
3761             * @throws SystemException if a system exception occurred
3762             */
3763            public void addDDMStructures(long pk, long[] ddmStructurePKs)
3764                    throws SystemException {
3765                    try {
3766                            for (long ddmStructurePK : ddmStructurePKs) {
3767                                    addDDMStructure.add(pk, ddmStructurePK);
3768                            }
3769                    }
3770                    catch (Exception e) {
3771                            throw processException(e);
3772                    }
3773                    finally {
3774                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3775                    }
3776            }
3777    
3778            /**
3779             * Adds an association between the document library file entry type and the d d m structures. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3780             *
3781             * @param pk the primary key of the document library file entry type
3782             * @param ddmStructures the d d m structures
3783             * @throws SystemException if a system exception occurred
3784             */
3785            public void addDDMStructures(long pk,
3786                    List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3787                    throws SystemException {
3788                    try {
3789                            for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3790                                    addDDMStructure.add(pk, ddmStructure.getPrimaryKey());
3791                            }
3792                    }
3793                    catch (Exception e) {
3794                            throw processException(e);
3795                    }
3796                    finally {
3797                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3798                    }
3799            }
3800    
3801            /**
3802             * Clears all associations between the document library file entry type and its d d m structures. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3803             *
3804             * @param pk the primary key of the document library file entry type to clear the associated d d m structures from
3805             * @throws SystemException if a system exception occurred
3806             */
3807            public void clearDDMStructures(long pk) throws SystemException {
3808                    try {
3809                            clearDDMStructures.clear(pk);
3810                    }
3811                    catch (Exception e) {
3812                            throw processException(e);
3813                    }
3814                    finally {
3815                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3816                    }
3817            }
3818    
3819            /**
3820             * Removes the association between the document library file entry type and the d d m structure. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3821             *
3822             * @param pk the primary key of the document library file entry type
3823             * @param ddmStructurePK the primary key of the d d m structure
3824             * @throws SystemException if a system exception occurred
3825             */
3826            public void removeDDMStructure(long pk, long ddmStructurePK)
3827                    throws SystemException {
3828                    try {
3829                            removeDDMStructure.remove(pk, ddmStructurePK);
3830                    }
3831                    catch (Exception e) {
3832                            throw processException(e);
3833                    }
3834                    finally {
3835                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3836                    }
3837            }
3838    
3839            /**
3840             * Removes the association between the document library file entry type and the d d m structure. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3841             *
3842             * @param pk the primary key of the document library file entry type
3843             * @param ddmStructure the d d m structure
3844             * @throws SystemException if a system exception occurred
3845             */
3846            public void removeDDMStructure(long pk,
3847                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure)
3848                    throws SystemException {
3849                    try {
3850                            removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3851                    }
3852                    catch (Exception e) {
3853                            throw processException(e);
3854                    }
3855                    finally {
3856                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3857                    }
3858            }
3859    
3860            /**
3861             * Removes the association between the document library file entry type and the d d m structures. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3862             *
3863             * @param pk the primary key of the document library file entry type
3864             * @param ddmStructurePKs the primary keys of the d d m structures
3865             * @throws SystemException if a system exception occurred
3866             */
3867            public void removeDDMStructures(long pk, long[] ddmStructurePKs)
3868                    throws SystemException {
3869                    try {
3870                            for (long ddmStructurePK : ddmStructurePKs) {
3871                                    removeDDMStructure.remove(pk, ddmStructurePK);
3872                            }
3873                    }
3874                    catch (Exception e) {
3875                            throw processException(e);
3876                    }
3877                    finally {
3878                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3879                    }
3880            }
3881    
3882            /**
3883             * Removes the association between the document library file entry type and the d d m structures. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3884             *
3885             * @param pk the primary key of the document library file entry type
3886             * @param ddmStructures the d d m structures
3887             * @throws SystemException if a system exception occurred
3888             */
3889            public void removeDDMStructures(long pk,
3890                    List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3891                    throws SystemException {
3892                    try {
3893                            for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3894                                    removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3895                            }
3896                    }
3897                    catch (Exception e) {
3898                            throw processException(e);
3899                    }
3900                    finally {
3901                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3902                    }
3903            }
3904    
3905            /**
3906             * Sets the d d m structures associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3907             *
3908             * @param pk the primary key of the document library file entry type
3909             * @param ddmStructurePKs the primary keys of the d d m structures to be associated with the document library file entry type
3910             * @throws SystemException if a system exception occurred
3911             */
3912            public void setDDMStructures(long pk, long[] ddmStructurePKs)
3913                    throws SystemException {
3914                    try {
3915                            Set<Long> ddmStructurePKSet = SetUtil.fromArray(ddmStructurePKs);
3916    
3917                            List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
3918                                    getDDMStructures(pk);
3919    
3920                            for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
3921                                    if (!ddmStructurePKSet.remove(ddmStructure.getPrimaryKey())) {
3922                                            removeDDMStructure.remove(pk, ddmStructure.getPrimaryKey());
3923                                    }
3924                            }
3925    
3926                            for (Long ddmStructurePK : ddmStructurePKSet) {
3927                                    addDDMStructure.add(pk, ddmStructurePK);
3928                            }
3929                    }
3930                    catch (Exception e) {
3931                            throw processException(e);
3932                    }
3933                    finally {
3934                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3935                    }
3936            }
3937    
3938            /**
3939             * Sets the d d m structures associated with the document library file entry type, removing and adding associations as necessary. Also notifies the appropriate model listeners and clears the mapping table finder cache.
3940             *
3941             * @param pk the primary key of the document library file entry type
3942             * @param ddmStructures the d d m structures to be associated with the document library file entry type
3943             * @throws SystemException if a system exception occurred
3944             */
3945            public void setDDMStructures(long pk,
3946                    List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures)
3947                    throws SystemException {
3948                    try {
3949                            long[] ddmStructurePKs = new long[ddmStructures.size()];
3950    
3951                            for (int i = 0; i < ddmStructures.size(); i++) {
3952                                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure =
3953                                            ddmStructures.get(i);
3954    
3955                                    ddmStructurePKs[i] = ddmStructure.getPrimaryKey();
3956                            }
3957    
3958                            setDDMStructures(pk, ddmStructurePKs);
3959                    }
3960                    catch (Exception e) {
3961                            throw processException(e);
3962                    }
3963                    finally {
3964                            FinderCacheUtil.clearCache(DLFileEntryTypeModelImpl.MAPPING_TABLE_DLFILEENTRYTYPES_DDMSTRUCTURES_NAME);
3965                    }
3966            }
3967    
3968            /**
3969             * Initializes the document library file entry type persistence.
3970             */
3971            public void afterPropertiesSet() {
3972                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3973                                            com.liferay.portal.util.PropsUtil.get(
3974                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileEntryType")));
3975    
3976                    if (listenerClassNames.length > 0) {
3977                            try {
3978                                    List<ModelListener<DLFileEntryType>> listenersList = new ArrayList<ModelListener<DLFileEntryType>>();
3979    
3980                                    for (String listenerClassName : listenerClassNames) {
3981                                            listenersList.add((ModelListener<DLFileEntryType>)InstanceFactory.newInstance(
3982                                                            listenerClassName));
3983                                    }
3984    
3985                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3986                            }
3987                            catch (Exception e) {
3988                                    _log.error(e);
3989                            }
3990                    }
3991    
3992                    containsDLFolder = new ContainsDLFolder();
3993    
3994                    addDLFolder = new AddDLFolder();
3995                    clearDLFolders = new ClearDLFolders();
3996                    removeDLFolder = new RemoveDLFolder();
3997    
3998                    containsDDMStructure = new ContainsDDMStructure();
3999    
4000                    addDDMStructure = new AddDDMStructure();
4001                    clearDDMStructures = new ClearDDMStructures();
4002                    removeDDMStructure = new RemoveDDMStructure();
4003            }
4004    
4005            public void destroy() {
4006                    EntityCacheUtil.removeCache(DLFileEntryTypeImpl.class.getName());
4007                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
4008                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
4009            }
4010    
4011            @BeanReference(type = DLContentPersistence.class)
4012            protected DLContentPersistence dlContentPersistence;
4013            @BeanReference(type = DLFileEntryPersistence.class)
4014            protected DLFileEntryPersistence dlFileEntryPersistence;
4015            @BeanReference(type = DLFileEntryMetadataPersistence.class)
4016            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
4017            @BeanReference(type = DLFileEntryTypePersistence.class)
4018            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
4019            @BeanReference(type = DLFileRankPersistence.class)
4020            protected DLFileRankPersistence dlFileRankPersistence;
4021            @BeanReference(type = DLFileShortcutPersistence.class)
4022            protected DLFileShortcutPersistence dlFileShortcutPersistence;
4023            @BeanReference(type = DLFileVersionPersistence.class)
4024            protected DLFileVersionPersistence dlFileVersionPersistence;
4025            @BeanReference(type = DLFolderPersistence.class)
4026            protected DLFolderPersistence dlFolderPersistence;
4027            @BeanReference(type = DLSyncPersistence.class)
4028            protected DLSyncPersistence dlSyncPersistence;
4029            @BeanReference(type = ResourcePersistence.class)
4030            protected ResourcePersistence resourcePersistence;
4031            @BeanReference(type = UserPersistence.class)
4032            protected UserPersistence userPersistence;
4033            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
4034            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
4035            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
4036            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
4037            @BeanReference(type = DDMStructurePersistence.class)
4038            protected DDMStructurePersistence ddmStructurePersistence;
4039            protected ContainsDLFolder containsDLFolder;
4040            protected AddDLFolder addDLFolder;
4041            protected ClearDLFolders clearDLFolders;
4042            protected RemoveDLFolder removeDLFolder;
4043            protected ContainsDDMStructure containsDDMStructure;
4044            protected AddDDMStructure addDDMStructure;
4045            protected ClearDDMStructures clearDDMStructures;
4046            protected RemoveDDMStructure removeDDMStructure;
4047    
4048            protected class ContainsDLFolder {
4049                    protected ContainsDLFolder() {
4050                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4051                                            _SQL_CONTAINSDLFOLDER,
4052                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4053                                            RowMapper.COUNT);
4054                    }
4055    
4056                    protected boolean contains(long fileEntryTypeId, long folderId) {
4057                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4058                                                    new Long(fileEntryTypeId), new Long(folderId)
4059                                            });
4060    
4061                            if (results.size() > 0) {
4062                                    Integer count = results.get(0);
4063    
4064                                    if (count.intValue() > 0) {
4065                                            return true;
4066                                    }
4067                            }
4068    
4069                            return false;
4070                    }
4071    
4072                    private MappingSqlQuery<Integer> _mappingSqlQuery;
4073            }
4074    
4075            protected class AddDLFolder {
4076                    protected AddDLFolder() {
4077                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4078                                            "INSERT INTO DLFileEntryTypes_DLFolders (fileEntryTypeId, folderId) VALUES (?, ?)",
4079                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4080                    }
4081    
4082                    protected void add(long fileEntryTypeId, long folderId)
4083                            throws SystemException {
4084                            if (!containsDLFolder.contains(fileEntryTypeId, folderId)) {
4085                                    ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4086                                            dlFolderPersistence.getListeners();
4087    
4088                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4089                                            listener.onBeforeAddAssociation(fileEntryTypeId,
4090                                                    com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4091                                                    folderId);
4092                                    }
4093    
4094                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4095                                            listener.onBeforeAddAssociation(folderId,
4096                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4097                                    }
4098    
4099                                    _sqlUpdate.update(new Object[] {
4100                                                    new Long(fileEntryTypeId), new Long(folderId)
4101                                            });
4102    
4103                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4104                                            listener.onAfterAddAssociation(fileEntryTypeId,
4105                                                    com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4106                                                    folderId);
4107                                    }
4108    
4109                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4110                                            listener.onAfterAddAssociation(folderId,
4111                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4112                                    }
4113                            }
4114                    }
4115    
4116                    private SqlUpdate _sqlUpdate;
4117            }
4118    
4119            protected class ClearDLFolders {
4120                    protected ClearDLFolders() {
4121                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4122                                            "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?",
4123                                            new int[] { java.sql.Types.BIGINT });
4124                    }
4125    
4126                    protected void clear(long fileEntryTypeId) throws SystemException {
4127                            ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4128                                    dlFolderPersistence.getListeners();
4129    
4130                            List<com.liferay.portlet.documentlibrary.model.DLFolder> dlFolders = null;
4131    
4132                            if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4133                                    dlFolders = getDLFolders(fileEntryTypeId);
4134    
4135                                    for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4136                                            for (ModelListener<DLFileEntryType> listener : listeners) {
4137                                                    listener.onBeforeRemoveAssociation(fileEntryTypeId,
4138                                                            com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4139                                                            dlFolder.getPrimaryKey());
4140                                            }
4141    
4142                                            for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4143                                                    listener.onBeforeRemoveAssociation(dlFolder.getPrimaryKey(),
4144                                                            DLFileEntryType.class.getName(), fileEntryTypeId);
4145                                            }
4146                                    }
4147                            }
4148    
4149                            _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4150    
4151                            if ((listeners.length > 0) || (dlFolderListeners.length > 0)) {
4152                                    for (com.liferay.portlet.documentlibrary.model.DLFolder dlFolder : dlFolders) {
4153                                            for (ModelListener<DLFileEntryType> listener : listeners) {
4154                                                    listener.onAfterRemoveAssociation(fileEntryTypeId,
4155                                                            com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4156                                                            dlFolder.getPrimaryKey());
4157                                            }
4158    
4159                                            for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4160                                                    listener.onAfterRemoveAssociation(dlFolder.getPrimaryKey(),
4161                                                            DLFileEntryType.class.getName(), fileEntryTypeId);
4162                                            }
4163                                    }
4164                            }
4165                    }
4166    
4167                    private SqlUpdate _sqlUpdate;
4168            }
4169    
4170            protected class RemoveDLFolder {
4171                    protected RemoveDLFolder() {
4172                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4173                                            "DELETE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?",
4174                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4175                    }
4176    
4177                    protected void remove(long fileEntryTypeId, long folderId)
4178                            throws SystemException {
4179                            if (containsDLFolder.contains(fileEntryTypeId, folderId)) {
4180                                    ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder>[] dlFolderListeners =
4181                                            dlFolderPersistence.getListeners();
4182    
4183                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4184                                            listener.onBeforeRemoveAssociation(fileEntryTypeId,
4185                                                    com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4186                                                    folderId);
4187                                    }
4188    
4189                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4190                                            listener.onBeforeRemoveAssociation(folderId,
4191                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4192                                    }
4193    
4194                                    _sqlUpdate.update(new Object[] {
4195                                                    new Long(fileEntryTypeId), new Long(folderId)
4196                                            });
4197    
4198                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4199                                            listener.onAfterRemoveAssociation(fileEntryTypeId,
4200                                                    com.liferay.portlet.documentlibrary.model.DLFolder.class.getName(),
4201                                                    folderId);
4202                                    }
4203    
4204                                    for (ModelListener<com.liferay.portlet.documentlibrary.model.DLFolder> listener : dlFolderListeners) {
4205                                            listener.onAfterRemoveAssociation(folderId,
4206                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4207                                    }
4208                            }
4209                    }
4210    
4211                    private SqlUpdate _sqlUpdate;
4212            }
4213    
4214            protected class ContainsDDMStructure {
4215                    protected ContainsDDMStructure() {
4216                            _mappingSqlQuery = MappingSqlQueryFactoryUtil.getMappingSqlQuery(getDataSource(),
4217                                            _SQL_CONTAINSDDMSTRUCTURE,
4218                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT },
4219                                            RowMapper.COUNT);
4220                    }
4221    
4222                    protected boolean contains(long fileEntryTypeId, long structureId) {
4223                            List<Integer> results = _mappingSqlQuery.execute(new Object[] {
4224                                                    new Long(fileEntryTypeId), new Long(structureId)
4225                                            });
4226    
4227                            if (results.size() > 0) {
4228                                    Integer count = results.get(0);
4229    
4230                                    if (count.intValue() > 0) {
4231                                            return true;
4232                                    }
4233                            }
4234    
4235                            return false;
4236                    }
4237    
4238                    private MappingSqlQuery<Integer> _mappingSqlQuery;
4239            }
4240    
4241            protected class AddDDMStructure {
4242                    protected AddDDMStructure() {
4243                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4244                                            "INSERT INTO DLFileEntryTypes_DDMStructures (fileEntryTypeId, structureId) VALUES (?, ?)",
4245                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4246                    }
4247    
4248                    protected void add(long fileEntryTypeId, long structureId)
4249                            throws SystemException {
4250                            if (!containsDDMStructure.contains(fileEntryTypeId, structureId)) {
4251                                    ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4252                                            ddmStructurePersistence.getListeners();
4253    
4254                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4255                                            listener.onBeforeAddAssociation(fileEntryTypeId,
4256                                                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4257                                                    structureId);
4258                                    }
4259    
4260                                    for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4261                                            listener.onBeforeAddAssociation(structureId,
4262                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4263                                    }
4264    
4265                                    _sqlUpdate.update(new Object[] {
4266                                                    new Long(fileEntryTypeId), new Long(structureId)
4267                                            });
4268    
4269                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4270                                            listener.onAfterAddAssociation(fileEntryTypeId,
4271                                                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4272                                                    structureId);
4273                                    }
4274    
4275                                    for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4276                                            listener.onAfterAddAssociation(structureId,
4277                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4278                                    }
4279                            }
4280                    }
4281    
4282                    private SqlUpdate _sqlUpdate;
4283            }
4284    
4285            protected class ClearDDMStructures {
4286                    protected ClearDDMStructures() {
4287                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4288                                            "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?",
4289                                            new int[] { java.sql.Types.BIGINT });
4290                    }
4291    
4292                    protected void clear(long fileEntryTypeId) throws SystemException {
4293                            ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4294                                    ddmStructurePersistence.getListeners();
4295    
4296                            List<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> ddmStructures =
4297                                    null;
4298    
4299                            if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4300                                    ddmStructures = getDDMStructures(fileEntryTypeId);
4301    
4302                                    for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4303                                            for (ModelListener<DLFileEntryType> listener : listeners) {
4304                                                    listener.onBeforeRemoveAssociation(fileEntryTypeId,
4305                                                            com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4306                                                            ddmStructure.getPrimaryKey());
4307                                            }
4308    
4309                                            for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4310                                                    listener.onBeforeRemoveAssociation(ddmStructure.getPrimaryKey(),
4311                                                            DLFileEntryType.class.getName(), fileEntryTypeId);
4312                                            }
4313                                    }
4314                            }
4315    
4316                            _sqlUpdate.update(new Object[] { new Long(fileEntryTypeId) });
4317    
4318                            if ((listeners.length > 0) || (ddmStructureListeners.length > 0)) {
4319                                    for (com.liferay.portlet.dynamicdatamapping.model.DDMStructure ddmStructure : ddmStructures) {
4320                                            for (ModelListener<DLFileEntryType> listener : listeners) {
4321                                                    listener.onAfterRemoveAssociation(fileEntryTypeId,
4322                                                            com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4323                                                            ddmStructure.getPrimaryKey());
4324                                            }
4325    
4326                                            for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4327                                                    listener.onAfterRemoveAssociation(ddmStructure.getPrimaryKey(),
4328                                                            DLFileEntryType.class.getName(), fileEntryTypeId);
4329                                            }
4330                                    }
4331                            }
4332                    }
4333    
4334                    private SqlUpdate _sqlUpdate;
4335            }
4336    
4337            protected class RemoveDDMStructure {
4338                    protected RemoveDDMStructure() {
4339                            _sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(getDataSource(),
4340                                            "DELETE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?",
4341                                            new int[] { java.sql.Types.BIGINT, java.sql.Types.BIGINT });
4342                    }
4343    
4344                    protected void remove(long fileEntryTypeId, long structureId)
4345                            throws SystemException {
4346                            if (containsDDMStructure.contains(fileEntryTypeId, structureId)) {
4347                                    ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure>[] ddmStructureListeners =
4348                                            ddmStructurePersistence.getListeners();
4349    
4350                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4351                                            listener.onBeforeRemoveAssociation(fileEntryTypeId,
4352                                                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4353                                                    structureId);
4354                                    }
4355    
4356                                    for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4357                                            listener.onBeforeRemoveAssociation(structureId,
4358                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4359                                    }
4360    
4361                                    _sqlUpdate.update(new Object[] {
4362                                                    new Long(fileEntryTypeId), new Long(structureId)
4363                                            });
4364    
4365                                    for (ModelListener<DLFileEntryType> listener : listeners) {
4366                                            listener.onAfterRemoveAssociation(fileEntryTypeId,
4367                                                    com.liferay.portlet.dynamicdatamapping.model.DDMStructure.class.getName(),
4368                                                    structureId);
4369                                    }
4370    
4371                                    for (ModelListener<com.liferay.portlet.dynamicdatamapping.model.DDMStructure> listener : ddmStructureListeners) {
4372                                            listener.onAfterRemoveAssociation(structureId,
4373                                                    DLFileEntryType.class.getName(), fileEntryTypeId);
4374                                    }
4375                            }
4376                    }
4377    
4378                    private SqlUpdate _sqlUpdate;
4379            }
4380    
4381            private static final String _SQL_SELECT_DLFILEENTRYTYPE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType";
4382            private static final String _SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT dlFileEntryType FROM DLFileEntryType dlFileEntryType WHERE ";
4383            private static final String _SQL_COUNT_DLFILEENTRYTYPE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType";
4384            private static final String _SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(dlFileEntryType) FROM DLFileEntryType dlFileEntryType WHERE ";
4385            private static final String _SQL_GETDLFOLDERS = "SELECT {DLFolder.*} FROM DLFolder INNER JOIN DLFileEntryTypes_DLFolders ON (DLFileEntryTypes_DLFolders.folderId = DLFolder.folderId) WHERE (DLFileEntryTypes_DLFolders.fileEntryTypeId = ?)";
4386            private static final String _SQL_GETDLFOLDERSSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ?";
4387            private static final String _SQL_CONTAINSDLFOLDER = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DLFolders WHERE fileEntryTypeId = ? AND folderId = ?";
4388            private static final String _SQL_GETDDMSTRUCTURES = "SELECT {DDMStructure.*} FROM DDMStructure INNER JOIN DLFileEntryTypes_DDMStructures ON (DLFileEntryTypes_DDMStructures.structureId = DDMStructure.structureId) WHERE (DLFileEntryTypes_DDMStructures.fileEntryTypeId = ?)";
4389            private static final String _SQL_GETDDMSTRUCTURESSIZE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ?";
4390            private static final String _SQL_CONTAINSDDMSTRUCTURE = "SELECT COUNT(*) AS COUNT_VALUE FROM DLFileEntryTypes_DDMStructures WHERE fileEntryTypeId = ? AND structureId = ?";
4391            private static final String _FINDER_COLUMN_UUID_UUID_1 = "dlFileEntryType.uuid IS NULL";
4392            private static final String _FINDER_COLUMN_UUID_UUID_2 = "dlFileEntryType.uuid = ?";
4393            private static final String _FINDER_COLUMN_UUID_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?)";
4394            private static final String _FINDER_COLUMN_UUID_G_UUID_1 = "dlFileEntryType.uuid IS NULL AND ";
4395            private static final String _FINDER_COLUMN_UUID_G_UUID_2 = "dlFileEntryType.uuid = ? AND ";
4396            private static final String _FINDER_COLUMN_UUID_G_UUID_3 = "(dlFileEntryType.uuid IS NULL OR dlFileEntryType.uuid = ?) AND ";
4397            private static final String _FINDER_COLUMN_UUID_G_GROUPID_2 = "dlFileEntryType.groupId = ?";
4398            private static final String _FINDER_COLUMN_GROUPID_GROUPID_2 = "dlFileEntryType.groupId = ?";
4399            private static final String _FINDER_COLUMN_GROUPID_GROUPID_5 = "(" +
4400                    _removeConjunction(_FINDER_COLUMN_GROUPID_GROUPID_2) + ")";
4401            private static final String _FINDER_COLUMN_G_N_GROUPID_2 = "dlFileEntryType.groupId = ? AND ";
4402            private static final String _FINDER_COLUMN_G_N_NAME_1 = "dlFileEntryType.name IS NULL";
4403            private static final String _FINDER_COLUMN_G_N_NAME_2 = "dlFileEntryType.name = ?";
4404            private static final String _FINDER_COLUMN_G_N_NAME_3 = "(dlFileEntryType.name IS NULL OR dlFileEntryType.name = ?)";
4405    
4406            private static String _removeConjunction(String sql) {
4407                    int pos = sql.indexOf(" AND ");
4408    
4409                    if (pos != -1) {
4410                            sql = sql.substring(0, pos);
4411                    }
4412    
4413                    return sql;
4414            }
4415    
4416            private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "dlFileEntryType.fileEntryTypeId";
4417            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_WHERE = "SELECT DISTINCT {dlFileEntryType.*} FROM DLFileEntryType dlFileEntryType WHERE ";
4418            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_1 =
4419                    "SELECT {DLFileEntryType.*} FROM (SELECT DISTINCT dlFileEntryType.fileEntryTypeId FROM DLFileEntryType dlFileEntryType WHERE ";
4420            private static final String _FILTER_SQL_SELECT_DLFILEENTRYTYPE_NO_INLINE_DISTINCT_WHERE_2 =
4421                    ") TEMP_TABLE INNER JOIN DLFileEntryType ON TEMP_TABLE.fileEntryTypeId = DLFileEntryType.fileEntryTypeId";
4422            private static final String _FILTER_SQL_COUNT_DLFILEENTRYTYPE_WHERE = "SELECT COUNT(DISTINCT dlFileEntryType.fileEntryTypeId) AS COUNT_VALUE FROM DLFileEntryType dlFileEntryType WHERE ";
4423            private static final String _FILTER_ENTITY_ALIAS = "dlFileEntryType";
4424            private static final String _FILTER_ENTITY_TABLE = "DLFileEntryType";
4425            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileEntryType.";
4426            private static final String _ORDER_BY_ENTITY_TABLE = "DLFileEntryType.";
4427            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileEntryType exists with the primary key ";
4428            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileEntryType exists with the key {";
4429            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
4430            private static Log _log = LogFactoryUtil.getLog(DLFileEntryTypePersistenceImpl.class);
4431            private static DLFileEntryType _nullDLFileEntryType = new DLFileEntryTypeImpl() {
4432                            @Override
4433                            public Object clone() {
4434                                    return this;
4435                            }
4436    
4437                            @Override
4438                            public CacheModel<DLFileEntryType> toCacheModel() {
4439                                    return _nullDLFileEntryTypeCacheModel;
4440                            }
4441                    };
4442    
4443            private static CacheModel<DLFileEntryType> _nullDLFileEntryTypeCacheModel = new CacheModel<DLFileEntryType>() {
4444                            public DLFileEntryType toEntityModel() {
4445                                    return _nullDLFileEntryType;
4446                            }
4447                    };
4448    }