From f6f7c3a630e977a8e92fa374b87e2b31175fb459 Mon Sep 17 00:00:00 2001 From: r-ca Date: Wed, 24 Jan 2024 16:49:42 +0900 Subject: [PATCH] =?UTF-8?q?getDocumentPageListRev=E5=AE=9F=E8=A3=85,=20?= =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F=E3=83=A1?= =?UTF-8?q?=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]; }); }