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