From cd784cad157b2616ea53588cdca0e6277ddbc33d Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 09:06:13 +0900 Subject: [PATCH] =?UTF-8?q?combineDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index df756211..4d92e314 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -27,6 +27,7 @@ import one.nem.lacerta.source.database.common.DateTypeConverter; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.FolderEntity; import one.nem.lacerta.source.database.entity.TagEntity; +import one.nem.lacerta.source.database.entity.ToxiDocumentEntity; import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; @@ -296,7 +297,26 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public CompletableFuture combineDocument(String parentId, String childId) { - return null; + return CompletableFuture.supplyAsync(() -> { + DocumentEntity parentDocumentEntity = database.documentDao().findById(parentId); + DocumentEntity childDocumentEntity = database.documentDao().findById(childId); + if (parentDocumentEntity == null || childDocumentEntity == null) { + logger.warn("LacertaLibraryImpl", "DocumentEntity is not found."); + return null; + } + parentDocumentEntity.isCombineParent = true; + childDocumentEntity.isCombineChild = true; + database.documentDao().update(parentDocumentEntity); + database.documentDao().update(childDocumentEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity"); + + ToxiDocumentEntity toxiDocumentEntity = new ToxiDocumentEntity(); + toxiDocumentEntity.parentDocumentId = parentId; + toxiDocumentEntity.childDocumentId = childId; + database.toxiDocumentDao().insert(toxiDocumentEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentEntity"); + return null; + }); } @Override