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.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.CacheModel;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.service.persistence.LayoutPersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.documentlibrary.NoSuchFileRankException;
043    import com.liferay.portlet.documentlibrary.model.DLFileRank;
044    import com.liferay.portlet.documentlibrary.model.impl.DLFileRankImpl;
045    import com.liferay.portlet.documentlibrary.model.impl.DLFileRankModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * The persistence implementation for the document library file rank service.
055     *
056     * <p>
057     * Caching information and settings can be found in <code>portal.properties</code>
058     * </p>
059     *
060     * @author Brian Wing Shun Chan
061     * @see DLFileRankPersistence
062     * @see DLFileRankUtil
063     * @generated
064     */
065    public class DLFileRankPersistenceImpl extends BasePersistenceImpl<DLFileRank>
066            implements DLFileRankPersistence {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * Never modify or reference this class directly. Always use {@link DLFileRankUtil} to access the document library file rank persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
071             */
072            public static final String FINDER_CLASS_NAME_ENTITY = DLFileRankImpl.class.getName();
073            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List1";
075            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
076                    ".List2";
077            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
078                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
079                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUserId",
080                            new String[] {
081                                    Long.class.getName(),
082                                    
083                            "java.lang.Integer", "java.lang.Integer",
084                                    "com.liferay.portal.kernel.util.OrderByComparator"
085                            });
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
087                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
088                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
089                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUserId",
090                            new String[] { Long.class.getName() },
091                            DLFileRankModelImpl.USERID_COLUMN_BITMASK);
092            public static final FinderPath FINDER_PATH_COUNT_BY_USERID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
093                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
094                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUserId",
095                            new String[] { Long.class.getName() });
096            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID =
097                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
098                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
099                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByFileEntryId",
100                            new String[] {
101                                    Long.class.getName(),
102                                    
103                            "java.lang.Integer", "java.lang.Integer",
104                                    "com.liferay.portal.kernel.util.OrderByComparator"
105                            });
106            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID =
107                    new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
108                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
109                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByFileEntryId",
110                            new String[] { Long.class.getName() },
111                            DLFileRankModelImpl.FILEENTRYID_COLUMN_BITMASK);
112            public static final FinderPath FINDER_PATH_COUNT_BY_FILEENTRYID = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
113                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
114                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByFileEntryId",
115                            new String[] { Long.class.getName() });
116            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
117                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
118                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U",
119                            new String[] {
120                                    Long.class.getName(), Long.class.getName(),
121                                    
122                            "java.lang.Integer", "java.lang.Integer",
123                                    "com.liferay.portal.kernel.util.OrderByComparator"
124                            });
125            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
126                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
127                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U",
128                            new String[] { Long.class.getName(), Long.class.getName() },
129                            DLFileRankModelImpl.GROUPID_COLUMN_BITMASK |
130                            DLFileRankModelImpl.USERID_COLUMN_BITMASK);
131            public static final FinderPath FINDER_PATH_COUNT_BY_G_U = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
132                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
133                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U",
134                            new String[] { Long.class.getName(), Long.class.getName() });
135            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_A = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
136                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
137                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByG_U_A",
138                            new String[] {
139                                    Long.class.getName(), Long.class.getName(),
140                                    Boolean.class.getName(),
141                                    
142                            "java.lang.Integer", "java.lang.Integer",
143                                    "com.liferay.portal.kernel.util.OrderByComparator"
144                            });
145            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_A = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
146                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
147                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByG_U_A",
148                            new String[] {
149                                    Long.class.getName(), Long.class.getName(),
150                                    Boolean.class.getName()
151                            },
152                            DLFileRankModelImpl.GROUPID_COLUMN_BITMASK |
153                            DLFileRankModelImpl.USERID_COLUMN_BITMASK |
154                            DLFileRankModelImpl.ACTIVE_COLUMN_BITMASK);
155            public static final FinderPath FINDER_PATH_COUNT_BY_G_U_A = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
156                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
157                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_U_A",
158                            new String[] {
159                                    Long.class.getName(), Long.class.getName(),
160                                    Boolean.class.getName()
161                            });
162            public static final FinderPath FINDER_PATH_FETCH_BY_C_U_F = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
163                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
164                            FINDER_CLASS_NAME_ENTITY, "fetchByC_U_F",
165                            new String[] {
166                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
167                            },
168                            DLFileRankModelImpl.COMPANYID_COLUMN_BITMASK |
169                            DLFileRankModelImpl.USERID_COLUMN_BITMASK |
170                            DLFileRankModelImpl.FILEENTRYID_COLUMN_BITMASK);
171            public static final FinderPath FINDER_PATH_COUNT_BY_C_U_F = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
172                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
173                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_U_F",
174                            new String[] {
175                                    Long.class.getName(), Long.class.getName(), Long.class.getName()
176                            });
177            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
178                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
179                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
180            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
181                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, DLFileRankImpl.class,
182                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
183            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
184                            DLFileRankModelImpl.FINDER_CACHE_ENABLED, Long.class,
185                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
186    
187            /**
188             * Caches the document library file rank in the entity cache if it is enabled.
189             *
190             * @param dlFileRank the document library file rank
191             */
192            public void cacheResult(DLFileRank dlFileRank) {
193                    EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
194                            DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
195    
196                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
197                            new Object[] {
198                                    Long.valueOf(dlFileRank.getCompanyId()),
199                                    Long.valueOf(dlFileRank.getUserId()),
200                                    Long.valueOf(dlFileRank.getFileEntryId())
201                            }, dlFileRank);
202    
203                    dlFileRank.resetOriginalValues();
204            }
205    
206            /**
207             * Caches the document library file ranks in the entity cache if it is enabled.
208             *
209             * @param dlFileRanks the document library file ranks
210             */
211            public void cacheResult(List<DLFileRank> dlFileRanks) {
212                    for (DLFileRank dlFileRank : dlFileRanks) {
213                            if (EntityCacheUtil.getResult(
214                                                    DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
215                                                    DLFileRankImpl.class, dlFileRank.getPrimaryKey()) == null) {
216                                    cacheResult(dlFileRank);
217                            }
218                            else {
219                                    dlFileRank.resetOriginalValues();
220                            }
221                    }
222            }
223    
224            /**
225             * Clears the cache for all document library file ranks.
226             *
227             * <p>
228             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
229             * </p>
230             */
231            @Override
232            public void clearCache() {
233                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
234                            CacheRegistryUtil.clear(DLFileRankImpl.class.getName());
235                    }
236    
237                    EntityCacheUtil.clearCache(DLFileRankImpl.class.getName());
238    
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
240                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
242            }
243    
244            /**
245             * Clears the cache for the document library file rank.
246             *
247             * <p>
248             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
249             * </p>
250             */
251            @Override
252            public void clearCache(DLFileRank dlFileRank) {
253                    EntityCacheUtil.removeResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
254                            DLFileRankImpl.class, dlFileRank.getPrimaryKey());
255    
256                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
257                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
258    
259                    clearUniqueFindersCache(dlFileRank);
260            }
261    
262            @Override
263            public void clearCache(List<DLFileRank> dlFileRanks) {
264                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
265                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
266    
267                    for (DLFileRank dlFileRank : dlFileRanks) {
268                            EntityCacheUtil.removeResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
269                                    DLFileRankImpl.class, dlFileRank.getPrimaryKey());
270    
271                            clearUniqueFindersCache(dlFileRank);
272                    }
273            }
274    
275            protected void clearUniqueFindersCache(DLFileRank dlFileRank) {
276                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F,
277                            new Object[] {
278                                    Long.valueOf(dlFileRank.getCompanyId()),
279                                    Long.valueOf(dlFileRank.getUserId()),
280                                    Long.valueOf(dlFileRank.getFileEntryId())
281                            });
282            }
283    
284            /**
285             * Creates a new document library file rank with the primary key. Does not add the document library file rank to the database.
286             *
287             * @param fileRankId the primary key for the new document library file rank
288             * @return the new document library file rank
289             */
290            public DLFileRank create(long fileRankId) {
291                    DLFileRank dlFileRank = new DLFileRankImpl();
292    
293                    dlFileRank.setNew(true);
294                    dlFileRank.setPrimaryKey(fileRankId);
295    
296                    return dlFileRank;
297            }
298    
299            /**
300             * Removes the document library file rank with the primary key from the database. Also notifies the appropriate model listeners.
301             *
302             * @param fileRankId the primary key of the document library file rank
303             * @return the document library file rank that was removed
304             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
305             * @throws SystemException if a system exception occurred
306             */
307            public DLFileRank remove(long fileRankId)
308                    throws NoSuchFileRankException, SystemException {
309                    return remove(Long.valueOf(fileRankId));
310            }
311    
312            /**
313             * Removes the document library file rank with the primary key from the database. Also notifies the appropriate model listeners.
314             *
315             * @param primaryKey the primary key of the document library file rank
316             * @return the document library file rank that was removed
317             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
318             * @throws SystemException if a system exception occurred
319             */
320            @Override
321            public DLFileRank remove(Serializable primaryKey)
322                    throws NoSuchFileRankException, SystemException {
323                    Session session = null;
324    
325                    try {
326                            session = openSession();
327    
328                            DLFileRank dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
329                                            primaryKey);
330    
331                            if (dlFileRank == null) {
332                                    if (_log.isWarnEnabled()) {
333                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
334                                    }
335    
336                                    throw new NoSuchFileRankException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
337                                            primaryKey);
338                            }
339    
340                            return remove(dlFileRank);
341                    }
342                    catch (NoSuchFileRankException nsee) {
343                            throw nsee;
344                    }
345                    catch (Exception e) {
346                            throw processException(e);
347                    }
348                    finally {
349                            closeSession(session);
350                    }
351            }
352    
353            @Override
354            protected DLFileRank removeImpl(DLFileRank dlFileRank)
355                    throws SystemException {
356                    dlFileRank = toUnwrappedModel(dlFileRank);
357    
358                    Session session = null;
359    
360                    try {
361                            session = openSession();
362    
363                            if (dlFileRank.isCachedModel()) {
364                                    dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
365                                                    dlFileRank.getPrimaryKeyObj());
366                            }
367    
368                            session.delete(dlFileRank);
369                    }
370                    catch (Exception e) {
371                            throw processException(e);
372                    }
373                    finally {
374                            closeSession(session);
375                    }
376    
377                    clearCache(dlFileRank);
378    
379                    return dlFileRank;
380            }
381    
382            @Override
383            public DLFileRank updateImpl(
384                    com.liferay.portlet.documentlibrary.model.DLFileRank dlFileRank)
385                    throws SystemException {
386                    dlFileRank = toUnwrappedModel(dlFileRank);
387    
388                    boolean isNew = dlFileRank.isNew();
389    
390                    DLFileRankModelImpl dlFileRankModelImpl = (DLFileRankModelImpl)dlFileRank;
391    
392                    Session session = null;
393    
394                    try {
395                            session = openSession();
396    
397                            if (dlFileRank.isNew()) {
398                                    session.save(dlFileRank);
399    
400                                    dlFileRank.setNew(false);
401                            }
402                            else {
403                                    session.merge(dlFileRank);
404                            }
405                    }
406                    catch (Exception e) {
407                            throw processException(e);
408                    }
409                    finally {
410                            closeSession(session);
411                    }
412    
413                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
414    
415                    if (isNew || !DLFileRankModelImpl.COLUMN_BITMASK_ENABLED) {
416                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
417                    }
418    
419                    else {
420                            if ((dlFileRankModelImpl.getColumnBitmask() &
421                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask()) != 0) {
422                                    Object[] args = new Object[] {
423                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
424                                            };
425    
426                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
427                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
428                                            args);
429    
430                                    args = new Object[] {
431                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
432                                            };
433    
434                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
435                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID,
436                                            args);
437                            }
438    
439                            if ((dlFileRankModelImpl.getColumnBitmask() &
440                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID.getColumnBitmask()) != 0) {
441                                    Object[] args = new Object[] {
442                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
443                                            };
444    
445                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
446                                            args);
447                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
448                                            args);
449    
450                                    args = new Object[] {
451                                                    Long.valueOf(dlFileRankModelImpl.getFileEntryId())
452                                            };
453    
454                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
455                                            args);
456                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID,
457                                            args);
458                            }
459    
460                            if ((dlFileRankModelImpl.getColumnBitmask() &
461                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U.getColumnBitmask()) != 0) {
462                                    Object[] args = new Object[] {
463                                                    Long.valueOf(dlFileRankModelImpl.getOriginalGroupId()),
464                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId())
465                                            };
466    
467                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
468                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
469                                            args);
470    
471                                    args = new Object[] {
472                                                    Long.valueOf(dlFileRankModelImpl.getGroupId()),
473                                                    Long.valueOf(dlFileRankModelImpl.getUserId())
474                                            };
475    
476                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U, args);
477                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U,
478                                            args);
479                            }
480    
481                            if ((dlFileRankModelImpl.getColumnBitmask() &
482                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_A.getColumnBitmask()) != 0) {
483                                    Object[] args = new Object[] {
484                                                    Long.valueOf(dlFileRankModelImpl.getOriginalGroupId()),
485                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId()),
486                                                    Boolean.valueOf(dlFileRankModelImpl.getOriginalActive())
487                                            };
488    
489                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_A, args);
490                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_A,
491                                            args);
492    
493                                    args = new Object[] {
494                                                    Long.valueOf(dlFileRankModelImpl.getGroupId()),
495                                                    Long.valueOf(dlFileRankModelImpl.getUserId()),
496                                                    Boolean.valueOf(dlFileRankModelImpl.getActive())
497                                            };
498    
499                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_U_A, args);
500                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_A,
501                                            args);
502                            }
503                    }
504    
505                    EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
506                            DLFileRankImpl.class, dlFileRank.getPrimaryKey(), dlFileRank);
507    
508                    if (isNew) {
509                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
510                                    new Object[] {
511                                            Long.valueOf(dlFileRank.getCompanyId()),
512                                            Long.valueOf(dlFileRank.getUserId()),
513                                            Long.valueOf(dlFileRank.getFileEntryId())
514                                    }, dlFileRank);
515                    }
516                    else {
517                            if ((dlFileRankModelImpl.getColumnBitmask() &
518                                            FINDER_PATH_FETCH_BY_C_U_F.getColumnBitmask()) != 0) {
519                                    Object[] args = new Object[] {
520                                                    Long.valueOf(dlFileRankModelImpl.getOriginalCompanyId()),
521                                                    Long.valueOf(dlFileRankModelImpl.getOriginalUserId()),
522                                                    Long.valueOf(dlFileRankModelImpl.getOriginalFileEntryId())
523                                            };
524    
525                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_U_F, args);
526    
527                                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F, args);
528    
529                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
530                                            new Object[] {
531                                                    Long.valueOf(dlFileRank.getCompanyId()),
532                                                    Long.valueOf(dlFileRank.getUserId()),
533                                                    Long.valueOf(dlFileRank.getFileEntryId())
534                                            }, dlFileRank);
535                            }
536                    }
537    
538                    return dlFileRank;
539            }
540    
541            protected DLFileRank toUnwrappedModel(DLFileRank dlFileRank) {
542                    if (dlFileRank instanceof DLFileRankImpl) {
543                            return dlFileRank;
544                    }
545    
546                    DLFileRankImpl dlFileRankImpl = new DLFileRankImpl();
547    
548                    dlFileRankImpl.setNew(dlFileRank.isNew());
549                    dlFileRankImpl.setPrimaryKey(dlFileRank.getPrimaryKey());
550    
551                    dlFileRankImpl.setFileRankId(dlFileRank.getFileRankId());
552                    dlFileRankImpl.setGroupId(dlFileRank.getGroupId());
553                    dlFileRankImpl.setCompanyId(dlFileRank.getCompanyId());
554                    dlFileRankImpl.setUserId(dlFileRank.getUserId());
555                    dlFileRankImpl.setCreateDate(dlFileRank.getCreateDate());
556                    dlFileRankImpl.setFileEntryId(dlFileRank.getFileEntryId());
557                    dlFileRankImpl.setActive(dlFileRank.isActive());
558    
559                    return dlFileRankImpl;
560            }
561    
562            /**
563             * Returns the document library file rank with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
564             *
565             * @param primaryKey the primary key of the document library file rank
566             * @return the document library file rank
567             * @throws com.liferay.portal.NoSuchModelException if a document library file rank with the primary key could not be found
568             * @throws SystemException if a system exception occurred
569             */
570            @Override
571            public DLFileRank findByPrimaryKey(Serializable primaryKey)
572                    throws NoSuchModelException, SystemException {
573                    return findByPrimaryKey(((Long)primaryKey).longValue());
574            }
575    
576            /**
577             * Returns the document library file rank with the primary key or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileRankException} if it could not be found.
578             *
579             * @param fileRankId the primary key of the document library file rank
580             * @return the document library file rank
581             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
582             * @throws SystemException if a system exception occurred
583             */
584            public DLFileRank findByPrimaryKey(long fileRankId)
585                    throws NoSuchFileRankException, SystemException {
586                    DLFileRank dlFileRank = fetchByPrimaryKey(fileRankId);
587    
588                    if (dlFileRank == null) {
589                            if (_log.isWarnEnabled()) {
590                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileRankId);
591                            }
592    
593                            throw new NoSuchFileRankException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
594                                    fileRankId);
595                    }
596    
597                    return dlFileRank;
598            }
599    
600            /**
601             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
602             *
603             * @param primaryKey the primary key of the document library file rank
604             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
605             * @throws SystemException if a system exception occurred
606             */
607            @Override
608            public DLFileRank fetchByPrimaryKey(Serializable primaryKey)
609                    throws SystemException {
610                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
611            }
612    
613            /**
614             * Returns the document library file rank with the primary key or returns <code>null</code> if it could not be found.
615             *
616             * @param fileRankId the primary key of the document library file rank
617             * @return the document library file rank, or <code>null</code> if a document library file rank with the primary key could not be found
618             * @throws SystemException if a system exception occurred
619             */
620            public DLFileRank fetchByPrimaryKey(long fileRankId)
621                    throws SystemException {
622                    DLFileRank dlFileRank = (DLFileRank)EntityCacheUtil.getResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
623                                    DLFileRankImpl.class, fileRankId);
624    
625                    if (dlFileRank == _nullDLFileRank) {
626                            return null;
627                    }
628    
629                    if (dlFileRank == null) {
630                            Session session = null;
631    
632                            boolean hasException = false;
633    
634                            try {
635                                    session = openSession();
636    
637                                    dlFileRank = (DLFileRank)session.get(DLFileRankImpl.class,
638                                                    Long.valueOf(fileRankId));
639                            }
640                            catch (Exception e) {
641                                    hasException = true;
642    
643                                    throw processException(e);
644                            }
645                            finally {
646                                    if (dlFileRank != null) {
647                                            cacheResult(dlFileRank);
648                                    }
649                                    else if (!hasException) {
650                                            EntityCacheUtil.putResult(DLFileRankModelImpl.ENTITY_CACHE_ENABLED,
651                                                    DLFileRankImpl.class, fileRankId, _nullDLFileRank);
652                                    }
653    
654                                    closeSession(session);
655                            }
656                    }
657    
658                    return dlFileRank;
659            }
660    
661            /**
662             * Returns all the document library file ranks where userId = &#63;.
663             *
664             * @param userId the user ID
665             * @return the matching document library file ranks
666             * @throws SystemException if a system exception occurred
667             */
668            public List<DLFileRank> findByUserId(long userId) throws SystemException {
669                    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
670            }
671    
672            /**
673             * Returns a range of all the document library file ranks where userId = &#63;.
674             *
675             * <p>
676             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
677             * </p>
678             *
679             * @param userId the user ID
680             * @param start the lower bound of the range of document library file ranks
681             * @param end the upper bound of the range of document library file ranks (not inclusive)
682             * @return the range of matching document library file ranks
683             * @throws SystemException if a system exception occurred
684             */
685            public List<DLFileRank> findByUserId(long userId, int start, int end)
686                    throws SystemException {
687                    return findByUserId(userId, start, end, null);
688            }
689    
690            /**
691             * Returns an ordered range of all the document library file ranks where userId = &#63;.
692             *
693             * <p>
694             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
695             * </p>
696             *
697             * @param userId the user ID
698             * @param start the lower bound of the range of document library file ranks
699             * @param end the upper bound of the range of document library file ranks (not inclusive)
700             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
701             * @return the ordered range of matching document library file ranks
702             * @throws SystemException if a system exception occurred
703             */
704            public List<DLFileRank> findByUserId(long userId, int start, int end,
705                    OrderByComparator orderByComparator) throws SystemException {
706                    FinderPath finderPath = null;
707                    Object[] finderArgs = null;
708    
709                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
710                                    (orderByComparator == null)) {
711                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
712                            finderArgs = new Object[] { userId };
713                    }
714                    else {
715                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
716                            finderArgs = new Object[] { userId, start, end, orderByComparator };
717                    }
718    
719                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
720                                    finderArgs, this);
721    
722                    if ((list != null) && !list.isEmpty()) {
723                            for (DLFileRank dlFileRank : list) {
724                                    if ((userId != dlFileRank.getUserId())) {
725                                            list = null;
726    
727                                            break;
728                                    }
729                            }
730                    }
731    
732                    if (list == null) {
733                            StringBundler query = null;
734    
735                            if (orderByComparator != null) {
736                                    query = new StringBundler(3 +
737                                                    (orderByComparator.getOrderByFields().length * 3));
738                            }
739                            else {
740                                    query = new StringBundler(3);
741                            }
742    
743                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
744    
745                            query.append(_FINDER_COLUMN_USERID_USERID_2);
746    
747                            if (orderByComparator != null) {
748                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
749                                            orderByComparator);
750                            }
751    
752                            else {
753                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
754                            }
755    
756                            String sql = query.toString();
757    
758                            Session session = null;
759    
760                            try {
761                                    session = openSession();
762    
763                                    Query q = session.createQuery(sql);
764    
765                                    QueryPos qPos = QueryPos.getInstance(q);
766    
767                                    qPos.add(userId);
768    
769                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
770                                                    end);
771                            }
772                            catch (Exception e) {
773                                    throw processException(e);
774                            }
775                            finally {
776                                    if (list == null) {
777                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
778                                    }
779                                    else {
780                                            cacheResult(list);
781    
782                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
783                                    }
784    
785                                    closeSession(session);
786                            }
787                    }
788    
789                    return list;
790            }
791    
792            /**
793             * Returns the first document library file rank in the ordered set where userId = &#63;.
794             *
795             * @param userId the user ID
796             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
797             * @return the first matching document library file rank
798             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
799             * @throws SystemException if a system exception occurred
800             */
801            public DLFileRank findByUserId_First(long userId,
802                    OrderByComparator orderByComparator)
803                    throws NoSuchFileRankException, SystemException {
804                    DLFileRank dlFileRank = fetchByUserId_First(userId, orderByComparator);
805    
806                    if (dlFileRank != null) {
807                            return dlFileRank;
808                    }
809    
810                    StringBundler msg = new StringBundler(4);
811    
812                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
813    
814                    msg.append("userId=");
815                    msg.append(userId);
816    
817                    msg.append(StringPool.CLOSE_CURLY_BRACE);
818    
819                    throw new NoSuchFileRankException(msg.toString());
820            }
821    
822            /**
823             * Returns the first document library file rank in the ordered set where userId = &#63;.
824             *
825             * @param userId the user ID
826             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
827             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
828             * @throws SystemException if a system exception occurred
829             */
830            public DLFileRank fetchByUserId_First(long userId,
831                    OrderByComparator orderByComparator) throws SystemException {
832                    List<DLFileRank> list = findByUserId(userId, 0, 1, orderByComparator);
833    
834                    if (!list.isEmpty()) {
835                            return list.get(0);
836                    }
837    
838                    return null;
839            }
840    
841            /**
842             * Returns the last document library file rank in the ordered set where userId = &#63;.
843             *
844             * @param userId the user ID
845             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
846             * @return the last matching document library file rank
847             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
848             * @throws SystemException if a system exception occurred
849             */
850            public DLFileRank findByUserId_Last(long userId,
851                    OrderByComparator orderByComparator)
852                    throws NoSuchFileRankException, SystemException {
853                    DLFileRank dlFileRank = fetchByUserId_Last(userId, orderByComparator);
854    
855                    if (dlFileRank != null) {
856                            return dlFileRank;
857                    }
858    
859                    StringBundler msg = new StringBundler(4);
860    
861                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
862    
863                    msg.append("userId=");
864                    msg.append(userId);
865    
866                    msg.append(StringPool.CLOSE_CURLY_BRACE);
867    
868                    throw new NoSuchFileRankException(msg.toString());
869            }
870    
871            /**
872             * Returns the last document library file rank in the ordered set where userId = &#63;.
873             *
874             * @param userId the user ID
875             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
876             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
877             * @throws SystemException if a system exception occurred
878             */
879            public DLFileRank fetchByUserId_Last(long userId,
880                    OrderByComparator orderByComparator) throws SystemException {
881                    int count = countByUserId(userId);
882    
883                    List<DLFileRank> list = findByUserId(userId, count - 1, count,
884                                    orderByComparator);
885    
886                    if (!list.isEmpty()) {
887                            return list.get(0);
888                    }
889    
890                    return null;
891            }
892    
893            /**
894             * Returns the document library file ranks before and after the current document library file rank in the ordered set where userId = &#63;.
895             *
896             * @param fileRankId the primary key of the current document library file rank
897             * @param userId the user ID
898             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
899             * @return the previous, current, and next document library file rank
900             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
901             * @throws SystemException if a system exception occurred
902             */
903            public DLFileRank[] findByUserId_PrevAndNext(long fileRankId, long userId,
904                    OrderByComparator orderByComparator)
905                    throws NoSuchFileRankException, SystemException {
906                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
907    
908                    Session session = null;
909    
910                    try {
911                            session = openSession();
912    
913                            DLFileRank[] array = new DLFileRankImpl[3];
914    
915                            array[0] = getByUserId_PrevAndNext(session, dlFileRank, userId,
916                                            orderByComparator, true);
917    
918                            array[1] = dlFileRank;
919    
920                            array[2] = getByUserId_PrevAndNext(session, dlFileRank, userId,
921                                            orderByComparator, false);
922    
923                            return array;
924                    }
925                    catch (Exception e) {
926                            throw processException(e);
927                    }
928                    finally {
929                            closeSession(session);
930                    }
931            }
932    
933            protected DLFileRank getByUserId_PrevAndNext(Session session,
934                    DLFileRank dlFileRank, long userId,
935                    OrderByComparator orderByComparator, boolean previous) {
936                    StringBundler query = null;
937    
938                    if (orderByComparator != null) {
939                            query = new StringBundler(6 +
940                                            (orderByComparator.getOrderByFields().length * 6));
941                    }
942                    else {
943                            query = new StringBundler(3);
944                    }
945    
946                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
947    
948                    query.append(_FINDER_COLUMN_USERID_USERID_2);
949    
950                    if (orderByComparator != null) {
951                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
952    
953                            if (orderByConditionFields.length > 0) {
954                                    query.append(WHERE_AND);
955                            }
956    
957                            for (int i = 0; i < orderByConditionFields.length; i++) {
958                                    query.append(_ORDER_BY_ENTITY_ALIAS);
959                                    query.append(orderByConditionFields[i]);
960    
961                                    if ((i + 1) < orderByConditionFields.length) {
962                                            if (orderByComparator.isAscending() ^ previous) {
963                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
964                                            }
965                                            else {
966                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
967                                            }
968                                    }
969                                    else {
970                                            if (orderByComparator.isAscending() ^ previous) {
971                                                    query.append(WHERE_GREATER_THAN);
972                                            }
973                                            else {
974                                                    query.append(WHERE_LESSER_THAN);
975                                            }
976                                    }
977                            }
978    
979                            query.append(ORDER_BY_CLAUSE);
980    
981                            String[] orderByFields = orderByComparator.getOrderByFields();
982    
983                            for (int i = 0; i < orderByFields.length; i++) {
984                                    query.append(_ORDER_BY_ENTITY_ALIAS);
985                                    query.append(orderByFields[i]);
986    
987                                    if ((i + 1) < orderByFields.length) {
988                                            if (orderByComparator.isAscending() ^ previous) {
989                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
990                                            }
991                                            else {
992                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
993                                            }
994                                    }
995                                    else {
996                                            if (orderByComparator.isAscending() ^ previous) {
997                                                    query.append(ORDER_BY_ASC);
998                                            }
999                                            else {
1000                                                    query.append(ORDER_BY_DESC);
1001                                            }
1002                                    }
1003                            }
1004                    }
1005    
1006                    else {
1007                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1008                    }
1009    
1010                    String sql = query.toString();
1011    
1012                    Query q = session.createQuery(sql);
1013    
1014                    q.setFirstResult(0);
1015                    q.setMaxResults(2);
1016    
1017                    QueryPos qPos = QueryPos.getInstance(q);
1018    
1019                    qPos.add(userId);
1020    
1021                    if (orderByComparator != null) {
1022                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1023    
1024                            for (Object value : values) {
1025                                    qPos.add(value);
1026                            }
1027                    }
1028    
1029                    List<DLFileRank> list = q.list();
1030    
1031                    if (list.size() == 2) {
1032                            return list.get(1);
1033                    }
1034                    else {
1035                            return null;
1036                    }
1037            }
1038    
1039            /**
1040             * Returns all the document library file ranks where fileEntryId = &#63;.
1041             *
1042             * @param fileEntryId the file entry ID
1043             * @return the matching document library file ranks
1044             * @throws SystemException if a system exception occurred
1045             */
1046            public List<DLFileRank> findByFileEntryId(long fileEntryId)
1047                    throws SystemException {
1048                    return findByFileEntryId(fileEntryId, QueryUtil.ALL_POS,
1049                            QueryUtil.ALL_POS, null);
1050            }
1051    
1052            /**
1053             * Returns a range of all the document library file ranks where fileEntryId = &#63;.
1054             *
1055             * <p>
1056             * 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.
1057             * </p>
1058             *
1059             * @param fileEntryId the file entry ID
1060             * @param start the lower bound of the range of document library file ranks
1061             * @param end the upper bound of the range of document library file ranks (not inclusive)
1062             * @return the range of matching document library file ranks
1063             * @throws SystemException if a system exception occurred
1064             */
1065            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
1066                    int end) throws SystemException {
1067                    return findByFileEntryId(fileEntryId, start, end, null);
1068            }
1069    
1070            /**
1071             * Returns an ordered range of all the document library file ranks where fileEntryId = &#63;.
1072             *
1073             * <p>
1074             * 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.
1075             * </p>
1076             *
1077             * @param fileEntryId the file entry ID
1078             * @param start the lower bound of the range of document library file ranks
1079             * @param end the upper bound of the range of document library file ranks (not inclusive)
1080             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1081             * @return the ordered range of matching document library file ranks
1082             * @throws SystemException if a system exception occurred
1083             */
1084            public List<DLFileRank> findByFileEntryId(long fileEntryId, int start,
1085                    int end, OrderByComparator orderByComparator) throws SystemException {
1086                    FinderPath finderPath = null;
1087                    Object[] finderArgs = null;
1088    
1089                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1090                                    (orderByComparator == null)) {
1091                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_FILEENTRYID;
1092                            finderArgs = new Object[] { fileEntryId };
1093                    }
1094                    else {
1095                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_FILEENTRYID;
1096                            finderArgs = new Object[] { fileEntryId, start, end, orderByComparator };
1097                    }
1098    
1099                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1100                                    finderArgs, this);
1101    
1102                    if ((list != null) && !list.isEmpty()) {
1103                            for (DLFileRank dlFileRank : list) {
1104                                    if ((fileEntryId != dlFileRank.getFileEntryId())) {
1105                                            list = null;
1106    
1107                                            break;
1108                                    }
1109                            }
1110                    }
1111    
1112                    if (list == null) {
1113                            StringBundler query = null;
1114    
1115                            if (orderByComparator != null) {
1116                                    query = new StringBundler(3 +
1117                                                    (orderByComparator.getOrderByFields().length * 3));
1118                            }
1119                            else {
1120                                    query = new StringBundler(3);
1121                            }
1122    
1123                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1124    
1125                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1126    
1127                            if (orderByComparator != null) {
1128                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1129                                            orderByComparator);
1130                            }
1131    
1132                            else {
1133                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1134                            }
1135    
1136                            String sql = query.toString();
1137    
1138                            Session session = null;
1139    
1140                            try {
1141                                    session = openSession();
1142    
1143                                    Query q = session.createQuery(sql);
1144    
1145                                    QueryPos qPos = QueryPos.getInstance(q);
1146    
1147                                    qPos.add(fileEntryId);
1148    
1149                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1150                                                    end);
1151                            }
1152                            catch (Exception e) {
1153                                    throw processException(e);
1154                            }
1155                            finally {
1156                                    if (list == null) {
1157                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1158                                    }
1159                                    else {
1160                                            cacheResult(list);
1161    
1162                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1163                                    }
1164    
1165                                    closeSession(session);
1166                            }
1167                    }
1168    
1169                    return list;
1170            }
1171    
1172            /**
1173             * Returns the first document library file rank in the ordered set where fileEntryId = &#63;.
1174             *
1175             * @param fileEntryId the file entry ID
1176             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1177             * @return the first matching document library file rank
1178             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1179             * @throws SystemException if a system exception occurred
1180             */
1181            public DLFileRank findByFileEntryId_First(long fileEntryId,
1182                    OrderByComparator orderByComparator)
1183                    throws NoSuchFileRankException, SystemException {
1184                    DLFileRank dlFileRank = fetchByFileEntryId_First(fileEntryId,
1185                                    orderByComparator);
1186    
1187                    if (dlFileRank != null) {
1188                            return dlFileRank;
1189                    }
1190    
1191                    StringBundler msg = new StringBundler(4);
1192    
1193                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1194    
1195                    msg.append("fileEntryId=");
1196                    msg.append(fileEntryId);
1197    
1198                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1199    
1200                    throw new NoSuchFileRankException(msg.toString());
1201            }
1202    
1203            /**
1204             * Returns the first document library file rank in the ordered set where fileEntryId = &#63;.
1205             *
1206             * @param fileEntryId the file entry ID
1207             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1208             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1209             * @throws SystemException if a system exception occurred
1210             */
1211            public DLFileRank fetchByFileEntryId_First(long fileEntryId,
1212                    OrderByComparator orderByComparator) throws SystemException {
1213                    List<DLFileRank> list = findByFileEntryId(fileEntryId, 0, 1,
1214                                    orderByComparator);
1215    
1216                    if (!list.isEmpty()) {
1217                            return list.get(0);
1218                    }
1219    
1220                    return null;
1221            }
1222    
1223            /**
1224             * Returns the last document library file rank in the ordered set where fileEntryId = &#63;.
1225             *
1226             * @param fileEntryId the file entry ID
1227             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1228             * @return the last matching document library file rank
1229             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1230             * @throws SystemException if a system exception occurred
1231             */
1232            public DLFileRank findByFileEntryId_Last(long fileEntryId,
1233                    OrderByComparator orderByComparator)
1234                    throws NoSuchFileRankException, SystemException {
1235                    DLFileRank dlFileRank = fetchByFileEntryId_Last(fileEntryId,
1236                                    orderByComparator);
1237    
1238                    if (dlFileRank != null) {
1239                            return dlFileRank;
1240                    }
1241    
1242                    StringBundler msg = new StringBundler(4);
1243    
1244                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1245    
1246                    msg.append("fileEntryId=");
1247                    msg.append(fileEntryId);
1248    
1249                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1250    
1251                    throw new NoSuchFileRankException(msg.toString());
1252            }
1253    
1254            /**
1255             * Returns the last document library file rank in the ordered set where fileEntryId = &#63;.
1256             *
1257             * @param fileEntryId the file entry ID
1258             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1259             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1260             * @throws SystemException if a system exception occurred
1261             */
1262            public DLFileRank fetchByFileEntryId_Last(long fileEntryId,
1263                    OrderByComparator orderByComparator) throws SystemException {
1264                    int count = countByFileEntryId(fileEntryId);
1265    
1266                    List<DLFileRank> list = findByFileEntryId(fileEntryId, count - 1,
1267                                    count, orderByComparator);
1268    
1269                    if (!list.isEmpty()) {
1270                            return list.get(0);
1271                    }
1272    
1273                    return null;
1274            }
1275    
1276            /**
1277             * Returns the document library file ranks before and after the current document library file rank in the ordered set where fileEntryId = &#63;.
1278             *
1279             * @param fileRankId the primary key of the current document library file rank
1280             * @param fileEntryId the file entry ID
1281             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1282             * @return the previous, current, and next document library file rank
1283             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1284             * @throws SystemException if a system exception occurred
1285             */
1286            public DLFileRank[] findByFileEntryId_PrevAndNext(long fileRankId,
1287                    long fileEntryId, OrderByComparator orderByComparator)
1288                    throws NoSuchFileRankException, SystemException {
1289                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1290    
1291                    Session session = null;
1292    
1293                    try {
1294                            session = openSession();
1295    
1296                            DLFileRank[] array = new DLFileRankImpl[3];
1297    
1298                            array[0] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1299                                            fileEntryId, orderByComparator, true);
1300    
1301                            array[1] = dlFileRank;
1302    
1303                            array[2] = getByFileEntryId_PrevAndNext(session, dlFileRank,
1304                                            fileEntryId, orderByComparator, false);
1305    
1306                            return array;
1307                    }
1308                    catch (Exception e) {
1309                            throw processException(e);
1310                    }
1311                    finally {
1312                            closeSession(session);
1313                    }
1314            }
1315    
1316            protected DLFileRank getByFileEntryId_PrevAndNext(Session session,
1317                    DLFileRank dlFileRank, long fileEntryId,
1318                    OrderByComparator orderByComparator, boolean previous) {
1319                    StringBundler query = null;
1320    
1321                    if (orderByComparator != null) {
1322                            query = new StringBundler(6 +
1323                                            (orderByComparator.getOrderByFields().length * 6));
1324                    }
1325                    else {
1326                            query = new StringBundler(3);
1327                    }
1328    
1329                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1330    
1331                    query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
1332    
1333                    if (orderByComparator != null) {
1334                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1335    
1336                            if (orderByConditionFields.length > 0) {
1337                                    query.append(WHERE_AND);
1338                            }
1339    
1340                            for (int i = 0; i < orderByConditionFields.length; i++) {
1341                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1342                                    query.append(orderByConditionFields[i]);
1343    
1344                                    if ((i + 1) < orderByConditionFields.length) {
1345                                            if (orderByComparator.isAscending() ^ previous) {
1346                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1347                                            }
1348                                            else {
1349                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1350                                            }
1351                                    }
1352                                    else {
1353                                            if (orderByComparator.isAscending() ^ previous) {
1354                                                    query.append(WHERE_GREATER_THAN);
1355                                            }
1356                                            else {
1357                                                    query.append(WHERE_LESSER_THAN);
1358                                            }
1359                                    }
1360                            }
1361    
1362                            query.append(ORDER_BY_CLAUSE);
1363    
1364                            String[] orderByFields = orderByComparator.getOrderByFields();
1365    
1366                            for (int i = 0; i < orderByFields.length; i++) {
1367                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1368                                    query.append(orderByFields[i]);
1369    
1370                                    if ((i + 1) < orderByFields.length) {
1371                                            if (orderByComparator.isAscending() ^ previous) {
1372                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1373                                            }
1374                                            else {
1375                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1376                                            }
1377                                    }
1378                                    else {
1379                                            if (orderByComparator.isAscending() ^ previous) {
1380                                                    query.append(ORDER_BY_ASC);
1381                                            }
1382                                            else {
1383                                                    query.append(ORDER_BY_DESC);
1384                                            }
1385                                    }
1386                            }
1387                    }
1388    
1389                    else {
1390                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1391                    }
1392    
1393                    String sql = query.toString();
1394    
1395                    Query q = session.createQuery(sql);
1396    
1397                    q.setFirstResult(0);
1398                    q.setMaxResults(2);
1399    
1400                    QueryPos qPos = QueryPos.getInstance(q);
1401    
1402                    qPos.add(fileEntryId);
1403    
1404                    if (orderByComparator != null) {
1405                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1406    
1407                            for (Object value : values) {
1408                                    qPos.add(value);
1409                            }
1410                    }
1411    
1412                    List<DLFileRank> list = q.list();
1413    
1414                    if (list.size() == 2) {
1415                            return list.get(1);
1416                    }
1417                    else {
1418                            return null;
1419                    }
1420            }
1421    
1422            /**
1423             * Returns all the document library file ranks where groupId = &#63; and userId = &#63;.
1424             *
1425             * @param groupId the group ID
1426             * @param userId the user ID
1427             * @return the matching document library file ranks
1428             * @throws SystemException if a system exception occurred
1429             */
1430            public List<DLFileRank> findByG_U(long groupId, long userId)
1431                    throws SystemException {
1432                    return findByG_U(groupId, userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1433                            null);
1434            }
1435    
1436            /**
1437             * Returns a range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1438             *
1439             * <p>
1440             * 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.
1441             * </p>
1442             *
1443             * @param groupId the group ID
1444             * @param userId the user ID
1445             * @param start the lower bound of the range of document library file ranks
1446             * @param end the upper bound of the range of document library file ranks (not inclusive)
1447             * @return the range of matching document library file ranks
1448             * @throws SystemException if a system exception occurred
1449             */
1450            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1451                    int end) throws SystemException {
1452                    return findByG_U(groupId, userId, start, end, null);
1453            }
1454    
1455            /**
1456             * Returns an ordered range of all the document library file ranks where groupId = &#63; and userId = &#63;.
1457             *
1458             * <p>
1459             * 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.
1460             * </p>
1461             *
1462             * @param groupId the group ID
1463             * @param userId the user ID
1464             * @param start the lower bound of the range of document library file ranks
1465             * @param end the upper bound of the range of document library file ranks (not inclusive)
1466             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1467             * @return the ordered range of matching document library file ranks
1468             * @throws SystemException if a system exception occurred
1469             */
1470            public List<DLFileRank> findByG_U(long groupId, long userId, int start,
1471                    int end, OrderByComparator orderByComparator) throws SystemException {
1472                    FinderPath finderPath = null;
1473                    Object[] finderArgs = null;
1474    
1475                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1476                                    (orderByComparator == null)) {
1477                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U;
1478                            finderArgs = new Object[] { groupId, userId };
1479                    }
1480                    else {
1481                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U;
1482                            finderArgs = new Object[] {
1483                                            groupId, userId,
1484                                            
1485                                            start, end, orderByComparator
1486                                    };
1487                    }
1488    
1489                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1490                                    finderArgs, this);
1491    
1492                    if ((list != null) && !list.isEmpty()) {
1493                            for (DLFileRank dlFileRank : list) {
1494                                    if ((groupId != dlFileRank.getGroupId()) ||
1495                                                    (userId != dlFileRank.getUserId())) {
1496                                            list = null;
1497    
1498                                            break;
1499                                    }
1500                            }
1501                    }
1502    
1503                    if (list == null) {
1504                            StringBundler query = null;
1505    
1506                            if (orderByComparator != null) {
1507                                    query = new StringBundler(4 +
1508                                                    (orderByComparator.getOrderByFields().length * 3));
1509                            }
1510                            else {
1511                                    query = new StringBundler(4);
1512                            }
1513    
1514                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1515    
1516                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1517    
1518                            query.append(_FINDER_COLUMN_G_U_USERID_2);
1519    
1520                            if (orderByComparator != null) {
1521                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1522                                            orderByComparator);
1523                            }
1524    
1525                            else {
1526                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1527                            }
1528    
1529                            String sql = query.toString();
1530    
1531                            Session session = null;
1532    
1533                            try {
1534                                    session = openSession();
1535    
1536                                    Query q = session.createQuery(sql);
1537    
1538                                    QueryPos qPos = QueryPos.getInstance(q);
1539    
1540                                    qPos.add(groupId);
1541    
1542                                    qPos.add(userId);
1543    
1544                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1545                                                    end);
1546                            }
1547                            catch (Exception e) {
1548                                    throw processException(e);
1549                            }
1550                            finally {
1551                                    if (list == null) {
1552                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1553                                    }
1554                                    else {
1555                                            cacheResult(list);
1556    
1557                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1558                                    }
1559    
1560                                    closeSession(session);
1561                            }
1562                    }
1563    
1564                    return list;
1565            }
1566    
1567            /**
1568             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1569             *
1570             * @param groupId the group ID
1571             * @param userId the user ID
1572             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1573             * @return the first matching document library file rank
1574             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1575             * @throws SystemException if a system exception occurred
1576             */
1577            public DLFileRank findByG_U_First(long groupId, long userId,
1578                    OrderByComparator orderByComparator)
1579                    throws NoSuchFileRankException, SystemException {
1580                    DLFileRank dlFileRank = fetchByG_U_First(groupId, userId,
1581                                    orderByComparator);
1582    
1583                    if (dlFileRank != null) {
1584                            return dlFileRank;
1585                    }
1586    
1587                    StringBundler msg = new StringBundler(6);
1588    
1589                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1590    
1591                    msg.append("groupId=");
1592                    msg.append(groupId);
1593    
1594                    msg.append(", userId=");
1595                    msg.append(userId);
1596    
1597                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1598    
1599                    throw new NoSuchFileRankException(msg.toString());
1600            }
1601    
1602            /**
1603             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1604             *
1605             * @param groupId the group ID
1606             * @param userId the user ID
1607             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1608             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1609             * @throws SystemException if a system exception occurred
1610             */
1611            public DLFileRank fetchByG_U_First(long groupId, long userId,
1612                    OrderByComparator orderByComparator) throws SystemException {
1613                    List<DLFileRank> list = findByG_U(groupId, userId, 0, 1,
1614                                    orderByComparator);
1615    
1616                    if (!list.isEmpty()) {
1617                            return list.get(0);
1618                    }
1619    
1620                    return null;
1621            }
1622    
1623            /**
1624             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1625             *
1626             * @param groupId the group ID
1627             * @param userId the user ID
1628             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1629             * @return the last matching document library file rank
1630             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1631             * @throws SystemException if a system exception occurred
1632             */
1633            public DLFileRank findByG_U_Last(long groupId, long userId,
1634                    OrderByComparator orderByComparator)
1635                    throws NoSuchFileRankException, SystemException {
1636                    DLFileRank dlFileRank = fetchByG_U_Last(groupId, userId,
1637                                    orderByComparator);
1638    
1639                    if (dlFileRank != null) {
1640                            return dlFileRank;
1641                    }
1642    
1643                    StringBundler msg = new StringBundler(6);
1644    
1645                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1646    
1647                    msg.append("groupId=");
1648                    msg.append(groupId);
1649    
1650                    msg.append(", userId=");
1651                    msg.append(userId);
1652    
1653                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1654    
1655                    throw new NoSuchFileRankException(msg.toString());
1656            }
1657    
1658            /**
1659             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1660             *
1661             * @param groupId the group ID
1662             * @param userId the user ID
1663             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1664             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
1665             * @throws SystemException if a system exception occurred
1666             */
1667            public DLFileRank fetchByG_U_Last(long groupId, long userId,
1668                    OrderByComparator orderByComparator) throws SystemException {
1669                    int count = countByG_U(groupId, userId);
1670    
1671                    List<DLFileRank> list = findByG_U(groupId, userId, count - 1, count,
1672                                    orderByComparator);
1673    
1674                    if (!list.isEmpty()) {
1675                            return list.get(0);
1676                    }
1677    
1678                    return null;
1679            }
1680    
1681            /**
1682             * Returns the document library file ranks before and after the current document library file rank in the ordered set where groupId = &#63; and userId = &#63;.
1683             *
1684             * @param fileRankId the primary key of the current document library file rank
1685             * @param groupId the group ID
1686             * @param userId the user ID
1687             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1688             * @return the previous, current, and next document library file rank
1689             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
1690             * @throws SystemException if a system exception occurred
1691             */
1692            public DLFileRank[] findByG_U_PrevAndNext(long fileRankId, long groupId,
1693                    long userId, OrderByComparator orderByComparator)
1694                    throws NoSuchFileRankException, SystemException {
1695                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
1696    
1697                    Session session = null;
1698    
1699                    try {
1700                            session = openSession();
1701    
1702                            DLFileRank[] array = new DLFileRankImpl[3];
1703    
1704                            array[0] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1705                                            userId, orderByComparator, true);
1706    
1707                            array[1] = dlFileRank;
1708    
1709                            array[2] = getByG_U_PrevAndNext(session, dlFileRank, groupId,
1710                                            userId, orderByComparator, false);
1711    
1712                            return array;
1713                    }
1714                    catch (Exception e) {
1715                            throw processException(e);
1716                    }
1717                    finally {
1718                            closeSession(session);
1719                    }
1720            }
1721    
1722            protected DLFileRank getByG_U_PrevAndNext(Session session,
1723                    DLFileRank dlFileRank, long groupId, long userId,
1724                    OrderByComparator orderByComparator, boolean previous) {
1725                    StringBundler query = null;
1726    
1727                    if (orderByComparator != null) {
1728                            query = new StringBundler(6 +
1729                                            (orderByComparator.getOrderByFields().length * 6));
1730                    }
1731                    else {
1732                            query = new StringBundler(3);
1733                    }
1734    
1735                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
1736    
1737                    query.append(_FINDER_COLUMN_G_U_GROUPID_2);
1738    
1739                    query.append(_FINDER_COLUMN_G_U_USERID_2);
1740    
1741                    if (orderByComparator != null) {
1742                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1743    
1744                            if (orderByConditionFields.length > 0) {
1745                                    query.append(WHERE_AND);
1746                            }
1747    
1748                            for (int i = 0; i < orderByConditionFields.length; i++) {
1749                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1750                                    query.append(orderByConditionFields[i]);
1751    
1752                                    if ((i + 1) < orderByConditionFields.length) {
1753                                            if (orderByComparator.isAscending() ^ previous) {
1754                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1755                                            }
1756                                            else {
1757                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1758                                            }
1759                                    }
1760                                    else {
1761                                            if (orderByComparator.isAscending() ^ previous) {
1762                                                    query.append(WHERE_GREATER_THAN);
1763                                            }
1764                                            else {
1765                                                    query.append(WHERE_LESSER_THAN);
1766                                            }
1767                                    }
1768                            }
1769    
1770                            query.append(ORDER_BY_CLAUSE);
1771    
1772                            String[] orderByFields = orderByComparator.getOrderByFields();
1773    
1774                            for (int i = 0; i < orderByFields.length; i++) {
1775                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1776                                    query.append(orderByFields[i]);
1777    
1778                                    if ((i + 1) < orderByFields.length) {
1779                                            if (orderByComparator.isAscending() ^ previous) {
1780                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1781                                            }
1782                                            else {
1783                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1784                                            }
1785                                    }
1786                                    else {
1787                                            if (orderByComparator.isAscending() ^ previous) {
1788                                                    query.append(ORDER_BY_ASC);
1789                                            }
1790                                            else {
1791                                                    query.append(ORDER_BY_DESC);
1792                                            }
1793                                    }
1794                            }
1795                    }
1796    
1797                    else {
1798                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1799                    }
1800    
1801                    String sql = query.toString();
1802    
1803                    Query q = session.createQuery(sql);
1804    
1805                    q.setFirstResult(0);
1806                    q.setMaxResults(2);
1807    
1808                    QueryPos qPos = QueryPos.getInstance(q);
1809    
1810                    qPos.add(groupId);
1811    
1812                    qPos.add(userId);
1813    
1814                    if (orderByComparator != null) {
1815                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
1816    
1817                            for (Object value : values) {
1818                                    qPos.add(value);
1819                            }
1820                    }
1821    
1822                    List<DLFileRank> list = q.list();
1823    
1824                    if (list.size() == 2) {
1825                            return list.get(1);
1826                    }
1827                    else {
1828                            return null;
1829                    }
1830            }
1831    
1832            /**
1833             * Returns all the document library file ranks where groupId = &#63; and userId = &#63; and active = &#63;.
1834             *
1835             * @param groupId the group ID
1836             * @param userId the user ID
1837             * @param active the active
1838             * @return the matching document library file ranks
1839             * @throws SystemException if a system exception occurred
1840             */
1841            public List<DLFileRank> findByG_U_A(long groupId, long userId,
1842                    boolean active) throws SystemException {
1843                    return findByG_U_A(groupId, userId, active, QueryUtil.ALL_POS,
1844                            QueryUtil.ALL_POS, null);
1845            }
1846    
1847            /**
1848             * Returns a range of all the document library file ranks where groupId = &#63; and userId = &#63; and active = &#63;.
1849             *
1850             * <p>
1851             * 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.
1852             * </p>
1853             *
1854             * @param groupId the group ID
1855             * @param userId the user ID
1856             * @param active the active
1857             * @param start the lower bound of the range of document library file ranks
1858             * @param end the upper bound of the range of document library file ranks (not inclusive)
1859             * @return the range of matching document library file ranks
1860             * @throws SystemException if a system exception occurred
1861             */
1862            public List<DLFileRank> findByG_U_A(long groupId, long userId,
1863                    boolean active, int start, int end) throws SystemException {
1864                    return findByG_U_A(groupId, userId, active, start, end, null);
1865            }
1866    
1867            /**
1868             * Returns an ordered range of all the document library file ranks where groupId = &#63; and userId = &#63; and active = &#63;.
1869             *
1870             * <p>
1871             * 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.
1872             * </p>
1873             *
1874             * @param groupId the group ID
1875             * @param userId the user ID
1876             * @param active the active
1877             * @param start the lower bound of the range of document library file ranks
1878             * @param end the upper bound of the range of document library file ranks (not inclusive)
1879             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1880             * @return the ordered range of matching document library file ranks
1881             * @throws SystemException if a system exception occurred
1882             */
1883            public List<DLFileRank> findByG_U_A(long groupId, long userId,
1884                    boolean active, int start, int end, OrderByComparator orderByComparator)
1885                    throws SystemException {
1886                    FinderPath finderPath = null;
1887                    Object[] finderArgs = null;
1888    
1889                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1890                                    (orderByComparator == null)) {
1891                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_G_U_A;
1892                            finderArgs = new Object[] { groupId, userId, active };
1893                    }
1894                    else {
1895                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_U_A;
1896                            finderArgs = new Object[] {
1897                                            groupId, userId, active,
1898                                            
1899                                            start, end, orderByComparator
1900                                    };
1901                    }
1902    
1903                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
1904                                    finderArgs, this);
1905    
1906                    if ((list != null) && !list.isEmpty()) {
1907                            for (DLFileRank dlFileRank : list) {
1908                                    if ((groupId != dlFileRank.getGroupId()) ||
1909                                                    (userId != dlFileRank.getUserId()) ||
1910                                                    (active != dlFileRank.getActive())) {
1911                                            list = null;
1912    
1913                                            break;
1914                                    }
1915                            }
1916                    }
1917    
1918                    if (list == null) {
1919                            StringBundler query = null;
1920    
1921                            if (orderByComparator != null) {
1922                                    query = new StringBundler(5 +
1923                                                    (orderByComparator.getOrderByFields().length * 3));
1924                            }
1925                            else {
1926                                    query = new StringBundler(5);
1927                            }
1928    
1929                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
1930    
1931                            query.append(_FINDER_COLUMN_G_U_A_GROUPID_2);
1932    
1933                            query.append(_FINDER_COLUMN_G_U_A_USERID_2);
1934    
1935                            query.append(_FINDER_COLUMN_G_U_A_ACTIVE_2);
1936    
1937                            if (orderByComparator != null) {
1938                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1939                                            orderByComparator);
1940                            }
1941    
1942                            else {
1943                                    query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
1944                            }
1945    
1946                            String sql = query.toString();
1947    
1948                            Session session = null;
1949    
1950                            try {
1951                                    session = openSession();
1952    
1953                                    Query q = session.createQuery(sql);
1954    
1955                                    QueryPos qPos = QueryPos.getInstance(q);
1956    
1957                                    qPos.add(groupId);
1958    
1959                                    qPos.add(userId);
1960    
1961                                    qPos.add(active);
1962    
1963                                    list = (List<DLFileRank>)QueryUtil.list(q, getDialect(), start,
1964                                                    end);
1965                            }
1966                            catch (Exception e) {
1967                                    throw processException(e);
1968                            }
1969                            finally {
1970                                    if (list == null) {
1971                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1972                                    }
1973                                    else {
1974                                            cacheResult(list);
1975    
1976                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1977                                    }
1978    
1979                                    closeSession(session);
1980                            }
1981                    }
1982    
1983                    return list;
1984            }
1985    
1986            /**
1987             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63; and active = &#63;.
1988             *
1989             * @param groupId the group ID
1990             * @param userId the user ID
1991             * @param active the active
1992             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1993             * @return the first matching document library file rank
1994             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
1995             * @throws SystemException if a system exception occurred
1996             */
1997            public DLFileRank findByG_U_A_First(long groupId, long userId,
1998                    boolean active, OrderByComparator orderByComparator)
1999                    throws NoSuchFileRankException, SystemException {
2000                    DLFileRank dlFileRank = fetchByG_U_A_First(groupId, userId, active,
2001                                    orderByComparator);
2002    
2003                    if (dlFileRank != null) {
2004                            return dlFileRank;
2005                    }
2006    
2007                    StringBundler msg = new StringBundler(8);
2008    
2009                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2010    
2011                    msg.append("groupId=");
2012                    msg.append(groupId);
2013    
2014                    msg.append(", userId=");
2015                    msg.append(userId);
2016    
2017                    msg.append(", active=");
2018                    msg.append(active);
2019    
2020                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2021    
2022                    throw new NoSuchFileRankException(msg.toString());
2023            }
2024    
2025            /**
2026             * Returns the first document library file rank in the ordered set where groupId = &#63; and userId = &#63; and active = &#63;.
2027             *
2028             * @param groupId the group ID
2029             * @param userId the user ID
2030             * @param active the active
2031             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2032             * @return the first matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
2033             * @throws SystemException if a system exception occurred
2034             */
2035            public DLFileRank fetchByG_U_A_First(long groupId, long userId,
2036                    boolean active, OrderByComparator orderByComparator)
2037                    throws SystemException {
2038                    List<DLFileRank> list = findByG_U_A(groupId, userId, active, 0, 1,
2039                                    orderByComparator);
2040    
2041                    if (!list.isEmpty()) {
2042                            return list.get(0);
2043                    }
2044    
2045                    return null;
2046            }
2047    
2048            /**
2049             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63; and active = &#63;.
2050             *
2051             * @param groupId the group ID
2052             * @param userId the user ID
2053             * @param active the active
2054             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2055             * @return the last matching document library file rank
2056             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
2057             * @throws SystemException if a system exception occurred
2058             */
2059            public DLFileRank findByG_U_A_Last(long groupId, long userId,
2060                    boolean active, OrderByComparator orderByComparator)
2061                    throws NoSuchFileRankException, SystemException {
2062                    DLFileRank dlFileRank = fetchByG_U_A_Last(groupId, userId, active,
2063                                    orderByComparator);
2064    
2065                    if (dlFileRank != null) {
2066                            return dlFileRank;
2067                    }
2068    
2069                    StringBundler msg = new StringBundler(8);
2070    
2071                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2072    
2073                    msg.append("groupId=");
2074                    msg.append(groupId);
2075    
2076                    msg.append(", userId=");
2077                    msg.append(userId);
2078    
2079                    msg.append(", active=");
2080                    msg.append(active);
2081    
2082                    msg.append(StringPool.CLOSE_CURLY_BRACE);
2083    
2084                    throw new NoSuchFileRankException(msg.toString());
2085            }
2086    
2087            /**
2088             * Returns the last document library file rank in the ordered set where groupId = &#63; and userId = &#63; and active = &#63;.
2089             *
2090             * @param groupId the group ID
2091             * @param userId the user ID
2092             * @param active the active
2093             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2094             * @return the last matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
2095             * @throws SystemException if a system exception occurred
2096             */
2097            public DLFileRank fetchByG_U_A_Last(long groupId, long userId,
2098                    boolean active, OrderByComparator orderByComparator)
2099                    throws SystemException {
2100                    int count = countByG_U_A(groupId, userId, active);
2101    
2102                    List<DLFileRank> list = findByG_U_A(groupId, userId, active, count - 1,
2103                                    count, orderByComparator);
2104    
2105                    if (!list.isEmpty()) {
2106                            return list.get(0);
2107                    }
2108    
2109                    return null;
2110            }
2111    
2112            /**
2113             * Returns the document library file ranks before and after the current document library file rank in the ordered set where groupId = &#63; and userId = &#63; and active = &#63;.
2114             *
2115             * @param fileRankId the primary key of the current document library file rank
2116             * @param groupId the group ID
2117             * @param userId the user ID
2118             * @param active the active
2119             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
2120             * @return the previous, current, and next document library file rank
2121             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a document library file rank with the primary key could not be found
2122             * @throws SystemException if a system exception occurred
2123             */
2124            public DLFileRank[] findByG_U_A_PrevAndNext(long fileRankId, long groupId,
2125                    long userId, boolean active, OrderByComparator orderByComparator)
2126                    throws NoSuchFileRankException, SystemException {
2127                    DLFileRank dlFileRank = findByPrimaryKey(fileRankId);
2128    
2129                    Session session = null;
2130    
2131                    try {
2132                            session = openSession();
2133    
2134                            DLFileRank[] array = new DLFileRankImpl[3];
2135    
2136                            array[0] = getByG_U_A_PrevAndNext(session, dlFileRank, groupId,
2137                                            userId, active, orderByComparator, true);
2138    
2139                            array[1] = dlFileRank;
2140    
2141                            array[2] = getByG_U_A_PrevAndNext(session, dlFileRank, groupId,
2142                                            userId, active, orderByComparator, false);
2143    
2144                            return array;
2145                    }
2146                    catch (Exception e) {
2147                            throw processException(e);
2148                    }
2149                    finally {
2150                            closeSession(session);
2151                    }
2152            }
2153    
2154            protected DLFileRank getByG_U_A_PrevAndNext(Session session,
2155                    DLFileRank dlFileRank, long groupId, long userId, boolean active,
2156                    OrderByComparator orderByComparator, boolean previous) {
2157                    StringBundler query = null;
2158    
2159                    if (orderByComparator != null) {
2160                            query = new StringBundler(6 +
2161                                            (orderByComparator.getOrderByFields().length * 6));
2162                    }
2163                    else {
2164                            query = new StringBundler(3);
2165                    }
2166    
2167                    query.append(_SQL_SELECT_DLFILERANK_WHERE);
2168    
2169                    query.append(_FINDER_COLUMN_G_U_A_GROUPID_2);
2170    
2171                    query.append(_FINDER_COLUMN_G_U_A_USERID_2);
2172    
2173                    query.append(_FINDER_COLUMN_G_U_A_ACTIVE_2);
2174    
2175                    if (orderByComparator != null) {
2176                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
2177    
2178                            if (orderByConditionFields.length > 0) {
2179                                    query.append(WHERE_AND);
2180                            }
2181    
2182                            for (int i = 0; i < orderByConditionFields.length; i++) {
2183                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2184                                    query.append(orderByConditionFields[i]);
2185    
2186                                    if ((i + 1) < orderByConditionFields.length) {
2187                                            if (orderByComparator.isAscending() ^ previous) {
2188                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2189                                            }
2190                                            else {
2191                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2192                                            }
2193                                    }
2194                                    else {
2195                                            if (orderByComparator.isAscending() ^ previous) {
2196                                                    query.append(WHERE_GREATER_THAN);
2197                                            }
2198                                            else {
2199                                                    query.append(WHERE_LESSER_THAN);
2200                                            }
2201                                    }
2202                            }
2203    
2204                            query.append(ORDER_BY_CLAUSE);
2205    
2206                            String[] orderByFields = orderByComparator.getOrderByFields();
2207    
2208                            for (int i = 0; i < orderByFields.length; i++) {
2209                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2210                                    query.append(orderByFields[i]);
2211    
2212                                    if ((i + 1) < orderByFields.length) {
2213                                            if (orderByComparator.isAscending() ^ previous) {
2214                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2215                                            }
2216                                            else {
2217                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2218                                            }
2219                                    }
2220                                    else {
2221                                            if (orderByComparator.isAscending() ^ previous) {
2222                                                    query.append(ORDER_BY_ASC);
2223                                            }
2224                                            else {
2225                                                    query.append(ORDER_BY_DESC);
2226                                            }
2227                                    }
2228                            }
2229                    }
2230    
2231                    else {
2232                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
2233                    }
2234    
2235                    String sql = query.toString();
2236    
2237                    Query q = session.createQuery(sql);
2238    
2239                    q.setFirstResult(0);
2240                    q.setMaxResults(2);
2241    
2242                    QueryPos qPos = QueryPos.getInstance(q);
2243    
2244                    qPos.add(groupId);
2245    
2246                    qPos.add(userId);
2247    
2248                    qPos.add(active);
2249    
2250                    if (orderByComparator != null) {
2251                            Object[] values = orderByComparator.getOrderByConditionValues(dlFileRank);
2252    
2253                            for (Object value : values) {
2254                                    qPos.add(value);
2255                            }
2256                    }
2257    
2258                    List<DLFileRank> list = q.list();
2259    
2260                    if (list.size() == 2) {
2261                            return list.get(1);
2262                    }
2263                    else {
2264                            return null;
2265                    }
2266            }
2267    
2268            /**
2269             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or throws a {@link com.liferay.portlet.documentlibrary.NoSuchFileRankException} if it could not be found.
2270             *
2271             * @param companyId the company ID
2272             * @param userId the user ID
2273             * @param fileEntryId the file entry ID
2274             * @return the matching document library file rank
2275             * @throws com.liferay.portlet.documentlibrary.NoSuchFileRankException if a matching document library file rank could not be found
2276             * @throws SystemException if a system exception occurred
2277             */
2278            public DLFileRank findByC_U_F(long companyId, long userId, long fileEntryId)
2279                    throws NoSuchFileRankException, SystemException {
2280                    DLFileRank dlFileRank = fetchByC_U_F(companyId, userId, fileEntryId);
2281    
2282                    if (dlFileRank == null) {
2283                            StringBundler msg = new StringBundler(8);
2284    
2285                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2286    
2287                            msg.append("companyId=");
2288                            msg.append(companyId);
2289    
2290                            msg.append(", userId=");
2291                            msg.append(userId);
2292    
2293                            msg.append(", fileEntryId=");
2294                            msg.append(fileEntryId);
2295    
2296                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2297    
2298                            if (_log.isWarnEnabled()) {
2299                                    _log.warn(msg.toString());
2300                            }
2301    
2302                            throw new NoSuchFileRankException(msg.toString());
2303                    }
2304    
2305                    return dlFileRank;
2306            }
2307    
2308            /**
2309             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
2310             *
2311             * @param companyId the company ID
2312             * @param userId the user ID
2313             * @param fileEntryId the file entry ID
2314             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
2315             * @throws SystemException if a system exception occurred
2316             */
2317            public DLFileRank fetchByC_U_F(long companyId, long userId, long fileEntryId)
2318                    throws SystemException {
2319                    return fetchByC_U_F(companyId, userId, fileEntryId, true);
2320            }
2321    
2322            /**
2323             * Returns the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
2324             *
2325             * @param companyId the company ID
2326             * @param userId the user ID
2327             * @param fileEntryId the file entry ID
2328             * @param retrieveFromCache whether to use the finder cache
2329             * @return the matching document library file rank, or <code>null</code> if a matching document library file rank could not be found
2330             * @throws SystemException if a system exception occurred
2331             */
2332            public DLFileRank fetchByC_U_F(long companyId, long userId,
2333                    long fileEntryId, boolean retrieveFromCache) throws SystemException {
2334                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
2335    
2336                    Object result = null;
2337    
2338                    if (retrieveFromCache) {
2339                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_U_F,
2340                                            finderArgs, this);
2341                    }
2342    
2343                    if (result instanceof DLFileRank) {
2344                            DLFileRank dlFileRank = (DLFileRank)result;
2345    
2346                            if ((companyId != dlFileRank.getCompanyId()) ||
2347                                            (userId != dlFileRank.getUserId()) ||
2348                                            (fileEntryId != dlFileRank.getFileEntryId())) {
2349                                    result = null;
2350                            }
2351                    }
2352    
2353                    if (result == null) {
2354                            StringBundler query = new StringBundler(5);
2355    
2356                            query.append(_SQL_SELECT_DLFILERANK_WHERE);
2357    
2358                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
2359    
2360                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
2361    
2362                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
2363    
2364                            query.append(DLFileRankModelImpl.ORDER_BY_JPQL);
2365    
2366                            String sql = query.toString();
2367    
2368                            Session session = null;
2369    
2370                            try {
2371                                    session = openSession();
2372    
2373                                    Query q = session.createQuery(sql);
2374    
2375                                    QueryPos qPos = QueryPos.getInstance(q);
2376    
2377                                    qPos.add(companyId);
2378    
2379                                    qPos.add(userId);
2380    
2381                                    qPos.add(fileEntryId);
2382    
2383                                    List<DLFileRank> list = q.list();
2384    
2385                                    result = list;
2386    
2387                                    DLFileRank dlFileRank = null;
2388    
2389                                    if (list.isEmpty()) {
2390                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
2391                                                    finderArgs, list);
2392                                    }
2393                                    else {
2394                                            dlFileRank = list.get(0);
2395    
2396                                            cacheResult(dlFileRank);
2397    
2398                                            if ((dlFileRank.getCompanyId() != companyId) ||
2399                                                            (dlFileRank.getUserId() != userId) ||
2400                                                            (dlFileRank.getFileEntryId() != fileEntryId)) {
2401                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_U_F,
2402                                                            finderArgs, dlFileRank);
2403                                            }
2404                                    }
2405    
2406                                    return dlFileRank;
2407                            }
2408                            catch (Exception e) {
2409                                    throw processException(e);
2410                            }
2411                            finally {
2412                                    if (result == null) {
2413                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_C_U_F,
2414                                                    finderArgs);
2415                                    }
2416    
2417                                    closeSession(session);
2418                            }
2419                    }
2420                    else {
2421                            if (result instanceof List<?>) {
2422                                    return null;
2423                            }
2424                            else {
2425                                    return (DLFileRank)result;
2426                            }
2427                    }
2428            }
2429    
2430            /**
2431             * Returns all the document library file ranks.
2432             *
2433             * @return the document library file ranks
2434             * @throws SystemException if a system exception occurred
2435             */
2436            public List<DLFileRank> findAll() throws SystemException {
2437                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2438            }
2439    
2440            /**
2441             * Returns a range of all the document library file ranks.
2442             *
2443             * <p>
2444             * 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.
2445             * </p>
2446             *
2447             * @param start the lower bound of the range of document library file ranks
2448             * @param end the upper bound of the range of document library file ranks (not inclusive)
2449             * @return the range of document library file ranks
2450             * @throws SystemException if a system exception occurred
2451             */
2452            public List<DLFileRank> findAll(int start, int end)
2453                    throws SystemException {
2454                    return findAll(start, end, null);
2455            }
2456    
2457            /**
2458             * Returns an ordered range of all the document library file ranks.
2459             *
2460             * <p>
2461             * 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.
2462             * </p>
2463             *
2464             * @param start the lower bound of the range of document library file ranks
2465             * @param end the upper bound of the range of document library file ranks (not inclusive)
2466             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
2467             * @return the ordered range of document library file ranks
2468             * @throws SystemException if a system exception occurred
2469             */
2470            public List<DLFileRank> findAll(int start, int end,
2471                    OrderByComparator orderByComparator) throws SystemException {
2472                    FinderPath finderPath = null;
2473                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
2474    
2475                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
2476                                    (orderByComparator == null)) {
2477                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
2478                            finderArgs = FINDER_ARGS_EMPTY;
2479                    }
2480                    else {
2481                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
2482                            finderArgs = new Object[] { start, end, orderByComparator };
2483                    }
2484    
2485                    List<DLFileRank> list = (List<DLFileRank>)FinderCacheUtil.getResult(finderPath,
2486                                    finderArgs, this);
2487    
2488                    if (list == null) {
2489                            StringBundler query = null;
2490                            String sql = null;
2491    
2492                            if (orderByComparator != null) {
2493                                    query = new StringBundler(2 +
2494                                                    (orderByComparator.getOrderByFields().length * 3));
2495    
2496                                    query.append(_SQL_SELECT_DLFILERANK);
2497    
2498                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2499                                            orderByComparator);
2500    
2501                                    sql = query.toString();
2502                            }
2503                            else {
2504                                    sql = _SQL_SELECT_DLFILERANK.concat(DLFileRankModelImpl.ORDER_BY_JPQL);
2505                            }
2506    
2507                            Session session = null;
2508    
2509                            try {
2510                                    session = openSession();
2511    
2512                                    Query q = session.createQuery(sql);
2513    
2514                                    if (orderByComparator == null) {
2515                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
2516                                                            start, end, false);
2517    
2518                                            Collections.sort(list);
2519                                    }
2520                                    else {
2521                                            list = (List<DLFileRank>)QueryUtil.list(q, getDialect(),
2522                                                            start, end);
2523                                    }
2524                            }
2525                            catch (Exception e) {
2526                                    throw processException(e);
2527                            }
2528                            finally {
2529                                    if (list == null) {
2530                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
2531                                    }
2532                                    else {
2533                                            cacheResult(list);
2534    
2535                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
2536                                    }
2537    
2538                                    closeSession(session);
2539                            }
2540                    }
2541    
2542                    return list;
2543            }
2544    
2545            /**
2546             * Removes all the document library file ranks where userId = &#63; from the database.
2547             *
2548             * @param userId the user ID
2549             * @throws SystemException if a system exception occurred
2550             */
2551            public void removeByUserId(long userId) throws SystemException {
2552                    for (DLFileRank dlFileRank : findByUserId(userId)) {
2553                            remove(dlFileRank);
2554                    }
2555            }
2556    
2557            /**
2558             * Removes all the document library file ranks where fileEntryId = &#63; from the database.
2559             *
2560             * @param fileEntryId the file entry ID
2561             * @throws SystemException if a system exception occurred
2562             */
2563            public void removeByFileEntryId(long fileEntryId) throws SystemException {
2564                    for (DLFileRank dlFileRank : findByFileEntryId(fileEntryId)) {
2565                            remove(dlFileRank);
2566                    }
2567            }
2568    
2569            /**
2570             * Removes all the document library file ranks where groupId = &#63; and userId = &#63; from the database.
2571             *
2572             * @param groupId the group ID
2573             * @param userId the user ID
2574             * @throws SystemException if a system exception occurred
2575             */
2576            public void removeByG_U(long groupId, long userId)
2577                    throws SystemException {
2578                    for (DLFileRank dlFileRank : findByG_U(groupId, userId)) {
2579                            remove(dlFileRank);
2580                    }
2581            }
2582    
2583            /**
2584             * Removes all the document library file ranks where groupId = &#63; and userId = &#63; and active = &#63; from the database.
2585             *
2586             * @param groupId the group ID
2587             * @param userId the user ID
2588             * @param active the active
2589             * @throws SystemException if a system exception occurred
2590             */
2591            public void removeByG_U_A(long groupId, long userId, boolean active)
2592                    throws SystemException {
2593                    for (DLFileRank dlFileRank : findByG_U_A(groupId, userId, active)) {
2594                            remove(dlFileRank);
2595                    }
2596            }
2597    
2598            /**
2599             * Removes the document library file rank where companyId = &#63; and userId = &#63; and fileEntryId = &#63; from the database.
2600             *
2601             * @param companyId the company ID
2602             * @param userId the user ID
2603             * @param fileEntryId the file entry ID
2604             * @return the document library file rank that was removed
2605             * @throws SystemException if a system exception occurred
2606             */
2607            public DLFileRank removeByC_U_F(long companyId, long userId,
2608                    long fileEntryId) throws NoSuchFileRankException, SystemException {
2609                    DLFileRank dlFileRank = findByC_U_F(companyId, userId, fileEntryId);
2610    
2611                    return remove(dlFileRank);
2612            }
2613    
2614            /**
2615             * Removes all the document library file ranks from the database.
2616             *
2617             * @throws SystemException if a system exception occurred
2618             */
2619            public void removeAll() throws SystemException {
2620                    for (DLFileRank dlFileRank : findAll()) {
2621                            remove(dlFileRank);
2622                    }
2623            }
2624    
2625            /**
2626             * Returns the number of document library file ranks where userId = &#63;.
2627             *
2628             * @param userId the user ID
2629             * @return the number of matching document library file ranks
2630             * @throws SystemException if a system exception occurred
2631             */
2632            public int countByUserId(long userId) throws SystemException {
2633                    Object[] finderArgs = new Object[] { userId };
2634    
2635                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_USERID,
2636                                    finderArgs, this);
2637    
2638                    if (count == null) {
2639                            StringBundler query = new StringBundler(2);
2640    
2641                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2642    
2643                            query.append(_FINDER_COLUMN_USERID_USERID_2);
2644    
2645                            String sql = query.toString();
2646    
2647                            Session session = null;
2648    
2649                            try {
2650                                    session = openSession();
2651    
2652                                    Query q = session.createQuery(sql);
2653    
2654                                    QueryPos qPos = QueryPos.getInstance(q);
2655    
2656                                    qPos.add(userId);
2657    
2658                                    count = (Long)q.uniqueResult();
2659                            }
2660                            catch (Exception e) {
2661                                    throw processException(e);
2662                            }
2663                            finally {
2664                                    if (count == null) {
2665                                            count = Long.valueOf(0);
2666                                    }
2667    
2668                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_USERID,
2669                                            finderArgs, count);
2670    
2671                                    closeSession(session);
2672                            }
2673                    }
2674    
2675                    return count.intValue();
2676            }
2677    
2678            /**
2679             * Returns the number of document library file ranks where fileEntryId = &#63;.
2680             *
2681             * @param fileEntryId the file entry ID
2682             * @return the number of matching document library file ranks
2683             * @throws SystemException if a system exception occurred
2684             */
2685            public int countByFileEntryId(long fileEntryId) throws SystemException {
2686                    Object[] finderArgs = new Object[] { fileEntryId };
2687    
2688                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2689                                    finderArgs, this);
2690    
2691                    if (count == null) {
2692                            StringBundler query = new StringBundler(2);
2693    
2694                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2695    
2696                            query.append(_FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2);
2697    
2698                            String sql = query.toString();
2699    
2700                            Session session = null;
2701    
2702                            try {
2703                                    session = openSession();
2704    
2705                                    Query q = session.createQuery(sql);
2706    
2707                                    QueryPos qPos = QueryPos.getInstance(q);
2708    
2709                                    qPos.add(fileEntryId);
2710    
2711                                    count = (Long)q.uniqueResult();
2712                            }
2713                            catch (Exception e) {
2714                                    throw processException(e);
2715                            }
2716                            finally {
2717                                    if (count == null) {
2718                                            count = Long.valueOf(0);
2719                                    }
2720    
2721                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_FILEENTRYID,
2722                                            finderArgs, count);
2723    
2724                                    closeSession(session);
2725                            }
2726                    }
2727    
2728                    return count.intValue();
2729            }
2730    
2731            /**
2732             * Returns the number of document library file ranks where groupId = &#63; and userId = &#63;.
2733             *
2734             * @param groupId the group ID
2735             * @param userId the user ID
2736             * @return the number of matching document library file ranks
2737             * @throws SystemException if a system exception occurred
2738             */
2739            public int countByG_U(long groupId, long userId) throws SystemException {
2740                    Object[] finderArgs = new Object[] { groupId, userId };
2741    
2742                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U,
2743                                    finderArgs, this);
2744    
2745                    if (count == null) {
2746                            StringBundler query = new StringBundler(3);
2747    
2748                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2749    
2750                            query.append(_FINDER_COLUMN_G_U_GROUPID_2);
2751    
2752                            query.append(_FINDER_COLUMN_G_U_USERID_2);
2753    
2754                            String sql = query.toString();
2755    
2756                            Session session = null;
2757    
2758                            try {
2759                                    session = openSession();
2760    
2761                                    Query q = session.createQuery(sql);
2762    
2763                                    QueryPos qPos = QueryPos.getInstance(q);
2764    
2765                                    qPos.add(groupId);
2766    
2767                                    qPos.add(userId);
2768    
2769                                    count = (Long)q.uniqueResult();
2770                            }
2771                            catch (Exception e) {
2772                                    throw processException(e);
2773                            }
2774                            finally {
2775                                    if (count == null) {
2776                                            count = Long.valueOf(0);
2777                                    }
2778    
2779                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U, finderArgs,
2780                                            count);
2781    
2782                                    closeSession(session);
2783                            }
2784                    }
2785    
2786                    return count.intValue();
2787            }
2788    
2789            /**
2790             * Returns the number of document library file ranks where groupId = &#63; and userId = &#63; and active = &#63;.
2791             *
2792             * @param groupId the group ID
2793             * @param userId the user ID
2794             * @param active the active
2795             * @return the number of matching document library file ranks
2796             * @throws SystemException if a system exception occurred
2797             */
2798            public int countByG_U_A(long groupId, long userId, boolean active)
2799                    throws SystemException {
2800                    Object[] finderArgs = new Object[] { groupId, userId, active };
2801    
2802                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_U_A,
2803                                    finderArgs, this);
2804    
2805                    if (count == null) {
2806                            StringBundler query = new StringBundler(4);
2807    
2808                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2809    
2810                            query.append(_FINDER_COLUMN_G_U_A_GROUPID_2);
2811    
2812                            query.append(_FINDER_COLUMN_G_U_A_USERID_2);
2813    
2814                            query.append(_FINDER_COLUMN_G_U_A_ACTIVE_2);
2815    
2816                            String sql = query.toString();
2817    
2818                            Session session = null;
2819    
2820                            try {
2821                                    session = openSession();
2822    
2823                                    Query q = session.createQuery(sql);
2824    
2825                                    QueryPos qPos = QueryPos.getInstance(q);
2826    
2827                                    qPos.add(groupId);
2828    
2829                                    qPos.add(userId);
2830    
2831                                    qPos.add(active);
2832    
2833                                    count = (Long)q.uniqueResult();
2834                            }
2835                            catch (Exception e) {
2836                                    throw processException(e);
2837                            }
2838                            finally {
2839                                    if (count == null) {
2840                                            count = Long.valueOf(0);
2841                                    }
2842    
2843                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_U_A,
2844                                            finderArgs, count);
2845    
2846                                    closeSession(session);
2847                            }
2848                    }
2849    
2850                    return count.intValue();
2851            }
2852    
2853            /**
2854             * Returns the number of document library file ranks where companyId = &#63; and userId = &#63; and fileEntryId = &#63;.
2855             *
2856             * @param companyId the company ID
2857             * @param userId the user ID
2858             * @param fileEntryId the file entry ID
2859             * @return the number of matching document library file ranks
2860             * @throws SystemException if a system exception occurred
2861             */
2862            public int countByC_U_F(long companyId, long userId, long fileEntryId)
2863                    throws SystemException {
2864                    Object[] finderArgs = new Object[] { companyId, userId, fileEntryId };
2865    
2866                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_U_F,
2867                                    finderArgs, this);
2868    
2869                    if (count == null) {
2870                            StringBundler query = new StringBundler(4);
2871    
2872                            query.append(_SQL_COUNT_DLFILERANK_WHERE);
2873    
2874                            query.append(_FINDER_COLUMN_C_U_F_COMPANYID_2);
2875    
2876                            query.append(_FINDER_COLUMN_C_U_F_USERID_2);
2877    
2878                            query.append(_FINDER_COLUMN_C_U_F_FILEENTRYID_2);
2879    
2880                            String sql = query.toString();
2881    
2882                            Session session = null;
2883    
2884                            try {
2885                                    session = openSession();
2886    
2887                                    Query q = session.createQuery(sql);
2888    
2889                                    QueryPos qPos = QueryPos.getInstance(q);
2890    
2891                                    qPos.add(companyId);
2892    
2893                                    qPos.add(userId);
2894    
2895                                    qPos.add(fileEntryId);
2896    
2897                                    count = (Long)q.uniqueResult();
2898                            }
2899                            catch (Exception e) {
2900                                    throw processException(e);
2901                            }
2902                            finally {
2903                                    if (count == null) {
2904                                            count = Long.valueOf(0);
2905                                    }
2906    
2907                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_U_F,
2908                                            finderArgs, count);
2909    
2910                                    closeSession(session);
2911                            }
2912                    }
2913    
2914                    return count.intValue();
2915            }
2916    
2917            /**
2918             * Returns the number of document library file ranks.
2919             *
2920             * @return the number of document library file ranks
2921             * @throws SystemException if a system exception occurred
2922             */
2923            public int countAll() throws SystemException {
2924                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2925                                    FINDER_ARGS_EMPTY, this);
2926    
2927                    if (count == null) {
2928                            Session session = null;
2929    
2930                            try {
2931                                    session = openSession();
2932    
2933                                    Query q = session.createQuery(_SQL_COUNT_DLFILERANK);
2934    
2935                                    count = (Long)q.uniqueResult();
2936                            }
2937                            catch (Exception e) {
2938                                    throw processException(e);
2939                            }
2940                            finally {
2941                                    if (count == null) {
2942                                            count = Long.valueOf(0);
2943                                    }
2944    
2945                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2946                                            FINDER_ARGS_EMPTY, count);
2947    
2948                                    closeSession(session);
2949                            }
2950                    }
2951    
2952                    return count.intValue();
2953            }
2954    
2955            /**
2956             * Initializes the document library file rank persistence.
2957             */
2958            public void afterPropertiesSet() {
2959                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2960                                            com.liferay.portal.util.PropsUtil.get(
2961                                                    "value.object.listener.com.liferay.portlet.documentlibrary.model.DLFileRank")));
2962    
2963                    if (listenerClassNames.length > 0) {
2964                            try {
2965                                    List<ModelListener<DLFileRank>> listenersList = new ArrayList<ModelListener<DLFileRank>>();
2966    
2967                                    for (String listenerClassName : listenerClassNames) {
2968                                            listenersList.add((ModelListener<DLFileRank>)InstanceFactory.newInstance(
2969                                                            listenerClassName));
2970                                    }
2971    
2972                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2973                            }
2974                            catch (Exception e) {
2975                                    _log.error(e);
2976                            }
2977                    }
2978            }
2979    
2980            public void destroy() {
2981                    EntityCacheUtil.removeCache(DLFileRankImpl.class.getName());
2982                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2983                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2984            }
2985    
2986            @BeanReference(type = DLContentPersistence.class)
2987            protected DLContentPersistence dlContentPersistence;
2988            @BeanReference(type = DLFileEntryPersistence.class)
2989            protected DLFileEntryPersistence dlFileEntryPersistence;
2990            @BeanReference(type = DLFileEntryMetadataPersistence.class)
2991            protected DLFileEntryMetadataPersistence dlFileEntryMetadataPersistence;
2992            @BeanReference(type = DLFileEntryTypePersistence.class)
2993            protected DLFileEntryTypePersistence dlFileEntryTypePersistence;
2994            @BeanReference(type = DLFileRankPersistence.class)
2995            protected DLFileRankPersistence dlFileRankPersistence;
2996            @BeanReference(type = DLFileShortcutPersistence.class)
2997            protected DLFileShortcutPersistence dlFileShortcutPersistence;
2998            @BeanReference(type = DLFileVersionPersistence.class)
2999            protected DLFileVersionPersistence dlFileVersionPersistence;
3000            @BeanReference(type = DLFolderPersistence.class)
3001            protected DLFolderPersistence dlFolderPersistence;
3002            @BeanReference(type = DLSyncPersistence.class)
3003            protected DLSyncPersistence dlSyncPersistence;
3004            @BeanReference(type = LayoutPersistence.class)
3005            protected LayoutPersistence layoutPersistence;
3006            @BeanReference(type = UserPersistence.class)
3007            protected UserPersistence userPersistence;
3008            private static final String _SQL_SELECT_DLFILERANK = "SELECT dlFileRank FROM DLFileRank dlFileRank";
3009            private static final String _SQL_SELECT_DLFILERANK_WHERE = "SELECT dlFileRank FROM DLFileRank dlFileRank WHERE ";
3010            private static final String _SQL_COUNT_DLFILERANK = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank";
3011            private static final String _SQL_COUNT_DLFILERANK_WHERE = "SELECT COUNT(dlFileRank) FROM DLFileRank dlFileRank WHERE ";
3012            private static final String _FINDER_COLUMN_USERID_USERID_2 = "dlFileRank.userId = ?";
3013            private static final String _FINDER_COLUMN_FILEENTRYID_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
3014            private static final String _FINDER_COLUMN_G_U_GROUPID_2 = "dlFileRank.groupId = ? AND ";
3015            private static final String _FINDER_COLUMN_G_U_USERID_2 = "dlFileRank.userId = ?";
3016            private static final String _FINDER_COLUMN_G_U_A_GROUPID_2 = "dlFileRank.groupId = ? AND ";
3017            private static final String _FINDER_COLUMN_G_U_A_USERID_2 = "dlFileRank.userId = ? AND ";
3018            private static final String _FINDER_COLUMN_G_U_A_ACTIVE_2 = "dlFileRank.active = ?";
3019            private static final String _FINDER_COLUMN_C_U_F_COMPANYID_2 = "dlFileRank.companyId = ? AND ";
3020            private static final String _FINDER_COLUMN_C_U_F_USERID_2 = "dlFileRank.userId = ? AND ";
3021            private static final String _FINDER_COLUMN_C_U_F_FILEENTRYID_2 = "dlFileRank.fileEntryId = ?";
3022            private static final String _ORDER_BY_ENTITY_ALIAS = "dlFileRank.";
3023            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No DLFileRank exists with the primary key ";
3024            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No DLFileRank exists with the key {";
3025            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3026            private static Log _log = LogFactoryUtil.getLog(DLFileRankPersistenceImpl.class);
3027            private static DLFileRank _nullDLFileRank = new DLFileRankImpl() {
3028                            @Override
3029                            public Object clone() {
3030                                    return this;
3031                            }
3032    
3033                            @Override
3034                            public CacheModel<DLFileRank> toCacheModel() {
3035                                    return _nullDLFileRankCacheModel;
3036                            }
3037                    };
3038    
3039            private static CacheModel<DLFileRank> _nullDLFileRankCacheModel = new CacheModel<DLFileRank>() {
3040                            public DLFileRank toEntityModel() {
3041                                    return _nullDLFileRank;
3042                            }
3043                    };
3044    }