public class CategorySyncHelper extends Object implements EntitySyncHelper<CategoryInfo>
Modifier and Type | Field and Description |
---|---|
private MemoryLocalStorage |
storage |
Constructor and Description |
---|
CategorySyncHelper(MemoryLocalStorage storage) |
Modifier and Type | Method and Description |
---|---|
void |
createOrUpdateEntityFromInfo(CategoryInfo 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<CategoryInfo> uploader,
SyncCategory cat) |
void |
download(Downloader<CategoryInfo> downloader)
Method should store all new Infos, received from server via downloader, to local storage as entities.
|
void |
uploadCreatedOrUpdated(Uploader<CategoryInfo> uploader)
Method should process all not deleted and 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. |
void |
uploadDeleted(Uploader<CategoryInfo> uploader)
Method should process all deleted and not synced entities from local storage:
convert each entity to Info pass each Info to uploader.upload - it will take care about deleting info to server mark uploaded entity as synced (to not sync it again until it will be changed) store updated entity to local db if needed. |
private final MemoryLocalStorage storage
public CategorySyncHelper(MemoryLocalStorage storage)
public void uploadDeleted(Uploader<CategoryInfo> uploader)
EntitySyncHelper
Method should process all deleted and not synced entities from local storage:
uploadDeleted
in interface EntitySyncHelper<CategoryInfo>
Uploader
public void uploadCreatedOrUpdated(Uploader<CategoryInfo> uploader)
EntitySyncHelper
Method should process all not deleted and not synced entities from local storage:
uploadCreatedOrUpdated
in interface EntitySyncHelper<CategoryInfo>
Uploader
private void doUpload(Uploader<CategoryInfo> uploader, SyncCategory cat)
public void download(Downloader<CategoryInfo> downloader)
EntitySyncHelper
Method should store all new Infos, received from server via downloader, to local storage as entities.
Downloader has two methods:
download
in interface EntitySyncHelper<CategoryInfo>
Downloader
public void createOrUpdateEntityFromInfo(CategoryInfo info)
EntitySyncHelper
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 EntitySyncHelper<CategoryInfo>
Copyright © 2016. All rights reserved.