Search in sources :

Example 86 with Session

use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.

the class SongPersistenceImpl method countByUserId.

/**
 * Returns the number of songs where userId = ?.
 *
 * @param userId the user ID
 * @return the number of matching songs
 * @throws SystemException if a system exception occurred
 */
@Override
public int countByUserId(long userId) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;
    Object[] finderArgs = new Object[] { userId };
    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);
    if (count == null) {
        StringBundler query = new StringBundler(2);
        query.append(_SQL_COUNT_SONG_WHERE);
        query.append(_FINDER_COLUMN_USERID_USERID_2);
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(userId);
            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) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 87 with Session

use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.

the class SongPersistenceImpl method findByGroupId_PrevAndNext.

/**
 * Returns the songs before and after the current song in the ordered set where groupId = ?.
 *
 * @param songId the primary key of the current song
 * @param groupId the group ID
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next song
 * @throws org.liferay.jukebox.NoSuchSongException if a song with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song[] findByGroupId_PrevAndNext(long songId, long groupId, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = getByGroupId_PrevAndNext(session, song, groupId, orderByComparator, true);
        array[1] = song;
        array[2] = getByGroupId_PrevAndNext(session, song, groupId, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SongImpl(org.liferay.jukebox.model.impl.SongImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 88 with Session

use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.

the class SongPersistenceImpl method findByG_S_PrevAndNext.

/**
 * Returns the songs before and after the current song in the ordered set where groupId = &#63; and status = &#63;.
 *
 * @param songId the primary key of the current song
 * @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 song
 * @throws org.liferay.jukebox.NoSuchSongException if a song with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song[] findByG_S_PrevAndNext(long songId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = getByG_S_PrevAndNext(session, song, groupId, status, orderByComparator, true);
        array[1] = song;
        array[2] = getByG_S_PrevAndNext(session, song, groupId, status, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SongImpl(org.liferay.jukebox.model.impl.SongImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 89 with Session

use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.

the class SongPersistenceImpl method findByG_A_S_PrevAndNext.

/**
 * Returns the songs before and after the current song in the ordered set where groupId = &#63; and albumId = &#63; and status = &#63;.
 *
 * @param songId the primary key of the current song
 * @param groupId the group ID
 * @param albumId the album ID
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next song
 * @throws org.liferay.jukebox.NoSuchSongException if a song with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song[] findByG_A_S_PrevAndNext(long songId, long groupId, long albumId, int status, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = getByG_A_S_PrevAndNext(session, song, groupId, albumId, status, orderByComparator, true);
        array[1] = song;
        array[2] = getByG_A_S_PrevAndNext(session, song, groupId, albumId, status, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SongImpl(org.liferay.jukebox.model.impl.SongImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 90 with Session

use of com.liferay.portal.kernel.dao.orm.Session in project liferay-ide by liferay.

the class SongPersistenceImpl method filterFindByG_LikeN_S_PrevAndNext.

/**
 * Returns the songs before and after the current song in the ordered set of songs that the user has permission to view where groupId = &#63; and name LIKE &#63; and status = &#63;.
 *
 * @param songId the primary key of the current song
 * @param groupId the group ID
 * @param name the name
 * @param status the status
 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
 * @return the previous, current, and next song
 * @throws org.liferay.jukebox.NoSuchSongException if a song with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song[] filterFindByG_LikeN_S_PrevAndNext(long songId, long groupId, String name, int status, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_LikeN_S_PrevAndNext(songId, groupId, name, status, orderByComparator);
    }
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = filterGetByG_LikeN_S_PrevAndNext(session, song, groupId, name, status, orderByComparator, true);
        array[1] = song;
        array[2] = filterGetByG_LikeN_S_PrevAndNext(session, song, groupId, name, status, orderByComparator, false);
        return array;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SongImpl(org.liferay.jukebox.model.impl.SongImpl) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Session(com.liferay.portal.kernel.dao.orm.Session)

Aggregations

Session (com.liferay.portal.kernel.dao.orm.Session)579 SystemException (com.liferay.portal.kernel.exception.SystemException)509 StringBundler (com.liferay.portal.kernel.util.StringBundler)365 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)344 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)314 Query (com.liferay.portal.kernel.dao.orm.Query)288 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)214 NoSuchArticleException (com.liferay.knowledgebase.NoSuchArticleException)194 List (java.util.List)181 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)173 ArrayList (java.util.ArrayList)173 KBArticle (com.liferay.knowledgebase.model.KBArticle)145 NoSuchSongException (org.liferay.jukebox.NoSuchSongException)58 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)53 KBArticleImpl (com.liferay.knowledgebase.model.impl.KBArticleImpl)46 NoSuchArtistException (org.liferay.jukebox.NoSuchArtistException)44 Song (org.liferay.jukebox.model.Song)42 Album (org.liferay.jukebox.model.Album)39 NoSuchCommentException (com.liferay.knowledgebase.NoSuchCommentException)34 NoSuchNodeException (com.liferay.portlet.wiki.NoSuchNodeException)34