Search in sources :

Example 46 with Album

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

the class AlbumStagedModelDataHandler method doRestoreStagedModel.

@Override
protected void doRestoreStagedModel(PortletDataContext portletDataContext, Album album) throws Exception {
    long userId = portletDataContext.getUserId(album.getUserUuid());
    Album existingAlbum = AlbumLocalServiceUtil.fetchAlbumByUuidAndGroupId(album.getUuid(), portletDataContext.getScopeGroupId());
    if ((existingAlbum == null) || !existingAlbum.isInTrash()) {
        return;
    }
    TrashHandler trashHandler = existingAlbum.getTrashHandler();
    if (trashHandler.isRestorable(existingAlbum.getAlbumId())) {
        trashHandler.restoreTrashEntry(userId, existingAlbum.getAlbumId());
    }
}
Also used : TrashHandler(com.liferay.portal.kernel.trash.TrashHandler) Album(org.liferay.jukebox.model.Album)

Example 47 with Album

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

the class AlbumModelImpl method equals.

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

Example 48 with Album

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

the class AlbumModelImpl method toModel.

/**
 * Converts the soap model instance into a normal model instance.
 *
 * @param soapModel the soap model instance to convert
 * @return the normal model instance
 */
public static Album toModel(AlbumSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    Album model = new AlbumImpl();
    model.setUuid(soapModel.getUuid());
    model.setAlbumId(soapModel.getAlbumId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setGroupId(soapModel.getGroupId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setArtistId(soapModel.getArtistId());
    model.setName(soapModel.getName());
    model.setYear(soapModel.getYear());
    model.setStatus(soapModel.getStatus());
    model.setStatusByUserId(soapModel.getStatusByUserId());
    model.setStatusByUserName(soapModel.getStatusByUserName());
    model.setStatusDate(soapModel.getStatusDate());
    return model;
}
Also used : Album(org.liferay.jukebox.model.Album)

Example 49 with Album

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

the class AlbumStagedModelDataHandler method doImportStagedModel.

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, Album album) throws Exception {
    long userId = portletDataContext.getUserId(album.getUserUuid());
    ServiceContext serviceContext = portletDataContext.createServiceContext(album);
    String artistPath = ExportImportPathUtil.getModelPath(portletDataContext, Artist.class.getName(), album.getArtistId());
    Artist artist = (Artist) portletDataContext.getZipEntryAsObject(artistPath);
    if (artist != null) {
        StagedModelDataHandlerUtil.importReferenceStagedModel(portletDataContext, album, Artist.class, album.getArtistId());
    }
    Map<Long, Long> artistIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Artist.class);
    long artistId = MapUtil.getLong(artistIds, album.getArtistId(), album.getArtistId());
    Album importedAlbum = null;
    if (portletDataContext.isDataStrategyMirror()) {
        Album existingAlbum = AlbumLocalServiceUtil.fetchAlbumByUuidAndGroupId(album.getUuid(), portletDataContext.getScopeGroupId());
        if (existingAlbum == null) {
            serviceContext.setUuid(album.getUuid());
            importedAlbum = AlbumLocalServiceUtil.addAlbum(userId, artistId, album.getName(), album.getYear(), null, serviceContext);
        } else {
            importedAlbum = AlbumLocalServiceUtil.updateAlbum(userId, existingAlbum.getAlbumId(), artistId, album.getName(), album.getYear(), null, serviceContext);
        }
    } else {
        importedAlbum = AlbumLocalServiceUtil.addAlbum(userId, artistId, album.getName(), album.getYear(), null, serviceContext);
    }
    Element albumElement = portletDataContext.getImportDataStagedModelElement(album);
    List<Element> attachmentElements = portletDataContext.getReferenceDataElements(albumElement, FileEntry.class, PortletDataContext.REFERENCE_TYPE_WEAK);
    for (Element attachmentElement : attachmentElements) {
        String path = attachmentElement.attributeValue("path");
        FileEntry fileEntry = (FileEntry) portletDataContext.getZipEntryAsObject(path);
        InputStream inputStream = null;
        try {
            String binPath = attachmentElement.attributeValue("bin-path");
            if (Validator.isNull(binPath) && portletDataContext.isPerformDirectBinaryImport()) {
                try {
                    inputStream = _getContentStream(fileEntry);
                } catch (NoSuchFileException nsfe) {
                }
            } else {
                inputStream = portletDataContext.getZipEntryAsInputStream(binPath);
            }
            if (inputStream == null) {
                if (_log.isWarnEnabled()) {
                    _log.warn("Unable to import attachment for file entry " + fileEntry.getFileEntryId());
                }
                continue;
            }
            importedAlbum = AlbumLocalServiceUtil.updateAlbum(userId, importedAlbum.getAlbumId(), importedAlbum.getArtistId(), importedAlbum.getName(), importedAlbum.getYear(), inputStream, serviceContext);
        } finally {
            StreamUtil.cleanUp(inputStream);
        }
    }
    portletDataContext.importClassedModel(album, importedAlbum);
}
Also used : Artist(org.liferay.jukebox.model.Artist) ServiceContext(com.liferay.portal.service.ServiceContext) UnsyncByteArrayInputStream(com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream) InputStream(java.io.InputStream) Element(com.liferay.portal.kernel.xml.Element) NoSuchFileException(com.liferay.portlet.documentlibrary.NoSuchFileException) Album(org.liferay.jukebox.model.Album) FileEntry(com.liferay.portal.kernel.repository.model.FileEntry) DLFileEntry(com.liferay.portlet.documentlibrary.model.DLFileEntry) Map(java.util.Map)

Example 50 with Album

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

the class AlbumExportActionableDynamicQuery method performAction.

@Override
@SuppressWarnings("unused")
protected void performAction(Object object) throws PortalException, SystemException {
    Album stagedModel = (Album) object;
    StagedModelDataHandlerUtil.exportStagedModel(_portletDataContext, stagedModel);
}
Also used : Album(org.liferay.jukebox.model.Album)

Aggregations

Album (org.liferay.jukebox.model.Album)97 NoSuchAlbumException (org.liferay.jukebox.NoSuchAlbumException)55 StringBundler (com.liferay.portal.kernel.util.StringBundler)53 SystemException (com.liferay.portal.kernel.exception.SystemException)37 Session (com.liferay.portal.kernel.dao.orm.Session)34 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)32 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)31 Query (com.liferay.portal.kernel.dao.orm.Query)22 AlbumImpl (org.liferay.jukebox.model.impl.AlbumImpl)18 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)17 ArrayList (java.util.ArrayList)17 List (java.util.List)17 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)11 Indexable (com.liferay.portal.kernel.search.Indexable)8 User (com.liferay.portal.model.User)6 Song (org.liferay.jukebox.model.Song)6 ServiceContext (com.liferay.portal.service.ServiceContext)4 Date (java.util.Date)4 Artist (org.liferay.jukebox.model.Artist)4 PortalException (com.liferay.portal.kernel.exception.PortalException)3