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;
}
}
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;
}
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);
}
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);
}
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());
}
}
Aggregations