Skip to content

Commit 21080ae

Browse files
committed
Save planned=false for ad-hoc LOIs.
1 parent 26f2447 commit 21080ae

File tree

7 files changed

+22
-5
lines changed

7 files changed

+22
-5
lines changed

ground/src/main/java/com/google/android/ground/model/locationofinterest/LocationOfInterest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ data class LocationOfInterest(
5555
val isOpportunistic: Boolean = false,
5656
/** Custom map of properties for this LOI. Corresponds to the properties field in GeoJSON */
5757
val properties: LoiProperties = mapOf(),
58+
/** Whether the LOI was predefined in the survey or not (i.e. added ad hoc). */
59+
val planned: Boolean? = null,
5860
) {
5961

6062
/**

ground/src/main/java/com/google/android/ground/persistence/local/room/converter/ConverterExt.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ import com.google.android.ground.persistence.local.room.relations.TaskEntityAndR
4141
import com.google.android.ground.ui.map.Bounds
4242
import com.google.common.reflect.TypeToken
4343
import com.google.gson.Gson
44-
import java.util.*
4544
import kotlinx.collections.immutable.toPersistentList
4645
import kotlinx.collections.immutable.toPersistentMap
4746
import org.json.JSONObject
4847
import timber.log.Timber
48+
import java.util.*
4949

5050
fun AuditInfo.toLocalDataStoreObject(): AuditInfoEntity =
5151
AuditInfoEntity(
@@ -147,6 +147,7 @@ fun LocationOfInterest.toLocalDataStoreObject() =
147147
ownerEmail = ownerEmail,
148148
isOpportunistic = isOpportunistic,
149149
properties = properties,
150+
// TODO(#2300): Add `planned` field for local storage.
150151
)
151152

152153
fun LocationOfInterestEntity.toModelObject(survey: Survey): LocationOfInterest =
@@ -167,6 +168,7 @@ fun LocationOfInterestEntity.toModelObject(survey: Survey): LocationOfInterest =
167168
?: throw LocalDataConsistencyException(
168169
"Unknown jobId ${this.jobId} in location of interest ${this.id}"
169170
)
171+
// TODO(#2300): Add `planned` field for rendering use.
170172
)
171173
}
172174

@@ -211,7 +213,7 @@ fun LocationOfInterestMutation.toLocalDataStoreObject() =
211213
clientTimestamp = clientTimestamp.time,
212214
lastError = lastError,
213215
retryCount = retryCount,
214-
newProperties = properties
216+
newProperties = properties,
215217
)
216218

217219
fun LocationOfInterestMutationEntity.toModelObject() =

ground/src/main/java/com/google/android/ground/persistence/local/room/entity/LocationOfInterestEntity.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616
package com.google.android.ground.persistence.local.room.entity
1717

18-
import androidx.room.*
18+
import androidx.room.ColumnInfo
19+
import androidx.room.Embedded
20+
import androidx.room.Entity
21+
import androidx.room.Index
22+
import androidx.room.PrimaryKey
1923
import com.google.android.ground.model.locationofinterest.LoiProperties
2024
import com.google.android.ground.persistence.local.room.fields.EntityState
2125

@@ -37,4 +41,5 @@ data class LocationOfInterestEntity(
3741
val ownerEmail: String?,
3842
val isOpportunistic: Boolean,
3943
val properties: LoiProperties,
44+
// TODO(#2300): Add `planned` field for local storage.
4045
)

ground/src/main/java/com/google/android/ground/persistence/local/room/entity/LocationOfInterestMutationEntity.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616
package com.google.android.ground.persistence.local.room.entity
1717

18-
import androidx.room.*
18+
import androidx.room.ColumnInfo
19+
import androidx.room.Entity
20+
import androidx.room.ForeignKey
21+
import androidx.room.Index
22+
import androidx.room.PrimaryKey
1923
import com.google.android.ground.model.locationofinterest.LoiProperties
2024
import com.google.android.ground.persistence.local.room.fields.MutationEntitySyncStatus
2125
import com.google.android.ground.persistence.local.room.fields.MutationEntityType

ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/LoiConverter.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ object LoiConverter {
3333
const val GEOMETRY_COORDINATES = "coordinates"
3434
const val GEOMETRY = "geometry"
3535
const val SUBMISSION_COUNT = "submissionCount"
36+
const val PLANNED = "planned"
3637

3738
fun toLoi(survey: Survey, doc: DocumentSnapshot): Result<LocationOfInterest> = runCatching {
3839
toLoiUnchecked(survey, doc)
@@ -71,7 +72,8 @@ object LoiConverter {
7172
// TODO(#929): Set geometry once LOI has been updated to use our own model.
7273
geometry = geometry,
7374
submissionCount = submissionCount,
74-
properties = loiDoc.properties ?: mapOf()
75+
properties = loiDoc.properties ?: mapOf(),
76+
planned = loiDoc.planned,
7577
)
7678
}
7779
}

ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/LoiDocument.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ data class LoiDocument(
3232
val lastModified: AuditInfoNestedObject? = null,
3333
val submissionCount: Int? = null,
3434
val properties: LoiProperties? = null,
35+
val planned: Boolean? = null,
3536
)

ground/src/main/java/com/google/android/ground/persistence/remote/firebase/schema/LoiMutationConverter.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ internal object LoiMutationConverter {
5555
Mutation.Type.CREATE -> {
5656
map[LoiConverter.CREATED] = auditInfo
5757
map[LoiConverter.LAST_MODIFIED] = auditInfo
58+
map[LoiConverter.PLANNED] = false
5859
}
5960
Mutation.Type.UPDATE -> {
6061
map[LoiConverter.LAST_MODIFIED] = auditInfo

0 commit comments

Comments
 (0)