Search in sources :

Example 41 with Artist

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

the class ArtistModelImpl method equals.

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

Example 42 with Artist

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

the class ArtistModelImpl 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 Artist toModel(ArtistSoap soapModel) {
    if (soapModel == null) {
        return null;
    }
    Artist model = new ArtistImpl();
    model.setUuid(soapModel.getUuid());
    model.setArtistId(soapModel.getArtistId());
    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.setStatus(soapModel.getStatus());
    model.setStatusByUserId(soapModel.getStatusByUserId());
    model.setStatusByUserName(soapModel.getStatusByUserName());
    model.setStatusDate(soapModel.getStatusDate());
    model.setName(soapModel.getName());
    model.setBio(soapModel.getBio());
    return model;
}
Also used : Artist(org.liferay.jukebox.model.Artist)

Example 43 with Artist

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

the class ArtistExportActionableDynamicQuery method performAction.

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

Example 44 with Artist

use of org.liferay.jukebox.model.Artist 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 45 with Artist

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

the class ArtistStagedModelDataHandler method doRestoreStagedModel.

@Override
protected void doRestoreStagedModel(PortletDataContext portletDataContext, Artist artist) throws Exception {
    long userId = portletDataContext.getUserId(artist.getUserUuid());
    Artist existingArtist = ArtistLocalServiceUtil.fetchArtistByUuidAndGroupId(artist.getUuid(), portletDataContext.getScopeGroupId());
    if ((existingArtist == null) || !existingArtist.isInTrash()) {
        return;
    }
    TrashHandler trashHandler = existingArtist.getTrashHandler();
    if (trashHandler.isRestorable(existingArtist.getArtistId())) {
        trashHandler.restoreTrashEntry(userId, existingArtist.getArtistId());
    }
}
Also used : Artist(org.liferay.jukebox.model.Artist) TrashHandler(com.liferay.portal.kernel.trash.TrashHandler)

Aggregations

Artist (org.liferay.jukebox.model.Artist)79 NoSuchArtistException (org.liferay.jukebox.NoSuchArtistException)45 StringBundler (com.liferay.portal.kernel.util.StringBundler)43 SystemException (com.liferay.portal.kernel.exception.SystemException)30 Session (com.liferay.portal.kernel.dao.orm.Session)28 SQLQuery (com.liferay.portal.kernel.dao.orm.SQLQuery)26 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)25 Query (com.liferay.portal.kernel.dao.orm.Query)18 ArrayList (java.util.ArrayList)15 ArtistImpl (org.liferay.jukebox.model.impl.ArtistImpl)15 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)14 List (java.util.List)14 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)9 Document (com.liferay.portal.kernel.search.Document)5 DLFileEntry (com.liferay.portlet.documentlibrary.model.DLFileEntry)4 Album (org.liferay.jukebox.model.Album)4 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)3 Indexable (com.liferay.portal.kernel.search.Indexable)3 Element (com.liferay.portal.kernel.xml.Element)3 PortalException (com.liferay.portal.kernel.exception.PortalException)2