combineDocument実装

This commit is contained in:
r-ca 2024-01-28 09:06:13 +09:00
parent 68635e2f12
commit cd784cad15
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -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.DocumentEntity;
import one.nem.lacerta.source.database.entity.FolderEntity; import one.nem.lacerta.source.database.entity.FolderEntity;
import one.nem.lacerta.source.database.entity.TagEntity; 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.source.database.entity.ToxiDocumentTagEntity;
import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.utils.LacertaLogger;
@ -296,8 +297,27 @@ public class LacertaLibraryImpl implements LacertaLibrary {
@Override @Override
public CompletableFuture<Void> combineDocument(String parentId, String childId) { public CompletableFuture<Void> combineDocument(String parentId, String childId) {
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; 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 @Override
public CompletableFuture<Void> uncombineDocument(String parentId, String childId) { public CompletableFuture<Void> uncombineDocument(String parentId, String childId) {