Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH.

Prototype

int STATUS_IN_TRASH

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH.

Click Source Link

Usage

From source file:org.liferay.jukebox.service.impl.AlbumLocalServiceImpl.java

License:Open Source License

@Indexable(type = IndexableType.REINDEX)
@Override/*from   www  . j a va  2s  . c  o  m*/
public Album moveAlbumToTrash(long userId, long albumId) throws PortalException, SystemException {

    ServiceContext serviceContext = new ServiceContext();

    // Folder

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    Album album = albumPersistence.findByPrimaryKey(albumId);

    int oldStatus = album.getStatus();

    album.setModifiedDate(serviceContext.getModifiedDate(now));
    album.setStatus(WorkflowConstants.STATUS_IN_TRASH);
    album.setStatusByUserId(user.getUserId());
    album.setStatusByUserName(user.getFullName());
    album.setStatusDate(serviceContext.getModifiedDate(now));

    albumPersistence.update(album);

    // Asset

    assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), false);

    // Trash

    TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, album.getGroupId(),
            Album.class.getName(), album.getAlbumId(), album.getUuid(), null, oldStatus, null, null);

    // Folders and entries

    List<Song> songs = songLocalService.getSongsByAlbumId(album.getAlbumId());

    moveDependentsToTrash(songs, trashEntry.getEntryId());

    return album;
}

From source file:org.liferay.jukebox.service.impl.AlbumLocalServiceImpl.java

License:Open Source License

@Indexable(type = IndexableType.REINDEX)
@Override//from   ww  w. j av  a 2s. c o  m
public Album restoreAlbumFromTrash(long userId, long albumId) throws PortalException, SystemException {

    ServiceContext serviceContext = new ServiceContext();

    // Folder

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    Album album = albumPersistence.findByPrimaryKey(albumId);

    TrashEntry trashEntry = trashEntryLocalService.getEntry(Album.class.getName(), albumId);

    album.setModifiedDate(serviceContext.getModifiedDate(now));
    album.setStatus(trashEntry.getStatus());
    album.setStatusByUserId(user.getUserId());
    album.setStatusByUserName(user.getFullName());
    album.setStatusDate(serviceContext.getModifiedDate(now));

    albumPersistence.update(album);

    assetEntryLocalService.updateVisible(Album.class.getName(), album.getAlbumId(), true);

    // Songs

    List<Song> songs = songLocalService.getSongsByAlbumId(album.getGroupId(), album.getAlbumId(),
            WorkflowConstants.STATUS_IN_TRASH);

    restoreDependentsFromTrash(songs, trashEntry.getEntryId());

    // Trash

    trashEntryLocalService.deleteEntry(trashEntry.getEntryId());

    return album;
}

From source file:org.liferay.jukebox.service.impl.AlbumLocalServiceImpl.java

License:Open Source License

protected void moveDependentsToTrash(List<Song> songs, long trashEntryId)
        throws PortalException, SystemException {

    for (Song song : songs) {

        // Entry//w  w w  . ja v a 2 s  .c  om

        if (song.isInTrash()) {
            continue;
        }

        int oldStatus = song.getStatus();

        song.setStatus(WorkflowConstants.STATUS_IN_TRASH);

        songPersistence.update(song);

        // Trash

        int status = oldStatus;

        if (oldStatus == WorkflowConstants.STATUS_PENDING) {
            status = WorkflowConstants.STATUS_DRAFT;
        }

        if (oldStatus != WorkflowConstants.STATUS_APPROVED) {
            trashVersionLocalService.addTrashVersion(trashEntryId, Song.class.getName(), song.getSongId(),
                    status, null);
        }

        // Asset

        assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);

        // Indexer

        Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);

        indexer.reindex(song);
    }
}

From source file:org.liferay.jukebox.service.impl.SongLocalServiceImpl.java

License:Open Source License

@Indexable(type = IndexableType.REINDEX)
public Song moveSongToTrash(long userId, Song song) throws PortalException, SystemException {

    ServiceContext serviceContext = new ServiceContext();

    // Entry/*  w w  w .j a  va2s  .c  o  m*/

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    int oldStatus = song.getStatus();

    song.setModifiedDate(serviceContext.getModifiedDate(now));
    song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
    song.setStatusByUserId(user.getUserId());
    song.setStatusByUserName(user.getFullName());
    song.setStatusDate(serviceContext.getModifiedDate(now));

    // Asset

    assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);

    // Trash

    UnicodeProperties typeSettingsProperties = new UnicodeProperties();

    typeSettingsProperties.put("title", song.getName());

    TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, song.getGroupId(),
            Song.class.getName(), song.getSongId(), song.getUuid(), null, oldStatus, null,
            typeSettingsProperties);

    song.setName(TrashUtil.getTrashTitle(trashEntry.getEntryId()));

    songPersistence.update(song);

    return song;
}

From source file:ua.org.gostroy.guestbook.service.persistence.EntryExportActionableDynamicQuery.java

License:Open Source License

@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
    Criterion modifiedDateCriterion = _portletDataContext.getDateRangeCriteria("modifiedDate");
    Criterion statusDateCriterion = _portletDataContext.getDateRangeCriteria("statusDate");

    if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
        Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

        disjunction.add(modifiedDateCriterion);
        disjunction.add(statusDateCriterion);

        dynamicQuery.add(disjunction);//w  w w.j av a 2 s.  co m
    }

    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");

    if (_portletDataContext.isInitialPublication()) {
        dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
    } else {
        StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                .getStagedModelDataHandler(Entry.class.getName());

        dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
    }
}

From source file:ua.org.gostroy.guestbook.service.persistence.GuestbookExportActionableDynamicQuery.java

License:Open Source License

@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
    Criterion modifiedDateCriterion = _portletDataContext.getDateRangeCriteria("modifiedDate");
    Criterion statusDateCriterion = _portletDataContext.getDateRangeCriteria("statusDate");

    if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
        Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

        disjunction.add(modifiedDateCriterion);
        disjunction.add(statusDateCriterion);

        dynamicQuery.add(disjunction);/*from   w  w w. j a  v  a  2  s  . c  om*/
    }

    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");

    if (_portletDataContext.isInitialPublication()) {
        dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
    } else {
        StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                .getStagedModelDataHandler(Guestbook.class.getName());

        dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
    }
}