mirror of
https://github.com/etesync/android
synced 2025-01-11 00:01:12 +00:00
ServiceEntity: rename fetch to fetchOrCreate.
This is what it was doing anyway.
This commit is contained in:
parent
9600cd3f1f
commit
990ab81c2b
@ -144,7 +144,7 @@ public class JournalModel {
|
||||
@Index(value = "service_unique_together")
|
||||
CollectionInfo.Type type;
|
||||
|
||||
public static ServiceEntity fetch(EntityDataStore<Persistable> data, String account, CollectionInfo.Type type) {
|
||||
public static ServiceEntity fetchOrCreate(EntityDataStore<Persistable> data, String account, CollectionInfo.Type type) {
|
||||
ServiceEntity service = data.select(ServiceEntity.class).where(ServiceEntity.ACCOUNT.eq(account).and(ServiceEntity.TYPE.eq(type))).limit(1).get().firstOrNull();
|
||||
if (service == null) {
|
||||
// If our first time, create service and a journal
|
||||
|
@ -74,7 +74,7 @@ class AddressBooksSyncAdapterService : SyncAdapterService() {
|
||||
private fun updateLocalAddressBooks(provider: ContentProviderClient, account: Account) {
|
||||
val context = context
|
||||
val data = (getContext().applicationContext as App).data
|
||||
val service = JournalModel.Service.fetch(data, account.name, CollectionInfo.Type.ADDRESS_BOOK)
|
||||
val service = JournalModel.Service.fetchOrCreate(data, account.name, CollectionInfo.Type.ADDRESS_BOOK)
|
||||
|
||||
val remote = HashMap<String, JournalEntity>()
|
||||
val remoteJournals = JournalEntity.getJournals(data, service)
|
||||
|
@ -59,7 +59,7 @@ class CalendarsSyncAdapterService : SyncAdapterService() {
|
||||
@Throws(CalendarStorageException::class)
|
||||
private fun updateLocalCalendars(provider: ContentProviderClient, account: Account, settings: AccountSettings) {
|
||||
val data = (context.applicationContext as App).data
|
||||
val service = JournalModel.Service.fetch(data, account.name, CollectionInfo.Type.CALENDAR)
|
||||
val service = JournalModel.Service.fetchOrCreate(data, account.name, CollectionInfo.Type.CALENDAR)
|
||||
|
||||
val remote = HashMap<String, JournalEntity>()
|
||||
val remoteJournals = JournalEntity.getJournals(data, service)
|
||||
|
@ -229,7 +229,7 @@ abstract class SyncAdapterService : Service() {
|
||||
|
||||
private fun saveCollections(journals: Iterable<Pair<JournalManager.Journal, CollectionInfo>>) {
|
||||
val data = (context.applicationContext as App).data
|
||||
val service = JournalModel.Service.fetch(data, account.name, serviceType)
|
||||
val service = JournalModel.Service.fetchOrCreate(data, account.name, serviceType)
|
||||
|
||||
val existing = HashMap<String, JournalEntity>()
|
||||
for (journalEntity in JournalEntity.getJournals(data, service)) {
|
||||
|
@ -89,7 +89,7 @@ constructor(protected val context: Context, protected val account: Account, prot
|
||||
httpClient = HttpClient.Builder(context, settings).setForeground(false).build()
|
||||
|
||||
data = (context.applicationContext as App).data
|
||||
val serviceEntity = JournalModel.Service.fetch(data, accountName, serviceType)
|
||||
val serviceEntity = JournalModel.Service.fetchOrCreate(data, accountName, serviceType)
|
||||
info = JournalEntity.fetch(data, serviceEntity, journalUid)!!.info
|
||||
|
||||
// dismiss previous error notifications
|
||||
|
@ -78,7 +78,7 @@ class TasksSyncAdapterService: SyncAdapterService() {
|
||||
|
||||
private fun updateLocalTaskLists(provider: TaskProvider, account: Account, settings: AccountSettings) {
|
||||
val data = (context.applicationContext as App).data
|
||||
var service = JournalModel.Service.fetch(data, account.name, CollectionInfo.Type.TASKS)
|
||||
var service = JournalModel.Service.fetchOrCreate(data, account.name, CollectionInfo.Type.TASKS)
|
||||
|
||||
val remote = HashMap<String, JournalEntity>()
|
||||
val remoteJournals = JournalEntity.getJournals(data, service)
|
||||
|
@ -95,7 +95,7 @@ class CreateCollectionFragment : DialogFragment(), LoaderManager.LoaderCallbacks
|
||||
CollectionInfo.Type.TASKS -> authority = TaskProvider.ProviderName.OpenTasks.authority
|
||||
}
|
||||
|
||||
val serviceEntity = JournalModel.Service.fetch(data, account.name, info.type)
|
||||
val serviceEntity = JournalModel.Service.fetchOrCreate(data, account.name, info.type)
|
||||
info.serviceID = serviceEntity.id
|
||||
|
||||
val settings = AccountSettings(context, account)
|
||||
|
Loading…
Reference in New Issue
Block a user