diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java index c5957e8b..eb11e289 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -20,6 +20,9 @@ public interface LacertaLibrary { CompletableFuture getLibraryPage(String pageId, int limit); CompletableFuture getLibraryPage(String pageId, int limit, int offset); + // Get Folder List + CompletableFuture> getFolderList(String parentId); + // Create Folder CompletableFuture createFolder(String parentId, String name); 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 5067f701..139cf2bf 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 @@ -127,6 +127,31 @@ public class LacertaLibraryImpl implements LacertaLibrary { }); } + @Override + public CompletableFuture> getFolderList(String parentId) { + return CompletableFuture.supplyAsync(() -> { + List folderEntities; + if (parentId == null) { // When root folder + folderEntities = database.folderDao().findRootFolders(); + } else { + folderEntities = database.folderDao().findByParentId(parentId); + } + + ArrayList listItems = new ArrayList<>(); + for (FolderEntity childFolderEntity : folderEntities) { + logger.debug("LacertaLibraryImpl", "childFolderEntity.name: " + childFolderEntity.name); + ListItem listItem = new ListItem(); + listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER); + listItem.setTitle(childFolderEntity.name); + listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる + listItem.setItemId(childFolderEntity.id); + listItems.add(listItem); + } + + return listItems; + }); + } + @Override public CompletableFuture createFolder(String parentId, String name) { return CompletableFuture.supplyAsync(() -> {