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