From 07e14eb90c4701b8c9c4f4d24b98366037e9af4a Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 01:27:11 +0900 Subject: [PATCH] =?UTF-8?q?getRevisionHistoryByDocumentId=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/LacertaVcs.java | 7 ++++++ .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+) 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");