diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 1f5d31ea..4874bd7b 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -1,5 +1,10 @@ package one.nem.lacerta.vcs; +import java.util.ArrayList; +import java.util.concurrent.CompletableFuture; + +import one.nem.lacerta.model.VcsRevModel; + public interface LacertaVcs { // Actions @@ -13,6 +18,8 @@ public interface LacertaVcs { public void generateRevisionAtCurrent(String message); + public CompletableFuture> getRevisionHistoryByDocumentId(String documentId); + // debug public void printLog(); diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index 89cd8d2d..347c138a 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -3,11 +3,13 @@ package one.nem.lacerta.vcs.impl; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.CompletableFuture; import javax.inject.Inject; import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; +import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; @@ -122,6 +124,26 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id); } + @Override + public CompletableFuture> getRevisionHistoryByDocumentId(String documentId) { + return CompletableFuture.supplyAsync(() -> { + logger.debug(TAG, "getRevisionHistoryByDocumentId"); + ArrayList vcsRevModels = new ArrayList<>(); + + List vcsRevEntities = database.vcsRevDao().findByDocumentId(documentId); + vcsRevEntities.forEach(vcsRevEntity -> { + VcsRevModel vcsRevModel = new VcsRevModel(); + vcsRevModel.setDocumentId(vcsRevEntity.documentId); + vcsRevModel.setBranchName(vcsRevEntity.branchName); + vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage); + vcsRevModel.setLogIds(vcsRevEntity.logIds); + vcsRevModels.add(vcsRevModel); + }); + + return vcsRevModels; + }); + } + @Override public void printLog() { logger.debug(TAG, "printLog");