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 4d92e314..39a4221d 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 @@ -321,7 +321,23 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public CompletableFuture uncombineDocument(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 = false; + childDocumentEntity.isCombineChild = false; + database.documentDao().update(parentDocumentEntity); + database.documentDao().update(childDocumentEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity"); + + database.toxiDocumentDao().deleteByParentIdAndChildId(parentId, childId); + logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentEntity"); + return null; + }); } @Override