From e8556ec8303d214caa71a8fcbf0895bf86abb9c2 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 29 Apr 2022 14:17:35 +0200 Subject: [PATCH] Renaming aggregated summary model --- .../room/model/EventAnnotationsSummary.kt | 4 +-- ... => LiveLocationShareAggregatedSummary.kt} | 2 +- .../mapper/EventAnnotationsSummaryMapper.kt | 4 +-- ...veLocationShareAggregatedSummaryMapper.kt} | 14 ++++----- .../database/migration/MigrateSessionTo027.kt | 22 +++++++------- .../model/EventAnnotationsSummaryEntity.kt | 4 +-- .../database/model/SessionRealmModule.kt | 4 +-- ...veLocationShareAggregatedSummaryEntity.kt} | 2 +- ...ationShareAggregatedSummaryEntityQuery.kt} | 30 +++++++++---------- ...DefaultLiveLocationAggregationProcessor.kt | 6 ++-- 10 files changed, 46 insertions(+), 46 deletions(-) rename matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/{LiveLocationAggregatedSummary.kt => LiveLocationShareAggregatedSummary.kt} (96%) rename matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/{LiveLocationAggregatedSummaryMapper.kt => LiveLocationShareAggregatedSummaryMapper.kt} (79%) rename matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/{LiveLocationAggregatedSummaryEntity.kt => LiveLocationShareAggregatedSummaryEntity.kt} (95%) rename matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/{LiveLocationAggregatedSummaryEntityQuery.kt => LiveLocationShareAggregatedSummaryEntityQuery.kt} (56%) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt index cf64be4bc8..14dc288239 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/EventAnnotationsSummary.kt @@ -15,7 +15,7 @@ */ 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( val eventId: String, @@ -23,5 +23,5 @@ data class EventAnnotationsSummary( val editSummary: EditAggregatedSummary? = null, val pollResponseSummary: PollResponseAggregatedSummary? = null, val referencesAggregatedSummary: ReferencesAggregatedSummary? = null, - val liveLocationAggregatedSummary: LiveLocationAggregatedSummary? = null, + val liveLocationShareAggregatedSummary: LiveLocationShareAggregatedSummary? = null, ) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationShareAggregatedSummary.kt similarity index 96% rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationShareAggregatedSummary.kt index 6cd286fb28..5d4d670a74 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationAggregatedSummary.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/livelocation/LiveLocationShareAggregatedSummary.kt @@ -21,7 +21,7 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageBeaconLocati /** * Aggregation info concerning a live location share. */ -data class LiveLocationAggregatedSummary( +data class LiveLocationShareAggregatedSummary( /** * Event id of the event that started the live. */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt index 79184cdc4b..1f8d2e76d9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/EventAnnotationsSummaryMapper.kt @@ -59,8 +59,8 @@ internal object EventAnnotationsSummaryMapper { pollResponseSummary = annotationsSummary.pollResponseSummary?.let { PollResponseAggregatedSummaryEntityMapper.map(it) }, - liveLocationAggregatedSummary = annotationsSummary.liveLocationAggregatedSummary?.let { - LiveLocationAggregatedSummaryMapper.map(it) + liveLocationShareAggregatedSummary = annotationsSummary.liveLocationShareAggregatedSummary?.let { + LiveLocationShareAggregatedSummaryMapper.map(it) } ) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationShareAggregatedSummaryMapper.kt similarity index 79% rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationShareAggregatedSummaryMapper.kt index ff68cfb56f..2bc17c03e9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationAggregatedSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/LiveLocationShareAggregatedSummaryMapper.kt @@ -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.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.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 { - return LiveLocationAggregatedSummary( + fun map(entity: LiveLocationShareAggregatedSummaryEntity): LiveLocationShareAggregatedSummary { + return LiveLocationShareAggregatedSummary( eventId = entity.eventId, roomId = entity.roomId, isActive = entity.isActive, @@ -34,8 +34,8 @@ internal object LiveLocationAggregatedSummaryMapper { ) } - fun map(model: LiveLocationAggregatedSummary): LiveLocationAggregatedSummaryEntity { - return LiveLocationAggregatedSummaryEntity( + fun map(model: LiveLocationShareAggregatedSummary): LiveLocationShareAggregatedSummaryEntity { + return LiveLocationShareAggregatedSummaryEntity( eventId = model.eventId, roomId = model.roomId, isActive = model.isActive, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo027.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo027.kt index decb4066c5..c2d137f5c3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo027.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/migration/MigrateSessionTo027.kt @@ -19,7 +19,7 @@ package org.matrix.android.sdk.internal.database.migration import io.realm.DynamicRealm import io.realm.FieldAttribute 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 /** @@ -29,18 +29,18 @@ import org.matrix.android.sdk.internal.util.database.RealmMigrator internal class MigrateSessionTo027(realm: DynamicRealm) : RealmMigrator(realm, 27) { override fun doMigrate(realm: DynamicRealm) { - val liveLocationSummaryEntity = realm.schema.get("LiveLocationAggregatedSummaryEntity") - ?: realm.schema.create("LiveLocationAggregatedSummaryEntity") - .addField(LiveLocationAggregatedSummaryEntityFields.EVENT_ID, String::class.java, FieldAttribute.REQUIRED) - .addField(LiveLocationAggregatedSummaryEntityFields.ROOM_ID, String::class.java, FieldAttribute.REQUIRED) - .addField(LiveLocationAggregatedSummaryEntityFields.IS_ACTIVE, Boolean::class.java) - .setNullable(LiveLocationAggregatedSummaryEntityFields.IS_ACTIVE, true) - .addField(LiveLocationAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, Long::class.java) - .setNullable(LiveLocationAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, true) - .addField(LiveLocationAggregatedSummaryEntityFields.LAST_LOCATION_CONTENT, String::class.java) + val liveLocationSummaryEntity = realm.schema.get("LiveLocationShareAggregatedSummaryEntity") + ?: realm.schema.create("LiveLocationShareAggregatedSummaryEntity") + .addField(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, String::class.java, FieldAttribute.REQUIRED) + .addField(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, String::class.java, FieldAttribute.REQUIRED) + .addField(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, Boolean::class.java) + .setNullable(LiveLocationShareAggregatedSummaryEntityFields.IS_ACTIVE, true) + .addField(LiveLocationShareAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, Long::class.java) + .setNullable(LiveLocationShareAggregatedSummaryEntityFields.END_OF_LIVE_TIMESTAMP_AS_MILLISECONDS, true) + .addField(LiveLocationShareAggregatedSummaryEntityFields.LAST_LOCATION_CONTENT, String::class.java) ?: return realm.schema.get("EventAnnotationsSummaryEntity") - ?.addRealmObjectField(EventAnnotationsSummaryEntityFields.LIVE_LOCATION_AGGREGATED_SUMMARY.`$`, liveLocationSummaryEntity) + ?.addRealmObjectField(EventAnnotationsSummaryEntityFields.LIVE_LOCATION_SHARE_AGGREGATED_SUMMARY.`$`, liveLocationSummaryEntity) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventAnnotationsSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventAnnotationsSummaryEntity.kt index 537c39be32..c3abd8b028 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventAnnotationsSummaryEntity.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/EventAnnotationsSummaryEntity.kt @@ -18,7 +18,7 @@ package org.matrix.android.sdk.internal.database.model import io.realm.RealmList import io.realm.RealmObject 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 internal open class EventAnnotationsSummaryEntity( @@ -29,7 +29,7 @@ internal open class EventAnnotationsSummaryEntity( var editSummary: EditAggregatedSummaryEntity? = null, var referencesSummaryEntity: ReferencesAggregatedSummaryEntity? = null, var pollResponseSummary: PollResponseAggregatedSummaryEntity? = null, - var liveLocationAggregatedSummary: LiveLocationAggregatedSummaryEntity? = null, + var liveLocationShareAggregatedSummary: LiveLocationShareAggregatedSummaryEntity? = null, ) : RealmObject() { /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/SessionRealmModule.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/SessionRealmModule.kt index 210d0989fe..9a92b14510 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/SessionRealmModule.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/SessionRealmModule.kt @@ -17,7 +17,7 @@ package org.matrix.android.sdk.internal.database.model 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.threads.ThreadSummaryEntity @@ -48,7 +48,7 @@ import org.matrix.android.sdk.internal.database.model.threads.ThreadSummaryEntit EditAggregatedSummaryEntity::class, EditionOfEvent::class, PollResponseAggregatedSummaryEntity::class, - LiveLocationAggregatedSummaryEntity::class, + LiveLocationShareAggregatedSummaryEntity::class, ReferencesAggregatedSummaryEntity::class, PushRulesEntity::class, PushRuleEntity::class, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationAggregatedSummaryEntity.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationShareAggregatedSummaryEntity.kt similarity index 95% rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationAggregatedSummaryEntity.kt rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationShareAggregatedSummaryEntity.kt index c093da60ad..21e92d262a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationAggregatedSummaryEntity.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/model/livelocation/LiveLocationShareAggregatedSummaryEntity.kt @@ -22,7 +22,7 @@ import io.realm.annotations.PrimaryKey /** * Aggregation info concerning a live location share. */ -internal open class LiveLocationAggregatedSummaryEntity( +internal open class LiveLocationShareAggregatedSummaryEntity( /** * Event id of the event that started the live. */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationAggregatedSummaryEntityQuery.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationShareAggregatedSummaryEntityQuery.kt similarity index 56% rename from matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationAggregatedSummaryEntityQuery.kt rename to matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationShareAggregatedSummaryEntityQuery.kt index 63841e1abd..2e2e939fa2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationAggregatedSummaryEntityQuery.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/LiveLocationShareAggregatedSummaryEntityQuery.kt @@ -20,38 +20,38 @@ import io.realm.Realm import io.realm.RealmQuery import io.realm.kotlin.where 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.LiveLocationAggregatedSummaryEntityFields +import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntity +import org.matrix.android.sdk.internal.database.model.livelocation.LiveLocationShareAggregatedSummaryEntityFields -internal fun LiveLocationAggregatedSummaryEntity.Companion.where( +internal fun LiveLocationShareAggregatedSummaryEntity.Companion.where( realm: Realm, roomId: String, eventId: String, -): RealmQuery { - return realm.where() - .equalTo(LiveLocationAggregatedSummaryEntityFields.ROOM_ID, roomId) - .equalTo(LiveLocationAggregatedSummaryEntityFields.EVENT_ID, eventId) +): RealmQuery { + return realm.where() + .equalTo(LiveLocationShareAggregatedSummaryEntityFields.ROOM_ID, roomId) + .equalTo(LiveLocationShareAggregatedSummaryEntityFields.EVENT_ID, eventId) } -internal fun LiveLocationAggregatedSummaryEntity.Companion.create( +internal fun LiveLocationShareAggregatedSummaryEntity.Companion.create( realm: Realm, roomId: String, eventId: String, -): LiveLocationAggregatedSummaryEntity { - val obj = realm.createObject(LiveLocationAggregatedSummaryEntity::class.java, eventId).apply { +): LiveLocationShareAggregatedSummaryEntity { + val obj = realm.createObject(LiveLocationShareAggregatedSummaryEntity::class.java, eventId).apply { this.roomId = roomId } val annotationSummary = EventAnnotationsSummaryEntity.getOrCreate(realm, roomId = roomId, eventId = eventId) - annotationSummary.liveLocationAggregatedSummary = obj + annotationSummary.liveLocationShareAggregatedSummary = obj return obj } -internal fun LiveLocationAggregatedSummaryEntity.Companion.getOrCreate( +internal fun LiveLocationShareAggregatedSummaryEntity.Companion.getOrCreate( realm: Realm, roomId: String, eventId: String, -): LiveLocationAggregatedSummaryEntity { - return LiveLocationAggregatedSummaryEntity.where(realm, roomId, eventId).findFirst() - ?: LiveLocationAggregatedSummaryEntity.create(realm, roomId, eventId) +): LiveLocationShareAggregatedSummaryEntity { + return LiveLocationShareAggregatedSummaryEntity.where(realm, roomId, eventId).findFirst() + ?: LiveLocationShareAggregatedSummaryEntity.create(realm, roomId, eventId) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt index 536a8473b6..035011fe7b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/aggregation/livelocation/DefaultLiveLocationAggregationProcessor.kt @@ -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.MessageBeaconLocationDataContent 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 timber.log.Timber import javax.inject.Inject @@ -48,7 +48,7 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L return } - val aggregatedSummary = LiveLocationAggregatedSummaryEntity.getOrCreate( + val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate( realm = realm, roomId = roomId, eventId = targetEventId @@ -70,7 +70,7 @@ internal class DefaultLiveLocationAggregationProcessor @Inject constructor() : L return } - val aggregatedSummary = LiveLocationAggregatedSummaryEntity.getOrCreate( + val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.getOrCreate( realm = realm, roomId = roomId, eventId = targetEventId