Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/schemas/it.niedermann.owncloud.notes.persistence.NotesRoomDatabase/18.json22
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java2
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java9
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java1
4 files changed, 24 insertions, 10 deletions
diff --git a/app/schemas/it.niedermann.owncloud.notes.persistence.NotesRoomDatabase/18.json b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesRoomDatabase/18.json
index 74214109..baa0a94c 100644
--- a/app/schemas/it.niedermann.owncloud.notes.persistence.NotesRoomDatabase/18.json
+++ b/app/schemas/it.niedermann.owncloud.notes.persistence.NotesRoomDatabase/18.json
@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 18,
- "identityHash": "6d6111b4da8084c8f73df0eb63e39070",
+ "identityHash": "cf4429b4afde78dd86d282a0d0dfea47",
"entities": [
{
"tableName": "LocalAccountEntity",
@@ -80,7 +80,7 @@
},
{
"tableName": "NoteEntity",
- "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `remoteId` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `status` TEXT, `title` TEXT, `modified` INTEGER NOT NULL, `content` TEXT, `favorite` INTEGER, `eTag` TEXT, `excerpt` TEXT, `scrollY` INTEGER NOT NULL, `category` TEXT, PRIMARY KEY(`id`))",
+ "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `remoteId` INTEGER NOT NULL, `accountId` INTEGER NOT NULL, `status` TEXT, `title` TEXT, `modified` INTEGER NOT NULL, `content` TEXT, `favorite` INTEGER, `eTag` TEXT, `excerpt` TEXT, `scrollY` INTEGER NOT NULL, `category_id` INTEGER, `category_accountId` INTEGER, `category_title` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
@@ -149,8 +149,20 @@
"notNull": true
},
{
- "fieldPath": "category",
- "columnName": "category",
+ "fieldPath": "category.id",
+ "columnName": "category_id",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "category.accountId",
+ "columnName": "category_accountId",
+ "affinity": "INTEGER",
+ "notNull": false
+ },
+ {
+ "fieldPath": "category.title",
+ "columnName": "category_title",
"affinity": "TEXT",
"notNull": false
}
@@ -200,7 +212,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
- "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6d6111b4da8084c8f73df0eb63e39070')"
+ "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'cf4429b4afde78dd86d282a0d0dfea47')"
]
}
} \ No newline at end of file
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java
index 3bbd1e97..4dc4b2c9 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/CategoryDao.java
@@ -19,7 +19,7 @@ public interface CategoryDao {
*
* @param accountId The user accountId
*/
- @Query("DELETE FROM CategoryEntity WHERE accountId = :accountId AND id NOT IN (SELECT category FROM NoteEntity)")
+ @Query("DELETE FROM CategoryEntity WHERE accountId = :accountId AND id NOT IN (SELECT category_id FROM NoteEntity)")
void removeEmptyCategory(long accountId);
@Insert
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java
index 9fcdfd7b..136d1703 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/dao/NoteDao.java
@@ -4,6 +4,7 @@ import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -35,8 +36,8 @@ public interface NoteDao {
* @param accountId get the remoteIds from all notes of this account
* @return {@link Set<String>} remoteIds from all notes
*/
- @Query("SELECT remoteId FROM NoteEntity WHERE accountId = :accountId AND status != \"LOCAL_DELETED\"")
- Set<String> getRemoteIds(long accountId);
+ @Query("SELECT DISTINCT remoteId FROM NoteEntity WHERE accountId = :accountId AND status != \"LOCAL_DELETED\"")
+ List<Long> getRemoteIds(long accountId);
/**
@@ -45,9 +46,9 @@ public interface NoteDao {
* @param remoteId int - remote ID of the requested Note
* @return {@link DBNote#getId()}
*/
- @Query("SELECT id FROM noteentity WHERE accountId = :accountId AND remoteId = :remoteId AND status != \"LOCAL_DELETED\"")
+ @Query("SELECT id FROM NoteEntity WHERE accountId = :accountId AND remoteId = :remoteId AND status != \"LOCAL_DELETED\"")
Long getLocalIdByRemoteId(long accountId, long remoteId);
- @Query("SELECT favorite, COUNT(*) FROM noteentity WHERE status != \"LOCAL_DELETED\" AND accountId = :accountId GROUP BY favorite ORDER BY favorite")
+ @Query("SELECT favorite, COUNT(*) FROM NoteEntity WHERE status != \"LOCAL_DELETED\" AND accountId = :accountId GROUP BY favorite ORDER BY favorite")
Map<String, Integer> getFavoritesCount(long accountId);
}
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java
index 9d277b1a..e98f8e94 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/entity/NoteEntity.java
@@ -25,6 +25,7 @@ public class NoteEntity {
private String eTag;
private String excerpt;
private int scrollY;
+ @Embedded(prefix = "category_")
private CategoryEntity category;
public long getId() {