From 72e39368aa49115cf99200ce5180487b19546336 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 31 Oct 2018 15:16:22 -0600 Subject: [PATCH] Created Authority entity and AuthoritiyDao to create the Authorities db table with Room --- .../bitsybitshareswallet/daos/AuthorityDao.kt | 17 +++++++++++++ .../daos/BitsyDatabase.kt | 1 + .../bitsybitshareswallet/models/Authority.kt | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/daos/AuthorityDao.kt create mode 100644 app/src/main/java/cy/agorise/bitsybitshareswallet/models/Authority.kt diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/AuthorityDao.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/AuthorityDao.kt new file mode 100644 index 0000000..678e6af --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/AuthorityDao.kt @@ -0,0 +1,17 @@ +package cy.agorise.bitsybitshareswallet.daos + +import androidx.lifecycle.LiveData +import androidx.room.Dao +import androidx.room.Insert +import androidx.room.Query +import cy.agorise.bitsybitshareswallet.models.Authority + +@Dao +interface AuthorityDao { + + @Query("SELECT * FROM authorities") + fun getAllAuthorities(): LiveData> + + @Insert + fun insert(authority: Authority) +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt index 02c0a2f..b1dfa75 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/daos/BitsyDatabase.kt @@ -12,6 +12,7 @@ abstract class BitsyDatabase : RoomDatabase() { abstract fun assetDao(): AssetDao abstract fun balanceDao(): BalanceDao abstract fun userAccountDao(): UserAccountDao + abstract fun authorityDao(): AuthorityDao companion object { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/models/Authority.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/models/Authority.kt new file mode 100644 index 0000000..38d6c80 --- /dev/null +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/models/Authority.kt @@ -0,0 +1,25 @@ +package cy.agorise.bitsybitshareswallet.models + +import androidx.room.ColumnInfo +import androidx.room.Entity +import androidx.room.ForeignKey +import androidx.room.PrimaryKey + +@Entity(tableName = "authorities", foreignKeys = + [ForeignKey( + entity = UserAccount::class, + parentColumns = ["id"], + childColumns = ["user_id"], + onUpdate = ForeignKey.CASCADE, + onDelete = ForeignKey.CASCADE + )] +) +data class Authority ( + @PrimaryKey(autoGenerate = true) + @ColumnInfo(name = "id") val id: Long, + @ColumnInfo(name = "encrypted_brainkey") val encryptedBrainkey: String, + @ColumnInfo(name = "encrypted_sequence_number") val encryptedSequenceNumber: String, // TODO verify data type + @ColumnInfo(name = "encrypted_wif") val encryptedWif: String, + @ColumnInfo(name = "user_id") val userId: String, + @ColumnInfo(name = "authority_type") val authorityType: Int +) \ No newline at end of file