From 55b34d964c1ad912a7ec0dee0688e6e2959ace4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:07:18 +0900 Subject: [PATCH 01/10] =?UTF-8?q?Folder=E3=82=92=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AB=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/database/dao/FolderDao.java | 8 ++++++++ .../source/database/entity/FolderEntity.java | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java create mode 100644 source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java new file mode 100644 index 00000000..be3ccbe7 --- /dev/null +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java @@ -0,0 +1,8 @@ +package one.nem.lacerta.source.database.dao; + +import androidx.room.Dao; + +@Dao +public interface FolderDao { + +} diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java new file mode 100644 index 00000000..d8236696 --- /dev/null +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java @@ -0,0 +1,19 @@ +package one.nem.lacerta.source.database.entity; + +import androidx.annotation.NonNull; +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.PrimaryKey; + +@Entity(tableName = "folder") +public class FolderEntity { + + @PrimaryKey + @ColumnInfo(name = "id") + @NonNull + public String id; // フォルダID + + @ColumnInfo(name = "title") + public String name; // フォルダ名 + +} From 2cfab24c76285b9f14b715f18842362123b40d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:07:28 +0900 Subject: [PATCH 02/10] =?UTF-8?q?Injection=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/data/impl/LacertaLibraryImpl.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 49f7303a..26441dec 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 @@ -1,10 +1,21 @@ package one.nem.lacerta.data.impl; +import javax.inject.Inject; + import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.source.database.LacertaDatabase; +import one.nem.lacerta.utils.LacertaLogger; public class LacertaLibraryImpl implements LacertaLibrary { + + @Inject + LacertaLogger logger; + + @Inject + LacertaDatabase database; + @Override public LibraryItemPage getRecentDocument(int limit) { return null; From b7cb4369d178a7f331b0d76038e0faae167d5674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:08:24 +0900 Subject: [PATCH 03/10] =?UTF-8?q?=E3=82=AF=E3=82=A8=E3=83=AA=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/DocumentDao.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java index 265b20bc..01bcec67 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java @@ -28,6 +28,10 @@ public interface DocumentDao { @Query("SELECT * FROM Document WHERE id IN (:ids)") List findByIds(List ids); + @Query("SELECT * FROM Document WHERE public_path = :publicPath") + DocumentEntity findByPublicPath(String publicPath); + + // Insert @Insert void insert(DocumentEntity document); From c80576d0467dcce98f7041dd2fae3f15c09fe426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:08:45 +0900 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/dao/DocumentDao.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java index 01bcec67..b4d53202 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java @@ -28,9 +28,8 @@ public interface DocumentDao { @Query("SELECT * FROM Document WHERE id IN (:ids)") List findByIds(List ids); - @Query("SELECT * FROM Document WHERE public_path = :publicPath") - DocumentEntity findByPublicPath(String publicPath); - + @Query("SELECT * FROM Document WHERE public_path = :publicPath LIMIT :limit") + List findByPublicPathWithLimit(String publicPath, int limit); // Insert @Insert From d22644e37a47c2832c7466ea693bd270b104eb6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:08:54 +0900 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E3=81=AB=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/build.gradle b/source/build.gradle index 84bcd0a1..f4c32001 100644 --- a/source/build.gradle +++ b/source/build.gradle @@ -47,4 +47,7 @@ dependencies { // Utils モジュール implementation project(':utils') + // Model + implementation project(':model') + } \ No newline at end of file From 8c9dc14f162c26a1256e5f90b6769a6a1057af68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:09:27 +0900 Subject: [PATCH 06/10] =?UTF-8?q?DB=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=87=E3=83=BC=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/LacertaDatabase.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java index bb8667ab..47e0e4bb 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java +++ b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java @@ -4,6 +4,8 @@ import androidx.room.Database; import androidx.room.RoomDatabase; // Entities +import one.nem.lacerta.source.database.dao.FolderDao; +import one.nem.lacerta.source.database.entity.FolderEntity; import one.nem.lacerta.source.database.entity.TagEntity; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.LibraryEntity; @@ -17,11 +19,12 @@ import one.nem.lacerta.source.database.dao.LibraryDao; import one.nem.lacerta.source.database.dao.VcsRevDao; import one.nem.lacerta.source.database.dao.VcsLogDao; -@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class}, version = 3) +@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class}, version = 4) public abstract class LacertaDatabase extends RoomDatabase { public abstract TagDao tagDao(); public abstract DocumentDao documentDao(); public abstract LibraryDao libraryDao(); public abstract VcsRevDao vcsRevDao(); public abstract VcsLogDao vcsLogDao(); + public abstract FolderDao folderDao(); } From c82952f397a3ec074f43472db6c825bdcf1275e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:11:12 +0900 Subject: [PATCH 07/10] =?UTF-8?q?=E3=82=B9=E3=82=AD=E3=83=BC=E3=83=9E?= =?UTF-8?q?=E6=9B=B4=E6=96=B0,=20Dao=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/source/database/dao/FolderDao.java | 15 +++++++++++++++ .../source/database/entity/FolderEntity.java | 3 +++ 2 files changed, 18 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java index be3ccbe7..1d429245 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/FolderDao.java @@ -1,8 +1,23 @@ package one.nem.lacerta.source.database.dao; import androidx.room.Dao; +import androidx.room.Insert; +import androidx.room.Query; + +import one.nem.lacerta.source.database.entity.FolderEntity; @Dao public interface FolderDao { + @Query("SELECT * FROM Folder WHERE id = :id") + FolderEntity findById(String id); + + @Query("SELECT * FROM Folder WHERE public_path = :publicPath") + FolderEntity findByPublicPath(String publicPath); + + @Insert + void insert(FolderEntity folderEntity); + + @Insert + void insertAll(FolderEntity... folderEntities); } diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java index d8236696..f3a9091d 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/FolderEntity.java @@ -16,4 +16,7 @@ public class FolderEntity { @ColumnInfo(name = "title") public String name; // フォルダ名 + @ColumnInfo(name = "public_path") + public String publicPath; // 公開パス + } From 3be6185c21ebe73badca9745958bf4b8e694409f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:15:47 +0900 Subject: [PATCH 08/10] =?UTF-8?q?getRecentDocument=E3=81=AE=E6=88=BB?= =?UTF-8?q?=E3=82=8A=E5=80=A4=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/data/LacertaLibrary.java | 7 +++++-- .../one/nem/lacerta/data/impl/LacertaLibraryImpl.java | 7 +++++-- .../one/nem/lacerta/data/impl/LacertaLibraryStubImpl.java | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) 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 4748d7d0..eeb8546b 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -1,5 +1,8 @@ package one.nem.lacerta.data; +import java.util.ArrayList; + +import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.LibraryItemPage; @@ -8,8 +11,8 @@ import one.nem.lacerta.model.document.DocumentDetail; public interface LacertaLibrary { // Get History - LibraryItemPage getRecentDocument(int limit); - LibraryItemPage getRecentDocument(int limit, int offset); + ArrayList getRecentDocument(int limit); + ArrayList getRecentDocument(int limit, int offset); // Get Library page LibraryItemPage getLibraryPage(int limit); 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 26441dec..bf6a8a8f 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 @@ -1,9 +1,12 @@ package one.nem.lacerta.data.impl; +import java.util.ArrayList; + import javax.inject.Inject; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; +import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.utils.LacertaLogger; @@ -17,12 +20,12 @@ public class LacertaLibraryImpl implements LacertaLibrary { LacertaDatabase database; @Override - public LibraryItemPage getRecentDocument(int limit) { + public ArrayList getRecentDocument(int limit) { return null; } @Override - public LibraryItemPage getRecentDocument(int limit, int offset) { + public ArrayList getRecentDocument(int limit, int offset) { return null; } diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryStubImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryStubImpl.java index 47d547f8..df5aec9a 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryStubImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryStubImpl.java @@ -148,8 +148,8 @@ public class LacertaLibraryStubImpl implements LacertaLibrary { * @return ページオブジェクト */ @Override - public LibraryItemPage getRecentDocument(int limit) { - return getRecentDocumentPage(limit); + public ArrayList getRecentDocument(int limit) { + return getRecentDocumentPage(limit).getListItems(); } /** @@ -159,8 +159,8 @@ public class LacertaLibraryStubImpl implements LacertaLibrary { * @return ページオブジェクト */ @Override - public LibraryItemPage getRecentDocument(int limit, int offset) { - return getRecentDocumentPage(limit); + public ArrayList getRecentDocument(int limit, int offset) { + return getRecentDocumentPage(limit).getListItems(); } /** From 1c3fdf921d2545c5ac312b5333eafba01995dd03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:52:05 +0900 Subject: [PATCH 09/10] =?UTF-8?q?Dao=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/dao/DocumentDao.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java index b4d53202..802afb7f 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/DocumentDao.java @@ -31,6 +31,9 @@ public interface DocumentDao { @Query("SELECT * FROM Document WHERE public_path = :publicPath LIMIT :limit") List findByPublicPathWithLimit(String publicPath, int limit); + @Query("SELECT * FROM Document ORDER BY created_at DESC LIMIT :limit") + List getRecentDocument(int limit); + // Insert @Insert void insert(DocumentEntity document); From e0d63122bdf695e7d45ee58bf2ccad6862678a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:52:13 +0900 Subject: [PATCH 10/10] =?UTF-8?q?getRecentDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) 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 bf6a8a8f..01a7209f 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 @@ -1,14 +1,19 @@ package one.nem.lacerta.data.impl; +import java.text.DateFormat; import java.util.ArrayList; +import java.util.List; import javax.inject.Inject; import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.ListItem; +import one.nem.lacerta.model.ListItemType; import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.source.database.LacertaDatabase; +import one.nem.lacerta.source.database.common.DateTypeConverter; +import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.utils.LacertaLogger; public class LacertaLibraryImpl implements LacertaLibrary { @@ -21,12 +26,23 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public ArrayList getRecentDocument(int limit) { - return null; + List documentEntities = database.documentDao().getRecentDocument(limit); + + ArrayList listItems = new ArrayList<>(); + for (DocumentEntity documentEntity : documentEntities) { + ListItem listItem = new ListItem(); + listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); + listItem.setTitle(documentEntity.title); + listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); + listItem.setItemId(documentEntity.id); + listItems.add(listItem); + } + return listItems; } @Override public ArrayList getRecentDocument(int limit, int offset) { - return null; + return null; // TODO-rca: Implement } @Override