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