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