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