Search in sources :

Example 31 with WikiNode

use of com.liferay.portlet.wiki.model.WikiNode in project liferay-ide by liferay.

the class WikiNodePersistenceImpl method filterGetByGroupId_PrevAndNext.

protected WikiNode filterGetByGroupId_PrevAndNext(Session session, WikiNode wikiNode, long groupId, OrderByComparator orderByComparator, boolean previous) {
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6));
    } else {
        query = new StringBundler(3);
    }
    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
    }
    query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
    }
    if (orderByComparator != null) {
        String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
        if (orderByConditionFields.length > 0) {
            query.append(WHERE_AND);
        }
        for (int i = 0; i < orderByConditionFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByConditionFields[i]);
            if ((i + 1) < orderByConditionFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
                } else {
                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN);
                } else {
                    query.append(WHERE_LESSER_THAN);
                }
            }
        }
        query.append(ORDER_BY_CLAUSE);
        String[] orderByFields = orderByComparator.getOrderByFields();
        for (int i = 0; i < orderByFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByFields[i]);
            if ((i + 1) < orderByFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC_HAS_NEXT);
                } else {
                    query.append(ORDER_BY_DESC_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC);
                } else {
                    query.append(ORDER_BY_DESC);
                }
            }
        }
    } else {
        if (getDB().isSupportsInlineDistinct()) {
            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(WikiNodeModelImpl.ORDER_BY_SQL);
        }
    }
    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), WikiNode.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
    SQLQuery q = session.createSQLQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    if (getDB().isSupportsInlineDistinct()) {
        q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
    } else {
        q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
    }
    QueryPos qPos = QueryPos.getInstance(q);
    qPos.add(groupId);
    if (orderByComparator != null) {
        Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
        for (Object value : values) {
            qPos.add(value);
        }
    }
    List<WikiNode> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : WikiNode(com.liferay.portlet.wiki.model.WikiNode) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 32 with WikiNode

use of com.liferay.portlet.wiki.model.WikiNode in project liferay-ide by liferay.

the class WikiNodePersistenceImpl method fetchByPrimaryKey.

/**
 * Returns the wiki node with the primary key or returns <code>null</code> if it could not be found.
 *
 * @param primaryKey the primary key of the wiki node
 * @return the wiki node, or <code>null</code> if a wiki node with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    WikiNode wikiNode = (WikiNode) EntityCacheUtil.getResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED, WikiNodeImpl.class, primaryKey);
    if (wikiNode == _nullWikiNode) {
        return null;
    }
    if (wikiNode == null) {
        Session session = null;
        try {
            session = openSession();
            wikiNode = (WikiNode) session.get(WikiNodeImpl.class, primaryKey);
            if (wikiNode != null) {
                cacheResult(wikiNode);
            } else {
                EntityCacheUtil.putResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED, WikiNodeImpl.class, primaryKey, _nullWikiNode);
            }
        } catch (Exception e) {
            EntityCacheUtil.removeResult(WikiNodeModelImpl.ENTITY_CACHE_ENABLED, WikiNodeImpl.class, primaryKey);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return wikiNode;
}
Also used : WikiNodeImpl(com.liferay.portlet.wiki.model.impl.WikiNodeImpl) WikiNode(com.liferay.portlet.wiki.model.WikiNode) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchNodeException(com.liferay.portlet.wiki.NoSuchNodeException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 33 with WikiNode

use of com.liferay.portlet.wiki.model.WikiNode in project liferay-ide by liferay.

the class WikiNodePersistenceImpl method filterGetByG_S_PrevAndNext.

protected WikiNode filterGetByG_S_PrevAndNext(Session session, WikiNode wikiNode, long groupId, int status, OrderByComparator orderByComparator, boolean previous) {
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6));
    } else {
        query = new StringBundler(3);
    }
    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_WIKINODE_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_1);
    }
    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
    query.append(_FINDER_COLUMN_G_S_STATUS_2);
    if (!getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_WIKINODE_NO_INLINE_DISTINCT_WHERE_2);
    }
    if (orderByComparator != null) {
        String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
        if (orderByConditionFields.length > 0) {
            query.append(WHERE_AND);
        }
        for (int i = 0; i < orderByConditionFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByConditionFields[i]);
            if ((i + 1) < orderByConditionFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
                } else {
                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(WHERE_GREATER_THAN);
                } else {
                    query.append(WHERE_LESSER_THAN);
                }
            }
        }
        query.append(ORDER_BY_CLAUSE);
        String[] orderByFields = orderByComparator.getOrderByFields();
        for (int i = 0; i < orderByFields.length; i++) {
            if (getDB().isSupportsInlineDistinct()) {
                query.append(_ORDER_BY_ENTITY_ALIAS);
            } else {
                query.append(_ORDER_BY_ENTITY_TABLE);
            }
            query.append(orderByFields[i]);
            if ((i + 1) < orderByFields.length) {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC_HAS_NEXT);
                } else {
                    query.append(ORDER_BY_DESC_HAS_NEXT);
                }
            } else {
                if (orderByComparator.isAscending() ^ previous) {
                    query.append(ORDER_BY_ASC);
                } else {
                    query.append(ORDER_BY_DESC);
                }
            }
        }
    } else {
        if (getDB().isSupportsInlineDistinct()) {
            query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(WikiNodeModelImpl.ORDER_BY_SQL);
        }
    }
    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), WikiNode.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
    SQLQuery q = session.createSQLQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    if (getDB().isSupportsInlineDistinct()) {
        q.addEntity(_FILTER_ENTITY_ALIAS, WikiNodeImpl.class);
    } else {
        q.addEntity(_FILTER_ENTITY_TABLE, WikiNodeImpl.class);
    }
    QueryPos qPos = QueryPos.getInstance(q);
    qPos.add(groupId);
    qPos.add(status);
    if (orderByComparator != null) {
        Object[] values = orderByComparator.getOrderByConditionValues(wikiNode);
        for (Object value : values) {
            qPos.add(value);
        }
    }
    List<WikiNode> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : WikiNode(com.liferay.portlet.wiki.model.WikiNode) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 34 with WikiNode

use of com.liferay.portlet.wiki.model.WikiNode in project liferay-ide by liferay.

the class WikiNodePersistenceImpl method findByC_S_First.

/**
 * Returns the first wiki node in the ordered set where companyId = &#63; and status = &#63;.
 *
 * @param companyId the company ID
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the first matching wiki node
 * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode findByC_S_First(long companyId, int status, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    WikiNode wikiNode = fetchByC_S_First(companyId, status, orderByComparator);
    if (wikiNode != null) {
        return wikiNode;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("companyId=");
    msg.append(companyId);
    msg.append(", status=");
    msg.append(status);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchNodeException(msg.toString());
}
Also used : WikiNode(com.liferay.portlet.wiki.model.WikiNode) NoSuchNodeException(com.liferay.portlet.wiki.NoSuchNodeException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 35 with WikiNode

use of com.liferay.portlet.wiki.model.WikiNode in project liferay-ide by liferay.

the class WikiNodePersistenceImpl method findByG_S_Last.

/**
 * Returns the last wiki node in the ordered set where groupId = &#63; and status = &#63;.
 *
 * @param groupId the group ID
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching wiki node
 * @throws com.liferay.portlet.wiki.NoSuchNodeException if a matching wiki node could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode findByG_S_Last(long groupId, int status, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    WikiNode wikiNode = fetchByG_S_Last(groupId, status, orderByComparator);
    if (wikiNode != null) {
        return wikiNode;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("groupId=");
    msg.append(groupId);
    msg.append(", status=");
    msg.append(status);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchNodeException(msg.toString());
}
Also used : WikiNode(com.liferay.portlet.wiki.model.WikiNode) NoSuchNodeException(com.liferay.portlet.wiki.NoSuchNodeException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

WikiNode (com.liferay.portlet.wiki.model.WikiNode)45 NoSuchNodeException (com.liferay.portlet.wiki.NoSuchNodeException)35 StringBundler (com.liferay.portal.kernel.util.StringBundler)33 Session (com.liferay.portal.kernel.dao.orm.Session)21 SystemException (com.liferay.portal.kernel.exception.SystemException)21 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)19 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)18 Query (com.liferay.portal.kernel.dao.orm.Query)15 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)11 WikiNodeImpl (com.liferay.portlet.wiki.model.impl.WikiNodeImpl)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)7