com.liferay.object.service.persistence.impl.ObjectFolderPersistenceImpl Maven / Gradle / Ivy
/**
* SPDX-FileCopyrightText: (c) 2023 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.object.service.persistence.impl;
import com.liferay.object.exception.DuplicateObjectFolderExternalReferenceCodeException;
import com.liferay.object.exception.NoSuchObjectFolderException;
import com.liferay.object.model.ObjectFolder;
import com.liferay.object.model.ObjectFolderTable;
import com.liferay.object.model.impl.ObjectFolderImpl;
import com.liferay.object.model.impl.ObjectFolderModelImpl;
import com.liferay.object.service.persistence.ObjectFolderPersistence;
import com.liferay.object.service.persistence.ObjectFolderUtil;
import com.liferay.object.service.persistence.impl.constants.ObjectPersistenceConstants;
import com.liferay.petra.string.StringBundler;
import com.liferay.portal.kernel.configuration.Configuration;
import com.liferay.portal.kernel.dao.orm.EntityCache;
import com.liferay.portal.kernel.dao.orm.FinderCache;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.SQLQuery;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.dao.orm.SessionFactory;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.sanitizer.Sanitizer;
import com.liferay.portal.kernel.sanitizer.SanitizerException;
import com.liferay.portal.kernel.sanitizer.SanitizerUtil;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import com.liferay.portal.kernel.security.permission.InlineSQLHelperUtil;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.PropsKeys;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import javax.sql.DataSource;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
* The persistence implementation for the object folder service.
*
*
* Caching information and settings can be found in portal.properties
*
*
* @author Marco Leo
* @generated
*/
@Component(service = ObjectFolderPersistence.class)
public class ObjectFolderPersistenceImpl
extends BasePersistenceImpl
implements ObjectFolderPersistence {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. Always use ObjectFolderUtil
to access the object folder persistence. Modify service.xml
and rerun ServiceBuilder to regenerate this class.
*/
public static final String FINDER_CLASS_NAME_ENTITY =
ObjectFolderImpl.class.getName();
public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List1";
public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
FINDER_CLASS_NAME_ENTITY + ".List2";
private FinderPath _finderPathWithPaginationFindAll;
private FinderPath _finderPathWithoutPaginationFindAll;
private FinderPath _finderPathCountAll;
private FinderPath _finderPathWithPaginationFindByUuid;
private FinderPath _finderPathWithoutPaginationFindByUuid;
private FinderPath _finderPathCountByUuid;
/**
* Returns all the object folders where uuid = ?.
*
* @param uuid the uuid
* @return the matching object folders
*/
@Override
public List findByUuid(String uuid) {
return findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders
*/
@Override
public List findByUuid(String uuid, int start, int end) {
return findByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the object folders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid(uuid, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the object folders where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching object folders
*/
@Override
public List findByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid;
finderArgs = new Object[] {uuid};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid;
finderArgs = new Object[] {uuid, start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (ObjectFolder objectFolder : list) {
if (!uuid.equals(objectFolder.getUuid())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first object folder in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByUuid_First(
String uuid, OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByUuid_First(uuid, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the first object folder in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByUuid_First(
String uuid, OrderByComparator orderByComparator) {
List list = findByUuid(uuid, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last object folder in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByUuid_Last(
String uuid, OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByUuid_Last(uuid, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the last object folder in the ordered set where uuid = ?.
*
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByUuid_Last(
String uuid, OrderByComparator orderByComparator) {
int count = countByUuid(uuid);
if (count == 0) {
return null;
}
List list = findByUuid(
uuid, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the object folders before and after the current object folder in the ordered set where uuid = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] findByUuid_PrevAndNext(
long objectFolderId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
uuid = Objects.toString(uuid, "");
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = getByUuid_PrevAndNext(
session, objectFolder, uuid, orderByComparator, true);
array[1] = objectFolder;
array[2] = getByUuid_PrevAndNext(
session, objectFolder, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder getByUuid_PrevAndNext(
Session session, ObjectFolder objectFolder, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the object folders that the user has permission to view where uuid = ?.
*
* @param uuid the uuid
* @return the matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid(String uuid) {
return filterFindByUuid(
uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders that the user has permission to view where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid(
String uuid, int start, int end) {
return filterFindByUuid(uuid, start, end, null);
}
/**
* Returns an ordered range of all the object folders that the user has permissions to view where uuid = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid(
String uuid, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByUuid(uuid, start, end, orderByComparator);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the object folders before and after the current object folder in the ordered set of object folders that the user has permission to view where uuid = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param uuid the uuid
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] filterFindByUuid_PrevAndNext(
long objectFolderId, String uuid,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
if (!InlineSQLHelperUtil.isEnabled()) {
return findByUuid_PrevAndNext(
objectFolderId, uuid, orderByComparator);
}
uuid = Objects.toString(uuid, "");
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = filterGetByUuid_PrevAndNext(
session, objectFolder, uuid, orderByComparator, true);
array[1] = objectFolder;
array[2] = filterGetByUuid_PrevAndNext(
session, objectFolder, uuid, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder filterGetByUuid_PrevAndNext(
Session session, ObjectFolder objectFolder, String uuid,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the object folders where uuid = ? from the database.
*
* @param uuid the uuid
*/
@Override
public void removeByUuid(String uuid) {
for (ObjectFolder objectFolder :
findByUuid(uuid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(objectFolder);
}
}
/**
* Returns the number of object folders where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching object folders
*/
@Override
public int countByUuid(String uuid) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid;
Object[] finderArgs = new Object[] {uuid};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of object folders that the user has permission to view where uuid = ?.
*
* @param uuid the uuid
* @return the number of matching object folders that the user has permission to view
*/
@Override
public int filterCountByUuid(String uuid) {
if (!InlineSQLHelperUtil.isEnabled()) {
return countByUuid(uuid);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_UUID_2_SQL);
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_UUID_UUID_2 =
"objectFolder.uuid = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3 =
"(objectFolder.uuid IS NULL OR objectFolder.uuid = '')";
private static final String _FINDER_COLUMN_UUID_UUID_2_SQL =
"objectFolder.uuid_ = ?";
private static final String _FINDER_COLUMN_UUID_UUID_3_SQL =
"(objectFolder.uuid_ IS NULL OR objectFolder.uuid_ = '')";
private FinderPath _finderPathWithPaginationFindByUuid_C;
private FinderPath _finderPathWithoutPaginationFindByUuid_C;
private FinderPath _finderPathCountByUuid_C;
/**
* Returns all the object folders where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching object folders
*/
@Override
public List findByUuid_C(String uuid, long companyId) {
return findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end) {
return findByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the object folders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByUuid_C(
uuid, companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the object folders where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching object folders
*/
@Override
public List findByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByUuid_C;
finderArgs = new Object[] {uuid, companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByUuid_C;
finderArgs = new Object[] {
uuid, companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (ObjectFolder objectFolder : list) {
if (!uuid.equals(objectFolder.getUuid()) ||
(companyId != objectFolder.getCompanyId())) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first object folder in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByUuid_C_First(
uuid, companyId, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the first object folder in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByUuid_C_First(
String uuid, long companyId,
OrderByComparator orderByComparator) {
List list = findByUuid_C(
uuid, companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last object folder in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByUuid_C_Last(
uuid, companyId, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("uuid=");
sb.append(uuid);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the last object folder in the ordered set where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByUuid_C_Last(
String uuid, long companyId,
OrderByComparator orderByComparator) {
int count = countByUuid_C(uuid, companyId);
if (count == 0) {
return null;
}
List list = findByUuid_C(
uuid, companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the object folders before and after the current object folder in the ordered set where uuid = ? and companyId = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] findByUuid_C_PrevAndNext(
long objectFolderId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
uuid = Objects.toString(uuid, "");
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = getByUuid_C_PrevAndNext(
session, objectFolder, uuid, companyId, orderByComparator,
true);
array[1] = objectFolder;
array[2] = getByUuid_C_PrevAndNext(
session, objectFolder, uuid, companyId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder getByUuid_C_PrevAndNext(
Session session, ObjectFolder objectFolder, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the object folders that the user has permission to view where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid_C(String uuid, long companyId) {
return filterFindByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders that the user has permission to view where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid_C(
String uuid, long companyId, int start, int end) {
return filterFindByUuid_C(uuid, companyId, start, end, null);
}
/**
* Returns an ordered range of all the object folders that the user has permissions to view where uuid = ? and companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param uuid the uuid
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByUuid_C(
String uuid, long companyId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByUuid_C(uuid, companyId, start, end, orderByComparator);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the object folders before and after the current object folder in the ordered set of object folders that the user has permission to view where uuid = ? and companyId = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param uuid the uuid
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] filterFindByUuid_C_PrevAndNext(
long objectFolderId, String uuid, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByUuid_C_PrevAndNext(
objectFolderId, uuid, companyId, orderByComparator);
}
uuid = Objects.toString(uuid, "");
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = filterGetByUuid_C_PrevAndNext(
session, objectFolder, uuid, companyId, orderByComparator,
true);
array[1] = objectFolder;
array[2] = filterGetByUuid_C_PrevAndNext(
session, objectFolder, uuid, companyId, orderByComparator,
false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder filterGetByUuid_C_PrevAndNext(
Session session, ObjectFolder objectFolder, String uuid, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
6 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(5);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the object folders where uuid = ? and companyId = ? from the database.
*
* @param uuid the uuid
* @param companyId the company ID
*/
@Override
public void removeByUuid_C(String uuid, long companyId) {
for (ObjectFolder objectFolder :
findByUuid_C(
uuid, companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
null)) {
remove(objectFolder);
}
}
/**
* Returns the number of object folders where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching object folders
*/
@Override
public int countByUuid_C(String uuid, long companyId) {
uuid = Objects.toString(uuid, "");
FinderPath finderPath = _finderPathCountByUuid_C;
Object[] finderArgs = new Object[] {uuid, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of object folders that the user has permission to view where uuid = ? and companyId = ?.
*
* @param uuid the uuid
* @param companyId the company ID
* @return the number of matching object folders that the user has permission to view
*/
@Override
public int filterCountByUuid_C(String uuid, long companyId) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByUuid_C(uuid, companyId);
}
uuid = Objects.toString(uuid, "");
StringBundler sb = new StringBundler(3);
sb.append(_FILTER_SQL_COUNT_OBJECTFOLDER_WHERE);
boolean bindUuid = false;
if (uuid.isEmpty()) {
sb.append(_FINDER_COLUMN_UUID_C_UUID_3_SQL);
}
else {
bindUuid = true;
sb.append(_FINDER_COLUMN_UUID_C_UUID_2_SQL);
}
sb.append(_FINDER_COLUMN_UUID_C_COMPANYID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
if (bindUuid) {
queryPos.add(uuid);
}
queryPos.add(companyId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_UUID_C_UUID_2 =
"objectFolder.uuid = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3 =
"(objectFolder.uuid IS NULL OR objectFolder.uuid = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_2_SQL =
"objectFolder.uuid_ = ? AND ";
private static final String _FINDER_COLUMN_UUID_C_UUID_3_SQL =
"(objectFolder.uuid_ IS NULL OR objectFolder.uuid_ = '') AND ";
private static final String _FINDER_COLUMN_UUID_C_COMPANYID_2 =
"objectFolder.companyId = ?";
private FinderPath _finderPathWithPaginationFindByCompanyId;
private FinderPath _finderPathWithoutPaginationFindByCompanyId;
private FinderPath _finderPathCountByCompanyId;
/**
* Returns all the object folders where companyId = ?.
*
* @param companyId the company ID
* @return the matching object folders
*/
@Override
public List findByCompanyId(long companyId) {
return findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders
*/
@Override
public List findByCompanyId(
long companyId, int start, int end) {
return findByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the object folders where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
return findByCompanyId(companyId, start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the object folders where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of matching object folders
*/
@Override
public List findByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindByCompanyId;
finderArgs = new Object[] {companyId};
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindByCompanyId;
finderArgs = new Object[] {
companyId, start, end, orderByComparator
};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
if ((list != null) && !list.isEmpty()) {
for (ObjectFolder objectFolder : list) {
if (companyId != objectFolder.getCompanyId()) {
list = null;
break;
}
}
}
}
if (list == null) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Returns the first object folder in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByCompanyId_First(
long companyId, OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByCompanyId_First(
companyId, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the first object folder in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the first matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByCompanyId_First(
long companyId, OrderByComparator orderByComparator) {
List list = findByCompanyId(
companyId, 0, 1, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the last object folder in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByCompanyId_Last(
long companyId, OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByCompanyId_Last(
companyId, orderByComparator);
if (objectFolder != null) {
return objectFolder;
}
StringBundler sb = new StringBundler(4);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append("}");
throw new NoSuchObjectFolderException(sb.toString());
}
/**
* Returns the last object folder in the ordered set where companyId = ?.
*
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the last matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByCompanyId_Last(
long companyId, OrderByComparator orderByComparator) {
int count = countByCompanyId(companyId);
if (count == 0) {
return null;
}
List list = findByCompanyId(
companyId, count - 1, count, orderByComparator);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
/**
* Returns the object folders before and after the current object folder in the ordered set where companyId = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] findByCompanyId_PrevAndNext(
long objectFolderId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = getByCompanyId_PrevAndNext(
session, objectFolder, companyId, orderByComparator, true);
array[1] = objectFolder;
array[2] = getByCompanyId_PrevAndNext(
session, objectFolder, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder getByCompanyId_PrevAndNext(
Session session, ObjectFolder objectFolder, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
4 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(3);
}
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByConditionFields[i]);
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
sb.append(_ORDER_BY_ENTITY_ALIAS);
sb.append(orderByFields[i]);
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
String sql = sb.toString();
Query query = session.createQuery(sql);
query.setFirstResult(0);
query.setMaxResults(2);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = query.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Returns all the object folders that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the matching object folders that the user has permission to view
*/
@Override
public List filterFindByCompanyId(long companyId) {
return filterFindByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders that the user has permission to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end) {
return filterFindByCompanyId(companyId, start, end, null);
}
/**
* Returns an ordered range of all the object folders that the user has permissions to view where companyId = ?.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param companyId the company ID
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of matching object folders that the user has permission to view
*/
@Override
public List filterFindByCompanyId(
long companyId, int start, int end,
OrderByComparator orderByComparator) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId(companyId, start, end, orderByComparator);
}
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
3 + (orderByComparator.getOrderByFields().length * 2));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
if (getDB().isSupportsInlineDistinct()) {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
}
else {
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(
_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(
_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
return (List)QueryUtil.list(
sqlQuery, getDialect(), start, end);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
/**
* Returns the object folders before and after the current object folder in the ordered set of object folders that the user has permission to view where companyId = ?.
*
* @param objectFolderId the primary key of the current object folder
* @param companyId the company ID
* @param orderByComparator the comparator to order the set by (optionally null
)
* @return the previous, current, and next object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder[] filterFindByCompanyId_PrevAndNext(
long objectFolderId, long companyId,
OrderByComparator orderByComparator)
throws NoSuchObjectFolderException {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return findByCompanyId_PrevAndNext(
objectFolderId, companyId, orderByComparator);
}
ObjectFolder objectFolder = findByPrimaryKey(objectFolderId);
Session session = null;
try {
session = openSession();
ObjectFolder[] array = new ObjectFolderImpl[3];
array[0] = filterGetByCompanyId_PrevAndNext(
session, objectFolder, companyId, orderByComparator, true);
array[1] = objectFolder;
array[2] = filterGetByCompanyId_PrevAndNext(
session, objectFolder, companyId, orderByComparator, false);
return array;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
protected ObjectFolder filterGetByCompanyId_PrevAndNext(
Session session, ObjectFolder objectFolder, long companyId,
OrderByComparator orderByComparator, boolean previous) {
StringBundler sb = null;
if (orderByComparator != null) {
sb = new StringBundler(
5 + (orderByComparator.getOrderByConditionFields().length * 3) +
(orderByComparator.getOrderByFields().length * 3));
}
else {
sb = new StringBundler(4);
}
if (getDB().isSupportsInlineDistinct()) {
sb.append(_FILTER_SQL_SELECT_OBJECTFOLDER_WHERE);
}
else {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1);
}
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
if (!getDB().isSupportsInlineDistinct()) {
sb.append(
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2);
}
if (orderByComparator != null) {
String[] orderByConditionFields =
orderByComparator.getOrderByConditionFields();
if (orderByConditionFields.length > 0) {
sb.append(WHERE_AND);
}
for (int i = 0; i < orderByConditionFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByConditionFields[i],
true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByConditionFields[i],
true));
}
if ((i + 1) < orderByConditionFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN_HAS_NEXT);
}
else {
sb.append(WHERE_LESSER_THAN_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(WHERE_GREATER_THAN);
}
else {
sb.append(WHERE_LESSER_THAN);
}
}
}
sb.append(ORDER_BY_CLAUSE);
String[] orderByFields = orderByComparator.getOrderByFields();
for (int i = 0; i < orderByFields.length; i++) {
if (getDB().isSupportsInlineDistinct()) {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_ALIAS, orderByFields[i], true));
}
else {
sb.append(
getColumnName(
_ORDER_BY_ENTITY_TABLE, orderByFields[i], true));
}
if ((i + 1) < orderByFields.length) {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC_HAS_NEXT);
}
else {
sb.append(ORDER_BY_DESC_HAS_NEXT);
}
}
else {
if (orderByComparator.isAscending() ^ previous) {
sb.append(ORDER_BY_ASC);
}
else {
sb.append(ORDER_BY_DESC);
}
}
}
}
else {
if (getDB().isSupportsInlineDistinct()) {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL_INLINE_DISTINCT);
}
else {
sb.append(ObjectFolderModelImpl.ORDER_BY_SQL);
}
}
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.setFirstResult(0);
sqlQuery.setMaxResults(2);
if (getDB().isSupportsInlineDistinct()) {
sqlQuery.addEntity(_FILTER_ENTITY_ALIAS, ObjectFolderImpl.class);
}
else {
sqlQuery.addEntity(_FILTER_ENTITY_TABLE, ObjectFolderImpl.class);
}
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
if (orderByComparator != null) {
for (Object orderByConditionValue :
orderByComparator.getOrderByConditionValues(objectFolder)) {
queryPos.add(orderByConditionValue);
}
}
List list = sqlQuery.list();
if (list.size() == 2) {
return list.get(1);
}
else {
return null;
}
}
/**
* Removes all the object folders where companyId = ? from the database.
*
* @param companyId the company ID
*/
@Override
public void removeByCompanyId(long companyId) {
for (ObjectFolder objectFolder :
findByCompanyId(
companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
remove(objectFolder);
}
}
/**
* Returns the number of object folders where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching object folders
*/
@Override
public int countByCompanyId(long companyId) {
FinderPath finderPath = _finderPathCountByCompanyId;
Object[] finderArgs = new Object[] {companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(2);
sb.append(_SQL_COUNT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
/**
* Returns the number of object folders that the user has permission to view where companyId = ?.
*
* @param companyId the company ID
* @return the number of matching object folders that the user has permission to view
*/
@Override
public int filterCountByCompanyId(long companyId) {
if (!InlineSQLHelperUtil.isEnabled(companyId, 0)) {
return countByCompanyId(companyId);
}
StringBundler sb = new StringBundler(2);
sb.append(_FILTER_SQL_COUNT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
String sql = InlineSQLHelperUtil.replacePermissionCheck(
sb.toString(), ObjectFolder.class.getName(),
_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN);
Session session = null;
try {
session = openSession();
SQLQuery sqlQuery = session.createSynchronizedSQLQuery(sql);
sqlQuery.addScalar(
COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG);
QueryPos queryPos = QueryPos.getInstance(sqlQuery);
queryPos.add(companyId);
Long count = (Long)sqlQuery.uniqueResult();
return count.intValue();
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 =
"objectFolder.companyId = ?";
private FinderPath _finderPathFetchByC_N;
private FinderPath _finderPathCountByC_N;
/**
* Returns the object folder where companyId = ? and name = ? or throws a NoSuchObjectFolderException
if it could not be found.
*
* @param companyId the company ID
* @param name the name
* @return the matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByC_N(long companyId, String name)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByC_N(companyId, name);
if (objectFolder == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("companyId=");
sb.append(companyId);
sb.append(", name=");
sb.append(name);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchObjectFolderException(sb.toString());
}
return objectFolder;
}
/**
* Returns the object folder where companyId = ? and name = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param companyId the company ID
* @param name the name
* @return the matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByC_N(long companyId, String name) {
return fetchByC_N(companyId, name, true);
}
/**
* Returns the object folder where companyId = ? and name = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param companyId the company ID
* @param name the name
* @param useFinderCache whether to use the finder cache
* @return the matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByC_N(
long companyId, String name, boolean useFinderCache) {
name = Objects.toString(name, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {companyId, name};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByC_N, finderArgs, this);
}
if (result instanceof ObjectFolder) {
ObjectFolder objectFolder = (ObjectFolder)result;
if ((companyId != objectFolder.getCompanyId()) ||
!Objects.equals(name, objectFolder.getName())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_C_N_COMPANYID_2);
boolean bindName = false;
if (name.isEmpty()) {
sb.append(_FINDER_COLUMN_C_N_NAME_3);
}
else {
bindName = true;
sb.append(_FINDER_COLUMN_C_N_NAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (bindName) {
queryPos.add(name);
}
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByC_N, finderArgs, list);
}
}
else {
if (list.size() > 1) {
Collections.sort(list, Collections.reverseOrder());
if (_log.isWarnEnabled()) {
if (!useFinderCache) {
finderArgs = new Object[] {companyId, name};
}
_log.warn(
"ObjectFolderPersistenceImpl.fetchByC_N(long, String, boolean) with parameters (" +
StringUtil.merge(finderArgs) +
") yields a result set with more than 1 result. This violates the logical unique restriction. There is no order guarantee on which result is returned by this finder.");
}
}
ObjectFolder objectFolder = list.get(0);
result = objectFolder;
cacheResult(objectFolder);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (ObjectFolder)result;
}
}
/**
* Removes the object folder where companyId = ? and name = ? from the database.
*
* @param companyId the company ID
* @param name the name
* @return the object folder that was removed
*/
@Override
public ObjectFolder removeByC_N(long companyId, String name)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = findByC_N(companyId, name);
return remove(objectFolder);
}
/**
* Returns the number of object folders where companyId = ? and name = ?.
*
* @param companyId the company ID
* @param name the name
* @return the number of matching object folders
*/
@Override
public int countByC_N(long companyId, String name) {
name = Objects.toString(name, "");
FinderPath finderPath = _finderPathCountByC_N;
Object[] finderArgs = new Object[] {companyId, name};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_OBJECTFOLDER_WHERE);
sb.append(_FINDER_COLUMN_C_N_COMPANYID_2);
boolean bindName = false;
if (name.isEmpty()) {
sb.append(_FINDER_COLUMN_C_N_NAME_3);
}
else {
bindName = true;
sb.append(_FINDER_COLUMN_C_N_NAME_2);
}
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
queryPos.add(companyId);
if (bindName) {
queryPos.add(name);
}
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_C_N_COMPANYID_2 =
"objectFolder.companyId = ? AND ";
private static final String _FINDER_COLUMN_C_N_NAME_2 =
"objectFolder.name = ?";
private static final String _FINDER_COLUMN_C_N_NAME_3 =
"(objectFolder.name IS NULL OR objectFolder.name = '')";
private FinderPath _finderPathFetchByERC_C;
private FinderPath _finderPathCountByERC_C;
/**
* Returns the object folder where externalReferenceCode = ? and companyId = ? or throws a NoSuchObjectFolderException
if it could not be found.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the matching object folder
* @throws NoSuchObjectFolderException if a matching object folder could not be found
*/
@Override
public ObjectFolder findByERC_C(
String externalReferenceCode, long companyId)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByERC_C(
externalReferenceCode, companyId);
if (objectFolder == null) {
StringBundler sb = new StringBundler(6);
sb.append(_NO_SUCH_ENTITY_WITH_KEY);
sb.append("externalReferenceCode=");
sb.append(externalReferenceCode);
sb.append(", companyId=");
sb.append(companyId);
sb.append("}");
if (_log.isDebugEnabled()) {
_log.debug(sb.toString());
}
throw new NoSuchObjectFolderException(sb.toString());
}
return objectFolder;
}
/**
* Returns the object folder where externalReferenceCode = ? and companyId = ? or returns null
if it could not be found. Uses the finder cache.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByERC_C(
String externalReferenceCode, long companyId) {
return fetchByERC_C(externalReferenceCode, companyId, true);
}
/**
* Returns the object folder where externalReferenceCode = ? and companyId = ? or returns null
if it could not be found, optionally using the finder cache.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @param useFinderCache whether to use the finder cache
* @return the matching object folder, or null
if a matching object folder could not be found
*/
@Override
public ObjectFolder fetchByERC_C(
String externalReferenceCode, long companyId, boolean useFinderCache) {
externalReferenceCode = Objects.toString(externalReferenceCode, "");
Object[] finderArgs = null;
if (useFinderCache) {
finderArgs = new Object[] {externalReferenceCode, companyId};
}
Object result = null;
if (useFinderCache) {
result = finderCache.getResult(
_finderPathFetchByERC_C, finderArgs, this);
}
if (result instanceof ObjectFolder) {
ObjectFolder objectFolder = (ObjectFolder)result;
if (!Objects.equals(
externalReferenceCode,
objectFolder.getExternalReferenceCode()) ||
(companyId != objectFolder.getCompanyId())) {
result = null;
}
}
if (result == null) {
StringBundler sb = new StringBundler(4);
sb.append(_SQL_SELECT_OBJECTFOLDER_WHERE);
boolean bindExternalReferenceCode = false;
if (externalReferenceCode.isEmpty()) {
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3);
}
else {
bindExternalReferenceCode = true;
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2);
}
sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindExternalReferenceCode) {
queryPos.add(externalReferenceCode);
}
queryPos.add(companyId);
List list = query.list();
if (list.isEmpty()) {
if (useFinderCache) {
finderCache.putResult(
_finderPathFetchByERC_C, finderArgs, list);
}
}
else {
ObjectFolder objectFolder = list.get(0);
result = objectFolder;
cacheResult(objectFolder);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
if (result instanceof List>) {
return null;
}
else {
return (ObjectFolder)result;
}
}
/**
* Removes the object folder where externalReferenceCode = ? and companyId = ? from the database.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the object folder that was removed
*/
@Override
public ObjectFolder removeByERC_C(
String externalReferenceCode, long companyId)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = findByERC_C(
externalReferenceCode, companyId);
return remove(objectFolder);
}
/**
* Returns the number of object folders where externalReferenceCode = ? and companyId = ?.
*
* @param externalReferenceCode the external reference code
* @param companyId the company ID
* @return the number of matching object folders
*/
@Override
public int countByERC_C(String externalReferenceCode, long companyId) {
externalReferenceCode = Objects.toString(externalReferenceCode, "");
FinderPath finderPath = _finderPathCountByERC_C;
Object[] finderArgs = new Object[] {externalReferenceCode, companyId};
Long count = (Long)finderCache.getResult(finderPath, finderArgs, this);
if (count == null) {
StringBundler sb = new StringBundler(3);
sb.append(_SQL_COUNT_OBJECTFOLDER_WHERE);
boolean bindExternalReferenceCode = false;
if (externalReferenceCode.isEmpty()) {
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3);
}
else {
bindExternalReferenceCode = true;
sb.append(_FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2);
}
sb.append(_FINDER_COLUMN_ERC_C_COMPANYID_2);
String sql = sb.toString();
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
QueryPos queryPos = QueryPos.getInstance(query);
if (bindExternalReferenceCode) {
queryPos.add(externalReferenceCode);
}
queryPos.add(companyId);
count = (Long)query.uniqueResult();
finderCache.putResult(finderPath, finderArgs, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_2 =
"objectFolder.externalReferenceCode = ? AND ";
private static final String _FINDER_COLUMN_ERC_C_EXTERNALREFERENCECODE_3 =
"(objectFolder.externalReferenceCode IS NULL OR objectFolder.externalReferenceCode = '') AND ";
private static final String _FINDER_COLUMN_ERC_C_COMPANYID_2 =
"objectFolder.companyId = ?";
public ObjectFolderPersistenceImpl() {
Map dbColumnNames = new HashMap();
dbColumnNames.put("uuid", "uuid_");
setDBColumnNames(dbColumnNames);
setModelClass(ObjectFolder.class);
setModelImplClass(ObjectFolderImpl.class);
setModelPKClass(long.class);
setTable(ObjectFolderTable.INSTANCE);
}
/**
* Caches the object folder in the entity cache if it is enabled.
*
* @param objectFolder the object folder
*/
@Override
public void cacheResult(ObjectFolder objectFolder) {
entityCache.putResult(
ObjectFolderImpl.class, objectFolder.getPrimaryKey(), objectFolder);
finderCache.putResult(
_finderPathFetchByC_N,
new Object[] {objectFolder.getCompanyId(), objectFolder.getName()},
objectFolder);
finderCache.putResult(
_finderPathFetchByERC_C,
new Object[] {
objectFolder.getExternalReferenceCode(),
objectFolder.getCompanyId()
},
objectFolder);
}
private int _valueObjectFinderCacheListThreshold;
/**
* Caches the object folders in the entity cache if it is enabled.
*
* @param objectFolders the object folders
*/
@Override
public void cacheResult(List objectFolders) {
if ((_valueObjectFinderCacheListThreshold == 0) ||
((_valueObjectFinderCacheListThreshold > 0) &&
(objectFolders.size() > _valueObjectFinderCacheListThreshold))) {
return;
}
for (ObjectFolder objectFolder : objectFolders) {
if (entityCache.getResult(
ObjectFolderImpl.class, objectFolder.getPrimaryKey()) ==
null) {
cacheResult(objectFolder);
}
}
}
/**
* Clears the cache for all object folders.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache() {
entityCache.clearCache(ObjectFolderImpl.class);
finderCache.clearCache(ObjectFolderImpl.class);
}
/**
* Clears the cache for the object folder.
*
*
* The EntityCache
and FinderCache
are both cleared by this method.
*
*/
@Override
public void clearCache(ObjectFolder objectFolder) {
entityCache.removeResult(ObjectFolderImpl.class, objectFolder);
}
@Override
public void clearCache(List objectFolders) {
for (ObjectFolder objectFolder : objectFolders) {
entityCache.removeResult(ObjectFolderImpl.class, objectFolder);
}
}
@Override
public void clearCache(Set primaryKeys) {
finderCache.clearCache(ObjectFolderImpl.class);
for (Serializable primaryKey : primaryKeys) {
entityCache.removeResult(ObjectFolderImpl.class, primaryKey);
}
}
protected void cacheUniqueFindersCache(
ObjectFolderModelImpl objectFolderModelImpl) {
Object[] args = new Object[] {
objectFolderModelImpl.getCompanyId(),
objectFolderModelImpl.getName()
};
finderCache.putResult(_finderPathCountByC_N, args, Long.valueOf(1));
finderCache.putResult(
_finderPathFetchByC_N, args, objectFolderModelImpl);
args = new Object[] {
objectFolderModelImpl.getExternalReferenceCode(),
objectFolderModelImpl.getCompanyId()
};
finderCache.putResult(_finderPathCountByERC_C, args, Long.valueOf(1));
finderCache.putResult(
_finderPathFetchByERC_C, args, objectFolderModelImpl);
}
/**
* Creates a new object folder with the primary key. Does not add the object folder to the database.
*
* @param objectFolderId the primary key for the new object folder
* @return the new object folder
*/
@Override
public ObjectFolder create(long objectFolderId) {
ObjectFolder objectFolder = new ObjectFolderImpl();
objectFolder.setNew(true);
objectFolder.setPrimaryKey(objectFolderId);
String uuid = PortalUUIDUtil.generate();
objectFolder.setUuid(uuid);
objectFolder.setCompanyId(CompanyThreadLocal.getCompanyId());
return objectFolder;
}
/**
* Removes the object folder with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param objectFolderId the primary key of the object folder
* @return the object folder that was removed
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder remove(long objectFolderId)
throws NoSuchObjectFolderException {
return remove((Serializable)objectFolderId);
}
/**
* Removes the object folder with the primary key from the database. Also notifies the appropriate model listeners.
*
* @param primaryKey the primary key of the object folder
* @return the object folder that was removed
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder remove(Serializable primaryKey)
throws NoSuchObjectFolderException {
Session session = null;
try {
session = openSession();
ObjectFolder objectFolder = (ObjectFolder)session.get(
ObjectFolderImpl.class, primaryKey);
if (objectFolder == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchObjectFolderException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return remove(objectFolder);
}
catch (NoSuchObjectFolderException noSuchEntityException) {
throw noSuchEntityException;
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
@Override
protected ObjectFolder removeImpl(ObjectFolder objectFolder) {
Session session = null;
try {
session = openSession();
if (!session.contains(objectFolder)) {
objectFolder = (ObjectFolder)session.get(
ObjectFolderImpl.class, objectFolder.getPrimaryKeyObj());
}
if (objectFolder != null) {
session.delete(objectFolder);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
if (objectFolder != null) {
clearCache(objectFolder);
}
return objectFolder;
}
@Override
public ObjectFolder updateImpl(ObjectFolder objectFolder) {
boolean isNew = objectFolder.isNew();
if (!(objectFolder instanceof ObjectFolderModelImpl)) {
InvocationHandler invocationHandler = null;
if (ProxyUtil.isProxyClass(objectFolder.getClass())) {
invocationHandler = ProxyUtil.getInvocationHandler(
objectFolder);
throw new IllegalArgumentException(
"Implement ModelWrapper in objectFolder proxy " +
invocationHandler.getClass());
}
throw new IllegalArgumentException(
"Implement ModelWrapper in custom ObjectFolder implementation " +
objectFolder.getClass());
}
ObjectFolderModelImpl objectFolderModelImpl =
(ObjectFolderModelImpl)objectFolder;
if (Validator.isNull(objectFolder.getUuid())) {
String uuid = PortalUUIDUtil.generate();
objectFolder.setUuid(uuid);
}
if (Validator.isNull(objectFolder.getExternalReferenceCode())) {
objectFolder.setExternalReferenceCode(objectFolder.getUuid());
}
else {
if (!Objects.equals(
objectFolderModelImpl.getColumnOriginalValue(
"externalReferenceCode"),
objectFolder.getExternalReferenceCode())) {
long userId = GetterUtil.getLong(
PrincipalThreadLocal.getName());
if (userId > 0) {
long companyId = objectFolder.getCompanyId();
long groupId = 0;
long classPK = 0;
if (!isNew) {
classPK = objectFolder.getPrimaryKey();
}
try {
objectFolder.setExternalReferenceCode(
SanitizerUtil.sanitize(
companyId, groupId, userId,
ObjectFolder.class.getName(), classPK,
ContentTypes.TEXT_HTML, Sanitizer.MODE_ALL,
objectFolder.getExternalReferenceCode(), null));
}
catch (SanitizerException sanitizerException) {
throw new SystemException(sanitizerException);
}
}
}
ObjectFolder ercObjectFolder = fetchByERC_C(
objectFolder.getExternalReferenceCode(),
objectFolder.getCompanyId());
if (isNew) {
if (ercObjectFolder != null) {
throw new DuplicateObjectFolderExternalReferenceCodeException(
"Duplicate object folder with external reference code " +
objectFolder.getExternalReferenceCode() +
" and company " + objectFolder.getCompanyId());
}
}
else {
if ((ercObjectFolder != null) &&
(objectFolder.getObjectFolderId() !=
ercObjectFolder.getObjectFolderId())) {
throw new DuplicateObjectFolderExternalReferenceCodeException(
"Duplicate object folder with external reference code " +
objectFolder.getExternalReferenceCode() +
" and company " + objectFolder.getCompanyId());
}
}
}
ServiceContext serviceContext =
ServiceContextThreadLocal.getServiceContext();
Date date = new Date();
if (isNew && (objectFolder.getCreateDate() == null)) {
if (serviceContext == null) {
objectFolder.setCreateDate(date);
}
else {
objectFolder.setCreateDate(serviceContext.getCreateDate(date));
}
}
if (!objectFolderModelImpl.hasSetModifiedDate()) {
if (serviceContext == null) {
objectFolder.setModifiedDate(date);
}
else {
objectFolder.setModifiedDate(
serviceContext.getModifiedDate(date));
}
}
Session session = null;
try {
session = openSession();
if (isNew) {
session.save(objectFolder);
}
else {
objectFolder = (ObjectFolder)session.merge(objectFolder);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
entityCache.putResult(
ObjectFolderImpl.class, objectFolderModelImpl, false, true);
cacheUniqueFindersCache(objectFolderModelImpl);
if (isNew) {
objectFolder.setNew(false);
}
objectFolder.resetOriginalValues();
return objectFolder;
}
/**
* Returns the object folder with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException
if it could not be found.
*
* @param primaryKey the primary key of the object folder
* @return the object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder findByPrimaryKey(Serializable primaryKey)
throws NoSuchObjectFolderException {
ObjectFolder objectFolder = fetchByPrimaryKey(primaryKey);
if (objectFolder == null) {
if (_log.isDebugEnabled()) {
_log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
throw new NoSuchObjectFolderException(
_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
}
return objectFolder;
}
/**
* Returns the object folder with the primary key or throws a NoSuchObjectFolderException
if it could not be found.
*
* @param objectFolderId the primary key of the object folder
* @return the object folder
* @throws NoSuchObjectFolderException if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder findByPrimaryKey(long objectFolderId)
throws NoSuchObjectFolderException {
return findByPrimaryKey((Serializable)objectFolderId);
}
/**
* Returns the object folder with the primary key or returns null
if it could not be found.
*
* @param objectFolderId the primary key of the object folder
* @return the object folder, or null
if a object folder with the primary key could not be found
*/
@Override
public ObjectFolder fetchByPrimaryKey(long objectFolderId) {
return fetchByPrimaryKey((Serializable)objectFolderId);
}
/**
* Returns all the object folders.
*
* @return the object folders
*/
@Override
public List findAll() {
return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
}
/**
* Returns a range of all the object folders.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @return the range of object folders
*/
@Override
public List findAll(int start, int end) {
return findAll(start, end, null);
}
/**
* Returns an ordered range of all the object folders.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @return the ordered range of object folders
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator) {
return findAll(start, end, orderByComparator, true);
}
/**
* Returns an ordered range of all the object folders.
*
*
* Useful when paginating results. Returns a maximum of end - start
instances. start
and end
are not primary keys, they are indexes in the result set. Thus, 0
refers to the first result in the set. Setting both start
and end
to QueryUtil#ALL_POS
will return the full result set. If orderByComparator
is specified, then the query will include the given ORDER BY logic. If orderByComparator
is absent, then the query will include the default ORDER BY logic from ObjectFolderModelImpl
.
*
*
* @param start the lower bound of the range of object folders
* @param end the upper bound of the range of object folders (not inclusive)
* @param orderByComparator the comparator to order the results by (optionally null
)
* @param useFinderCache whether to use the finder cache
* @return the ordered range of object folders
*/
@Override
public List findAll(
int start, int end, OrderByComparator orderByComparator,
boolean useFinderCache) {
FinderPath finderPath = null;
Object[] finderArgs = null;
if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
(orderByComparator == null)) {
if (useFinderCache) {
finderPath = _finderPathWithoutPaginationFindAll;
finderArgs = FINDER_ARGS_EMPTY;
}
}
else if (useFinderCache) {
finderPath = _finderPathWithPaginationFindAll;
finderArgs = new Object[] {start, end, orderByComparator};
}
List list = null;
if (useFinderCache) {
list = (List)finderCache.getResult(
finderPath, finderArgs, this);
}
if (list == null) {
StringBundler sb = null;
String sql = null;
if (orderByComparator != null) {
sb = new StringBundler(
2 + (orderByComparator.getOrderByFields().length * 2));
sb.append(_SQL_SELECT_OBJECTFOLDER);
appendOrderByComparator(
sb, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
sql = sb.toString();
}
else {
sql = _SQL_SELECT_OBJECTFOLDER;
sql = sql.concat(ObjectFolderModelImpl.ORDER_BY_JPQL);
}
Session session = null;
try {
session = openSession();
Query query = session.createQuery(sql);
list = (List)QueryUtil.list(
query, getDialect(), start, end);
cacheResult(list);
if (useFinderCache) {
finderCache.putResult(finderPath, finderArgs, list);
}
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return list;
}
/**
* Removes all the object folders from the database.
*
*/
@Override
public void removeAll() {
for (ObjectFolder objectFolder : findAll()) {
remove(objectFolder);
}
}
/**
* Returns the number of object folders.
*
* @return the number of object folders
*/
@Override
public int countAll() {
Long count = (Long)finderCache.getResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, this);
if (count == null) {
Session session = null;
try {
session = openSession();
Query query = session.createQuery(_SQL_COUNT_OBJECTFOLDER);
count = (Long)query.uniqueResult();
finderCache.putResult(
_finderPathCountAll, FINDER_ARGS_EMPTY, count);
}
catch (Exception exception) {
throw processException(exception);
}
finally {
closeSession(session);
}
}
return count.intValue();
}
@Override
public Set getBadColumnNames() {
return _badColumnNames;
}
@Override
protected EntityCache getEntityCache() {
return entityCache;
}
@Override
protected String getPKDBName() {
return "objectFolderId";
}
@Override
protected String getSelectSQL() {
return _SQL_SELECT_OBJECTFOLDER;
}
@Override
protected Map getTableColumnsMap() {
return ObjectFolderModelImpl.TABLE_COLUMNS_MAP;
}
/**
* Initializes the object folder persistence.
*/
@Activate
public void activate() {
_valueObjectFinderCacheListThreshold = GetterUtil.getInteger(
PropsUtil.get(PropsKeys.VALUE_OBJECT_FINDER_CACHE_LIST_THRESHOLD));
_finderPathWithPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathWithoutPaginationFindAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0],
new String[0], true);
_finderPathCountAll = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll",
new String[0], new String[0], false);
_finderPathWithPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid",
new String[] {
String.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"uuid_"}, true);
_finderPathWithoutPaginationFindByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
true);
_finderPathCountByUuid = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid",
new String[] {String.class.getName()}, new String[] {"uuid_"},
false);
_finderPathWithPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByUuid_C",
new String[] {
String.class.getName(), Long.class.getName(),
Integer.class.getName(), Integer.class.getName(),
OrderByComparator.class.getName()
},
new String[] {"uuid_", "companyId"}, true);
_finderPathWithoutPaginationFindByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, true);
_finderPathCountByUuid_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByUuid_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"uuid_", "companyId"}, false);
_finderPathWithPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
new String[] {
Long.class.getName(), Integer.class.getName(),
Integer.class.getName(), OrderByComparator.class.getName()
},
new String[] {"companyId"}, true);
_finderPathWithoutPaginationFindByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
true);
_finderPathCountByCompanyId = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
new String[] {Long.class.getName()}, new String[] {"companyId"},
false);
_finderPathFetchByC_N = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByC_N",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"companyId", "name"}, true);
_finderPathCountByC_N = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_N",
new String[] {Long.class.getName(), String.class.getName()},
new String[] {"companyId", "name"}, false);
_finderPathFetchByERC_C = new FinderPath(
FINDER_CLASS_NAME_ENTITY, "fetchByERC_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"externalReferenceCode", "companyId"}, true);
_finderPathCountByERC_C = new FinderPath(
FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByERC_C",
new String[] {String.class.getName(), Long.class.getName()},
new String[] {"externalReferenceCode", "companyId"}, false);
ObjectFolderUtil.setPersistence(this);
}
@Deactivate
public void deactivate() {
ObjectFolderUtil.setPersistence(null);
entityCache.removeCache(ObjectFolderImpl.class.getName());
}
@Override
@Reference(
target = ObjectPersistenceConstants.SERVICE_CONFIGURATION_FILTER,
unbind = "-"
)
public void setConfiguration(Configuration configuration) {
}
@Override
@Reference(
target = ObjectPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setDataSource(DataSource dataSource) {
super.setDataSource(dataSource);
}
@Override
@Reference(
target = ObjectPersistenceConstants.ORIGIN_BUNDLE_SYMBOLIC_NAME_FILTER,
unbind = "-"
)
public void setSessionFactory(SessionFactory sessionFactory) {
super.setSessionFactory(sessionFactory);
}
@Reference
protected EntityCache entityCache;
@Reference
protected FinderCache finderCache;
private static final String _SQL_SELECT_OBJECTFOLDER =
"SELECT objectFolder FROM ObjectFolder objectFolder";
private static final String _SQL_SELECT_OBJECTFOLDER_WHERE =
"SELECT objectFolder FROM ObjectFolder objectFolder WHERE ";
private static final String _SQL_COUNT_OBJECTFOLDER =
"SELECT COUNT(objectFolder) FROM ObjectFolder objectFolder";
private static final String _SQL_COUNT_OBJECTFOLDER_WHERE =
"SELECT COUNT(objectFolder) FROM ObjectFolder objectFolder WHERE ";
private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN =
"objectFolder.objectFolderId";
private static final String _FILTER_SQL_SELECT_OBJECTFOLDER_WHERE =
"SELECT DISTINCT {objectFolder.*} FROM ObjectFolder objectFolder WHERE ";
private static final String
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_1 =
"SELECT {ObjectFolder.*} FROM (SELECT DISTINCT objectFolder.objectFolderId FROM ObjectFolder objectFolder WHERE ";
private static final String
_FILTER_SQL_SELECT_OBJECTFOLDER_NO_INLINE_DISTINCT_WHERE_2 =
") TEMP_TABLE INNER JOIN ObjectFolder ON TEMP_TABLE.objectFolderId = ObjectFolder.objectFolderId";
private static final String _FILTER_SQL_COUNT_OBJECTFOLDER_WHERE =
"SELECT COUNT(DISTINCT objectFolder.objectFolderId) AS COUNT_VALUE FROM ObjectFolder objectFolder WHERE ";
private static final String _FILTER_ENTITY_ALIAS = "objectFolder";
private static final String _FILTER_ENTITY_TABLE = "ObjectFolder";
private static final String _ORDER_BY_ENTITY_ALIAS = "objectFolder.";
private static final String _ORDER_BY_ENTITY_TABLE = "ObjectFolder.";
private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
"No ObjectFolder exists with the primary key ";
private static final String _NO_SUCH_ENTITY_WITH_KEY =
"No ObjectFolder exists with the key {";
private static final Log _log = LogFactoryUtil.getLog(
ObjectFolderPersistenceImpl.class);
private static final Set _badColumnNames = SetUtil.fromArray(
new String[] {"uuid"});
@Override
protected FinderCache getFinderCache() {
return finderCache;
}
}