From 4dc68854d38551e17afa6ae1a68525185afc0eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 14 Dec 2023 10:50:33 +0900 Subject: [PATCH] =?UTF-8?q?=E5=90=8D=E5=89=8D=E3=81=8C=E7=B4=9B=E3=82=89?= =?UTF-8?q?=E3=82=8F=E3=81=97=E3=81=99=E3=81=8E=E3=81=9F=E3=81=AE=E3=81=A7?= =?UTF-8?q?*Entity=E3=81=AB=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/data/impl/DocumentImpl.java | 4 --- .../source/database/LacertaDatabase.java | 8 ++--- .../source/database/dao/DocumentDao.java | 34 +++++++++---------- .../source/database/dao/LibraryDao.java | 14 ++++---- .../lacerta/source/database/dao/TagDao.java | 34 +++++++++---------- .../{Document.java => DocumentEntity.java} | 2 +- .../{Library.java => LibraryEntity.java} | 2 +- .../entity/{Tag.java => TagEntity.java} | 2 +- 8 files changed, 48 insertions(+), 52 deletions(-) rename source/src/main/java/one/nem/lacerta/source/database/entity/{Document.java => DocumentEntity.java} (96%) rename source/src/main/java/one/nem/lacerta/source/database/entity/{Library.java => LibraryEntity.java} (94%) rename source/src/main/java/one/nem/lacerta/source/database/entity/{Tag.java => TagEntity.java} (94%) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 117e0c88..74bd1f1b 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -8,10 +8,6 @@ import one.nem.lacerta.data.Document; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentDetail; -import one.nem.lacerta.model.document.path.DocumentPath; -import one.nem.lacerta.model.document.tag.DocumentTag; - -import one.nem.lacerta.source.database.entity.Document; import one.nem.lacerta.source.database.LacertaDatabase; 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 4909c922..68aea700 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,16 +4,16 @@ import androidx.room.Database; import androidx.room.RoomDatabase; // Entities -import one.nem.lacerta.source.database.entity.Tag; -import one.nem.lacerta.source.database.entity.Document; -import one.nem.lacerta.source.database.entity.Library; +import one.nem.lacerta.source.database.entity.TagEntity; +import one.nem.lacerta.source.database.entity.DocumentEntity; +import one.nem.lacerta.source.database.entity.LibraryEntity; // Daos import one.nem.lacerta.source.database.dao.TagDao; import one.nem.lacerta.source.database.dao.DocumentDao; import one.nem.lacerta.source.database.dao.LibraryDao; -@Database(entities = {Tag.class, Document.class, Library.class}, version = 1) +@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class}, version = 1) public abstract class LacertaDatabase extends RoomDatabase { public abstract TagDao tagDao(); public abstract DocumentDao documentDao(); 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 f744f160..6503d67e 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 @@ -8,7 +8,7 @@ import androidx.room.Update; import java.util.List; -import one.nem.lacerta.source.database.entity.Document; +import one.nem.lacerta.source.database.entity.DocumentEntity; @Dao @@ -16,46 +16,46 @@ public interface DocumentDao { // Select - @Query("SELECT * FROM document WHERE id = :id") - Document findById(String id); + @Query("SELECT * FROM DocumentEntity WHERE id = :id") + DocumentEntity findById(String id); - @Query("SELECT * FROM document") - List findAll(); + @Query("SELECT * FROM DocumentEntity") + List findAll(); - @Query("SELECT * FROM document WHERE id IN (:ids)") - List findByIds(List ids); + @Query("SELECT * FROM DocumentEntity WHERE id IN (:ids)") + List findByIds(List ids); // Insert @Insert - void insert(Document document); + void insert(DocumentEntity document); @Insert - void insertAll(Document... documents); + void insertAll(DocumentEntity... documents); @Insert - void insertAll(List documents); + void insertAll(List documents); // Update @Update - void update(Document document); + void update(DocumentEntity document); @Update - void updateAll(Document... documents); + void updateAll(DocumentEntity... documents); @Update - void updateAll(List documents); + void updateAll(List documents); // Delete @Delete - void delete(Document document); + void delete(DocumentEntity document); @Delete - void deleteAll(Document... documents); + void deleteAll(DocumentEntity... documents); @Delete - void deleteAll(List documents); + void deleteAll(List documents); - @Query("DELETE FROM document WHERE id = :id") + @Query("DELETE FROM DocumentEntity WHERE id = :id") void deleteById(String id); } diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/LibraryDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/LibraryDao.java index 87a05162..ddb74188 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/LibraryDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/LibraryDao.java @@ -5,19 +5,19 @@ import androidx.room.Query; import java.util.List; -import one.nem.lacerta.source.database.entity.Library; +import one.nem.lacerta.source.database.entity.LibraryEntity; @Dao public interface LibraryDao { - @Query("SELECT * FROM library WHERE id = :id") - Library findById(String id); + @Query("SELECT * FROM LibraryEntity WHERE id = :id") + LibraryEntity findById(String id); - @Query("SELECT * FROM library") - List findAll(); + @Query("SELECT * FROM LibraryEntity") + List findAll(); - @Query("SELECT * FROM library WHERE id IN (:ids)") - List findByIds(List ids); + @Query("SELECT * FROM LibraryEntity WHERE id IN (:ids)") + List findByIds(List ids); // WIP // TODO-rca: Insert, Update, Delete diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/TagDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/TagDao.java index 125bc4f3..850d22ec 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/TagDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/TagDao.java @@ -8,52 +8,52 @@ import androidx.room.Update; import java.util.List; -import one.nem.lacerta.source.database.entity.Tag; +import one.nem.lacerta.source.database.entity.TagEntity; @Dao public interface TagDao { // Select - @Query("SELECT * FROM tag WHERE id = :id") - Tag findById(String id); + @Query("SELECT * FROM TagEntity WHERE id = :id") + TagEntity findById(String id); - @Query("SELECT * FROM tag") - List findAll(); + @Query("SELECT * FROM TagEntity") + List findAll(); - @Query("SELECT * FROM tag WHERE id IN (:ids)") - List findByIds(List ids); + @Query("SELECT * FROM TagEntity WHERE id IN (:ids)") + List findByIds(List ids); // Insert @Insert - void insert(Tag tag); + void insert(TagEntity tag); @Insert - void insertAll(Tag... tags); + void insertAll(TagEntity... tags); @Insert - void insertAll(List tags); + void insertAll(List tags); // Update @Update - void update(Tag tag); + void update(TagEntity tag); @Update - void updateAll(Tag... tags); + void updateAll(TagEntity... tags); @Update - void updateAll(List tags); + void updateAll(List tags); // Delete @Delete - void delete(Tag tag); + void delete(TagEntity tag); @Delete - void deleteAll(Tag... tags); + void deleteAll(TagEntity... tags); @Delete - void deleteAll(List tags); + void deleteAll(List tags); - @Query("DELETE FROM tag WHERE id = :id") + @Query("DELETE FROM TagEntity WHERE id = :id") void deleteById(String id); } diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/Document.java b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java similarity index 96% rename from source/src/main/java/one/nem/lacerta/source/database/entity/Document.java rename to source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java index 528070ab..60a4a162 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/Document.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java @@ -12,7 +12,7 @@ import java.util.Date; @Entity(tableName = "document") @TypeConverters(DateTypeConverter.class) -public class Document { +public class DocumentEntity { @PrimaryKey @ColumnInfo(name = "id") @NonNull diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/Library.java b/source/src/main/java/one/nem/lacerta/source/database/entity/LibraryEntity.java similarity index 94% rename from source/src/main/java/one/nem/lacerta/source/database/entity/Library.java rename to source/src/main/java/one/nem/lacerta/source/database/entity/LibraryEntity.java index 34cb7e1c..2fff1b57 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/Library.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/LibraryEntity.java @@ -6,7 +6,7 @@ import androidx.room.Entity; import androidx.room.PrimaryKey; @Entity(tableName = "library") -public class Library { +public class LibraryEntity { @PrimaryKey @ColumnInfo(name = "id") diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/Tag.java b/source/src/main/java/one/nem/lacerta/source/database/entity/TagEntity.java similarity index 94% rename from source/src/main/java/one/nem/lacerta/source/database/entity/Tag.java rename to source/src/main/java/one/nem/lacerta/source/database/entity/TagEntity.java index c34be882..ff7e9a82 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/Tag.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/TagEntity.java @@ -6,7 +6,7 @@ import androidx.room.Entity; import androidx.room.PrimaryKey; @Entity(tableName = "tag") -public class Tag { +public class TagEntity { @PrimaryKey @ColumnInfo(name = "id")