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