mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-28 01:24:03 +03:00
Rename UserNgEntity to UserEntity
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
25a5346435
commit
4233e1bbc1
5 changed files with 38 additions and 38 deletions
|
@ -35,13 +35,13 @@ import com.nextcloud.talk.data.source.local.converters.SignalingSettingsConverte
|
|||
import com.nextcloud.talk.data.storage.ArbitraryStoragesDao
|
||||
import com.nextcloud.talk.data.storage.model.ArbitraryStorageNgEntity
|
||||
import com.nextcloud.talk.data.user.UsersDao
|
||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
||||
import com.nextcloud.talk.data.user.model.UserEntity
|
||||
import net.sqlcipher.database.SQLiteDatabase
|
||||
import net.sqlcipher.database.SupportFactory
|
||||
import java.util.Locale
|
||||
|
||||
@Database(
|
||||
entities = [UserNgEntity::class, ArbitraryStorageNgEntity::class],
|
||||
entities = [UserEntity::class, ArbitraryStorageNgEntity::class],
|
||||
version = 8,
|
||||
exportSchema = true
|
||||
)
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
package com.nextcloud.talk.data.user
|
||||
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
||||
import com.nextcloud.talk.data.user.model.UserEntity
|
||||
|
||||
object UserMapper {
|
||||
fun toModel(entities: List<UserNgEntity?>?): List<User> {
|
||||
fun toModel(entities: List<UserEntity?>?): List<User> {
|
||||
return if (entities == null) {
|
||||
ArrayList()
|
||||
} else {
|
||||
|
@ -36,7 +36,7 @@ object UserMapper {
|
|||
}
|
||||
}
|
||||
|
||||
fun toModel(entity: UserNgEntity?): User? {
|
||||
fun toModel(entity: UserEntity?): User? {
|
||||
return if (entity == null) {
|
||||
null
|
||||
} else {
|
||||
|
@ -57,23 +57,23 @@ object UserMapper {
|
|||
}
|
||||
}
|
||||
|
||||
fun toEntity(model: User): UserNgEntity {
|
||||
var userNgEntity: UserNgEntity? = null
|
||||
fun toEntity(model: User): UserEntity {
|
||||
var UserEntity: UserEntity? = null
|
||||
model.id?.let {
|
||||
userNgEntity = UserNgEntity(it, model.userId, model.username, model.baseUrl)
|
||||
UserEntity = UserEntity(it, model.userId, model.username, model.baseUrl)
|
||||
} ?: run {
|
||||
userNgEntity = UserNgEntity(userId = model.userId, username = model.username, baseUrl = model.baseUrl)
|
||||
UserEntity = UserEntity(userId = model.userId, username = model.username, baseUrl = model.baseUrl)
|
||||
}
|
||||
|
||||
userNgEntity!!.token = model.token
|
||||
userNgEntity!!.displayName = model.displayName
|
||||
userNgEntity!!.pushConfigurationState = model.pushConfigurationState
|
||||
userNgEntity!!.capabilities = model.capabilities
|
||||
userNgEntity!!.clientCertificate = model.clientCertificate
|
||||
userNgEntity!!.externalSignalingServer = model.externalSignalingServer
|
||||
userNgEntity!!.current = model.current
|
||||
userNgEntity!!.scheduledForDeletion = model.scheduledForDeletion
|
||||
UserEntity!!.token = model.token
|
||||
UserEntity!!.displayName = model.displayName
|
||||
UserEntity!!.pushConfigurationState = model.pushConfigurationState
|
||||
UserEntity!!.capabilities = model.capabilities
|
||||
UserEntity!!.clientCertificate = model.clientCertificate
|
||||
UserEntity!!.externalSignalingServer = model.externalSignalingServer
|
||||
UserEntity!!.current = model.current
|
||||
UserEntity!!.scheduledForDeletion = model.scheduledForDeletion
|
||||
|
||||
return userNgEntity!!
|
||||
return UserEntity!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import androidx.room.OnConflictStrategy
|
|||
import androidx.room.Query
|
||||
import androidx.room.Transaction
|
||||
import androidx.room.Update
|
||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
||||
import com.nextcloud.talk.data.user.model.UserEntity
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.SingleObserver
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
@ -41,58 +41,58 @@ import java.lang.Boolean.TRUE
|
|||
abstract class UsersDao {
|
||||
// get active user
|
||||
@Query("SELECT * FROM User where current = 1")
|
||||
abstract fun getActiveUser(): Single<UserNgEntity?>
|
||||
abstract fun getActiveUser(): Single<UserEntity?>
|
||||
|
||||
@Query("SELECT * FROM User where current = 1")
|
||||
abstract fun getActiveUserSynchronously(): UserNgEntity?
|
||||
abstract fun getActiveUserSynchronously(): UserEntity?
|
||||
|
||||
@Query("SELECT * FROM User WHERE current = 1")
|
||||
abstract fun getActiveUserLiveData(): Single<UserNgEntity?>
|
||||
abstract fun getActiveUserLiveData(): Single<UserEntity?>
|
||||
|
||||
@Query("DELETE FROM User WHERE id = :id")
|
||||
abstract fun deleteUserWithId(id: Long)
|
||||
|
||||
@Update
|
||||
abstract fun updateUser(user: UserNgEntity): Int
|
||||
abstract fun updateUser(user: UserEntity): Int
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract fun saveUser(user: UserNgEntity): Long
|
||||
abstract fun saveUser(user: UserEntity): Long
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
abstract fun saveUsers(vararg users: UserNgEntity): List<Long>
|
||||
abstract fun saveUsers(vararg users: UserEntity): List<Long>
|
||||
|
||||
// get all users not scheduled for deletion
|
||||
@Query("SELECT * FROM User where current != 0")
|
||||
abstract fun getUsers(): Single<List<UserNgEntity>>
|
||||
abstract fun getUsers(): Single<List<UserEntity>>
|
||||
|
||||
@Query("SELECT * FROM User where id = :id")
|
||||
abstract fun getUserWithId(id: Long): Single<UserNgEntity?>
|
||||
abstract fun getUserWithId(id: Long): Single<UserEntity?>
|
||||
|
||||
@Query("SELECT * FROM User where id = :id AND scheduledForDeletion != 1")
|
||||
abstract fun getUserWithIdNotScheduledForDeletion(id: Long): Single<UserNgEntity?>
|
||||
abstract fun getUserWithIdNotScheduledForDeletion(id: Long): Single<UserEntity?>
|
||||
|
||||
@Query("SELECT * FROM User where userId = :userId")
|
||||
abstract fun getUserWithUserId(userId: String): Single<UserNgEntity?>
|
||||
abstract fun getUserWithUserId(userId: String): Single<UserEntity?>
|
||||
|
||||
@Query("SELECT * FROM User where userId != :userId")
|
||||
abstract fun getUsersWithoutUserId(userId: Long): Single<List<UserNgEntity>>
|
||||
abstract fun getUsersWithoutUserId(userId: Long): Single<List<UserEntity>>
|
||||
|
||||
@Query("SELECT * FROM User where current = 0")
|
||||
abstract fun getUsersScheduledForDeletion(): Single<List<UserNgEntity>>
|
||||
abstract fun getUsersScheduledForDeletion(): Single<List<UserEntity>>
|
||||
|
||||
@Query("SELECT * FROM User where scheduledForDeletion = 0")
|
||||
abstract fun getUsersNotScheduledForDeletion(): Single<List<UserNgEntity>>
|
||||
abstract fun getUsersNotScheduledForDeletion(): Single<List<UserEntity>>
|
||||
|
||||
@Query("SELECT * FROM User WHERE username = :username AND baseUrl = :server")
|
||||
abstract fun getUserWithUsernameAndServer(username: String, server: String): Single<UserNgEntity?>
|
||||
abstract fun getUserWithUsernameAndServer(username: String, server: String): Single<UserEntity?>
|
||||
|
||||
@Transaction
|
||||
open suspend fun setUserAsActiveWithId(id: Long): Boolean {
|
||||
val users = getUsers()
|
||||
var result = TRUE
|
||||
|
||||
users.subscribe(object : SingleObserver<List<UserNgEntity>> {
|
||||
override fun onSuccess(users: List<UserNgEntity>) {
|
||||
users.subscribe(object : SingleObserver<List<UserEntity>> {
|
||||
override fun onSuccess(users: List<UserEntity>) {
|
||||
for (user in users) {
|
||||
// removed from clause: && UserStatus.ACTIVE == user.status
|
||||
if (user.id != id) {
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.lang.Boolean.FALSE
|
|||
@Parcelize
|
||||
@Serializable
|
||||
@Entity(tableName = "User")
|
||||
data class UserNgEntity(
|
||||
data class UserEntity(
|
||||
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") var id: Long = 0,
|
||||
@ColumnInfo(name = "userId") var userId: String? = null,
|
||||
@ColumnInfo(name = "username") var username: String? = null,
|
|
@ -25,7 +25,7 @@ import android.text.TextUtils
|
|||
import com.bluelinelabs.logansquare.LoganSquare
|
||||
import com.nextcloud.talk.data.user.UsersRepository
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.data.user.model.UserNgEntity
|
||||
import com.nextcloud.talk.data.user.model.UserEntity
|
||||
import com.nextcloud.talk.models.ExternalSignalingServer
|
||||
import com.nextcloud.talk.models.json.capabilities.Capabilities
|
||||
import com.nextcloud.talk.models.json.push.PushConfigurationState
|
||||
|
@ -195,7 +195,7 @@ class UserManager internal constructor(private val userRepository: UsersReposito
|
|||
return user
|
||||
}
|
||||
|
||||
private fun validDisplayName(displayName: String?, user: UserNgEntity): Boolean {
|
||||
private fun validDisplayName(displayName: String?, user: UserEntity): Boolean {
|
||||
return if (displayName == null) {
|
||||
false
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue