From cbe5d1069aa01bd7cf5242be0e2abfa0b42822cc Mon Sep 17 00:00:00 2001 From: r-ca Date: Thu, 14 Dec 2023 01:20:21 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E6=A7=8B=E6=88=90=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/source/db/LacertaDatabase.java | 15 ------ .../one/nem/lacerta/source/db/RoomUtils.java | 20 ------- .../lacerta/source/db/RoomUtilsModule.java | 16 ------ .../lacerta/source/db/dao/DocumentsDao.java | 26 ---------- .../source/db/dao/RepositoriesDao.java | 25 --------- .../one/nem/lacerta/source/db/dao/placeholder | 0 .../lacerta/source/db/entity/Documents.java | 35 ------------- .../source/db/entity/Repositories.java | 16 ------ .../nem/lacerta/source/db/entity/placeholder | 0 .../nem/lacerta/source/jgit/RepoUtils.java | 52 ------------------- .../one/nem/lacerta/source/jgit/placeholder | 0 .../debug/DebugPlayGroundFragment.java | 7 ++- .../res/layout/fragment_debug_play_ground.xml | 34 ++++++++++++ .../nem/lacerta/utils/impl/FileUtilsImpl.java | 30 ----------- .../lacerta/utils/module/FileUtilsModule.java | 17 ------ .../lacerta/utils/repository/FileUtils.java | 11 ---- 16 files changed, 40 insertions(+), 264 deletions(-) delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/LacertaDatabase.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/RoomUtils.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/RoomUtilsModule.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/dao/DocumentsDao.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/dao/RepositoriesDao.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/dao/placeholder delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/entity/Documents.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/entity/Repositories.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/db/entity/placeholder delete mode 100644 data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java delete mode 100644 data/src/main/java/one/nem/lacerta/source/jgit/placeholder delete mode 100644 utils/src/main/java/one/nem/lacerta/utils/impl/FileUtilsImpl.java delete mode 100644 utils/src/main/java/one/nem/lacerta/utils/module/FileUtilsModule.java delete mode 100644 utils/src/main/java/one/nem/lacerta/utils/repository/FileUtils.java diff --git a/data/src/main/java/one/nem/lacerta/source/db/LacertaDatabase.java b/data/src/main/java/one/nem/lacerta/source/db/LacertaDatabase.java deleted file mode 100644 index 0d064bcd..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/LacertaDatabase.java +++ /dev/null @@ -1,15 +0,0 @@ -package one.nem.lacerta.source.db; - -import androidx.room.Database; -import androidx.room.RoomDatabase; - -import one.nem.lacerta.source.db.dao.DocumentsDao; -import one.nem.lacerta.source.db.dao.RepositoriesDao; -import one.nem.lacerta.source.db.entity.Documents; -import one.nem.lacerta.source.db.entity.Repositories; - -@Database(entities = {Documents.class, Repositories.class}, version = 1) -public abstract class LacertaDatabase extends RoomDatabase { - public abstract DocumentsDao documentsDao(); - public abstract RepositoriesDao repositoriesDao(); -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/RoomUtils.java b/data/src/main/java/one/nem/lacerta/source/db/RoomUtils.java deleted file mode 100644 index 6c51c58e..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/RoomUtils.java +++ /dev/null @@ -1,20 +0,0 @@ -package one.nem.lacerta.source.db; - -import android.content.Context; - -import javax.inject.Inject; - -import dagger.hilt.android.qualifiers.ApplicationContext; - -public class RoomUtils { - // Internal Utils - - - - @Inject // TODO-rca: 実装を切り離す? - RoomUtils(@ApplicationContext Context context) { - - } - - -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/RoomUtilsModule.java b/data/src/main/java/one/nem/lacerta/source/db/RoomUtilsModule.java deleted file mode 100644 index 2676fb53..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/RoomUtilsModule.java +++ /dev/null @@ -1,16 +0,0 @@ -package one.nem.lacerta.source.db; - -import android.content.Context; - -import dagger.Binds; -import dagger.Module; -import dagger.hilt.InstallIn; -import dagger.hilt.components.SingletonComponent; - -@Module -@InstallIn(SingletonComponent.class) -abstract public class RoomUtilsModule { - - @Binds - public abstract RoomUtils bindRoomUtils(Context context); -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/dao/DocumentsDao.java b/data/src/main/java/one/nem/lacerta/source/db/dao/DocumentsDao.java deleted file mode 100644 index 8cf66b47..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/dao/DocumentsDao.java +++ /dev/null @@ -1,26 +0,0 @@ -package one.nem.lacerta.source.db.dao; - - -import androidx.room.Dao; -import androidx.room.Query; - -import java.util.List; - -import one.nem.lacerta.source.db.entity.Documents; - -@Dao -public interface DocumentsDao { - - @Query("SELECT * FROM documents") - List getAll(); - - @Query("SELECT * FROM documents WHERE id IN (:ids)") - List loadAllByIds(int[] ids); - - @Query("SELECT * FROM documents WHERE title LIKE :title LIMIT 1") - Documents findByTitle(String title); - - @Query("SELECT * FROM documents WHERE id LIKE :id LIMIT 1") - Documents findById(String id); - -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/dao/RepositoriesDao.java b/data/src/main/java/one/nem/lacerta/source/db/dao/RepositoriesDao.java deleted file mode 100644 index ad87de1c..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/dao/RepositoriesDao.java +++ /dev/null @@ -1,25 +0,0 @@ -package one.nem.lacerta.source.db.dao; - -import androidx.room.Dao; -import androidx.room.Query; - -import java.util.List; - -import one.nem.lacerta.source.db.entity.Repositories; - -@Dao -public interface RepositoriesDao { - - @Query("SELECT * FROM repositories") - List getAll(); - - @Query("SELECT * FROM repositories WHERE id IN (:ids)") - List loadAllByIds(int[] ids); - - @Query("SELECT * FROM repositories WHERE relative_path LIKE :relativePath LIMIT 1") - Repositories findByRelativePath(String relativePath); - - @Query("SELECT * FROM repositories WHERE id LIKE :id LIMIT 1") - Repositories findById(String id); - -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/dao/placeholder b/data/src/main/java/one/nem/lacerta/source/db/dao/placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/data/src/main/java/one/nem/lacerta/source/db/entity/Documents.java b/data/src/main/java/one/nem/lacerta/source/db/entity/Documents.java deleted file mode 100644 index 123f4cbc..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/entity/Documents.java +++ /dev/null @@ -1,35 +0,0 @@ -package one.nem.lacerta.source.db.entity; - -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -import java.util.Date; - -import one.nem.lacerta.data.model.documents.enums.DocumentType; - -@Entity -public class Documents { - @PrimaryKey - private String id; - - @ColumnInfo(name = "title") - private String title; // Titleに変更する? - - @ColumnInfo(name = "type") - private DocumentType type; // DocumentTypeに変更する? - - @ColumnInfo(name = "created") - private Date created; - - @ColumnInfo(name = "updated") - private Date updated; - - @ColumnInfo(name = "tags") - private String[] tags; - - @ColumnInfo(name = "categories") - private String[] categories; - - // WIP -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/entity/Repositories.java b/data/src/main/java/one/nem/lacerta/source/db/entity/Repositories.java deleted file mode 100644 index 8d5a6567..00000000 --- a/data/src/main/java/one/nem/lacerta/source/db/entity/Repositories.java +++ /dev/null @@ -1,16 +0,0 @@ -package one.nem.lacerta.source.db.entity; - -import androidx.room.ColumnInfo; -import androidx.room.Entity; -import androidx.room.PrimaryKey; - -@Entity -public class Repositories { - - @PrimaryKey - private String id; - - @ColumnInfo(name = "relative_path") - private String relativePath; - -} diff --git a/data/src/main/java/one/nem/lacerta/source/db/entity/placeholder b/data/src/main/java/one/nem/lacerta/source/db/entity/placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java b/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java deleted file mode 100644 index 134f8117..00000000 --- a/data/src/main/java/one/nem/lacerta/source/jgit/RepoUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -package one.nem.lacerta.source.jgit; - -import org.eclipse.jgit.internal.storage.file.FileRepository; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; - -import java.io.File; -import java.nio.file.Path; - -import javax.inject.Inject; - -import one.nem.lacerta.utils.repository.FileUtils; - -public class RepoUtils { - // Internal Utils - - @Inject // TODO-rca: 実装を切り離す? - RepoUtils() { - } - - @Inject - FileUtils fileUtils; - - - public Repository createRepo(String id) { - Path rootPath = fileUtils.getExternalFilesDirPath(); - - try { - Repository repo = new FileRepositoryBuilder().setGitDir(rootPath.resolve(id).resolve(".git").toFile()).build(); - repo.create(); - return repo; - } catch (Exception e) { - // TODO-rca: handle exception - return null; - } - } - public Repository getRepo(String id) { - Path rootPath = fileUtils.getExternalFilesDirPath(); - try { - Repository repo = new FileRepositoryBuilder().setGitDir(rootPath.resolve(id).resolve(".git").toFile()).build(); - return repo; - } catch (Exception e) { - // TODO-rca: handle exception - return null; - } - } - public String getRepoName(Repository repo) { - return repo.getDirectory().getParentFile().getName(); - } - - -} diff --git a/data/src/main/java/one/nem/lacerta/source/jgit/placeholder b/data/src/main/java/one/nem/lacerta/source/jgit/placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java index 1a35138c..64b941ae 100644 --- a/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java +++ b/feature/debug/src/main/java/one/nem/lacerta/feature/debug/DebugPlayGroundFragment.java @@ -15,6 +15,8 @@ import one.nem.lacerta.data.repository.SharedPref; import one.nem.lacerta.data.model.shared_pref.enums.SharedPrefType; +import one.nem.lacerta.source.db.LacertaDatabase; + import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; @@ -28,6 +30,9 @@ public class DebugPlayGroundFragment extends Fragment { @Inject // DI SharedPref sharedPref; + @Inject + LacertaDatabase lacertaDatabase; // TODO-rca: Repositoryを噛ませる + public DebugPlayGroundFragment() { // Required empty public constructor } @@ -60,6 +65,6 @@ public class DebugPlayGroundFragment extends Fragment { // (viewは引数として受け取ってるviewなので、別メソッドに切り出したりするなら渡してあげる) // ShardPrefの要素数をトーストする例 - Toast.makeText(getContext(), "SharedPrefの要素数: " + sharedPref.getSharedPreferencesByTag(SharedPrefType.COMMON).getAll().size(), Toast.LENGTH_SHORT).show(); + Toast.makeText(getContext(), "DBの要素数" + lacertaDatabase.repositoriesDao(), Toast.LENGTH_SHORT).show(); } } \ No newline at end of file diff --git a/feature/debug/src/main/res/layout/fragment_debug_play_ground.xml b/feature/debug/src/main/res/layout/fragment_debug_play_ground.xml index 7e710ee1..a61cd016 100644 --- a/feature/debug/src/main/res/layout/fragment_debug_play_ground.xml +++ b/feature/debug/src/main/res/layout/fragment_debug_play_ground.xml @@ -11,4 +11,38 @@ android:layout_height="match_parent" android:text="@string/hello_blank_fragment" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/utils/src/main/java/one/nem/lacerta/utils/impl/FileUtilsImpl.java b/utils/src/main/java/one/nem/lacerta/utils/impl/FileUtilsImpl.java deleted file mode 100644 index 8bcb1f9f..00000000 --- a/utils/src/main/java/one/nem/lacerta/utils/impl/FileUtilsImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package one.nem.lacerta.utils.impl; - -import android.content.Context; - -import java.nio.file.Path; -import java.util.Objects; - -import javax.inject.Inject; - -import dagger.hilt.android.qualifiers.ApplicationContext; - -import one.nem.lacerta.utils.repository.FileUtils; - -public class FileUtilsImpl implements FileUtils { - - private final Context applicationContext; - - @Inject - public FileUtilsImpl(@ApplicationContext Context applicationContext) { - this.applicationContext = applicationContext; - } - - public Path getExternalFilesDirPath(String type) { - return Objects.requireNonNull(applicationContext.getExternalFilesDir(type)).toPath(); - } - - public Path getExternalFilesDirPath() { - return Objects.requireNonNull(applicationContext.getExternalFilesDir(null)).toPath(); - } -} diff --git a/utils/src/main/java/one/nem/lacerta/utils/module/FileUtilsModule.java b/utils/src/main/java/one/nem/lacerta/utils/module/FileUtilsModule.java deleted file mode 100644 index 0d136a46..00000000 --- a/utils/src/main/java/one/nem/lacerta/utils/module/FileUtilsModule.java +++ /dev/null @@ -1,17 +0,0 @@ -package one.nem.lacerta.utils.module; - -import dagger.Binds; -import dagger.Module; -import dagger.hilt.InstallIn; -import dagger.hilt.components.SingletonComponent; -import one.nem.lacerta.utils.repository.FileUtils; -import one.nem.lacerta.utils.impl.FileUtilsImpl; - -@Module -@InstallIn(SingletonComponent.class) -abstract public class FileUtilsModule { - - @Binds - public abstract FileUtils bindFileUtils(FileUtilsImpl fileUtilsImpl); - -} diff --git a/utils/src/main/java/one/nem/lacerta/utils/repository/FileUtils.java b/utils/src/main/java/one/nem/lacerta/utils/repository/FileUtils.java deleted file mode 100644 index 3ef84652..00000000 --- a/utils/src/main/java/one/nem/lacerta/utils/repository/FileUtils.java +++ /dev/null @@ -1,11 +0,0 @@ -package one.nem.lacerta.utils.repository; - -import java.nio.file.Path; - -public interface FileUtils { - - Path getExternalFilesDirPath(String type); - - Path getExternalFilesDirPath(); - -}