SyncUpTarget

Target for sync up:

  • what records to upload to server

  • how to upload those records

During a sync up, sync manager does the following:

  1. it calls getIdsOfRecordsToSyncUp to get the ids of records to sync up

  2. for each id it does:

a) if calls getFromLocalStore to get the record itself

b) if merge mode is leave-if-changed, it calls isNewerThanServer, if that returns false, it goes to the next id

c) otherwise it does one of the following three operations:

  • calls deleteOnServer if isLocallyDeleted returns true for the record (unless it is also locally created, in which case it gets deleted locally right away) if successful or not found is returned, it calls deleteFromLocalStore to delete record locally

  • calls createOnServer if isLocallyCreated returns true for the record if successful, it updates the id to be the id returned by the server and then calls cleanAndSaveInSmartstore to reset local flags and save the record locally

  • calls updateOnServer if isLocallyUpdated returns true for the record if successful, it calls cleanAndSaveInSmartstore to reset local flags and save the record if not found and merge mode is overwrite, it calls createOnServer to recreate the record on the server

Inheritors

Constructors

Link copied to clipboard
constructor(createFieldlist: List<String>? = null, updateFieldlist: List<String>? = null, idFieldName: String? = null, modificationDateFieldName: String? = null, externalIdFieldName: String? = null)

Construct SyncUpTarget

constructor(target: JSONObject)

Construct SyncUpTarget from json

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun addSyncId(record: JSONObject, syncId: Long)
Link copied to clipboard

Same as isNewerThanServer but operating over a list of records (expected to be of the same sobject type) Return map from record store id to boolean

Link copied to clipboard
open override fun asJSON(): JSONObject
Link copied to clipboard
fun cleanAndSaveInLocalStore(syncManager: SyncManager, soupName: String, record: JSONObject)

Save cleaned record in local store

Link copied to clipboard
fun cleanAndSaveInSmartStore(smartStore: SmartStore, soupName: String, record: JSONObject, idFieldName: String?, handleTx: Boolean)
Link copied to clipboard
fun cleanRecord(record: JSONObject)
Link copied to clipboard
open fun createOnServer(syncManager: SyncManager, record: JSONObject, fieldlist: List<String>?): String?

Save locally created record back to server

Link copied to clipboard
fun deleteFromLocalStore(syncManager: SyncManager, soupName: String, record: JSONObject)

Delete record from local store

Link copied to clipboard
open fun deleteOnServer(syncManager: SyncManager, record: JSONObject): Int

Delete locally deleted record from server

Link copied to clipboard
fun getDirtyRecordIds(syncManager: SyncManager, soupName: String, idField: String): SortedSet<String>

Return ids of "dirty" records (records locally created/upated or deleted)

Link copied to clipboard
fun getFromLocalStore(syncManager: SyncManager, soupName: String, storeId: String): JSONObject

Get record from local store by storeId

fun getFromLocalStore(syncManager: SyncManager, soupName: String, storeIds: List<String>): List<JSONObject>

Get records from local store by storeId

Link copied to clipboard
fun getIdsOfRecordsToSyncUp(syncManager: SyncManager, soupName: String): Set<String>

Return ids of records to sync up

Link copied to clipboard
fun isDirty(record: JSONObject): Boolean

Given a record, return true if it was locally created/updated or deleted

Link copied to clipboard

Given a record, return true if it was locally created

Link copied to clipboard

Given a record, return true if it was locally deleted

Link copied to clipboard

Given a record, return true if it was locally updated

Link copied to clipboard
open fun isNewerThanServer(syncManager: SyncManager, record: JSONObject): Boolean

Return true if record is more recent than corresponding record on server NB: also return true if both were deleted or if local mod date is missing

Link copied to clipboard
open fun saveRecordsToLocalStore(syncManager: SyncManager, soupName: String, records: JSONArray, syncId: Long)

Save records to local store

Link copied to clipboard

Save record with last error if any

Link copied to clipboard
open fun updateOnServer(syncManager: SyncManager, record: JSONObject, fieldlist: List<String>?): Int

Save locally updated record back to server