mirror of https://github.com/tasks/tasks
Producteev Shared Desktop initial work. what's here: synchronizing multiple workspaces, displaying this information, displaying task responsiblity info, switching things into multiple workspaces
parent
8b4b79db88
commit
aa2fe7db1b
@ -1,86 +1,30 @@
|
|||||||
/**
|
|
||||||
* See the file "LICENSE" for the full license governing this code.
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.producteev.sync;
|
package com.todoroo.astrid.producteev.sync;
|
||||||
|
|
||||||
|
|
||||||
import android.content.ContentValues;
|
|
||||||
|
|
||||||
import com.todoroo.andlib.data.AbstractModel;
|
|
||||||
import com.todoroo.andlib.data.Property;
|
|
||||||
import com.todoroo.andlib.data.Table;
|
|
||||||
import com.todoroo.andlib.data.TodorooCursor;
|
|
||||||
import com.todoroo.andlib.data.Property.LongProperty;
|
import com.todoroo.andlib.data.Property.LongProperty;
|
||||||
import com.todoroo.andlib.data.Property.StringProperty;
|
import com.todoroo.andlib.data.Property.StringProperty;
|
||||||
import com.todoroo.astrid.model.Task;
|
import com.todoroo.astrid.model.StoreObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data Model which represents a dashboard in Producteev
|
* {@link StoreObject} entries for a Producteev Dashboard
|
||||||
*
|
*
|
||||||
* @author Tim Su <tim@todoroo.com>
|
* @author Tim Su <tim@todoroo.com>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("nls")
|
public class ProducteevDashboard {
|
||||||
public class ProducteevDashboard extends AbstractModel {
|
|
||||||
|
|
||||||
// --- table
|
|
||||||
|
|
||||||
public static final Table TABLE = new Table("dashboards", ProducteevDashboard.class);
|
|
||||||
|
|
||||||
// --- properties
|
|
||||||
|
|
||||||
/** ID (corresponds to RTM ID) */
|
|
||||||
public static final LongProperty ID = new LongProperty(
|
|
||||||
TABLE, ID_PROPERTY_NAME);
|
|
||||||
|
|
||||||
/** Name */
|
|
||||||
public static final StringProperty NAME = new StringProperty(
|
|
||||||
TABLE, "name");
|
|
||||||
|
|
||||||
/** List of all properties for this model */
|
|
||||||
public static final Property<?>[] PROPERTIES = generateProperties(ProducteevDashboard.class);
|
|
||||||
|
|
||||||
// --- defaults
|
|
||||||
|
|
||||||
/** Default values container */
|
|
||||||
private static final ContentValues defaultValues = new ContentValues();
|
|
||||||
|
|
||||||
// static {
|
|
||||||
// defaultValues.put(POSITION.name, 0);
|
|
||||||
// defaultValues.put(ARCHIVED.name, 0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContentValues getDefaultValues() {
|
|
||||||
return defaultValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- data access boilerplate
|
|
||||||
|
|
||||||
public ProducteevDashboard() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProducteevDashboard(TodorooCursor<ProducteevDashboard> cursor) {
|
|
||||||
this();
|
|
||||||
readPropertiesFromCursor(cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromCursor(TodorooCursor<ProducteevDashboard> cursor) {
|
/** type*/
|
||||||
super.readPropertiesFromCursor(cursor);
|
public static final String TYPE = "pdv-dash"; //$NON-NLS-1$
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
/** dashboard id in producteev */
|
||||||
public long getId() {
|
public static final LongProperty REMOTE_ID = new LongProperty(StoreObject.TABLE,
|
||||||
return getIdHelper(ID);
|
StoreObject.ITEM.name);
|
||||||
};
|
|
||||||
|
|
||||||
// --- parcelable helpers
|
/** dashboard name */
|
||||||
|
public static final StringProperty NAME = new StringProperty(StoreObject.TABLE,
|
||||||
|
StoreObject.VALUE1.name);
|
||||||
|
|
||||||
private static final Creator<Task> CREATOR = new ModelCreator<Task>(Task.class);
|
/** users (list in the format "id_user,name;id_user,name;") */
|
||||||
|
public static final StringProperty USERS = new StringProperty(StoreObject.TABLE,
|
||||||
|
StoreObject.VALUE2.name);
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Creator<? extends AbstractModel> getCreator() {
|
|
||||||
return CREATOR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,76 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009, Todoroo Inc
|
|
||||||
* All Rights Reserved
|
|
||||||
* http://www.todoroo.com
|
|
||||||
*/
|
|
||||||
package com.todoroo.astrid.producteev.sync;
|
|
||||||
|
|
||||||
import com.todoroo.andlib.data.AbstractDatabase;
|
|
||||||
import com.todoroo.andlib.data.GenericDao;
|
|
||||||
import com.todoroo.andlib.data.Table;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Database wrapper
|
|
||||||
*
|
|
||||||
* @author Tim Su <tim@todoroo.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("nls")
|
|
||||||
public class ProducteevDatabase extends AbstractDatabase {
|
|
||||||
|
|
||||||
// --- constants
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Database version number. This variable must be updated when database
|
|
||||||
* tables are updated, as it determines whether a database needs updating.
|
|
||||||
*/
|
|
||||||
public static final int VERSION = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Database name (must be unique)
|
|
||||||
*/
|
|
||||||
private static final String NAME = "producteev";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of table/ If you're adding a new table, add it to this list and
|
|
||||||
* also make sure that our SQLite helper does the right thing.
|
|
||||||
*/
|
|
||||||
public static final Table[] TABLES = new Table[] {
|
|
||||||
ProducteevDashboard.TABLE,
|
|
||||||
};
|
|
||||||
|
|
||||||
// --- implementation
|
|
||||||
|
|
||||||
private final GenericDao<ProducteevDashboard> dao = new GenericDao<ProducteevDashboard>(ProducteevDashboard.class, this);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getName() {
|
|
||||||
return NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getVersion() {
|
|
||||||
return VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Table[] getTables() {
|
|
||||||
return TABLES;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GenericDao<ProducteevDashboard> getDao() {
|
|
||||||
return dao;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreateTables() {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean onUpgrade(int oldVersion, int newVersion) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2009, Todoroo Inc
|
||||||
|
* All Rights Reserved
|
||||||
|
* http://www.todoroo.com
|
||||||
|
*/
|
||||||
|
package com.todoroo.astrid.dao;
|
||||||
|
|
||||||
|
import com.todoroo.andlib.data.GenericDao;
|
||||||
|
import com.todoroo.andlib.service.Autowired;
|
||||||
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||||
|
import com.todoroo.andlib.sql.Criterion;
|
||||||
|
import com.todoroo.astrid.model.StoreObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Access layer for {@link StoreObject}-related operations.
|
||||||
|
*
|
||||||
|
* @author Tim Su <tim@todoroo.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StoreObjectDao extends GenericDao<StoreObject> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Database database;
|
||||||
|
|
||||||
|
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UR_UNINIT_READ")
|
||||||
|
public StoreObjectDao() {
|
||||||
|
super(StoreObject.class);
|
||||||
|
DependencyInjectionService.getInstance().inject(this);
|
||||||
|
setDatabase(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- SQL clause generators
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates SQL clauses
|
||||||
|
*/
|
||||||
|
public static class StoreObjectCriteria {
|
||||||
|
|
||||||
|
/** Returns all store objects with given type */
|
||||||
|
public static Criterion byType(String type) {
|
||||||
|
return StoreObject.TYPE.eq(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns store object with type and key */
|
||||||
|
public static Criterion byTypeAndItem(String type, String item) {
|
||||||
|
return Criterion.and(byType(type), StoreObject.ITEM.eq(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
/**
|
||||||
|
* See the file "LICENSE" for the full license governing this code.
|
||||||
|
*/
|
||||||
|
package com.todoroo.astrid.model;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
|
||||||
|
import com.todoroo.andlib.data.AbstractModel;
|
||||||
|
import com.todoroo.andlib.data.Property;
|
||||||
|
import com.todoroo.andlib.data.Property.LongProperty;
|
||||||
|
import com.todoroo.andlib.data.Property.StringProperty;
|
||||||
|
import com.todoroo.andlib.data.Table;
|
||||||
|
import com.todoroo.andlib.data.TodorooCursor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Model which represents a piece of data unrelated to a task
|
||||||
|
*
|
||||||
|
* @author Tim Su <tim@todoroo.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public class StoreObject extends AbstractModel {
|
||||||
|
|
||||||
|
// --- table
|
||||||
|
|
||||||
|
public static final Table TABLE = new Table("store", StoreObject.class);
|
||||||
|
|
||||||
|
// --- properties
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
public static final LongProperty ID = new LongProperty(
|
||||||
|
TABLE, ID_PROPERTY_NAME);
|
||||||
|
|
||||||
|
/** Store Type Key */
|
||||||
|
public static final StringProperty TYPE = new StringProperty(
|
||||||
|
TABLE, "type");
|
||||||
|
|
||||||
|
/** Store Item Key */
|
||||||
|
public static final StringProperty ITEM= new StringProperty(
|
||||||
|
TABLE, "item");
|
||||||
|
|
||||||
|
/** Store Value Column 1 */
|
||||||
|
public static final StringProperty VALUE1 = new StringProperty(
|
||||||
|
TABLE, "value");
|
||||||
|
|
||||||
|
/** Store Value Column 2 */
|
||||||
|
public static final StringProperty VALUE2 = new StringProperty(
|
||||||
|
TABLE, "value2");
|
||||||
|
|
||||||
|
/** Store Value Column 3 */
|
||||||
|
public static final StringProperty VALUE3 = new StringProperty(
|
||||||
|
TABLE, "value3");
|
||||||
|
|
||||||
|
/** Store Value Column 4 */
|
||||||
|
public static final StringProperty VALUE4 = new StringProperty(
|
||||||
|
TABLE, "value4");
|
||||||
|
|
||||||
|
/** Store Value Column 5 */
|
||||||
|
public static final StringProperty VALUE5 = new StringProperty(
|
||||||
|
TABLE, "value5");
|
||||||
|
|
||||||
|
/** List of all properties for this model */
|
||||||
|
public static final Property<?>[] PROPERTIES = generateProperties(StoreObject.class);
|
||||||
|
|
||||||
|
// --- defaults
|
||||||
|
|
||||||
|
/** Default values container */
|
||||||
|
private static final ContentValues defaultValues = new ContentValues();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentValues getDefaultValues() {
|
||||||
|
return defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- data access boilerplate
|
||||||
|
|
||||||
|
public StoreObject() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreObject(TodorooCursor<StoreObject> cursor) {
|
||||||
|
this();
|
||||||
|
readPropertiesFromCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromCursor(TodorooCursor<StoreObject> cursor) {
|
||||||
|
super.readPropertiesFromCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return getIdHelper(ID);
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- parcelable helpers
|
||||||
|
|
||||||
|
private static final Creator<StoreObject> CREATOR = new ModelCreator<StoreObject>(StoreObject.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Creator<? extends AbstractModel> getCreator() {
|
||||||
|
return CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue