List of usage examples for com.liferay.portal.kernel.diff DiffVersion DiffVersion
public DiffVersion(long userId, double version, Date modifiedDate)
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); }