Search in sources :

Example 71 with StringBundler

use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.

the class ArtistPersistenceImpl method findByUserId_Last.

/**
 * Returns the last artist in the ordered set where userId = ?.
 *
 * @param userId the user ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching artist
 * @throws org.liferay.jukebox.NoSuchArtistException if a matching artist could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Artist findByUserId_Last(long userId, OrderByComparator orderByComparator) throws NoSuchArtistException, SystemException {
    Artist artist = fetchByUserId_Last(userId, orderByComparator);
    if (artist != null) {
        return artist;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("userId=");
    msg.append(userId);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchArtistException(msg.toString());
}
Also used : Artist(org.liferay.jukebox.model.Artist) StringBundler(com.liferay.portal.kernel.util.StringBundler) NoSuchArtistException(org.liferay.jukebox.NoSuchArtistException)

Example 72 with StringBundler

use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.

the class ArtistPersistenceImpl method countByU_G.

/**
 * Returns the number of artists where userId = &#63; and groupId = &#63;.
 *
 * @param userId the user ID
 * @param groupId the group ID
 * @return the number of matching artists
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByU_G(long userId, long groupId) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_U_G;
    Object[] finderArgs = new Object[] { userId, groupId };
    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);
    if (count == null) {
        StringBundler query = new StringBundler(3);
        query.append(_SQL_COUNT_ARTIST_WHERE);
        query.append(_FINDER_COLUMN_U_G_USERID_2);
        query.append(_FINDER_COLUMN_U_G_GROUPID_2);
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(userId);
            qPos.add(groupId);
            count = (Long) q.uniqueResult();
            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return count.intValue();
}
Also used : SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) FinderPath(com.liferay.portal.kernel.dao.orm.FinderPath) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArtistException(org.liferay.jukebox.NoSuchArtistException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 73 with StringBundler

use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.

the class ArtistPersistenceImpl method findByUuid_Last.

/**
 * Returns the last artist in the ordered set where uuid = &#63;.
 *
 * @param uuid the uuid
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the last matching artist
 * @throws org.liferay.jukebox.NoSuchArtistException if a matching artist could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Artist findByUuid_Last(String uuid, OrderByComparator orderByComparator) throws NoSuchArtistException, SystemException {
    Artist artist = fetchByUuid_Last(uuid, orderByComparator);
    if (artist != null) {
        return artist;
    }
    StringBundler msg = new StringBundler(4);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(StringPool.CLOSE_CURLY_BRACE);
    throw new NoSuchArtistException(msg.toString());
}
Also used : Artist(org.liferay.jukebox.model.Artist) StringBundler(com.liferay.portal.kernel.util.StringBundler) NoSuchArtistException(org.liferay.jukebox.NoSuchArtistException)

Example 74 with StringBundler

use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.

the class ArtistPersistenceImpl method countByGroupId.

/**
 * Returns the number of artists where groupId = &#63;.
 *
 * @param groupId the group ID
 * @return the number of matching artists
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByGroupId(long groupId) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_GROUPID;
    Object[] finderArgs = new Object[] { groupId };
    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);
    if (count == null) {
        StringBundler query = new StringBundler(2);
        query.append(_SQL_COUNT_ARTIST_WHERE);
        query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(groupId);
            count = (Long) q.uniqueResult();
            FinderCacheUtil.putResult(finderPath, finderArgs, count);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return count.intValue();
}
Also used : SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) FinderPath(com.liferay.portal.kernel.dao.orm.FinderPath) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchArtistException(org.liferay.jukebox.NoSuchArtistException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 75 with StringBundler

use of com.liferay.portal.kernel.util.StringBundler in project liferay-ide by liferay.

the class ArtistPersistenceImpl method getByCompanyId_PrevAndNext.

protected Artist getByCompanyId_PrevAndNext(Session session, Artist artist, long companyId, 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_ARTIST_WHERE);
    query.append(_FINDER_COLUMN_COMPANYID_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(ArtistModelImpl.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(companyId);
    if (orderByComparator != null) {
        Object[] values = orderByComparator.getOrderByConditionValues(artist);
        for (Object value : values) {
            qPos.add(value);
        }
    }
    List<Artist> list = q.list();
    if (list.size() == 2) {
        return list.get(1);
    } else {
        return null;
    }
}
Also used : Artist(org.liferay.jukebox.model.Artist) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

StringBundler (com.liferay.portal.kernel.util.StringBundler)790 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)469 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)413 Session (com.liferay.portal.kernel.dao.orm.Session)365 Query (com.liferay.portal.kernel.dao.orm.Query)361 SystemException (com.liferay.portal.kernel.exception.SystemException)338 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)214 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)203 KBArticle (com.liferay.knowledgebase.model.KBArticle)203 List (java.util.List)180 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)173 ArrayList (java.util.ArrayList)173 Song (org.liferay.jukebox.model.Song)64 NoSuchSongException (org.liferay.jukebox.NoSuchSongException)61 Album (org.liferay.jukebox.model.Album)58 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)54 Artist (org.liferay.jukebox.model.Artist)47 NoSuchArtistException (org.liferay.jukebox.NoSuchArtistException)44 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)38 KBComment (com.liferay.knowledgebase.model.KBComment)36