Search in sources :

Example 81 with Song

use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.

the class SongPersistenceImpl method findByG_S_Last.

/**
 * Returns the last song in the ordered set where groupId = ? and status = ?.
 *
 * @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 song
 * @throws org.liferay.jukebox.NoSuchSongException if a matching song could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song findByG_S_Last(long groupId, int status, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = fetchByG_S_Last(groupId, status, orderByComparator);
    if (song != null) {
        return song;
    }
    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 NoSuchSongException(msg.toString());
}
Also used : Song(org.liferay.jukebox.model.Song) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Example 82 with Song

use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.

the class SongPersistenceImpl method findByCompanyId_PrevAndNext.

/**
 * Returns the songs before and after the current song in the ordered set where companyId = &#63;.
 *
 * @param songId the primary key of the current song
 * @param companyId the company 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[] findByCompanyId_PrevAndNext(long songId, long companyId, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = getByCompanyId_PrevAndNext(session, song, companyId, orderByComparator, true);
        array[1] = song;
        array[2] = getByCompanyId_PrevAndNext(session, song, companyId, 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 83 with Song

use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.

the class SongPersistenceImpl method fetchByG_A_A_N.

/**
 * Returns the song where groupId = &#63; and artistId = &#63; and albumId = &#63; and name = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
 *
 * @param groupId the group ID
 * @param artistId the artist ID
 * @param albumId the album ID
 * @param name the name
 * @param retrieveFromCache whether to use the finder cache
 * @return the matching song, or <code>null</code> if a matching song could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public Song fetchByG_A_A_N(long groupId, long artistId, long albumId, String name, boolean retrieveFromCache) throws SystemException {
    Object[] finderArgs = new Object[] { groupId, artistId, albumId, name };
    Object result = null;
    if (retrieveFromCache) {
        result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_A_A_N, finderArgs, this);
    }
    if (result instanceof Song) {
        Song song = (Song) result;
        if ((groupId != song.getGroupId()) || (artistId != song.getArtistId()) || (albumId != song.getAlbumId()) || !Validator.equals(name, song.getName())) {
            result = null;
        }
    }
    if (result == null) {
        StringBundler query = new StringBundler(6);
        query.append(_SQL_SELECT_SONG_WHERE);
        query.append(_FINDER_COLUMN_G_A_A_N_GROUPID_2);
        query.append(_FINDER_COLUMN_G_A_A_N_ARTISTID_2);
        query.append(_FINDER_COLUMN_G_A_A_N_ALBUMID_2);
        boolean bindName = false;
        if (name == null) {
            query.append(_FINDER_COLUMN_G_A_A_N_NAME_1);
        } else if (name.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_G_A_A_N_NAME_3);
        } else {
            bindName = true;
            query.append(_FINDER_COLUMN_G_A_A_N_NAME_2);
        }
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(groupId);
            qPos.add(artistId);
            qPos.add(albumId);
            if (bindName) {
                qPos.add(name);
            }
            List<Song> list = q.list();
            if (list.isEmpty()) {
                FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_A_N, finderArgs, list);
            } else {
                Song song = list.get(0);
                result = song;
                cacheResult(song);
                if ((song.getGroupId() != groupId) || (song.getArtistId() != artistId) || (song.getAlbumId() != albumId) || (song.getName() == null) || !song.getName().equals(name)) {
                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_A_A_N, finderArgs, song);
                }
            }
        } catch (Exception e) {
            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_A_A_N, finderArgs);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    if (result instanceof List<?>) {
        return null;
    } else {
        return (Song) result;
    }
}
Also used : Song(org.liferay.jukebox.model.Song) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) ArrayList(java.util.ArrayList) UnmodifiableList(com.liferay.portal.kernel.util.UnmodifiableList) List(java.util.List) 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 84 with Song

use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.

the class SongPersistenceImpl method filterFindByG_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 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[] filterFindByG_S_PrevAndNext(long songId, long groupId, int status, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_S_PrevAndNext(songId, groupId, status, orderByComparator);
    }
    Song song = findByPrimaryKey(songId);
    Session session = null;
    try {
        session = openSession();
        Song[] array = new SongImpl[3];
        array[0] = filterGetByG_S_PrevAndNext(session, song, groupId, status, orderByComparator, true);
        array[1] = song;
        array[2] = filterGetByG_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 85 with Song

use of org.liferay.jukebox.model.Song in project liferay-ide by liferay.

the class SongPersistenceImpl method filterFindByG_S.

/**
 * Returns an ordered range of all the songs that the user has permissions to view where groupId = &#63; and status = &#63;.
 *
 * <p>
 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link org.liferay.jukebox.model.impl.SongModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order.
 * </p>
 *
 * @param groupId the group ID
 * @param status the status
 * @param start the lower bound of the range of songs
 * @param end the upper bound of the range of songs (not inclusive)
 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
 * @return the ordered range of matching songs that the user has permission to view
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Song> filterFindByG_S(long groupId, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    if (!InlineSQLHelperUtil.isEnabled(groupId)) {
        return findByG_S(groupId, status, start, end, orderByComparator);
    }
    StringBundler query = null;
    if (orderByComparator != null) {
        query = new StringBundler(4 + (orderByComparator.getOrderByFields().length * 3));
    } else {
        query = new StringBundler(4);
    }
    if (getDB().isSupportsInlineDistinct()) {
        query.append(_FILTER_SQL_SELECT_SONG_WHERE);
    } else {
        query.append(_FILTER_SQL_SELECT_SONG_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_SONG_NO_INLINE_DISTINCT_WHERE_2);
    }
    if (orderByComparator != null) {
        if (getDB().isSupportsInlineDistinct()) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator, true);
        } else {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator, true);
        }
    } else {
        if (getDB().isSupportsInlineDistinct()) {
            query.append(SongModelImpl.ORDER_BY_JPQL);
        } else {
            query.append(SongModelImpl.ORDER_BY_SQL);
        }
    }
    String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Song.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);
    Session session = null;
    try {
        session = openSession();
        SQLQuery q = session.createSQLQuery(sql);
        if (getDB().isSupportsInlineDistinct()) {
            q.addEntity(_FILTER_ENTITY_ALIAS, SongImpl.class);
        } else {
            q.addEntity(_FILTER_ENTITY_TABLE, SongImpl.class);
        }
        QueryPos qPos = QueryPos.getInstance(q);
        qPos.add(groupId);
        qPos.add(status);
        return (List<Song>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}
Also used : Song(org.liferay.jukebox.model.Song) ArrayList(java.util.ArrayList) UnmodifiableList(com.liferay.portal.kernel.util.UnmodifiableList) List(java.util.List) SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) 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)

Aggregations

Song (org.liferay.jukebox.model.Song)110 NoSuchSongException (org.liferay.jukebox.NoSuchSongException)61 StringBundler (com.liferay.portal.kernel.util.StringBundler)59 SystemException (com.liferay.portal.kernel.exception.SystemException)39 Session (com.liferay.portal.kernel.dao.orm.Session)37 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)35 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)34 Query (com.liferay.portal.kernel.dao.orm.Query)25 ArrayList (java.util.ArrayList)22 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)19 List (java.util.List)19 SongImpl (org.liferay.jukebox.model.impl.SongImpl)19 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)12 Indexable (com.liferay.portal.kernel.search.Indexable)9 User (com.liferay.portal.model.User)7 ServiceContext (com.liferay.portal.service.ServiceContext)6 TrashEntry (com.liferay.portlet.trash.model.TrashEntry)6 Date (java.util.Date)6 Album (org.liferay.jukebox.model.Album)6 Folder (com.liferay.portal.kernel.repository.model.Folder)3