|
|
@ -51,6 +51,7 @@ import com.todoroo.astrid.utility.Preferences;
|
|
|
|
@SuppressWarnings("nls")
|
|
|
|
@SuppressWarnings("nls")
|
|
|
|
public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer> {
|
|
|
|
public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final long TASK_ID_UNSYNCED = 1L;
|
|
|
|
private ProducteevDataService dataService = null;
|
|
|
|
private ProducteevDataService dataService = null;
|
|
|
|
private ProducteevInvoker invoker = null;
|
|
|
|
private ProducteevInvoker invoker = null;
|
|
|
|
private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE;
|
|
|
|
private final ProducteevUtilities preferences = ProducteevUtilities.INSTANCE;
|
|
|
@ -299,7 +300,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void create(ProducteevTaskContainer local) throws IOException {
|
|
|
|
protected ProducteevTaskContainer create(ProducteevTaskContainer local) throws IOException {
|
|
|
|
Task localTask = local.task;
|
|
|
|
Task localTask = local.task;
|
|
|
|
long dashboard = ProducteevUtilities.INSTANCE.getDefaultDashboard();
|
|
|
|
long dashboard = ProducteevUtilities.INSTANCE.getDefaultDashboard();
|
|
|
|
if(local.pdvTask.containsNonNullValue(ProducteevTask.DASHBOARD_ID))
|
|
|
|
if(local.pdvTask.containsNonNullValue(ProducteevTask.DASHBOARD_ID))
|
|
|
@ -307,8 +308,8 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
|
|
|
|
|
|
|
|
|
|
|
|
if(dashboard == ProducteevUtilities.DASHBOARD_NO_SYNC) {
|
|
|
|
if(dashboard == ProducteevUtilities.DASHBOARD_NO_SYNC) {
|
|
|
|
// set a bogus task id, then return without creating
|
|
|
|
// set a bogus task id, then return without creating
|
|
|
|
local.pdvTask.setValue(ProducteevTask.ID, 1L);
|
|
|
|
local.pdvTask.setValue(ProducteevTask.ID, TASK_ID_UNSYNCED);
|
|
|
|
return;
|
|
|
|
return local;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject response = invoker.tasksCreate(localTask.getValue(Task.TITLE),
|
|
|
|
JSONObject response = invoker.tasksCreate(localTask.getValue(Task.TITLE),
|
|
|
@ -322,6 +323,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
transferIdentifiers(newRemoteTask, local);
|
|
|
|
transferIdentifiers(newRemoteTask, local);
|
|
|
|
push(local, newRemoteTask);
|
|
|
|
push(local, newRemoteTask);
|
|
|
|
|
|
|
|
return newRemoteTask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Create a task container for the given RtmTaskSeries
|
|
|
|
/** Create a task container for the given RtmTaskSeries
|
|
|
@ -403,14 +405,22 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
|
|
|
|
if(shouldTransmit(local, Task.DELETION_DATE, remote)) {
|
|
|
|
if(shouldTransmit(local, Task.DELETION_DATE, remote)) {
|
|
|
|
if(local.task.getValue(Task.DELETION_DATE) > 0)
|
|
|
|
if(local.task.getValue(Task.DELETION_DATE) > 0)
|
|
|
|
invoker.tasksDelete(idTask);
|
|
|
|
invoker.tasksDelete(idTask);
|
|
|
|
else
|
|
|
|
else {
|
|
|
|
create(local);
|
|
|
|
// if we create, we transfer identifiers to old remote
|
|
|
|
|
|
|
|
// in case it is used by caller for other purposes
|
|
|
|
|
|
|
|
ProducteevTaskContainer newRemote = create(local);
|
|
|
|
|
|
|
|
transferIdentifiers(newRemote, remote);
|
|
|
|
|
|
|
|
remote = newRemote;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// dashboard
|
|
|
|
// dashboard
|
|
|
|
if(remote != null && idDashboard != remote.pdvTask.getValue(ProducteevTask.DASHBOARD_ID)) {
|
|
|
|
if(remote != null && idDashboard != remote.pdvTask.getValue(ProducteevTask.DASHBOARD_ID)) {
|
|
|
|
invoker.tasksSetWorkspace(idTask, idDashboard);
|
|
|
|
invoker.tasksSetWorkspace(idTask, idDashboard);
|
|
|
|
remote = pull(local);
|
|
|
|
remote = pull(local);
|
|
|
|
|
|
|
|
} else if(remote == null && idTask == TASK_ID_UNSYNCED) {
|
|
|
|
|
|
|
|
// was un-synced, create remote
|
|
|
|
|
|
|
|
remote = create(local);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// core properties
|
|
|
|
// core properties
|
|
|
|