Search in sources :

Example 56 with Song

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

the class SongModelImpl method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof Song)) {
        return false;
    }
    Song song = (Song) obj;
    long primaryKey = song.getPrimaryKey();
    if (getPrimaryKey() == primaryKey) {
        return true;
    } else {
        return false;
    }
}
Also used : Song(org.liferay.jukebox.model.Song)

Example 57 with Song

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

the class JukeboxPortlet method deleteSong.

public void deleteSong(ActionRequest request, ActionResponse response) throws Exception {
    long songId = ParamUtil.getLong(request, "songId");
    boolean moveToTrash = ParamUtil.getBoolean(request, "moveToTrash");
    ServiceContext serviceContext = ServiceContextFactory.getInstance(Song.class.getName(), request);
    try {
        if (moveToTrash) {
            Song song = SongServiceUtil.moveSongToTrash(songId);
            Map<String, String[]> data = new HashMap<String, String[]>();
            data.put("deleteEntryClassName", new String[] { Song.class.getName() });
            data.put("deleteEntryTitle", new String[] { TrashUtil.getOriginalTitle(song.getName()) });
            data.put("restoreEntryIds", new String[] { String.valueOf(songId) });
            SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_DELETE_SUCCESS_DATA, data);
            SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);
        } else {
            SongServiceUtil.deleteSong(songId, serviceContext);
            SessionMessages.add(request, "songDeleted");
        }
        sendRedirect(request, response);
    } catch (Exception e) {
        SessionErrors.add(request, e.getClass().getName());
        response.setRenderParameter("jspPage", "/html/error.jsp");
    }
}
Also used : Song(org.liferay.jukebox.model.Song) HashMap(java.util.HashMap) ServiceContext(com.liferay.portal.service.ServiceContext) SongNameException(org.liferay.jukebox.SongNameException) PrincipalException(com.liferay.portal.security.auth.PrincipalException) DuplicatedSongException(org.liferay.jukebox.DuplicatedSongException) AlbumNameException(org.liferay.jukebox.AlbumNameException) ArtistNameException(org.liferay.jukebox.ArtistNameException)

Example 58 with Song

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

the class SongPersistenceImpl method findByG_LikeN_S.

/**
 * Returns an ordered range of all the songs where groupId = &#63; and name LIKE &#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 name the name
 * @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
 * @throws SystemException if a system exception occurred
 */
@Override
public List<Song> findByG_LikeN_S(long groupId, String name, int status, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;
    finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_G_LIKEN_S;
    finderArgs = new Object[] { groupId, name, status, start, end, orderByComparator };
    List<Song> list = (List<Song>) FinderCacheUtil.getResult(finderPath, finderArgs, this);
    if ((list != null) && !list.isEmpty()) {
        for (Song song : list) {
            if ((groupId != song.getGroupId()) || !StringUtil.wildcardMatches(song.getName(), name, CharPool.UNDERLINE, CharPool.PERCENT, CharPool.BACK_SLASH, false) || (status != song.getStatus())) {
                list = null;
                break;
            }
        }
    }
    if (list == null) {
        StringBundler query = null;
        if (orderByComparator != null) {
            query = new StringBundler(5 + (orderByComparator.getOrderByFields().length * 3));
        } else {
            query = new StringBundler(5);
        }
        query.append(_SQL_SELECT_SONG_WHERE);
        query.append(_FINDER_COLUMN_G_LIKEN_S_GROUPID_2);
        boolean bindName = false;
        if (name == null) {
            query.append(_FINDER_COLUMN_G_LIKEN_S_NAME_1);
        } else if (name.equals(StringPool.BLANK)) {
            query.append(_FINDER_COLUMN_G_LIKEN_S_NAME_3);
        } else {
            bindName = true;
            query.append(_FINDER_COLUMN_G_LIKEN_S_NAME_2);
        }
        query.append(_FINDER_COLUMN_G_LIKEN_S_STATUS_2);
        if (orderByComparator != null) {
            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
        } else if (pagination) {
            query.append(SongModelImpl.ORDER_BY_JPQL);
        }
        String sql = query.toString();
        Session session = null;
        try {
            session = openSession();
            Query q = session.createQuery(sql);
            QueryPos qPos = QueryPos.getInstance(q);
            qPos.add(groupId);
            if (bindName) {
                qPos.add(name.toLowerCase());
            }
            qPos.add(status);
            if (!pagination) {
                list = (List<Song>) QueryUtil.list(q, getDialect(), start, end, false);
                Collections.sort(list);
                list = new UnmodifiableList<Song>(list);
            } else {
                list = (List<Song>) QueryUtil.list(q, getDialect(), start, end);
            }
            cacheResult(list);
            FinderCacheUtil.putResult(finderPath, finderArgs, list);
        } catch (Exception e) {
            FinderCacheUtil.removeResult(finderPath, finderArgs);
            throw processException(e);
        } finally {
            closeSession(session);
        }
    }
    return list;
}
Also used : SQLQuery(com.liferay.portal.kernel.dao.orm.SQLQuery) Query(com.liferay.portal.kernel.dao.orm.Query) StringBundler(com.liferay.portal.kernel.util.StringBundler) SystemException(com.liferay.portal.kernel.exception.SystemException) NoSuchSongException(org.liferay.jukebox.NoSuchSongException) Song(org.liferay.jukebox.model.Song) FinderPath(com.liferay.portal.kernel.dao.orm.FinderPath) ArrayList(java.util.ArrayList) UnmodifiableList(com.liferay.portal.kernel.util.UnmodifiableList) List(java.util.List) QueryPos(com.liferay.portal.kernel.dao.orm.QueryPos) Session(com.liferay.portal.kernel.dao.orm.Session)

Example 59 with Song

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

the class SongPersistenceImpl method create.

/**
 * Creates a new song with the primary key. Does not add the song to the database.
 *
 * @param songId the primary key for the new song
 * @return the new song
 */
@Override
public Song create(long songId) {
    Song song = new SongImpl();
    song.setNew(true);
    song.setPrimaryKey(songId);
    String uuid = PortalUUIDUtil.generate();
    song.setUuid(uuid);
    return song;
}
Also used : Song(org.liferay.jukebox.model.Song) SongImpl(org.liferay.jukebox.model.impl.SongImpl)

Example 60 with Song

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

the class SongPersistenceImpl method findByUuid_C_Last.

/**
 * Returns the last song in the ordered set where uuid = &#63; and companyId = &#63;.
 *
 * @param uuid the uuid
 * @param companyId the company ID
 * @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 findByUuid_C_Last(String uuid, long companyId, OrderByComparator orderByComparator) throws NoSuchSongException, SystemException {
    Song song = fetchByUuid_C_Last(uuid, companyId, orderByComparator);
    if (song != null) {
        return song;
    }
    StringBundler msg = new StringBundler(6);
    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
    msg.append("uuid=");
    msg.append(uuid);
    msg.append(", companyId=");
    msg.append(companyId);
    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)

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