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