CompletableFeatureを使用して処理するように

This commit is contained in:
r-ca 2024-01-20 22:24:12 +09:00
parent 1d2f3345df
commit acc5b166d5
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -3,6 +3,7 @@ package one.nem.lacerta.data.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
// Hilt // Hilt
import javax.inject.Inject; import javax.inject.Inject;
@ -49,31 +50,30 @@ public class DocumentImpl implements Document {
@Override @Override
public DocumentDetail createDocument(DocumentMeta meta) { public CompletableFuture<DocumentDetail> createDocument(DocumentMeta meta) {
DocumentDetail detail = new DocumentDetail(); return CompletableFuture.supplyAsync(() -> {
detail.setMeta(meta); DocumentDetail detail = new DocumentDetail();
detail.setPages(new ArrayList<>()); detail.setMeta(meta);
detail.setPages(new ArrayList<>());
// Create DocumentEntity
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.id = meta.getId();
documentEntity.title = meta.getTitle();
documentEntity.author = meta.getAuthor();
documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.publicPath = meta.getPath().getStringPath();
documentEntity.tagIds = meta.getTagIds();
// TODO-rca: UIスレッドから追い出す database.documentDao().insert(documentEntity);
// Create DocumentEntity // Vcs
DocumentEntity documentEntity = new DocumentEntity(); LacertaVcs vcs = vcsFactory.create(meta.getId());
documentEntity.id = meta.getId(); vcs.createDocument(meta.getId());
documentEntity.title = meta.getTitle();
documentEntity.author = meta.getAuthor();
documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.publicPath = meta.getPath().getStringPath();
documentEntity.tagIds = meta.getTagIds();
database.documentDao().insert(documentEntity); return detail;
});
// Vcs
LacertaVcs vcs = vcsFactory.create(meta.getId());
vcs.createDocument(meta.getId());
return detail;
} }
@Override @Override
@ -102,6 +102,6 @@ public class DocumentImpl implements Document {
@Override @Override
public DocumentDetail getDocument(String documentId) { public DocumentDetail getDocument(String documentId) {
return null;
} }
} }