diff --git a/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml
new file mode 100644
index 00000000..4e72834f
--- /dev/null
+++ b/component/common/src/main/res/layout/lacerta_dialog_create_tag.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 51a236c5..19cd9b34 100644
--- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java
+++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java
@@ -9,6 +9,7 @@ import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.LibraryItemPage;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
+import one.nem.lacerta.model.document.tag.DocumentTag;
public interface LacertaLibrary {
@@ -29,4 +30,17 @@ public interface LacertaLibrary {
// Get Public Path
CompletableFuture getPublicPath(String itemId, ListItemType itemType);
+
+ // Tag
+ CompletableFuture> getTagList();
+
+ CompletableFuture createTag(DocumentTag tag);
+
+ CompletableFuture updateTag(DocumentTag tag);
+
+ CompletableFuture deleteTag(String tagId);
+
+ CompletableFuture addTagToDocument(String documentId, String tagId);
+
+ CompletableFuture removeTagFromDocument(String documentId, String tagId);
}
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 9c1e2c47..bcd3318e 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
@@ -78,11 +78,9 @@ public class DocumentImpl implements Document {
documentEntity.id = meta.getId();
documentEntity.title = meta.getTitle();
documentEntity.author = meta.getAuthor();
- documentEntity.defaultBranch = meta.getDefaultBranch();
documentEntity.updatedAt = meta.getUpdatedAt();
documentEntity.createdAt = meta.getCreatedAt();
documentEntity.parentId = meta.getParentId();
- documentEntity.tagIds = meta.getTagIds();
database.documentDao().insert(documentEntity);
@@ -103,11 +101,9 @@ public class DocumentImpl implements Document {
meta.setId(UUID.randomUUID().toString());
meta.setTitle("New Document");
meta.setAuthor("author");
- meta.setDefaultBranch("master");
meta.setUpdatedAt(new Date());
meta.setCreatedAt(new Date());
meta.setParentId(null);
- meta.setTags(new ArrayList<>());
return createDocument(meta);
}
@@ -168,11 +164,9 @@ public class DocumentImpl implements Document {
meta.setId(documentEntity.id);
meta.setTitle(documentEntity.title);
meta.setAuthor(documentEntity.author);
- meta.setDefaultBranch(documentEntity.defaultBranch);
meta.setUpdatedAt(documentEntity.updatedAt);
meta.setCreatedAt(documentEntity.createdAt);
meta.setParentId(documentEntity.parentId);
- meta.setTags(new ArrayList<>()); // TODO-rca: タグを取得する
DocumentDetail detail = new DocumentDetail();
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 4a8cd0b3..88ef000f 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,5 +1,7 @@
package one.nem.lacerta.data.impl;
+import android.nfc.Tag;
+
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
@@ -18,10 +20,13 @@ import one.nem.lacerta.model.ListItem;
import one.nem.lacerta.model.ListItemType;
import one.nem.lacerta.model.PublicPath;
import one.nem.lacerta.model.document.DocumentDetail;
+import one.nem.lacerta.model.document.tag.DocumentTag;
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.source.database.entity.FolderEntity;
+import one.nem.lacerta.source.database.entity.TagEntity;
+import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
import one.nem.lacerta.utils.FeatureSwitch;
import one.nem.lacerta.utils.LacertaLogger;
@@ -205,6 +210,86 @@ public class LacertaLibraryImpl implements LacertaLibrary {
});
}
+ // Converter
+ private DocumentTag convertTagEntityToDocumentTag(TagEntity tagEntity) {
+ DocumentTag documentTag = new DocumentTag();
+ documentTag.setId(tagEntity.id);
+ documentTag.setName(tagEntity.tagName);
+ documentTag.setColor(tagEntity.color);
+ return documentTag;
+ }
+
+ private TagEntity convertDocumentTagToTagEntity(DocumentTag documentTag) {
+ TagEntity tagEntity = new TagEntity();
+ tagEntity.id = documentTag.getId();
+ tagEntity.tagName = documentTag.getName();
+ tagEntity.color = documentTag.getColor();
+ return tagEntity;
+ }
+
+ @Override
+ public CompletableFuture> getTagList() {
+ return CompletableFuture.supplyAsync(() -> {
+ List tagEntities = database.tagDao().findAll();
+ logger.debug("LacertaLibraryImpl", "Database Query: Get TagEntity List (Size: " + tagEntities.size() + ")");
+ ArrayList documentTags = new ArrayList<>();
+ for (TagEntity tagEntity : tagEntities) {
+ documentTags.add(convertTagEntityToDocumentTag(tagEntity));
+ }
+ return documentTags;
+ });
+ }
+
+ @Override
+ public CompletableFuture createTag(DocumentTag tag) {
+ return CompletableFuture.supplyAsync(() -> {
+ TagEntity tagEntity = convertDocumentTagToTagEntity(tag);
+ database.tagDao().insert(tagEntity);
+ logger.debug("LacertaLibraryImpl", "Database Query: Inserted TagEntity (" + tag.getId() + ")");
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture updateTag(DocumentTag tag) {
+ return CompletableFuture.supplyAsync(() -> {
+ TagEntity tagEntity = convertDocumentTagToTagEntity(tag);
+ database.tagDao().update(tagEntity);
+ logger.debug("LacertaLibraryImpl", "Database Query: Updated TagEntity (" + tag.getId() + ")");
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture deleteTag(String tagId) {
+ return CompletableFuture.supplyAsync(() -> {
+ database.tagDao().deleteById(tagId);
+ logger.debug("LacertaLibraryImpl", "Database Query: Deleted TagEntity (" + tagId + ")");
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture addTagToDocument(String documentId, String tagId) {
+ return CompletableFuture.supplyAsync(() -> {
+ ToxiDocumentTagEntity toxiDocumentTagEntity = new ToxiDocumentTagEntity();
+ toxiDocumentTagEntity.documentId = documentId;
+ toxiDocumentTagEntity.tagId = tagId;
+ database.toxiDocumentTagDao().insert(toxiDocumentTagEntity);
+ logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentTagEntity");
+ return null;
+ });
+ }
+
+ @Override
+ public CompletableFuture removeTagFromDocument(String documentId, String tagId) {
+ return CompletableFuture.supplyAsync(() -> {
+ database.toxiDocumentTagDao().deleteByDocumentIdAndTagId(documentId, tagId);
+ logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentTagEntity");
+ return null;
+ });
+ }
+
/**
* 再帰的にパスを解決する
*
diff --git a/feature/setting/build.gradle b/feature/setting/build.gradle
index 31595be7..db8a19e6 100644
--- a/feature/setting/build.gradle
+++ b/feature/setting/build.gradle
@@ -1,5 +1,6 @@
plugins {
alias(libs.plugins.com.android.library)
+ id 'com.google.dagger.hilt.android'
}
android {
@@ -45,6 +46,10 @@ dependencies {
// shared
implementation project(':shared:ui')
+ implementation project(':data')
+
+ implementation project(':model')
+
// https://mvnrepository.com/artifact/androidx.preference/preference
implementation 'androidx.preference:preference:1.2.1'
diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java
new file mode 100644
index 00000000..46f96a7a
--- /dev/null
+++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTagManageFragment.java
@@ -0,0 +1,112 @@
+package one.nem.lacerta.setting;
+
+import android.os.Bundle;
+
+import androidx.appcompat.widget.Toolbar;
+import androidx.fragment.app.Fragment;
+import androidx.navigation.Navigation;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+import javax.inject.Inject;
+
+import dagger.hilt.android.AndroidEntryPoint;
+import one.nem.lacerta.data.LacertaLibrary;
+
+/**
+ * A simple {@link Fragment} subclass.
+ * Use the {@link SettingTagManageFragment#newInstance} factory method to
+ * create an instance of this fragment.
+ */
+@AndroidEntryPoint
+public class SettingTagManageFragment extends Fragment {
+
+ @Inject
+ LacertaLibrary lacertaLibrary;
+
+ public SettingTagManageFragment() {
+ // Required empty public constructor
+ }
+
+ public static SettingTagManageFragment newInstance() {
+ SettingTagManageFragment fragment = new SettingTagManageFragment();
+ Bundle args = new Bundle();
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ View view = inflater.inflate(R.layout.fragment_setting_tag_manage, container, false);
+
+ // Toolbar
+ Toolbar toolbar = view.findViewById(R.id.tag_manage_toolbar);
+ toolbarSetup(toolbar, true, "タグ管理");
+
+ return view;
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ RecyclerView recyclerView = view.findViewById(R.id.tag_item_recycler_view);
+ TagListItemAdapter adapter = new TagListItemAdapter((tagId, tagName, tagColor) -> {
+ Toast.makeText(getContext(), "Tag Clicked", Toast.LENGTH_SHORT).show();
+ });
+
+ recyclerView.setAdapter(adapter);
+ recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
+
+ lacertaLibrary.getTagList().thenAccept(documentTags -> {
+ adapter.setDocumentTags(documentTags);
+ adapter.notifyDataSetChanged();
+ });
+
+ }
+
+ /**
+ * ToolbarをInitする
+ *
+ * @param toolbar Toolbar
+ * @param showBackButton 戻るボタンを表示するか
+ * @param title タイトル
+ */
+ private void toolbarSetup(Toolbar toolbar, boolean showBackButton, String title) {
+ getActivity().runOnUiThread(() -> {
+ if (showBackButton) {
+ toolbar.setNavigationIcon(one.nem.lacerta.shared.ui.R.drawable.arrow_back_24px);
+ toolbar.setNavigationOnClickListener(v -> {
+ //this.libraryItemPage = lacertaLibrary.getLibraryPage(this.libraryItemPage.getParentId(), 10).join();
+ // Back
+ Navigation.findNavController(requireView()).popBackStack();
+ });
+ } else {
+ toolbar.setNavigationIcon(null);
+ }
+ toolbar.setTitle(title);
+ toolbar.getMenu().clear();
+ toolbar.inflateMenu(R.menu.setting_tag_manage_menu);
+ toolbar.setOnMenuItemClickListener(item -> {
+ if (item.getItemId() == R.id.setting_tag_manage_menu_add) {
+ Toast.makeText(getContext(), "Add Clicked", Toast.LENGTH_SHORT).show();
+ return true;
+ } else {
+ return false;
+ }
+ });
+ });
+ }
+}
\ No newline at end of file
diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java
index 6c789b17..364104e0 100644
--- a/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java
+++ b/feature/setting/src/main/java/one/nem/lacerta/setting/SettingTopFragment.java
@@ -74,6 +74,15 @@ public class SettingTopFragment extends Fragment {
)
);
+ settingListItems.add(
+ new SettingListItem(
+ "タグ管理", // TODO-rca: リソースに移動
+ "タグの追加・編集・削除", // TODO-rca: リソースに移動
+ ContextCompat.getDrawable(getContext(), one.nem.lacerta.shared.ui.R.drawable.sell_24px),
+ R.id.action_settingTopFragment_to_settingTagManageFragment
+ )
+ );
+
settingListItems.add(
new SettingListItem(
getResources().getString(one.nem.lacerta.shared.ui.R.string.setting_top_about_title),
diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemAdapter.java b/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemAdapter.java
new file mode 100644
index 00000000..539f12cd
--- /dev/null
+++ b/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemAdapter.java
@@ -0,0 +1,69 @@
+package one.nem.lacerta.setting;
+
+import android.graphics.Color;
+import android.media.Image;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import java.util.ArrayList;
+
+import one.nem.lacerta.model.document.tag.DocumentTag;
+
+public class TagListItemAdapter extends RecyclerView.Adapter {
+
+ ArrayList documentTags;
+
+ TagListItemSelectListener listener;
+
+ public TagListItemAdapter(TagListItemSelectListener listener) {
+ this.listener = listener;
+ }
+
+ public void setDocumentTags(ArrayList documentTags) {
+ this.documentTags = documentTags;
+ }
+
+ @NonNull
+ @Override
+ public TagListItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(one.nem.lacerta.shared.ui.R.layout.tag_list_full_item, parent, false);
+ return new TagListItemViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull TagListItemViewHolder holder, int position) {
+ DocumentTag documentTag = documentTags.get(position);
+
+ holder.tag_name.setText(documentTag.getName());
+ try {
+ holder.tag_icon.setColorFilter(Color.parseColor(documentTag.getColor()));
+ } catch (Exception e) {
+ holder.tag_name.setText("Sorry, Parse Error occurred");
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return documentTags == null ? 0 : documentTags.size();
+ }
+
+ public static class TagListItemViewHolder extends RecyclerView.ViewHolder {
+
+ ImageView tag_icon;
+ TextView tag_name;
+
+ public TagListItemViewHolder(@NonNull View itemView) {
+ super(itemView);
+
+ tag_icon = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.tag_icon);
+ tag_name = itemView.findViewById(one.nem.lacerta.shared.ui.R.id.tag_name);
+
+ }
+ }
+}
diff --git a/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemSelectListener.java b/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemSelectListener.java
new file mode 100644
index 00000000..df0f7dd0
--- /dev/null
+++ b/feature/setting/src/main/java/one/nem/lacerta/setting/TagListItemSelectListener.java
@@ -0,0 +1,6 @@
+package one.nem.lacerta.setting;
+
+public interface TagListItemSelectListener {
+
+ void onTagListItemSelect(String tagId, String tagName, String tagColor);
+}
diff --git a/feature/setting/src/main/res/layout/fragment_setting_tag_manage.xml b/feature/setting/src/main/res/layout/fragment_setting_tag_manage.xml
new file mode 100644
index 00000000..7fc105e4
--- /dev/null
+++ b/feature/setting/src/main/res/layout/fragment_setting_tag_manage.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+
+
+
\ No newline at end of file
diff --git a/feature/setting/src/main/res/menu/setting_tag_manage_menu.xml b/feature/setting/src/main/res/menu/setting_tag_manage_menu.xml
new file mode 100644
index 00000000..f012a68b
--- /dev/null
+++ b/feature/setting/src/main/res/menu/setting_tag_manage_menu.xml
@@ -0,0 +1,10 @@
+
+
\ No newline at end of file
diff --git a/feature/setting/src/main/res/navigation/feature_setting_navigation.xml b/feature/setting/src/main/res/navigation/feature_setting_navigation.xml
index ff08f2a9..4d382d4d 100644
--- a/feature/setting/src/main/res/navigation/feature_setting_navigation.xml
+++ b/feature/setting/src/main/res/navigation/feature_setting_navigation.xml
@@ -37,6 +37,9 @@
app:exitAnim="@anim/slide_to_left"
app:popEnterAnim="@anim/slide_from_left"
app:popExitAnim="@anim/slide_to_right" />
+
+
\ No newline at end of file
diff --git a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java
index 1093188e..ed686d0c 100644
--- a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java
+++ b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java
@@ -32,17 +32,10 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
*/
Date createdAt;
- /**
- * ドキュメントのタグ(DocumentTagインスタンスのリスト)
- */
- List tags;
-
String parentId;
String author;
- String defaultBranch;
-
// Constructor
public DocumentMeta() {
@@ -51,49 +44,33 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
public DocumentMeta(String title) {
this.id = UUID.randomUUID().toString();
this.title = title;
- this.tags = new ArrayList<>();
- this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする
- this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする
+ this.author = ""; // TODO-rca: 作者のデフォルト値を指定できるように
this.parentId = null;
this.updatedAt = new Date();
this.createdAt = new Date();
}
- public DocumentMeta(String title, List tags, String author, String defaultBranch) {
+ public DocumentMeta(String title, String author) {
this.id = UUID.randomUUID().toString();
this.title = title;
- this.tags = tags;
this.author = author;
- this.defaultBranch = defaultBranch;
}
- public DocumentMeta(String id, String title, List tags, String author, String defaultBranch) {
- this.id = id;
- this.title = title;
- this.tags = tags;
- this.author = author;
- this.defaultBranch = defaultBranch;
- }
-
- public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List tags, String author, String defaultBranch) {
+ public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String author) {
this.id = id;
this.title = title;
this.updatedAt = updatedAt;
this.createdAt = createdAt;
- this.tags = tags;
this.author = author;
- this.defaultBranch = defaultBranch;
}
- public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, List tags, String parentId, String author, String defaultBranch) {
+ public DocumentMeta(String id, String title, Date updatedAt, Date createdAt, String parentId, String author) {
this.id = id;
this.title = title;
this.updatedAt = updatedAt;
this.createdAt = createdAt;
- this.tags = tags;
this.parentId = parentId;
this.author = author;
- this.defaultBranch = defaultBranch;
}
// Getter
@@ -126,24 +103,6 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
return createdAt;
}
- /**
- * ドキュメントのタグ(DocumentTagインスタンスのリスト)を取得する
- */
- public List getTags() {
- return tags;
- }
-
- /**
- * ドキュメントのタグ(DocumentTagインスタンスのリスト)のID(String)を取得する
- */
- public List getTagIds() {
- List tagIds = new ArrayList<>();
- for (DocumentTag tag : tags) {
- tagIds.add(tag.getId());
- }
- return tagIds;
- }
-
/**
* ドキュメントの親フォルダのID(String)を取得する
*/
@@ -158,13 +117,6 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
return author;
}
- /**
- * ドキュメントのデフォルトブランチ(String)を取得する
- */
- public String getDefaultBranch() {
- return defaultBranch;
- }
-
// Setter
/**
@@ -199,14 +151,6 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.createdAt = createdAt;
}
- /**
- * ドキュメントのタグ(DocumentTagインスタンスのリスト)を設定する
- * @param tags ドキュメントのタグ(DocumentTagインスタンスのリスト)
- */
- public void setTags(List tags) {
- this.tags = tags;
- }
-
/**
* ドキュメントの親フォルダのID(String)を設定する
* @param parentId ドキュメントの親フォルダのID
@@ -223,14 +167,6 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応
this.author = author;
}
- /**
- * ドキュメントのデフォルトブランチ(String)を設定する
- * @param defaultBranch ドキュメントのデフォルトブランチ
- */
- public void setDefaultBranch(String defaultBranch) {
- this.defaultBranch = defaultBranch;
- }
-
/**
* updatedAtを現在時刻に設定する
*/
diff --git a/shared/ui/src/main/res/drawable/sell_24px.xml b/shared/ui/src/main/res/drawable/sell_24px.xml
new file mode 100644
index 00000000..60da88d6
--- /dev/null
+++ b/shared/ui/src/main/res/drawable/sell_24px.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/shared/ui/src/main/res/drawable/sell_fill24px.xml b/shared/ui/src/main/res/drawable/sell_fill24px.xml
new file mode 100644
index 00000000..6c9a74d6
--- /dev/null
+++ b/shared/ui/src/main/res/drawable/sell_fill24px.xml
@@ -0,0 +1,10 @@
+
+
+
diff --git a/shared/ui/src/main/res/layout/tag_list_full_item.xml b/shared/ui/src/main/res/layout/tag_list_full_item.xml
new file mode 100644
index 00000000..e0c5bc13
--- /dev/null
+++ b/shared/ui/src/main/res/layout/tag_list_full_item.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
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 47e0e4bb..bb9a5dd9 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
@@ -5,10 +5,12 @@ import androidx.room.RoomDatabase;
// Entities
import one.nem.lacerta.source.database.dao.FolderDao;
+import one.nem.lacerta.source.database.dao.ToxiDocumentTagDao;
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;
+import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
import one.nem.lacerta.source.database.entity.VcsRevEntity;
import one.nem.lacerta.source.database.entity.VcsLogEntity;
@@ -19,10 +21,11 @@ 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, FolderEntity.class}, version = 4)
+@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class, FolderEntity.class, ToxiDocumentTagEntity.class}, version = 6)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();
+ public abstract ToxiDocumentTagDao toxiDocumentTagDao();
public abstract LibraryDao libraryDao();
public abstract VcsRevDao vcsRevDao();
public abstract VcsLogDao vcsLogDao();
diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentTagDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentTagDao.java
new file mode 100644
index 00000000..ae1c44b3
--- /dev/null
+++ b/source/src/main/java/one/nem/lacerta/source/database/dao/ToxiDocumentTagDao.java
@@ -0,0 +1,37 @@
+package one.nem.lacerta.source.database.dao;
+
+import androidx.room.Dao;
+import androidx.room.Insert;
+import androidx.room.Query;
+
+import java.util.List;
+
+import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity;
+
+@Dao
+public interface ToxiDocumentTagDao {
+
+ @Query("SELECT * FROM toxi_document_tag WHERE document_id = :documentId")
+ List findByDocumentId(String documentId);
+
+ @Query("SELECT * FROM toxi_document_tag WHERE tag_id = :tagId")
+ List findByTagId(String tagId);
+
+ @Insert
+ void insert(ToxiDocumentTagEntity toxiDocumentTag);
+
+ @Insert
+ void insertAll(ToxiDocumentTagEntity... toxiDocumentTags);
+
+ @Insert
+ void insertAll(List toxiDocumentTags);
+
+ @Query("DELETE FROM toxi_document_tag WHERE document_id = :documentId")
+ void deleteByDocumentId(String documentId);
+
+ @Query("DELETE FROM toxi_document_tag WHERE tag_id = :tagId")
+ void deleteByTagId(String tagId);
+
+ @Query("DELETE FROM toxi_document_tag WHERE document_id = :documentId AND tag_id = :tagId")
+ void deleteByDocumentIdAndTagId(String documentId, String tagId);
+}
diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java
index 2c4e03ab..1e7891e9 100644
--- a/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java
+++ b/source/src/main/java/one/nem/lacerta/source/database/entity/DocumentEntity.java
@@ -34,12 +34,6 @@ public class DocumentEntity {
@ColumnInfo(name = "author")
public String author; // 作成者
- @ColumnInfo(name = "default_branch")
- public String defaultBranch; // デフォルトブランチ
-
- @ColumnInfo(name = "tag_ids")
- public List tagIds; // タグ
-
@ColumnInfo(name = "parent_id")
public String parentId; // 親フォルダID
}
diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/ToxiDocumentTagEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/ToxiDocumentTagEntity.java
new file mode 100644
index 00000000..3e01199c
--- /dev/null
+++ b/source/src/main/java/one/nem/lacerta/source/database/entity/ToxiDocumentTagEntity.java
@@ -0,0 +1,18 @@
+package one.nem.lacerta.source.database.entity;
+
+import androidx.annotation.NonNull;
+import androidx.room.ColumnInfo;
+import androidx.room.Entity;
+import androidx.room.PrimaryKey;
+
+@Entity(primaryKeys = {"document_id", "tag_id"}, tableName = "toxi_document_tag")
+public class ToxiDocumentTagEntity {
+
+ @NonNull
+ @ColumnInfo(name = "document_id")
+ public String documentId; // ドキュメントID
+
+ @NonNull
+ @ColumnInfo(name = "tag_id")
+ public String tagId; // タグID
+}