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