public class ProductSyncAdapter extends Object implements EntitySyncAdapter<ProductInfo>
Modifier and Type | Field and Description |
---|---|
private MemoryLocalStorage |
storage |
Constructor and Description |
---|
ProductSyncAdapter(MemoryLocalStorage storage) |
Modifier and Type | Method and Description |
---|---|
void |
createOrUpdateEntityFromInfo(ProductInfo info)
Method should update corresponding entity from info (entity could be located by identifier from info)
or create entity if client has no entity with such identifier.
|
private void |
doUpload(Uploader<ProductInfo> uploader,
SyncProduct product) |
void |
upload(Uploader<ProductInfo> uploader)
Method should process all not synced entities from local storage:
convert each entity to Info pass each Info to uploader.upload - it will take care about posting info to server if uploader returned new identifier for item, store it to local entity (that means entity is new and was created on server with new identifier) mark uploaded entity as synced (to not sync it again until it will be changed) store updated entity to local db To keep data consistancy you should process all not synced entities - both undeleted and deleted. |
private final MemoryLocalStorage storage
public ProductSyncAdapter(MemoryLocalStorage storage)
public void upload(Uploader<ProductInfo> uploader)
EntitySyncAdapter
Method should process all not synced entities from local storage:
upload
in interface EntitySyncAdapter<ProductInfo>
Uploader
private void doUpload(Uploader<ProductInfo> uploader, SyncProduct product)
public void createOrUpdateEntityFromInfo(ProductInfo info)
EntitySyncAdapter
Method should update corresponding entity from info (entity could be located by identifier from info) or create entity if client has no entity with such identifier.
createOrUpdateEntityFromInfo
in interface EntitySyncAdapter<ProductInfo>
Copyright © 2016. All rights reserved.