Example usage for com.liferay.portal.kernel.diff DiffVersion DiffVersion

List of usage examples for com.liferay.portal.kernel.diff DiffVersion DiffVersion

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.diff DiffVersion DiffVersion.

Prototype

public DiffVersion(long userId, double version, Date modifiedDate) 

Source Link

Usage

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static DiffVersionsInfo getDiffVersionsInfo(long groupId, String articleId, double sourceVersion,
        double targetVersion) {

    double previousVersion = 0;
    double nextVersion = 0;

    List<JournalArticle> articles = JournalArticleServiceUtil.getArticlesByArticleId(groupId, articleId,
            QueryUtil.ALL_POS, QueryUtil.ALL_POS, new ArticleVersionComparator(true));

    for (JournalArticle article : articles) {
        if ((article.getVersion() < sourceVersion) && (article.getVersion() > previousVersion)) {

            previousVersion = article.getVersion();
        }//from  w w  w  .  j av  a  2  s.  co m

        if ((article.getVersion() > targetVersion)
                && ((article.getVersion() < nextVersion) || (nextVersion == 0))) {

            nextVersion = article.getVersion();
        }
    }

    List<DiffVersion> diffVersions = new ArrayList<>();

    for (JournalArticle article : articles) {
        DiffVersion diffVersion = new DiffVersion(article.getUserId(), article.getVersion(),
                article.getModifiedDate());

        diffVersions.add(diffVersion);
    }

    return new DiffVersionsInfo(diffVersions, nextVersion, previousVersion);
}