private synchronized void pushUpdated(GtasksInvoker invoker, SyncResultCallback callback) { TodorooCursor<Task> queued = taskService.query( Query.select(Task.PROPERTIES) .join( Join.left( Metadata.TABLE, Criterion.and( MetadataCriteria.withKey(GtasksMetadata.METADATA_KEY), Task.ID.eq(Metadata.TASK)))) .where( Criterion.or( Task.MODIFICATION_DATE.gt(GtasksMetadata.LAST_SYNC), Criterion.and( Task.USER_ID.neq(Task.USER_ID_SELF), GtasksMetadata.ID.isNotNull()), Metadata.KEY.isNull()))); callback.incrementMax(queued.getCount() * 10); try { Task task = new Task(); for (queued.moveToFirst(); !queued.isAfterLast(); queued.moveToNext()) { task.readFromCursor(queued); try { gtasksSyncService.pushTaskOnSave(task, task.getMergedValues(), invoker, false); } catch (GoogleTasksException e) { handler.handleException("gtasks-sync-io", e, e.getType()); // $NON-NLS-1$ } catch (IOException e) { handler.handleException("gtasks-sync-io", e, e.toString()); // $NON-NLS-1$ } finally { callback.incrementProgress(10); } } } finally { queued.close(); } }
private void titleMatchWithActFm(Task task) { String title = task.getValue(Task.TITLE); TodorooCursor<Task> match = taskService.query( Query.select(Task.ID) .join( Join.left( Metadata.TABLE, Criterion.and( Metadata.KEY.eq(GtasksMetadata.METADATA_KEY), Metadata.TASK.eq(Task.ID)))) .where(Criterion.and(Task.TITLE.eq(title), GtasksMetadata.ID.isNull()))); try { if (match.getCount() > 0) { match.moveToFirst(); task.setId(match.get(Task.ID)); } } finally { match.close(); } }