Search in sources :

Example 31 with Qux

use of com.liferay.blade.workflow.asset.model.Qux in project liferay-blade-samples by liferay.

the class QuxPersistenceImpl method findByUuid_PrevAndNext.

/**
 * Returns the quxs before and after the current qux in the ordered set where uuid = ?.
 *
 * @param quxId the primary key of the current qux
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next qux
 * @throws NoSuchQuxException if a qux with the primary key could not be found
 */
@Override
public Qux[] findByUuid_PrevAndNext(long quxId, String uuid, OrderByComparator<Qux> orderByComparator) throws NoSuchQuxException {
    uuid = Objects.toString(uuid, "");
    Qux qux = findByPrimaryKey(quxId);
    Session session = null;
    try {
        session = openSession();
        Qux[] array = new QuxImpl[3];
        array[0] = getByUuid_PrevAndNext(session, qux, uuid, orderByComparator, true);
        array[1] = qux;
        array[2] = getByUuid_PrevAndNext(session, qux, uuid, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Qux(com.liferay.blade.workflow.asset.model.Qux) QuxImpl(com.liferay.blade.workflow.asset.model.impl.QuxImpl) NoSuchQuxException(com.liferay.blade.workflow.asset.exception.NoSuchQuxException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 32 with Qux

use of com.liferay.blade.workflow.asset.model.Qux in project liferay-blade-samples by liferay.

the class QuxPersistenceImpl method findByUuid_C_PrevAndNext.

/**
 * Returns the quxs before and after the current qux in the ordered set where uuid = &#63; and companyId = &#63;.
 *
 * @param quxId the primary key of the current qux
 * @param uuid the uuid
 * @param companyId the company ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next qux
 * @throws NoSuchQuxException if a qux with the primary key could not be found
 */
@Override
public Qux[] findByUuid_C_PrevAndNext(long quxId, String uuid, long companyId, OrderByComparator<Qux> orderByComparator) throws NoSuchQuxException {
    uuid = Objects.toString(uuid, "");
    Qux qux = findByPrimaryKey(quxId);
    Session session = null;
    try {
        session = openSession();
        Qux[] array = new QuxImpl[3];
        array[0] = getByUuid_C_PrevAndNext(session, qux, uuid, companyId, orderByComparator, true);
        array[1] = qux;
        array[2] = getByUuid_C_PrevAndNext(session, qux, uuid, companyId, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Qux(com.liferay.blade.workflow.asset.model.Qux) QuxImpl(com.liferay.blade.workflow.asset.model.impl.QuxImpl) NoSuchQuxException(com.liferay.blade.workflow.asset.exception.NoSuchQuxException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 33 with Qux

use of com.liferay.blade.workflow.asset.model.Qux in project liferay-blade-samples by liferay.

the class QuxPersistenceImpl method getByUuid_PrevAndNext.

protected Qux getByUuid_PrevAndNext(Session session, Qux qux, String uuid, OrderByComparator<Qux> orderByComparator, boolean previous) {
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3));
    } else {
        query = new StringBundler(3);
    }
    query.append(_SQL_SELECT_QUX_WHERE);
    boolean bindUuid = false;
    if (uuid.isEmpty()) {
        query.append(_FINDER_COLUMN_UUID_UUID_3);
    } else {
        bindUuid = true;
        query.append(_FINDER_COLUMN_UUID_UUID_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(QuxModelImpl.ORDER_BY_JPQL);
    }
    String sql = query.toString();
    Query q = session.createQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    QueryPos qPos = QueryPos.getInstance(q);
    if (bindUuid) {
        qPos.add(uuid);
    }
    if (orderByComparator != null) {
        for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(qux)) {
            qPos.add(orderByConditionValue);
        }
    }
    List<Qux> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : Query(com.liferay.portal.kernel.dao.orm.Query) Qux(com.liferay.blade.workflow.asset.model.Qux) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.petra.string.StringBundler)

Example 34 with Qux

use of com.liferay.blade.workflow.asset.model.Qux in project liferay-blade-samples by liferay.

the class QuxPersistenceImpl method create.

/**
 * Creates a new qux with the primary key. Does not add the qux to the database.
 *
 * @param quxId the primary key for the new qux
 * @return the new qux
 */
@Override
public Qux create(long quxId) {
    Qux qux = new QuxImpl();
    qux.setNew(true);
    qux.setPrimaryKey(quxId);
    String uuid = PortalUUIDUtil.generate();
    qux.setUuid(uuid);
    qux.setCompanyId(companyProvider.getCompanyId());
    return qux;
}
Also used : Qux(com.liferay.blade.workflow.asset.model.Qux) QuxImpl(com.liferay.blade.workflow.asset.model.impl.QuxImpl)

Example 35 with Qux

use of com.liferay.blade.workflow.asset.model.Qux in project liferay-blade-samples by liferay.

the class QuxPersistenceImpl method getByUuid_C_PrevAndNext.

protected Qux getByUuid_C_PrevAndNext(Session session, Qux qux, String uuid, long companyId, OrderByComparator<Qux> orderByComparator, boolean previous) {
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3));
    } else {
        query = new StringBundler(4);
    }
    query.append(_SQL_SELECT_QUX_WHERE);
    boolean bindUuid = false;
    if (uuid.isEmpty()) {
        query.append(_FINDER_COLUMN_UUID_C_UUID_3);
    } else {
        bindUuid = true;
        query.append(_FINDER_COLUMN_UUID_C_UUID_2);
    }
    query.append(_FINDER_COLUMN_UUID_C_COMPANYID_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(QuxModelImpl.ORDER_BY_JPQL);
    }
    String sql = query.toString();
    Query q = session.createQuery(sql);
    q.setFirstResult(0);
    q.setMaxResults(2);
    QueryPos qPos = QueryPos.getInstance(q);
    if (bindUuid) {
        qPos.add(uuid);
    }
    qPos.add(companyId);
    if (orderByComparator != null) {
        for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(qux)) {
            qPos.add(orderByConditionValue);
        }
    }
    List<Qux> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : Query(com.liferay.portal.kernel.dao.orm.Query) Qux(com.liferay.blade.workflow.asset.model.Qux) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.petra.string.StringBundler)

Aggregations

Qux (com.liferay.blade.workflow.asset.model.Qux)39 Test (org.junit.Test)14 StringBundler (com.liferay.petra.string.StringBundler)13 NoSuchQuxException (com.liferay.blade.workflow.asset.exception.NoSuchQuxException)12 Session (com.liferay.portal.kernel.dao.orm.Session)7 Query (com.liferay.portal.kernel.dao.orm.Query)6 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)5 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)5 QuxImpl (com.liferay.blade.workflow.asset.model.impl.QuxImpl)4 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)4 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)3 Serializable (java.io.Serializable)3 HashSet (java.util.HashSet)3 User (com.liferay.portal.kernel.model.User)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Function (java.util.function.Function)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelDataHandler (com.liferay.exportimport.kernel.lar.StagedModelDataHandler)1