Renaming aggregated summary model

This commit is contained in:
Maxime NATUREL 2022-04-29 14:17:35 +02:00
parent 1db0e71796
commit e8556ec830
10 changed files with 46 additions and 46 deletions

View File

@ -15,7 +15,7 @@
*/ */
package org.matrix.android.sdk.api.session.room.model package org.matrix.android.sdk.api.session.room.model
import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationAggregatedSummary import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationShareAggregatedSummary
data class EventAnnotationsSummary( data class EventAnnotationsSummary(
val eventId: String, val eventId: String,
@ -23,5 +23,5 @@ data class EventAnnotationsSummary(
val editSummary: EditAggregatedSummary? = null, val editSummary: EditAggregatedSummary? = null,
val pollResponseSummary: PollResponseAggregatedSummary? = null, val pollResponseSummary: PollResponseAggregatedSummary? = null,
val referencesAggregatedSummary: ReferencesAggregatedSummary? = null, val referencesAggregatedSummary: ReferencesAggregatedSummary? = null,
val liveLocationAggregatedSummary: LiveLocationAggregatedSummary? = null, val liveLocationShareAggregatedSummary: LiveLocationShareAggregatedSummary? = null,
) )

View File

@ -21,7 +21,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocati
/** /**
* Aggregation info concerning a live location share. * Aggregation info concerning a live location share.
*/ */
data class LiveLocationAggregatedSummary( data class LiveLocationShareAggregatedSummary(
/** /**
* Event id of the event that started the live. * Event id of the event that started the live.
*/ */

View File

@ -59,8 +59,8 @@ internal object EventAnnotationsSummaryMapper {
pollResponseSummary = annotationsSummary.pollResponseSummary?.let { pollResponseSummary = annotationsSummary.pollResponseSummary?.let {
PollResponseAggregatedSummaryEntityMapper.map(it) PollResponseAggregatedSummaryEntityMapper.map(it)
}, },
liveLocationAggregatedSummary = annotationsSummary.liveLocationAggregatedSummary?.let { liveLocationShareAggregatedSummary = annotationsSummary.liveLocationShareAggregatedSummary?.let {
LiveLocationAggregatedSummaryMapper.map(it) LiveLocationShareAggregatedSummaryMapper.map(it)
} }
) )
} }

View File

@ -18,14 +18,14 @@ package org.matrix.android.sdk.internal.database.mapper
import org.matrix.android.sdk.api.session.events.model.toContent import org.matrix.android.sdk.api.session.events.model.toContent
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationAggregatedSummary import org.matrix.android.sdk.api.session.room.model.livelocation.LiveLocationShareAggregatedSummary
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity
internal object LiveLocationAggregatedSummaryMapper { internal object LiveLocationShareAggregatedSummaryMapper {
fun map(entity: LiveLocationAggregatedSummaryEntity): LiveLocationAggregatedSummary { fun map(entity: LiveLocationShareAggregatedSummaryEntity): LiveLocationShareAggregatedSummary {
return LiveLocationAggregatedSummary( return LiveLocationShareAggregatedSummary(
eventId = entity.eventId, eventId = entity.eventId,
roomId = entity.roomId, roomId = entity.roomId,
isActive = entity.isActive, isActive = entity.isActive,
@ -34,8 +34,8 @@ internal object LiveLocationAggregatedSummaryMapper {
) )
} }
fun map(model: LiveLocationAggregatedSummary): LiveLocationAggregatedSummaryEntity { fun map(model: LiveLocationShareAggregatedSummary): LiveLocationShareAggregatedSummaryEntity {
return LiveLocationAggregatedSummaryEntity( return LiveLocationShareAggregatedSummaryEntity(
eventId = model.eventId, eventId = model.eventId,
roomId = model.roomId, roomId = model.roomId,
isActive = model.isActive, isActive = model.isActive,

View File

@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.database.migration
import io.realm.DynamicRealm import io.realm.DynamicRealm
import io.realm.FieldAttribute import io.realm.FieldAttribute
import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntityFields import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntityFields
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntityFields import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntityFields
import org.matrix.android.sdk.internal.util.database.RealmMigrator import org.matrix.android.sdk.internal.util.database.RealmMigrator
/** /**
@ -29,18 +29,18 @@ import org.matrix.android.sdk.internal.util.database.RealmMigrator
internal class MigrateSessionTo027(realm: DynamicRealm) : RealmMigrator(realm, 27) { internal class MigrateSessionTo027(realm: DynamicRealm) : RealmMigrator(realm, 27) {
override fun doMigrate(realm: DynamicRealm) { override fun doMigrate(realm: DynamicRealm) {
val liveLocationSummaryEntity = realm.schema.get("LiveLocationAggregatedSummaryEntity") val liveLocationSummaryEntity = realm.schema.get("LiveLocationShareAggregatedSummaryEntity")
?: realm.schema.create("LiveLocationAggregatedSummaryEntity") ?: realm.schema.create("LiveLocationShareAggregatedSummaryEntity")
.addField(LiveLocationAggregatedSummaryEntityFields.EVENT_ID, String::class.java, FieldAttribute.REQUIRED) .addField(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, String::class.java, FieldAttribute.REQUIRED)
.addField(LiveLocationAggregatedSummaryEntityFields.ROOM_ID, String::class.java, FieldAttribute.REQUIRED) .addField(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, String::class.java, FieldAttribute.REQUIRED)
.addField(LiveLocationAggregatedSummaryEntityFields.IS_ACTIVE, Boolean::class.java) .addField(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, Boolean::class.java)
.setNullable(LiveLocationAggregatedSummaryEntityFields.IS_ACTIVE, true) .setNullable(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, true)
.addField(LiveLocationAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, Long::class.java) .addField(LiveLocationShareAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, Long::class.java)
.setNullable(LiveLocationAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, true) .setNullable(LiveLocationShareAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, true)
.addField(LiveLocationAggregatedSummaryEntityFields.LAST_LOCATION_CONTENT, String::class.java) .addField(LiveLocationShareAggregatedSummaryEntityFields.LAST_LOCATION_CONTENT, String::class.java)
?: return ?: return
realm.schema.get("EventAnnotationsSummaryEntity") realm.schema.get("EventAnnotationsSummaryEntity")
?.addRealmObjectField(EventAnnotationsSummaryEntityFields.LIVE_LOCATION_AGGREGATED_SUMMARY.`$`, liveLocationSummaryEntity) ?.addRealmObjectField(EventAnnotationsSummaryEntityFields.LIVE_LOCATION_SHARE_AGGREGATED_SUMMARY.`$`, liveLocationSummaryEntity)
} }
} }

View File

@ -18,7 +18,7 @@ package org.matrix.android.sdk.internal.database.model
import io.realm.RealmList import io.realm.RealmList
import io.realm.RealmObject import io.realm.RealmObject
import io.realm.annotations.PrimaryKey import io.realm.annotations.PrimaryKey
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity
import timber.log.Timber import timber.log.Timber
internal open class EventAnnotationsSummaryEntity( internal open class EventAnnotationsSummaryEntity(
@ -29,7 +29,7 @@ internal open class EventAnnotationsSummaryEntity(
var editSummary: EditAggregatedSummaryEntity? = null, var editSummary: EditAggregatedSummaryEntity? = null,
var referencesSummaryEntity: ReferencesAggregatedSummaryEntity? = null, var referencesSummaryEntity: ReferencesAggregatedSummaryEntity? = null,
var pollResponseSummary: PollResponseAggregatedSummaryEntity? = null, var pollResponseSummary: PollResponseAggregatedSummaryEntity? = null,
var liveLocationAggregatedSummary: LiveLocationAggregatedSummaryEntity? = null, var liveLocationShareAggregatedSummary: LiveLocationShareAggregatedSummaryEntity? = null,
) : RealmObject() { ) : RealmObject() {
/** /**

View File

@ -17,7 +17,7 @@
package org.matrix.android.sdk.internal.database.model package org.matrix.android.sdk.internal.database.model
import io.realm.annotations.RealmModule import io.realm.annotations.RealmModule
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity
import org.matrix.android.sdk.internal.database.model.presence.UserPresenceEntity import org.matrix.android.sdk.internal.database.model.presence.UserPresenceEntity
import org.matrix.android.sdk.internal.database.model.threads.ThreadSummaryEntity import org.matrix.android.sdk.internal.database.model.threads.ThreadSummaryEntity
@ -48,7 +48,7 @@ import org.matrix.android.sdk.internal.database.model.threads.ThreadSummaryEntit
EditAggregatedSummaryEntity::class, EditAggregatedSummaryEntity::class,
EditionOfEvent::class, EditionOfEvent::class,
PollResponseAggregatedSummaryEntity::class, PollResponseAggregatedSummaryEntity::class,
LiveLocationAggregatedSummaryEntity::class, LiveLocationShareAggregatedSummaryEntity::class,
ReferencesAggregatedSummaryEntity::class, ReferencesAggregatedSummaryEntity::class,
PushRulesEntity::class, PushRulesEntity::class,
PushRuleEntity::class, PushRuleEntity::class,

View File

@ -22,7 +22,7 @@ import io.realm.annotations.PrimaryKey
/** /**
* Aggregation info concerning a live location share. * Aggregation info concerning a live location share.
*/ */
internal open class LiveLocationAggregatedSummaryEntity( internal open class LiveLocationShareAggregatedSummaryEntity(
/** /**
* Event id of the event that started the live. * Event id of the event that started the live.
*/ */

View File

@ -20,38 +20,38 @@ import io.realm.Realm
import io.realm.RealmQuery import io.realm.RealmQuery
import io.realm.kotlin.where import io.realm.kotlin.where
import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity import org.matrix.android.sdk.internal.database.model.EventAnnotationsSummaryEntity
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntityFields import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntityFields
internal fun LiveLocationAggregatedSummaryEntity.Companion.where( internal fun LiveLocationShareAggregatedSummaryEntity.Companion.where(
realm: Realm, realm: Realm,
roomId: String, roomId: String,
eventId: String, eventId: String,
): RealmQuery<LiveLocationAggregatedSummaryEntity> { ): RealmQuery<LiveLocationShareAggregatedSummaryEntity> {
return realm.where<LiveLocationAggregatedSummaryEntity>() return realm.where<LiveLocationShareAggregatedSummaryEntity>()
.equalTo(LiveLocationAggregatedSummaryEntityFields.ROOM_ID, roomId) .equalTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, roomId)
.equalTo(LiveLocationAggregatedSummaryEntityFields.EVENT_ID, eventId) .equalTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, eventId)
} }
internal fun LiveLocationAggregatedSummaryEntity.Companion.create( internal fun LiveLocationShareAggregatedSummaryEntity.Companion.create(
realm: Realm, realm: Realm,
roomId: String, roomId: String,
eventId: String, eventId: String,
): LiveLocationAggregatedSummaryEntity { ): LiveLocationShareAggregatedSummaryEntity {
val obj = realm.createObject(LiveLocationAggregatedSummaryEntity::class.java, eventId).apply { val obj = realm.createObject(LiveLocationShareAggregatedSummaryEntity::class.java, eventId).apply {
this.roomId = roomId this.roomId = roomId
} }
val annotationSummary = EventAnnotationsSummaryEntity.getOrCreate(realm, roomId = roomId, eventId = eventId) val annotationSummary = EventAnnotationsSummaryEntity.getOrCreate(realm, roomId = roomId, eventId = eventId)
annotationSummary.liveLocationAggregatedSummary = obj annotationSummary.liveLocationShareAggregatedSummary = obj
return obj return obj
} }
internal fun LiveLocationAggregatedSummaryEntity.Companion.getOrCreate( internal fun LiveLocationShareAggregatedSummaryEntity.Companion.getOrCreate(
realm: Realm, realm: Realm,
roomId: String, roomId: String,
eventId: String, eventId: String,
): LiveLocationAggregatedSummaryEntity { ): LiveLocationShareAggregatedSummaryEntity {
return LiveLocationAggregatedSummaryEntity.where(realm, roomId, eventId).findFirst() return LiveLocationShareAggregatedSummaryEntity.where(realm, roomId, eventId).findFirst()
?: LiveLocationAggregatedSummaryEntity.create(realm, roomId, eventId) ?: LiveLocationShareAggregatedSummaryEntity.create(realm, roomId, eventId)
} }

View File

@ -24,7 +24,7 @@ import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconInfoContent
import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocationDataContent
import org.matrix.android.sdk.internal.database.mapper.ContentMapper import org.matrix.android.sdk.internal.database.mapper.ContentMapper
import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationAggregatedSummaryEntity import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity
import org.matrix.android.sdk.internal.database.query.getOrCreate import org.matrix.android.sdk.internal.database.query.getOrCreate
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject
@ -48,7 +48,7 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L
return return
} }
val aggregatedSummary = LiveLocationAggregatedSummaryEntity.getOrCreate( val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate(
realm = realm, realm = realm,
roomId = roomId, roomId = roomId,
eventId = targetEventId eventId = targetEventId
@ -70,7 +70,7 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L
return return
} }
val aggregatedSummary = LiveLocationAggregatedSummaryEntity.getOrCreate( val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate(
realm = realm, realm = realm,
roomId = roomId, roomId = roomId,
eventId = targetEventId eventId = targetEventId