From b6f0a5554a3066f0343d93b14d0d8f32c44c0ca1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:49:17 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0,=20=E5=AE=9F=E8=A3=85=E3=81=84?= =?UTF-8?q?=E3=82=8D=E3=81=84=E3=82=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) 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 2bb23258..6bc1093a 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 @@ -157,12 +157,12 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public CompletableFuture> getLogHistoryInRev(String revId) { return CompletableFuture.supplyAsync(() -> { - logger.debug(TAG, "getLogHistoryAtRev"); + logger.debug(TAG, "getLogHistoryInRev"); ArrayList vcsLogModels = new ArrayList<>(); VcsRevEntity vcsRevEntity = database.vcsRevDao().findById(revId); - vcsRevEntity.logIds.forEach(logId -> { - VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); + ArrayList vcsLogEntities = getLogInRev(vcsRevEntity); + vcsLogEntities.forEach(vcsLogEntity -> { VcsLogModel vcsLogModel = new VcsLogModel(); vcsLogModel.setId(vcsLogEntity.id); vcsLogModel.setDocumentId(vcsLogEntity.documentId); @@ -176,9 +176,49 @@ public class LacertaVcsImpl implements LacertaVcs { }); } + private ArrayList getRevBeforeTargetId(String revId){ + ArrayList vcsRevEntities = new ArrayList<>(database.vcsRevDao().findByDocumentId(this.documentId)); + ArrayList vcsRevEntitiesBeforeTarget = new ArrayList<>(); + vcsRevEntities.forEach(vcsRevEntity -> { + if(vcsRevEntity.id.equals(revId)){ + vcsRevEntitiesBeforeTarget.add(vcsRevEntity); + return; + } + vcsRevEntitiesBeforeTarget.add(vcsRevEntity); + }); + + return vcsRevEntitiesBeforeTarget; + } + + private ArrayList getLogInRevs(ArrayList vcsRevEntities){ + ArrayList vcsLogEntities = new ArrayList<>(); + vcsRevEntities.forEach(vcsRevEntity -> { + vcsRevEntity.logIds.forEach(logId -> { + VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); + vcsLogEntities.add(vcsLogEntity); + }); + }); + + return vcsLogEntities; + } + + private ArrayList getLogInRev(VcsRevEntity revEntity) { + ArrayList vcsLogEntities = new ArrayList<>(); + revEntity.logIds.forEach(logId -> { + VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); + vcsLogEntities.add(vcsLogEntity); + }); + + return vcsLogEntities; + } + @Override public CompletableFuture> getDocumentDetailAtRev(String revId) { - return null; + return CompletableFuture.supplyAsync(() -> { + ArrayList vcsRevEntities = getRevBeforeTargetId(revId); + + + }); } @Override