ファイル名の一覧からPageリストを作成するメソッド実装

This commit is contained in:
r-ca 2024-01-24 17:01:33 +09:00
parent 8d4d9cab9a
commit aa2ebce32c
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 31 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import java.util.concurrent.CompletableFuture;
import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.page.Page;
import one.nem.lacerta.model.document.path.DocumentPath; import one.nem.lacerta.model.document.path.DocumentPath;
import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.model.document.tag.DocumentTag;
@ -25,4 +26,6 @@ public interface Document {
CompletableFuture<Void> updateDocument(DocumentDetail detail); CompletableFuture<Void> updateDocument(DocumentDetail detail);
CompletableFuture<DocumentDetail> getDocument(String documentId); CompletableFuture<DocumentDetail> getDocument(String documentId);
CompletableFuture<ArrayList<Page>> getDocumentPageListByFileNameList(String documentId, ArrayList<String> fileNameList);
} }

View File

@ -173,6 +173,34 @@ public class DocumentImpl implements Document {
}); });
} }
@Override
public CompletableFuture<ArrayList<Page>> getDocumentPageListByFileNameList(String documentId, ArrayList<String> fileNameList) {
return CompletableFuture.supplyAsync(() -> {
ArrayList<Page> pages = new ArrayList<>();
FileManager fileManager;
try {
fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()).resolve(documentId).resolve("raw");
} catch (IOException e) {
logger.error(TAG, "FileManager resolve error");
logger.trace(TAG, e.getMessage());
logger.e_code("1210ae5b-dd2f-42ef-bc15-40b9a9bbdb16");
return null;
}
fileNameList.forEach(fileName -> {
try {
pages.add(new Page(fileName, fileManager.loadBitmap(fileName)));
} catch (IOException e) {
logger.error(TAG, "Bitmap decode error");
logger.trace(TAG, e.getMessage());
logger.e_code("6f9ba0dc-ac63-401c-8f50-a2bd9ff5cb91");
}
});
return pages;
});
}
private CompletableFuture<ArrayList<XmlMetaPageModel>> getPagesByXmlMeta(String documentId) { private CompletableFuture<ArrayList<XmlMetaPageModel>> getPagesByXmlMeta(String documentId) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory()); FileManager fileManager = fileManagerFactory.create(deviceInfoUtils.getExternalStorageDirectory());