Search in sources :

Example 21 with WikiNode

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

the class WikiNodePersistenceImpl method findByGroupId_Last.

/**
 * Returns the last wiki node in the ordered set where groupId = ?.
 *
 * @param groupId the group ID
 * @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 findByGroupId_Last(long groupId, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    WikiNode wikiNode = fetchByGroupId_Last(groupId, orderByComparator);
    if (wikiNode != null) {
        return wikiNode;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("groupId=");
    msg.append(groupId);
    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 22 with WikiNode

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

the class WikiNodePersistenceImpl method filterFindByGroupId_PrevAndNext.

/**
 * Returns the wiki nodes before and after the current wiki node in the ordered set of wiki nodes that the user has permission to view where groupId = &#63;.
 *
 * @param nodeId the primary key of the current wiki node
 * @param groupId the group ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next wiki node
 * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode[] filterFindByGroupId_PrevAndNext(long nodeId, long groupId, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByGroupId_PrevAndNext(nodeId, groupId, orderByComparator);
    }
    WikiNode wikiNode = findByPrimaryKey(nodeId);
    Session session = null;
    try {
        session = openSession();
        WikiNode[] array = new WikiNodeImpl[3];
        array[0] = filterGetByGroupId_PrevAndNext(session, wikiNode, groupId, orderByComparator, true);
        array[1] = wikiNode;
        array[2] = filterGetByGroupId_PrevAndNext(session, wikiNode, groupId, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
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 23 with WikiNode

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

the class WikiNodePersistenceImpl method findByG_S_PrevAndNext.

/**
 * Returns the wiki nodes before and after the current wiki node in the ordered set where groupId = &#63; and status = &#63;.
 *
 * @param nodeId the primary key of the current wiki node
 * @param groupId the group ID
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next wiki node
 * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode[] findByG_S_PrevAndNext(long nodeId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    WikiNode wikiNode = findByPrimaryKey(nodeId);
    Session session = null;
    try {
        session = openSession();
        WikiNode[] array = new WikiNodeImpl[3];
        array[0] = getByG_S_PrevAndNext(session, wikiNode, groupId, status, orderByComparator, true);
        array[1] = wikiNode;
        array[2] = getByG_S_PrevAndNext(session, wikiNode, groupId, status, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
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 24 with WikiNode

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

the class WikiNodePersistenceImpl method filterFindByG_S_PrevAndNext.

/**
 * Returns the wiki nodes before and after the current wiki node in the ordered set of wiki nodes that the user has permission to view where groupId = &#63; and status = &#63;.
 *
 * @param nodeId the primary key of the current wiki node
 * @param groupId the group ID
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next wiki node
 * @throws com.liferay.portlet.wiki.NoSuchNodeException if a wiki node with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public WikiNode[] filterFindByG_S_PrevAndNext(long nodeId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchNodeException, SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_S_PrevAndNext(nodeId, groupId, status, orderByComparator);
    }
    WikiNode wikiNode = findByPrimaryKey(nodeId);
    Session session = null;
    try {
        session = openSession();
        WikiNode[] array = new WikiNodeImpl[3];
        array[0] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId, status, orderByComparator, true);
        array[1] = wikiNode;
        array[2] = filterGetByG_S_PrevAndNext(session, wikiNode, groupId, status, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
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 25 with WikiNode

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

the class WikiNodePersistenceImpl method getByG_S_PrevAndNext.

protected WikiNode getByG_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);
    }
    query.append(_SQL_SELECT_WIKINODE_WHERE);
    query.append(_FINDER_COLUMN_G_S_GROUPID_2);
    query.append(_FINDER_COLUMN_G_S_STATUS_2);
    if (orderByComparator != null) {
        String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
        if (orderByConditionFields.length > 0) {
            query.append(WHERE_AND);
        }
        for (int i = 0; i < orderByConditionFields.length; i++) {
            query.append(_ORDER_BY_ENTITY_ALIAS);
            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++) {
            query.append(_ORDER_BY_ENTITY_ALIAS);
            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 {
        query.append(WikiNodeModelImpl.ORDER_BY_JPQL);
    }
    String sql = query.toString();
    Query q = session.createQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    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 : SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) WikiNode(com.liferay.portlet.wiki.model.WikiNode) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) 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