From 93e7c10393aa85c049e4b492257a02cd6fd5c13a Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:34:37 +0900 Subject: [PATCH 01/44] =?UTF-8?q?VcsLogModel=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/model/VcsLogModel.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 model/src/main/java/one/nem/lacerta/model/VcsLogModel.java diff --git a/model/src/main/java/one/nem/lacerta/model/VcsLogModel.java b/model/src/main/java/one/nem/lacerta/model/VcsLogModel.java new file mode 100644 index 00000000..366f7a22 --- /dev/null +++ b/model/src/main/java/one/nem/lacerta/model/VcsLogModel.java @@ -0,0 +1,64 @@ +package one.nem.lacerta.model; + +import java.util.Date; + +public class VcsLogModel { + + String id; + String documentId; + String branchName; + String action; + Date createdAt; + + public VcsLogModel(String id, String documentId, String branchName, String action, Date createdAt) { + this.id = id; + this.documentId = documentId; + this.branchName = branchName; + this.action = action; + this.createdAt = createdAt; + } + + // Empty constructor + public VcsLogModel() { + } + + public String getId() { + return id; + } + + public String getDocumentId() { + return documentId; + } + + public String getBranchName() { + return branchName; + } + + public String getAction() { + return action; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setId(String id) { + this.id = id; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public void setBranchName(String branchName) { + this.branchName = branchName; + } + + public void setAction(String action) { + this.action = action; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} From 895cf64a158c551e3da0f3068e9d43491f289f9f Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:37:03 +0900 Subject: [PATCH 02/44] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/LacertaVcs.java | 7 +++++++ .../one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 12 ++++++++++++ 2 files changed, 19 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 664c45e1..20b3c6bd 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -3,7 +3,10 @@ package one.nem.lacerta.vcs; import java.util.ArrayList; import java.util.concurrent.CompletableFuture; +import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; +import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.source.database.entity.VcsLogEntity; public interface LacertaVcs { @@ -20,6 +23,10 @@ public interface LacertaVcs { public CompletableFuture> getRevisionHistory(); + public CompletableFuture> getLogHistory(); + + public CompletableFuture> getDocumentDetailAtRev(String revId); + // 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 93d701d2..6779df46 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 @@ -10,7 +10,9 @@ import javax.inject.Inject; import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; +import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; +import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; @@ -147,6 +149,16 @@ public class LacertaVcsImpl implements LacertaVcs { }); } + @Override + public CompletableFuture> getLogHistory() { + return null; + } + + @Override + public CompletableFuture> getDocumentDetailAtRev(String revId) { + return null; + } + @Override public void printLog() { logger.debug(TAG, "printLog"); From 904ae8d39f4085e1f4e828d81ec087e45f6fc06c Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:38:29 +0900 Subject: [PATCH 03/44] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/LacertaVcs.java | 3 ++- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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 20b3c6bd..5231f294 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -6,7 +6,6 @@ import java.util.concurrent.CompletableFuture; import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.model.document.DocumentDetail; -import one.nem.lacerta.source.database.entity.VcsLogEntity; public interface LacertaVcs { @@ -25,6 +24,8 @@ public interface LacertaVcs { public CompletableFuture> getLogHistory(); + public CompletableFuture> getLogHistoryInRev(String revId); + public CompletableFuture> getDocumentDetailAtRev(String revId); 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 6779df46..2bb23258 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 @@ -154,6 +154,28 @@ public class LacertaVcsImpl implements LacertaVcs { return null; } + @Override + public CompletableFuture> getLogHistoryInRev(String revId) { + return CompletableFuture.supplyAsync(() -> { + logger.debug(TAG, "getLogHistoryAtRev"); + ArrayList vcsLogModels = new ArrayList<>(); + + VcsRevEntity vcsRevEntity = database.vcsRevDao().findById(revId); + vcsRevEntity.logIds.forEach(logId -> { + VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); + VcsLogModel vcsLogModel = new VcsLogModel(); + vcsLogModel.setId(vcsLogEntity.id); + vcsLogModel.setDocumentId(vcsLogEntity.documentId); + vcsLogModel.setBranchName(vcsLogEntity.branchName); + vcsLogModel.setCreatedAt(vcsLogEntity.createdAt); + vcsLogModel.setAction(vcsLogEntity.action); + vcsLogModels.add(vcsLogModel); + }); + + return vcsLogModels; + }); + } + @Override public CompletableFuture> getDocumentDetailAtRev(String revId) { return null; From dafb49cca0a63d5fd71b13d41be463fd1084b171 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:39:51 +0900 Subject: [PATCH 04/44] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/VcsRevDao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java index 3213ca28..2df991fe 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsRevDao.java @@ -21,7 +21,7 @@ public interface VcsRevDao { @Query("SELECT * FROM vcs_rev WHERE id IN (:ids)") List findByIds(List ids); - @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId") + @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId ORDER BY created_at ASC") List findByDocumentId(String documentId); @Query("SELECT * FROM vcs_rev WHERE document_id = :documentId ORDER BY created_at DESC LIMIT 1") From b6f0a5554a3066f0343d93b14d0d8f32c44c0ca1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:49:17 +0900 Subject: [PATCH 05/44] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0,=20=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=E3=81=84=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 From fc1c8f66cc622965d4964e8833caf8b3a58e5a3e Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 15:53:46 +0900 Subject: [PATCH 06/44] =?UTF-8?q?=E5=AE=9F=E8=A3=85=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/LacertaVcs.java | 2 +- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) 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 5231f294..1db26d6a 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -26,7 +26,7 @@ public interface LacertaVcs { public CompletableFuture> getLogHistoryInRev(String revId); - public CompletableFuture> getDocumentDetailAtRev(String revId); + public CompletableFuture getDocumentDetailAtRev(String revId); // debug 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 6bc1093a..a9fd0709 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 @@ -13,7 +13,9 @@ import dagger.assisted.AssistedInject; import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.source.database.LacertaDatabase; +import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; import one.nem.lacerta.utils.LacertaLogger; @@ -212,12 +214,32 @@ public class LacertaVcsImpl implements LacertaVcs { return vcsLogEntities; } + private DocumentMeta createDocumentMeta() { + DocumentMeta documentMeta = new DocumentMeta(); + DocumentEntity documentEntity = database.documentDao().findById(documentId); + documentMeta.setId(documentEntity.id); + documentMeta.setCreatedAt(documentEntity.createdAt); + documentMeta.setUpdatedAt(documentEntity.updatedAt); + documentMeta.setDefaultBranch(documentEntity.defaultBranch); + documentMeta.setAuthor(documentEntity.author); + documentMeta.setParentId(documentEntity.parentId); + documentMeta.setTitle(documentEntity.title); + documentMeta.setTags(new ArrayList<>()); // TODO-rca: タグの実装 + + return documentMeta; + } + @Override - public CompletableFuture> getDocumentDetailAtRev(String revId) { + public CompletableFuture getDocumentDetailAtRev(String revId) { return CompletableFuture.supplyAsync(() -> { ArrayList vcsRevEntities = getRevBeforeTargetId(revId); + ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities); + DocumentDetail documentDetail = new DocumentDetail(); + documentDetail.setMeta(createDocumentMeta()); + // WIP + return null; }); } From d5ca5ebc904129563efa409502da9f619426fffb Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:21:27 +0900 Subject: [PATCH 07/44] =?UTF-8?q?=E5=BF=85=E8=A6=81=E3=81=AA=E3=83=A1?= =?UTF-8?q?=E3=82=BD=E3=83=83=E3=83=89=E4=BD=9C=E6=88=90=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 a9fd0709..be7e7722 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 @@ -22,7 +22,9 @@ import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.vcs.ActionType; import one.nem.lacerta.vcs.LacertaVcs; import one.nem.lacerta.vcs.internal.JsonUtils; +import one.nem.lacerta.vcs.model.action.DeletePage; import one.nem.lacerta.vcs.model.action.InsertPage; +import one.nem.lacerta.vcs.model.action.UpdatePage; public class LacertaVcsImpl implements LacertaVcs { @@ -229,6 +231,21 @@ public class LacertaVcsImpl implements LacertaVcs { return documentMeta; } + private DocumentDetail applyInsertPage(DocumentDetail documentDetail, InsertPage insertPage) { + // TODO-rca: 実装 + return null; + } + + private DocumentDetail applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { + // TODO-rca: 実装 + return null; + } + + private DocumentDetail applyDeletePage(DocumentDetail documentDetail, DeletePage deletePage) { + // TODO-rca: 実装 + return null; + } + @Override public CompletableFuture getDocumentDetailAtRev(String revId) { return CompletableFuture.supplyAsync(() -> { From 3d01ff3d816ec8af275c8fceb82b2709632d62ca Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:27:35 +0900 Subject: [PATCH 08/44] =?UTF-8?q?=E5=BC=95=E6=95=B0/=E6=88=BB=E3=82=8A?= =?UTF-8?q?=E5=80=A4=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 be7e7722..81ad3be4 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 @@ -14,6 +14,7 @@ import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentMeta; +import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.VcsLogEntity; @@ -231,17 +232,17 @@ public class LacertaVcsImpl implements LacertaVcs { return documentMeta; } - private DocumentDetail applyInsertPage(DocumentDetail documentDetail, InsertPage insertPage) { + private ArrayList applyInsertPage(ArrayList pages, InsertPage insertPage) { // TODO-rca: 実装 return null; } - private DocumentDetail applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { + private ArrayList applyUpdatePage(ArrayList pages, UpdatePage updatePage) { // TODO-rca: 実装 return null; } - private DocumentDetail applyDeletePage(DocumentDetail documentDetail, DeletePage deletePage) { + private ArrayList applyDeletePage(ArrayList pages, DeletePage deletePage) { // TODO-rca: 実装 return null; } From 85dba22f574a43dd84c57ba57a67f0c38a5950b2 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:28:39 +0900 Subject: [PATCH 09/44] =?UTF-8?q?Revert=20"=E5=BC=95=E6=95=B0/=E6=88=BB?= =?UTF-8?q?=E3=82=8A=E5=80=A4=E4=BF=AE=E6=AD=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3d01ff3d816ec8af275c8fceb82b2709632d62ca. --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 7 +++---- 1 file changed, 3 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 81ad3be4..be7e7722 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 @@ -14,7 +14,6 @@ import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentMeta; -import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.VcsLogEntity; @@ -232,17 +231,17 @@ public class LacertaVcsImpl implements LacertaVcs { return documentMeta; } - private ArrayList applyInsertPage(ArrayList pages, InsertPage insertPage) { + private DocumentDetail applyInsertPage(DocumentDetail documentDetail, InsertPage insertPage) { // TODO-rca: 実装 return null; } - private ArrayList applyUpdatePage(ArrayList pages, UpdatePage updatePage) { + private DocumentDetail applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { // TODO-rca: 実装 return null; } - private ArrayList applyDeletePage(ArrayList pages, DeletePage deletePage) { + private DocumentDetail applyDeletePage(DocumentDetail documentDetail, DeletePage deletePage) { // TODO-rca: 実装 return null; } From 3c237d3751c0d8a39fdcbc02888110c1cf567d6b Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:37:54 +0900 Subject: [PATCH 10/44] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/LacertaVcs.java | 2 +- .../one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) 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 1db26d6a..5392e9b2 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -26,7 +26,7 @@ public interface LacertaVcs { public CompletableFuture> getLogHistoryInRev(String revId); - public CompletableFuture getDocumentDetailAtRev(String revId); + public CompletableFuture> getDocumentPagePathListRev(String revId); // debug 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 be7e7722..56eebe43 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 @@ -231,12 +231,12 @@ public class LacertaVcsImpl implements LacertaVcs { return documentMeta; } - private DocumentDetail applyInsertPage(DocumentDetail documentDetail, InsertPage insertPage) { - // TODO-rca: 実装 - return null; + private ArrayList applyInsertPage(ArrayList fileNameList, InsertPage insertPage) { + fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); + return fileNameList; } - private DocumentDetail applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { + private ArrayList applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { // TODO-rca: 実装 return null; } @@ -247,7 +247,7 @@ public class LacertaVcsImpl implements LacertaVcs { } @Override - public CompletableFuture getDocumentDetailAtRev(String revId) { + public CompletableFuture> getDocumentPagePathListRev(String revId) { return CompletableFuture.supplyAsync(() -> { ArrayList vcsRevEntities = getRevBeforeTargetId(revId); ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities); @@ -255,8 +255,7 @@ public class LacertaVcsImpl implements LacertaVcs { DocumentDetail documentDetail = new DocumentDetail(); documentDetail.setMeta(createDocumentMeta()); - // WIP - return null; + vcsLogEntities. }); } From 3fbdc761dd147bfc55e0bf2fcc33cb5ff8603dda Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:42:17 +0900 Subject: [PATCH 11/44] =?UTF-8?q?LogEntity=E3=81=ABActionType=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/LacertaDatabase.java | 2 +- .../nem/lacerta/source/database/entity/VcsLogEntity.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java index e3d6a6b9..47e0e4bb 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java +++ b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java @@ -19,7 +19,7 @@ import one.nem.lacerta.source.database.dao.LibraryDao; import one.nem.lacerta.source.database.dao.VcsRevDao; import one.nem.lacerta.source.database.dao.VcsLogDao; -@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 5) +@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4) public abstract class LacertaDatabase extends RoomDatabase { public abstract TagDao tagDao(); public abstract DocumentDao documentDao(); diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java index 17628e8e..152d5333 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java @@ -40,6 +40,12 @@ public class VcsLogEntity { @ColumnInfo(name = "created_at") public Date createdAt; + /** + * アクションタイプ + */ + @ColumnInfo(name = "action_type") + public String actionType; + /** * 発生アクション */ From f6f7c3a630e977a8e92fa374b87e2b31175fb459 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:49:42 +0900 Subject: [PATCH 12/44] =?UTF-8?q?getDocumentPageListRev=E5=AE=9F=E8=A3=85,?= =?UTF-8?q?=20=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 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 56eebe43..322da58f 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 @@ -216,46 +216,30 @@ public class LacertaVcsImpl implements LacertaVcs { return vcsLogEntities; } - private DocumentMeta createDocumentMeta() { - DocumentMeta documentMeta = new DocumentMeta(); - DocumentEntity documentEntity = database.documentDao().findById(documentId); - documentMeta.setId(documentEntity.id); - documentMeta.setCreatedAt(documentEntity.createdAt); - documentMeta.setUpdatedAt(documentEntity.updatedAt); - documentMeta.setDefaultBranch(documentEntity.defaultBranch); - documentMeta.setAuthor(documentEntity.author); - documentMeta.setParentId(documentEntity.parentId); - documentMeta.setTitle(documentEntity.title); - documentMeta.setTags(new ArrayList<>()); // TODO-rca: タグの実装 - - return documentMeta; - } - - private ArrayList applyInsertPage(ArrayList fileNameList, InsertPage insertPage) { - fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); - return fileNameList; - } - - private ArrayList applyUpdatePage(DocumentDetail documentDetail, UpdatePage updatePage) { - // TODO-rca: 実装 - return null; - } - - private DocumentDetail applyDeletePage(DocumentDetail documentDetail, DeletePage deletePage) { - // TODO-rca: 実装 - return null; - } - @Override public CompletableFuture> getDocumentPagePathListRev(String revId) { return CompletableFuture.supplyAsync(() -> { ArrayList vcsRevEntities = getRevBeforeTargetId(revId); ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities); - DocumentDetail documentDetail = new DocumentDetail(); - documentDetail.setMeta(createDocumentMeta()); + final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; - vcsLogEntities. + vcsLogEntities.forEach(vcsLogEntity -> { + if (vcsLogEntity.actionType.equals(ActionType.INSERT_PAGE.getValue())){ + InsertPage insertPage = (InsertPage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.INSERT_PAGE); + fileNameList[0].add(insertPage.getIndex(), insertPage.getFileName()); + } else if (vcsLogEntity.actionType.equals(ActionType.UPDATE_PAGE.getValue())){ + UpdatePage updatePage = (UpdatePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.UPDATE_PAGE); + fileNameList[0].set(updatePage.getIndex(), updatePage.getFileName()); + } else if (vcsLogEntity.actionType.equals(ActionType.DELETE_PAGE.getValue())){ + DeletePage deletePage = (DeletePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.DELETE_PAGE); + fileNameList[0].remove(deletePage.getIndex()); + } else { + logger.debug(TAG, "Unknown action type"); + } + }); + + return fileNameList[0]; }); } From 8d4d9cab9a2ebe06b11d1099df8e155e47af7fe7 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:54:49 +0900 Subject: [PATCH 13/44] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 1 file changed, 1 insertion(+) 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 322da58f..2881724c 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 @@ -222,6 +222,7 @@ public class LacertaVcsImpl implements LacertaVcs { ArrayList vcsRevEntities = getRevBeforeTargetId(revId); ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities); + // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; vcsLogEntities.forEach(vcsLogEntity -> { From aa2ebce32c1a8fa89775e587a3eb7501545ddf4d Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:01:33 +0900 Subject: [PATCH 14/44] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E5=90=8D=E3=81=AE=E4=B8=80=E8=A6=A7=E3=81=8B=E3=82=89Page?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=82=92=E4=BD=9C=E6=88=90=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/data/Document.java | 3 ++ .../nem/lacerta/data/impl/DocumentImpl.java | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/Document.java b/data/src/main/java/one/nem/lacerta/data/Document.java index 70610913..3491fc7d 100644 --- a/data/src/main/java/one/nem/lacerta/data/Document.java +++ b/data/src/main/java/one/nem/lacerta/data/Document.java @@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.model.document.path.DocumentPath; import one.nem.lacerta.model.document.tag.DocumentTag; @@ -25,4 +26,6 @@ public interface Document { CompletableFuture updateDocument(DocumentDetail detail); CompletableFuture getDocument(String documentId); + + CompletableFuture> getDocumentPageListByFileNameList(String documentId, ArrayList fileNameList); } diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 7a303ec5..523c7277 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -173,6 +173,34 @@ public class DocumentImpl implements Document { }); } + @Override + public CompletableFuture> getDocumentPageListByFileNameList(String documentId, ArrayList fileNameList) { + return CompletableFuture.supplyAsync(() -> { + ArrayList pages = new ArrayList<>(); + FileManager fileManager; + try { + fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId).resolve("raw"); + } catch (IOException e) { + logger.error(TAG, "FileManager resolve error"); + logger.trace(TAG, e.getMessage()); + logger.e_code("1210ae5b-dd2f-42ef-bc15-40b9a9bbdb16"); + return null; + } + + fileNameList.forEach(fileName -> { + try { + pages.add(new Page(fileName, fileManager.loadBitmap(fileName))); + } catch (IOException e) { + logger.error(TAG, "Bitmap decode error"); + logger.trace(TAG, e.getMessage()); + logger.e_code("6f9ba0dc-ac63-401c-8f50-a2bd9ff5cb91"); + } + }); + + return pages; + }); + } + private CompletableFuture> getPagesByXmlMeta(String documentId) { return CompletableFuture.supplyAsync(() -> { FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()); From 5fc8a501ad01660e2136a03afe4bc04dc7100884 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:03:50 +0900 Subject: [PATCH 15/44] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E5=90=8D=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerMainActivity.java | 9 +-------- ...TopFragment.java => ViewerPrimaryFragment.java} | 14 +++++--------- .../src/main/res/layout/activity_viewer_main.xml | 2 +- .../res/navigation/component_viewer_navigation.xml | 6 +++--- 4 files changed, 10 insertions(+), 21 deletions(-) rename component/viewer/src/main/java/one/nem/lacerta/component/viewer/{ComponentViewerTopFragment.java => ViewerPrimaryFragment.java} (92%) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java index 435e472c..218fe7b0 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java @@ -2,7 +2,6 @@ package one.nem.lacerta.component.viewer; import android.content.Intent; import android.os.Bundle; -import android.util.Log; import android.widget.Toast; import androidx.activity.EdgeToEdge; @@ -10,12 +9,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat; -import androidx.fragment.app.FragmentManager; -import androidx.navigation.NavController; -import androidx.navigation.fragment.NavHostFragment; -import androidx.navigation.ui.NavigationUI; - -import com.google.android.material.bottomnavigation.BottomNavigationView; import javax.inject.Inject; @@ -62,7 +55,7 @@ public class ViewerMainActivity extends AppCompatActivity { // Navigation getSupportFragmentManager().beginTransaction() - .replace(R.id.nav_host_fragment, ComponentViewerTopFragment.newInstance(documentId, documentName)) + .replace(R.id.nav_host_fragment, ViewerPrimaryFragment.newInstance(documentId, documentName)) .commit(); } } \ No newline at end of file diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java similarity index 92% rename from component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java rename to component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java index 6e456d16..b7cda2a5 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ComponentViewerTopFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java @@ -1,12 +1,10 @@ package one.nem.lacerta.component.viewer; import android.app.AlertDialog; -import android.graphics.Bitmap; import android.os.Bundle; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; -import androidx.navigation.Navigation; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -16,24 +14,22 @@ import android.view.ViewGroup; import android.widget.Toast; import java.util.ArrayList; -import java.util.concurrent.CompletableFuture; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; import one.nem.lacerta.data.Document; -import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; /** * A simple {@link Fragment} subclass. - * Use the {@link ComponentViewerTopFragment#newInstance} factory method to + * Use the {@link ViewerPrimaryFragment#newInstance} factory method to * create an instance of this fragment. */ @AndroidEntryPoint -public class ComponentViewerTopFragment extends Fragment { +public class ViewerPrimaryFragment extends Fragment { @Inject Document document; @@ -46,12 +42,12 @@ public class ComponentViewerTopFragment extends Fragment { private String documentId; private String documentName; - public ComponentViewerTopFragment() { + public ViewerPrimaryFragment() { // Required empty public constructor } - public static ComponentViewerTopFragment newInstance(String documentId, String documentName) { - ComponentViewerTopFragment fragment = new ComponentViewerTopFragment(); + public static ViewerPrimaryFragment newInstance(String documentId, String documentName) { + ViewerPrimaryFragment fragment = new ViewerPrimaryFragment(); Bundle args = new Bundle(); args.putString("documentId", documentId); args.putString("documentName", documentName); diff --git a/component/viewer/src/main/res/layout/activity_viewer_main.xml b/component/viewer/src/main/res/layout/activity_viewer_main.xml index 73290603..89617f07 100644 --- a/component/viewer/src/main/res/layout/activity_viewer_main.xml +++ b/component/viewer/src/main/res/layout/activity_viewer_main.xml @@ -9,7 +9,7 @@ + app:startDestination="@id/viewerPrimaryFragment"> Date: Wed, 24 Jan 2024 17:04:36 +0900 Subject: [PATCH 16/44] =?UTF-8?q?=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=AF=E3=82=BF=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/viewer/ViewerPrimaryFragment.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java index b7cda2a5..740be76f 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java @@ -55,6 +55,16 @@ public class ViewerPrimaryFragment extends Fragment { return fragment; } + public static ViewerPrimaryFragment newInstance(String documentId, String documentName, String revisionId) { + ViewerPrimaryFragment fragment = new ViewerPrimaryFragment(); + Bundle args = new Bundle(); + args.putString("documentId", documentId); + args.putString("documentName", documentName); + args.putString("revisionId", revisionId); + fragment.setArguments(args); + return fragment; + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); From 778473f89879b6c6a49a720fa5df1f32d6cbfa89 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:09:32 +0900 Subject: [PATCH 17/44] =?UTF-8?q?=E3=83=AA=E3=83=93=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3ID=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=A6?= =?UTF-8?q?=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E3=81=9D=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../viewer/ViewerPrimaryFragment.java | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java index 740be76f..34696b6a 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java @@ -22,6 +22,8 @@ import one.nem.lacerta.data.Document; import one.nem.lacerta.model.document.page.Page; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.vcs.LacertaVcs; +import one.nem.lacerta.vcs.factory.LacertaVcsFactory; /** * A simple {@link Fragment} subclass. @@ -37,10 +39,14 @@ public class ViewerPrimaryFragment extends Fragment { @Inject LacertaLogger logger; + @Inject + LacertaVcsFactory lacertaVcsFactory; + private static final String TAG = "ComponentViewerTopFragment"; private String documentId; private String documentName; + private String revisionId; public ViewerPrimaryFragment() { // Required empty public constructor @@ -71,6 +77,7 @@ public class ViewerPrimaryFragment extends Fragment { if (getArguments() != null) { documentId = getArguments().getString("documentId"); documentName = getArguments().getString("documentName"); + revisionId = getArguments().getString("revisionId"); } } @@ -91,16 +98,34 @@ public class ViewerPrimaryFragment extends Fragment { }); recyclerView.setAdapter(viewerBodyAdapter); - if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); - document.getDocument(documentId).thenAccept(documentDetail -> { - ArrayList pages = documentDetail.getPages(); - logger.debug(TAG, "pages.size(): " + pages.size()); - viewerBodyAdapter.setPages(pages); - getActivity().runOnUiThread(() -> { - viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); - if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + if (revisionId.isEmpty()) { + logger.debug(TAG, "revisionId is empty, loading latest revision"); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); + document.getDocument(documentId).thenAccept(documentDetail -> { + ArrayList pages = documentDetail.getPages(); + logger.debug(TAG, "pages.size(): " + pages.size()); + viewerBodyAdapter.setPages(pages); + getActivity().runOnUiThread(() -> { + viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + }); }); - }); + } else { + logger.debug(TAG, "revisionId: " + revisionId); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); + LacertaVcs lacertaVcs = lacertaVcsFactory.create(documentId); + lacertaVcs.getDocumentPagePathListRev(revisionId).thenAccept(documentPathList -> { + logger.debug(TAG, "documentPathList.size(): " + documentPathList.size()); + document.getDocumentPageListByFileNameList(documentId, documentPathList).thenAccept(pages -> { + logger.debug(TAG, "pages.size(): " + pages.size()); + viewerBodyAdapter.setPages(pages); + getActivity().runOnUiThread(() -> { + viewerBodyAdapter.notifyItemRangeChanged(0, pages.size()); + if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.GONE); + }); + }); + }); + } return view; } From 7822fdd3c518109707134e0acada50ab798f0b42 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:10:48 +0900 Subject: [PATCH 18/44] =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rimaryFragment.java => ViewerListFragment.java} | 14 +++++++------- .../component/viewer/ViewerMainActivity.java | 2 +- .../src/main/res/layout/activity_viewer_main.xml | 2 +- .../res/navigation/component_viewer_navigation.xml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) rename component/viewer/src/main/java/one/nem/lacerta/component/viewer/{ViewerPrimaryFragment.java => ViewerListFragment.java} (94%) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java similarity index 94% rename from component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java rename to component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java index 34696b6a..09343c94 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerPrimaryFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java @@ -27,11 +27,11 @@ import one.nem.lacerta.vcs.factory.LacertaVcsFactory; /** * A simple {@link Fragment} subclass. - * Use the {@link ViewerPrimaryFragment#newInstance} factory method to + * Use the {@link ViewerListFragment#newInstance} factory method to * create an instance of this fragment. */ @AndroidEntryPoint -public class ViewerPrimaryFragment extends Fragment { +public class ViewerListFragment extends Fragment { @Inject Document document; @@ -48,12 +48,12 @@ public class ViewerPrimaryFragment extends Fragment { private String documentName; private String revisionId; - public ViewerPrimaryFragment() { + public ViewerListFragment() { // Required empty public constructor } - public static ViewerPrimaryFragment newInstance(String documentId, String documentName) { - ViewerPrimaryFragment fragment = new ViewerPrimaryFragment(); + public static ViewerListFragment newInstance(String documentId, String documentName) { + ViewerListFragment fragment = new ViewerListFragment(); Bundle args = new Bundle(); args.putString("documentId", documentId); args.putString("documentName", documentName); @@ -61,8 +61,8 @@ public class ViewerPrimaryFragment extends Fragment { return fragment; } - public static ViewerPrimaryFragment newInstance(String documentId, String documentName, String revisionId) { - ViewerPrimaryFragment fragment = new ViewerPrimaryFragment(); + public static ViewerListFragment newInstance(String documentId, String documentName, String revisionId) { + ViewerListFragment fragment = new ViewerListFragment(); Bundle args = new Bundle(); args.putString("documentId", documentId); args.putString("documentName", documentName); diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java index 218fe7b0..6c079c11 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerMainActivity.java @@ -55,7 +55,7 @@ public class ViewerMainActivity extends AppCompatActivity { // Navigation getSupportFragmentManager().beginTransaction() - .replace(R.id.nav_host_fragment, ViewerPrimaryFragment.newInstance(documentId, documentName)) + .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(documentId, documentName)) .commit(); } } \ No newline at end of file diff --git a/component/viewer/src/main/res/layout/activity_viewer_main.xml b/component/viewer/src/main/res/layout/activity_viewer_main.xml index 89617f07..f077ceec 100644 --- a/component/viewer/src/main/res/layout/activity_viewer_main.xml +++ b/component/viewer/src/main/res/layout/activity_viewer_main.xml @@ -9,7 +9,7 @@ + app:startDestination="@id/viewerListFragment"> Date: Wed, 24 Jan 2024 17:31:21 +0900 Subject: [PATCH 19/44] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=BF=E3=83=95?= =?UTF-8?q?=E3=82=A7=E3=83=BC=E3=82=B9=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/component/viewer/model/RevSelectListener.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 component/viewer/src/main/java/one/nem/lacerta/component/viewer/model/RevSelectListener.java diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/model/RevSelectListener.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/model/RevSelectListener.java new file mode 100644 index 00000000..f1a69486 --- /dev/null +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/model/RevSelectListener.java @@ -0,0 +1,5 @@ +package one.nem.lacerta.component.viewer.model; + +public interface RevSelectListener { + void onRevSelect(String revisionId); +} From 5639117e0ee941722dc0a6effea6efd8766a903b Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:32:58 +0900 Subject: [PATCH 20/44] =?UTF-8?q?=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=8A=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/viewer/RevAdapter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java index eb5c634f..4ad968c1 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/RevAdapter.java @@ -12,6 +12,7 @@ import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import one.nem.lacerta.component.viewer.model.RevSelectListener; import one.nem.lacerta.model.VcsRevModel; import one.nem.lacerta.utils.FeatureSwitch; @@ -19,11 +20,14 @@ public class RevAdapter extends RecyclerView.Adapter{ private ArrayList revModels; + private RevSelectListener revSelectListener; + public RevAdapter(ArrayList revModels) { this.revModels = revModels; } - public RevAdapter() { + public RevAdapter(RevSelectListener revSelectListener) { + this.revSelectListener = revSelectListener; } public void setRevModels(ArrayList revModels) { @@ -52,6 +56,13 @@ public class RevAdapter extends RecyclerView.Adapter{ } holder.revId.setText("RevID: " + revModel.getId()); + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + revSelectListener.onRevSelect(revModel.getId()); + } + }); + } @Override From 615d58f3cae96d8f9eeb2312b151c6bcd58af5e6 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:43:10 +0900 Subject: [PATCH 21/44] WIP --- .../component/viewer/ViewerListFragment.java | 4 ++-- .../viewer/ViewerVcsRevListFragment.java | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java index 09343c94..4c306755 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerListFragment.java @@ -98,7 +98,7 @@ public class ViewerListFragment extends Fragment { }); recyclerView.setAdapter(viewerBodyAdapter); - if (revisionId.isEmpty()) { + if (revisionId == null) { logger.debug(TAG, "revisionId is empty, loading latest revision"); if (FeatureSwitch.Viewer.showProgressBarWhenLoading) view.findViewById(R.id.loading_progress_bar).setVisibility(View.VISIBLE); document.getDocument(documentId).thenAccept(documentDetail -> { @@ -154,7 +154,7 @@ public class ViewerListFragment extends Fragment { if (item.getItemId() == R.id.action_open_vcs_rev_list) { // Open vcs rev list getParentFragmentManager().beginTransaction() - .replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId)) + .replace(R.id.nav_host_fragment, ViewerVcsRevListFragment.newInstance(documentId, documentName)) .commit(); return true; } else if (item.getItemId() == R.id.action_rename) { diff --git a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java index 237c1564..a86d7e88 100644 --- a/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java +++ b/component/viewer/src/main/java/one/nem/lacerta/component/viewer/ViewerVcsRevListFragment.java @@ -34,15 +34,17 @@ public class ViewerVcsRevListFragment extends Fragment { LacertaVcs lacertaVcs; private String documentId; + private String documentName; public ViewerVcsRevListFragment() { // Required empty public constructor } - public static ViewerVcsRevListFragment newInstance(String documentId) { + public static ViewerVcsRevListFragment newInstance(String documentId, String documentName) { ViewerVcsRevListFragment fragment = new ViewerVcsRevListFragment(); Bundle args = new Bundle(); args.putString("documentId", documentId); + args.putString("documentName", documentName); fragment.setArguments(args); return fragment; } @@ -66,17 +68,22 @@ public class ViewerVcsRevListFragment extends Fragment { // Init arg if (getArguments() != null) { this.documentId = getArguments().getString("documentId"); - logger.debug("ViewerVcsRevListFragment", "documentId: " + documentId); + logger.debug("ViewerVcsRevListFragment", "documentId: " + this.documentId); } // Init vcs - lacertaVcs = lacertaVcsFactory.create(documentId); + lacertaVcs = lacertaVcsFactory.create(this.documentId); // Init view RecyclerView recyclerView = view.findViewById(R.id.rev_list); // Init adapter - RevAdapter revAdapter = new RevAdapter(); + RevAdapter revAdapter = new RevAdapter(revisionId -> { + logger.debug("ViewerVcsRevListFragment", "Selected revisionId: " + revisionId); + getParentFragmentManager().beginTransaction() + .replace(R.id.nav_host_fragment, ViewerListFragment.newInstance(this.documentId, this.documentName, revisionId)) + .commit(); + }); // Set adapter recyclerView.setAdapter(revAdapter); From daab41620fbeb3de448987401e85ec3bacd59efb Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:45:16 +0900 Subject: [PATCH 22/44] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 6 ++---- 1 file changed, 2 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 2881724c..c865ede3 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 @@ -197,10 +197,8 @@ public class LacertaVcsImpl implements LacertaVcs { 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); - }); + List logIds = new ArrayList<>(vcsRevEntity.logIds); + vcsLogEntities.addAll(database.vcsLogDao().findByIds(logIds)); }); return vcsLogEntities; From b58e80f7eab1d8e8093f4f150da03396f00d7c73 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:48:00 +0900 Subject: [PATCH 23/44] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 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 c865ede3..af89c423 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 @@ -195,13 +195,11 @@ public class LacertaVcsImpl implements LacertaVcs { } private ArrayList getLogInRevs(ArrayList vcsRevEntities){ - ArrayList vcsLogEntities = new ArrayList<>(); + List logIds = new ArrayList<>(); vcsRevEntities.forEach(vcsRevEntity -> { - List logIds = new ArrayList<>(vcsRevEntity.logIds); - vcsLogEntities.addAll(database.vcsLogDao().findByIds(logIds)); + logIds.addAll(vcsRevEntity.logIds); }); - - return vcsLogEntities; + return new ArrayList<>(database.vcsLogDao().findByIds(logIds)); } private ArrayList getLogInRev(VcsRevEntity revEntity) { From cd1a58dcc01628420cb59490e75d352967fddf11 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:49:45 +0900 Subject: [PATCH 24/44] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 8 +------- 1 file changed, 1 insertion(+), 7 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 af89c423..81dc5b3d 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 @@ -203,13 +203,7 @@ public class LacertaVcsImpl implements LacertaVcs { } private ArrayList getLogInRev(VcsRevEntity revEntity) { - ArrayList vcsLogEntities = new ArrayList<>(); - revEntity.logIds.forEach(logId -> { - VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); - vcsLogEntities.add(vcsLogEntity); - }); - - return vcsLogEntities; + return new ArrayList<>(database.vcsLogDao().findByIds(revEntity.logIds)); } @Override From 8c4e651a7956ec43f913109ec110353d5e66c462 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:55:23 +0900 Subject: [PATCH 25/44] =?UTF-8?q?=E4=B8=80=E9=83=A8=E3=82=92=E9=9D=9E?= =?UTF-8?q?=E5=90=8C=E6=9C=9F=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 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 81dc5b3d..c0a55ac8 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 @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; import javax.inject.Inject; @@ -180,26 +181,31 @@ 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)){ + private CompletableFuture> getRevBeforeTargetIdAsync(String revId){ + return CompletableFuture.supplyAsync(() -> { + 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.add(vcsRevEntity); - }); + }); - return vcsRevEntitiesBeforeTarget; + return vcsRevEntitiesBeforeTarget; + }); } - private ArrayList getLogInRevs(ArrayList vcsRevEntities){ - List logIds = new ArrayList<>(); - vcsRevEntities.forEach(vcsRevEntity -> { - logIds.addAll(vcsRevEntity.logIds); + private CompletableFuture> getLogInRevs(ArrayList vcsRevEntities){ + return CompletableFuture.supplyAsync(() -> { + List logIds = new ArrayList<>(); + vcsRevEntities.forEach(vcsRevEntity -> { + logIds.addAll(vcsRevEntity.logIds); + }); + // TODO-rca: ソートしないといけないかも(順番が保証されているわけではない + 順番が変わるとほぼ確実に壊れる) + return new ArrayList<>(database.vcsLogDao().findByIds(logIds)); }); - return new ArrayList<>(database.vcsLogDao().findByIds(logIds)); } private ArrayList getLogInRev(VcsRevEntity revEntity) { @@ -209,8 +215,8 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public CompletableFuture> getDocumentPagePathListRev(String revId) { return CompletableFuture.supplyAsync(() -> { - ArrayList vcsRevEntities = getRevBeforeTargetId(revId); - ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities); + ArrayList vcsRevEntities = getRevBeforeTargetIdAsync(revId).join(); + ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities).join(); // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; From 929ba7347ce526afd999355e32d125a43764fd72 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:56:26 +0900 Subject: [PATCH 26/44] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 c0a55ac8..9e4ee843 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 @@ -215,8 +215,8 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public CompletableFuture> getDocumentPagePathListRev(String revId) { return CompletableFuture.supplyAsync(() -> { - ArrayList vcsRevEntities = getRevBeforeTargetIdAsync(revId).join(); - ArrayList vcsLogEntities = getLogInRevs(vcsRevEntities).join(); + logger.debug(TAG, "getDocumentPagePathListRev"); + ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevs).join(); // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; From f59c4445dcea41dcf9ea9bd7003adb2f47d99760 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:56:44 +0900 Subject: [PATCH 27/44] =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 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 9e4ee843..ed81a493 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 @@ -1,22 +1,15 @@ package one.nem.lacerta.vcs.impl; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; - -import javax.inject.Inject; import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; import one.nem.lacerta.model.VcsLogModel; import one.nem.lacerta.model.VcsRevModel; -import one.nem.lacerta.model.document.DocumentDetail; -import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.source.database.LacertaDatabase; -import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; import one.nem.lacerta.utils.LacertaLogger; @@ -197,7 +190,7 @@ public class LacertaVcsImpl implements LacertaVcs { }); } - private CompletableFuture> getLogInRevs(ArrayList vcsRevEntities){ + private CompletableFuture> getLogInRevsAsync(ArrayList vcsRevEntities){ return CompletableFuture.supplyAsync(() -> { List logIds = new ArrayList<>(); vcsRevEntities.forEach(vcsRevEntity -> { @@ -216,7 +209,7 @@ public class LacertaVcsImpl implements LacertaVcs { public CompletableFuture> getDocumentPagePathListRev(String revId) { return CompletableFuture.supplyAsync(() -> { logger.debug(TAG, "getDocumentPagePathListRev"); - ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevs).join(); + ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevsAsync).join(); // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; From f6bc9167d232b3b4d8d71d592e7daa505bc74a4b Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 17:58:13 +0900 Subject: [PATCH 28/44] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 ed81a493..280628aa 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 @@ -159,7 +159,7 @@ public class LacertaVcsImpl implements LacertaVcs { ArrayList vcsLogModels = new ArrayList<>(); VcsRevEntity vcsRevEntity = database.vcsRevDao().findById(revId); - ArrayList vcsLogEntities = getLogInRev(vcsRevEntity); + ArrayList vcsLogEntities = getLogInRevAsync(vcsRevEntity).join(); // TODO-rca: リファクタリング vcsLogEntities.forEach(vcsLogEntity -> { VcsLogModel vcsLogModel = new VcsLogModel(); vcsLogModel.setId(vcsLogEntity.id); @@ -201,8 +201,8 @@ public class LacertaVcsImpl implements LacertaVcs { }); } - private ArrayList getLogInRev(VcsRevEntity revEntity) { - return new ArrayList<>(database.vcsLogDao().findByIds(revEntity.logIds)); + private CompletableFuture> getLogInRevAsync(VcsRevEntity revEntity) { + return CompletableFuture.supplyAsync(() -> new ArrayList<>(database.vcsLogDao().findByIds(revEntity.logIds))); } @Override From d3afdbcef5824804b70fd12665a3729f998c3e46 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:02:57 +0900 Subject: [PATCH 29/44] =?UTF-8?q?=E3=83=AD=E3=82=B0=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 1 file changed, 1 insertion(+) 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 280628aa..4e6d3d56 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 @@ -210,6 +210,7 @@ public class LacertaVcsImpl implements LacertaVcs { return CompletableFuture.supplyAsync(() -> { logger.debug(TAG, "getDocumentPagePathListRev"); ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevsAsync).join(); + logger.debug(TAG, "Query finished\nSize: " + vcsLogEntities.size()); // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; From 826f8928d12ce594a004ae93c7aed1b8e48e033b Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:06:10 +0900 Subject: [PATCH 30/44] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 12 ++++++++---- 1 file changed, 8 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 4e6d3d56..a2a47081 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 @@ -185,7 +185,6 @@ public class LacertaVcsImpl implements LacertaVcs { } vcsRevEntitiesBeforeTarget.add(vcsRevEntity); }); - return vcsRevEntitiesBeforeTarget; }); } @@ -197,12 +196,18 @@ public class LacertaVcsImpl implements LacertaVcs { logIds.addAll(vcsRevEntity.logIds); }); // TODO-rca: ソートしないといけないかも(順番が保証されているわけではない + 順番が変わるとほぼ確実に壊れる) - return new ArrayList<>(database.vcsLogDao().findByIds(logIds)); + ArrayList vcsLogEntities = new ArrayList<>(database.vcsLogDao().findByIds(logIds)); + logger.debug(TAG, "getLogInRevsAsync finished\nResult size: " + vcsLogEntities.size()); + return vcsLogEntities; }); } private CompletableFuture> getLogInRevAsync(VcsRevEntity revEntity) { - return CompletableFuture.supplyAsync(() -> new ArrayList<>(database.vcsLogDao().findByIds(revEntity.logIds))); + return CompletableFuture.supplyAsync(() -> { + ArrayList vcsLogEntities = new ArrayList<>(database.vcsLogDao().findByIds(revEntity.logIds)); + logger.debug(TAG, "getLogInRevAsync finished\nResult size: " + vcsLogEntities.size()); + return vcsLogEntities; + }); } @Override @@ -210,7 +215,6 @@ public class LacertaVcsImpl implements LacertaVcs { return CompletableFuture.supplyAsync(() -> { logger.debug(TAG, "getDocumentPagePathListRev"); ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevsAsync).join(); - logger.debug(TAG, "Query finished\nSize: " + vcsLogEntities.size()); // finalで宣言しないとLambda式内で扱えないので final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; From 93cef07ce5674beb36db819bcb7f32111c5c2353 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:06:45 +0900 Subject: [PATCH 31/44] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 1 file changed, 1 insertion(+) 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 a2a47081..7626692e 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 @@ -185,6 +185,7 @@ public class LacertaVcsImpl implements LacertaVcs { } vcsRevEntitiesBeforeTarget.add(vcsRevEntity); }); + logger.debug(TAG, "getRevBeforeTargetIdAsync finished\nResult size: " + vcsRevEntitiesBeforeTarget.size()); return vcsRevEntitiesBeforeTarget; }); } From d778840484c50e04b6593e52a154fe79e1dab3d6 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:09:56 +0900 Subject: [PATCH 32/44] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 1 file changed, 1 insertion(+) 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 7626692e..3d71e76b 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 @@ -221,6 +221,7 @@ public class LacertaVcsImpl implements LacertaVcs { final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; vcsLogEntities.forEach(vcsLogEntity -> { + logger.debug(TAG, "getDocumentPagePathListRev: processing " + vcsLogEntity.id + "(Type: " + vcsLogEntity.actionType + ")"); if (vcsLogEntity.actionType.equals(ActionType.INSERT_PAGE.getValue())){ InsertPage insertPage = (InsertPage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.INSERT_PAGE); fileNameList[0].add(insertPage.getIndex(), insertPage.getFileName()); From 6e9606b05097f629ab9f4e98b8ad0bf829257f7a Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:10:37 +0900 Subject: [PATCH 33/44] =?UTF-8?q?ActionType=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 1 + 1 file changed, 1 insertion(+) 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 3d71e76b..e1bb62f8 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 @@ -57,6 +57,7 @@ public class LacertaVcsImpl implements LacertaVcs { vcsLogEntity.documentId = documentId; vcsLogEntity.branchName = "master"; vcsLogEntity.createdAt = new java.util.Date(); + vcsLogEntity.actionType = ActionType.INSERT_PAGE.getValue(); vcsLogEntity.action = JsonUtils.toJson(insertPage); database.vcsLogDao().insert(vcsLogEntity); } From 4b1ae7326b53646a22138233a0521ef1d9104a1d Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:11:25 +0900 Subject: [PATCH 34/44] =?UTF-8?q?ActionType=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 e1bb62f8..c60f2c76 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 @@ -76,7 +76,8 @@ public class LacertaVcsImpl implements LacertaVcs { vcsLogEntity.documentId = documentId; vcsLogEntity.branchName = "master"; vcsLogEntity.createdAt = new java.util.Date(); - vcsLogEntity.action = "ph-createDocument"; + vcsLogEntity.actionType = ActionType.CREATE_DOCUMENT.getValue(); + vcsLogEntity.action = ""; database.vcsLogDao().insert(vcsLogEntity); } From dfd488329b83e636ad4234652a3e99a28aa0c267 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:12:35 +0900 Subject: [PATCH 35/44] =?UTF-8?q?CREATE=5FDOCUMENT=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 c60f2c76..3dda05d7 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 @@ -233,8 +233,11 @@ public class LacertaVcsImpl implements LacertaVcs { } else if (vcsLogEntity.actionType.equals(ActionType.DELETE_PAGE.getValue())){ DeletePage deletePage = (DeletePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.DELETE_PAGE); fileNameList[0].remove(deletePage.getIndex()); + } else if (vcsLogEntity.actionType.equals(ActionType.CREATE_DOCUMENT.getValue())) { + // Ignore + logger.debug(TAG, "getDocumentPagePathListRev: Ignored action type: " + vcsLogEntity.actionType); } else { - logger.debug(TAG, "Unknown action type"); + logger.error(TAG, "getDocumentPagePathListRev: Unknown action type"); } }); From 16dfccca1443a9ba6406ac4137a07044ce5d3b2e Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:21:59 +0900 Subject: [PATCH 36/44] =?UTF-8?q?forEach=E6=96=87=E3=82=92=E3=82=84?= =?UTF-8?q?=E3=82=81=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 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 3dda05d7..04a13c59 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 @@ -219,29 +219,30 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "getDocumentPagePathListRev"); ArrayList vcsLogEntities = getRevBeforeTargetIdAsync(revId).thenCompose(this::getLogInRevsAsync).join(); - // finalで宣言しないとLambda式内で扱えないので - final ArrayList[] fileNameList = new ArrayList[]{new ArrayList<>()}; - - vcsLogEntities.forEach(vcsLogEntity -> { + ArrayList fileNameList = new ArrayList<>(); + for(VcsLogEntity vcsLogEntity : vcsLogEntities){ logger.debug(TAG, "getDocumentPagePathListRev: processing " + vcsLogEntity.id + "(Type: " + vcsLogEntity.actionType + ")"); if (vcsLogEntity.actionType.equals(ActionType.INSERT_PAGE.getValue())){ InsertPage insertPage = (InsertPage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.INSERT_PAGE); - fileNameList[0].add(insertPage.getIndex(), insertPage.getFileName()); + logger.debug(TAG, "getDocumentPagePathListRev: Inserting " + insertPage.getFileName() + " at " + insertPage.getIndex()); + fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); } else if (vcsLogEntity.actionType.equals(ActionType.UPDATE_PAGE.getValue())){ UpdatePage updatePage = (UpdatePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.UPDATE_PAGE); - fileNameList[0].set(updatePage.getIndex(), updatePage.getFileName()); + logger.debug(TAG, "getDocumentPagePathListRev: Updating " + updatePage.getFileName() + " at " + updatePage.getIndex()); + fileNameList.set(updatePage.getIndex(), updatePage.getFileName()); } else if (vcsLogEntity.actionType.equals(ActionType.DELETE_PAGE.getValue())){ DeletePage deletePage = (DeletePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.DELETE_PAGE); - fileNameList[0].remove(deletePage.getIndex()); + logger.debug(TAG, "getDocumentPagePathListRev: Deleting " + deletePage.getIndex()); + fileNameList.remove(deletePage.getIndex()); } else if (vcsLogEntity.actionType.equals(ActionType.CREATE_DOCUMENT.getValue())) { // Ignore logger.debug(TAG, "getDocumentPagePathListRev: Ignored action type: " + vcsLogEntity.actionType); } else { logger.error(TAG, "getDocumentPagePathListRev: Unknown action type"); } - }); + } - return fileNameList[0]; + return fileNameList; }); } From da5b134a2b15ee7b9da4bada8d7a3b2c1cf69ed1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:25:59 +0900 Subject: [PATCH 37/44] =?UTF-8?q?Index=E3=81=8B=E3=82=89=E6=BA=A2=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AE=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 04a13c59..e81ffa7d 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 @@ -225,7 +225,12 @@ public class LacertaVcsImpl implements LacertaVcs { if (vcsLogEntity.actionType.equals(ActionType.INSERT_PAGE.getValue())){ InsertPage insertPage = (InsertPage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.INSERT_PAGE); logger.debug(TAG, "getDocumentPagePathListRev: Inserting " + insertPage.getFileName() + " at " + insertPage.getIndex()); - fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); + if (fileNameList.size() <= insertPage.getIndex()) { + logger.debug(TAG, "Index out of range, appending"); + fileNameList.add(insertPage.getFileName()); + } else { + fileNameList.add(insertPage.getIndex(), insertPage.getFileName()); + } } else if (vcsLogEntity.actionType.equals(ActionType.UPDATE_PAGE.getValue())){ UpdatePage updatePage = (UpdatePage) JsonUtils.fromJson(vcsLogEntity.action, ActionType.UPDATE_PAGE); logger.debug(TAG, "getDocumentPagePathListRev: Updating " + updatePage.getFileName() + " at " + updatePage.getIndex()); From 749cad231c56230506879d6c8505142571836edd Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:29:19 +0900 Subject: [PATCH 38/44] =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AE=E9=A0=86?= =?UTF-8?q?=E7=95=AA=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/processor/impl/DocumentProcessorImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java index d2312b91..5b580cf8 100644 --- a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java +++ b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java @@ -74,13 +74,13 @@ public class DocumentProcessorImpl implements DocumentProcessor{ logger.debug("addNewPageToLast", "called"); String filename = UUID.randomUUID().toString() + ".png"; // TODO-rca: 拡張子を動的にする + lacertaVcs.insertPage(this.documentDetail.getPages().size(), filename); + Page page = new Page(); page.setFileName(filename); page.setBitmap(bitmap); this.documentDetail.getPages().add(page); - lacertaVcs.insertPage(documentDetail.getPages().size(), filename); - this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename); logger.info("addNewPageToLast", "finished"); From 70380df8fdcb5bcd7ea36714eb26044fc67799ae Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:31:45 +0900 Subject: [PATCH 39/44] =?UTF-8?q?Dao=E3=81=ABDelete=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/VcsLogDao.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index 7721555f..df6e7471 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -52,4 +52,8 @@ public interface VcsLogDao { @Update void updateAll(List vcsLogs); + + // Delete + @Query("DELETE FROM vcs_log WHERE id = :id") + void deleteById(String id); } From 383b34c3d24f332a4095a583b6fdbe2ed24c999b Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:33:56 +0900 Subject: [PATCH 40/44] =?UTF-8?q?=E6=9C=80=E5=BE=8C=E3=81=AE=E3=83=AC?= =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E5=89=8A=E9=99=A4=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/VcsLogDao.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index df6e7471..7e132ce0 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -56,4 +56,7 @@ public interface VcsLogDao { // Delete @Query("DELETE FROM vcs_log WHERE id = :id") void deleteById(String id); + + @Query("DELETE FROM vcs_log WHERE document_id = :documentId ORDER BY created_at LIMIT 1") + void deleteLatestByDocumentId(String documentId); } From 113bca723f75f0f6376b23df443701d44d96b945 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:34:25 +0900 Subject: [PATCH 41/44] =?UTF-8?q?=E6=9C=80=E5=BE=8C=E3=81=AB=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=97=E3=81=9FLog=E3=82=92=E5=89=8A=E9=99=A4?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java | 2 ++ .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 5 +++++ 2 files changed, 7 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 5392e9b2..cccc44ac 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -16,6 +16,8 @@ public interface LacertaVcs { public void deletePage(int index); + public void undo(); + public void createDocument(String documentId); public void generateRevisionAtCurrent(String message); 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 e81ffa7d..5e193bcd 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 @@ -67,6 +67,11 @@ public class LacertaVcsImpl implements LacertaVcs { } + @Override + public void undo() { + database.vcsLogDao().deleteLatestByDocumentId(documentId); + } + @Override public void createDocument(String documentId) { logger.debug(TAG, "createDocument"); From 6b3d0c0dae389892810481752a17059a64b654f7 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:36:08 +0900 Subject: [PATCH 42/44] =?UTF-8?q?=E5=A4=B1=E6=95=97=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=81=A8=E3=81=8D=E3=81=AB=E3=83=AD=E3=82=B0=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4=E3=81=97=E3=81=A6=E3=83=AA=E3=82=AB=E3=83=90=E3=83=AA?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../processor/impl/DocumentProcessorImpl.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java index 5b580cf8..fea8396f 100644 --- a/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java +++ b/processor/src/main/java/one/nem/lacerta/processor/impl/DocumentProcessorImpl.java @@ -76,16 +76,22 @@ public class DocumentProcessorImpl implements DocumentProcessor{ lacertaVcs.insertPage(this.documentDetail.getPages().size(), filename); - Page page = new Page(); - page.setFileName(filename); - page.setBitmap(bitmap); - this.documentDetail.getPages().add(page); + try { + Page page = new Page(); + page.setFileName(filename); + page.setBitmap(bitmap); + this.documentDetail.getPages().add(page); - this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename); - - logger.info("addNewPageToLast", "finished"); - logger.info("addNewPageToLast", "filename: " + filename); + this.fileManager.getNewInstance().createDirectoryIfNotExist(DEFAULT_SAVE_DIR).resolve(DEFAULT_SAVE_DIR).saveBitmap(bitmap, filename); + logger.info("addNewPageToLast", "finished"); + logger.info("addNewPageToLast", "filename: " + filename); + } catch (Exception e) { + logger.error("addNewPageToLast", "failed: Unknown error"); + logger.e_code("d9191286-6092-40b3-80ed-9239106a8c65"); + // Recover (Undo latest action) + lacertaVcs.undo(); + } return this; } From 0b7b499624d029363c00b2ff0ddfbc1c41b7f42a Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:36:59 +0900 Subject: [PATCH 43/44] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/VcsLogDao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index 7e132ce0..5e1eec55 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -57,6 +57,6 @@ public interface VcsLogDao { @Query("DELETE FROM vcs_log WHERE id = :id") void deleteById(String id); - @Query("DELETE FROM vcs_log WHERE document_id = :documentId ORDER BY created_at LIMIT 1") + @Query("DELETE FROM vcs_log WHERE document_id = :documentId LIMIT 1") void deleteLatestByDocumentId(String documentId); } From c1c705729a6ae44bf211446bab964089c9ceca8a Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 18:40:11 +0900 Subject: [PATCH 44/44] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/VcsLogDao.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index 5e1eec55..b8923de9 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -57,6 +57,6 @@ public interface VcsLogDao { @Query("DELETE FROM vcs_log WHERE id = :id") void deleteById(String id); - @Query("DELETE FROM vcs_log WHERE document_id = :documentId LIMIT 1") + @Query("DELETE FROM vcs_log WHERE id = (SELECT id FROM vcs_log WHERE document_id = :documentId ORDER BY created_at DESC LIMIT 1)") void deleteLatestByDocumentId(String documentId); }