This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6169c96
commit 32f34ac
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.ivy.data.db.dao.read | ||
|
||
import androidx.room.* | ||
import com.ivy.data.db.entity.TagEntity | ||
import java.util.* | ||
|
||
@Dao | ||
interface TagDao { | ||
@Query("SELECT * FROM tags ORDER BY orderNum ASC") | ||
suspend fun findAll(): List<TagEntity> | ||
|
||
@Query("SELECT * FROM tags WHERE id = :id") | ||
suspend fun findById(id: UUID): TagEntity? | ||
|
||
@Query("SELECT * FROM tags JOIN tags_transaction ON tags.id = tags_transaction.tagId WHERE associatedId IN (:ids) GROUP BY tags.id") | ||
@RewriteQueriesToDropUnusedColumns | ||
suspend fun findTagsByAssociatedIds(ids: List<UUID>): Map<@MapColumn(columnName = "id") UUID, List<TagEntity>> | ||
|
||
@Query("SELECT * FROM tags JOIN tags_transaction ON tags.id = tags_transaction.tagId WHERE associatedId = :id") | ||
@RewriteQueriesToDropUnusedColumns | ||
suspend fun findTagsByAssociatedId(id: UUID): List<TagEntity> | ||
} |
18 changes: 18 additions & 0 deletions
18
ivy-data/src/main/java/com/ivy/data/db/dao/read/TagTransactionDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ivy.data.db.dao.read | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Query | ||
import com.ivy.data.db.entity.TagTransactionEntity | ||
import java.util.UUID | ||
|
||
@Dao | ||
interface TagTransactionDao { | ||
@Query("SELECT * FROM tags_transaction") | ||
suspend fun findAll(): List<TagTransactionEntity> | ||
|
||
@Query("SELECT * FROM tags_transaction WHERE tagId = :id") | ||
suspend fun findById(id: UUID): TagTransactionEntity? | ||
|
||
@Query("SELECT * FROM tags_transaction WHERE associatedId = :associatedId") | ||
suspend fun findByAssociatedId(associatedId: UUID): TagTransactionEntity? | ||
} |
23 changes: 23 additions & 0 deletions
23
ivy-data/src/main/java/com/ivy/data/db/dao/write/WriteTagDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.ivy.data.db.dao.write | ||
|
||
import androidx.room.* | ||
import com.ivy.data.db.entity.TagEntity | ||
import java.util.* | ||
|
||
@Dao | ||
interface WriteTagDao { | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun save(value: TagEntity) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun save(value: List<TagEntity>) | ||
|
||
@Update | ||
suspend fun update(value: TagEntity) | ||
|
||
@Query("DELETE FROM tags WHERE id = :id") | ||
suspend fun deleteById(id: UUID) | ||
|
||
@Query("DELETE FROM tags") | ||
suspend fun deleteAll() | ||
} |
29 changes: 29 additions & 0 deletions
29
ivy-data/src/main/java/com/ivy/data/db/dao/write/WriteTagTransactionDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ivy.data.db.dao.write | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import com.ivy.data.db.entity.TagTransactionEntity | ||
import java.util.* | ||
|
||
@Dao | ||
interface WriteTagTransactionDao { | ||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun save(value: TagTransactionEntity) | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
suspend fun save(value: List<TagTransactionEntity>) | ||
|
||
@Query("DELETE FROM tags_transaction") | ||
suspend fun deleteAll() | ||
|
||
@Query("DELETE FROM tags_transaction WHERE tagId = :tagId AND associatedId = :associatedId") | ||
suspend fun deleteId(tagId: UUID, associatedId: UUID) | ||
|
||
@Query("DELETE FROM tags_transaction WHERE tagId = :tagId") | ||
suspend fun deleteAssociationsByTagId(tagId: UUID) | ||
|
||
@Query("DELETE FROM tags_transaction WHERE associatedId = :associatedId") | ||
suspend fun deleteAssociationsByAssociateId(associatedId: UUID) | ||
} |
39 changes: 39 additions & 0 deletions
39
temp-legacy-code/src/main/java/com/ivy/legacy/datamodel/Tag.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.ivy.legacy.datamodel | ||
|
||
import com.ivy.data.db.entity.TagEntity | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
data class Tag( | ||
val id: UUID = UUID.randomUUID(), | ||
|
||
val name: String, | ||
val description: String? = null, | ||
|
||
val color: Int, | ||
val icon: String? = null, | ||
val orderNum: Double = 0.0, | ||
|
||
val dateTime: LocalDateTime? = null, | ||
val isSynced: Boolean = false, | ||
val isDeleted: Boolean = false, | ||
|
||
val featureBit: Int = 0, | ||
val featureBitValue: String? = null | ||
) { | ||
fun toEntity(): TagEntity { | ||
return TagEntity( | ||
id, | ||
name, | ||
description, | ||
color, | ||
icon, | ||
orderNum, | ||
isSynced, | ||
isDeleted, | ||
dateTime, | ||
featureBit, | ||
featureBitValue | ||
) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
temp-legacy-code/src/main/java/com/ivy/legacy/datamodel/TagTransaction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ivy.legacy.datamodel | ||
|
||
import com.ivy.data.db.entity.TagTransactionEntity | ||
import java.util.* | ||
|
||
|
||
data class TagTransaction( | ||
val tagId: UUID, | ||
val associatedId: UUID, | ||
val isSynced: Boolean = false, | ||
val isDeleted: Boolean = false | ||
) { | ||
fun toEntity(): TagTransactionEntity { | ||
return TagTransactionEntity(tagId, associatedId, isSynced, isDeleted) | ||
} | ||
} |