mirror of https://github.com/tasks/tasks
Boilerplate for TaskListMetadata
parent
3201ba3726
commit
fa3bbf3445
@ -0,0 +1,145 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2012 Todoroo Inc
|
||||||
|
*
|
||||||
|
* See the file "LICENSE" for the full license governing this code.
|
||||||
|
*/
|
||||||
|
package com.todoroo.astrid.data;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import com.todoroo.andlib.data.AbstractModel;
|
||||||
|
import com.todoroo.andlib.data.Property;
|
||||||
|
import com.todoroo.andlib.data.Property.IntegerProperty;
|
||||||
|
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;
|
||||||
|
import com.todoroo.astrid.api.AstridApiConstants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Model which represents a user.
|
||||||
|
*
|
||||||
|
* @author Tim Su <tim@todoroo.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public final class TaskListMetadata extends RemoteModel {
|
||||||
|
|
||||||
|
// --- table and uri
|
||||||
|
|
||||||
|
/** table for this model */
|
||||||
|
public static final Table TABLE = new Table("task_list_metadata", TaskListMetadata.class);
|
||||||
|
|
||||||
|
/** model class for entries in the outstanding table */
|
||||||
|
public static final Class<? extends OutstandingEntry<TaskListMetadata>> OUTSTANDING_MODEL = TaskListMetadataOutstanding.class;
|
||||||
|
|
||||||
|
/** content uri for this model */
|
||||||
|
public static final Uri CONTENT_URI = Uri.parse("content://" + AstridApiConstants.API_PACKAGE + "/" +
|
||||||
|
TABLE.name);
|
||||||
|
|
||||||
|
// --- properties
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
public static final LongProperty ID = new LongProperty(
|
||||||
|
TABLE, ID_PROPERTY_NAME);
|
||||||
|
|
||||||
|
/** Remote id */
|
||||||
|
public static final StringProperty UUID = new StringProperty(
|
||||||
|
TABLE, UUID_PROPERTY_NAME);
|
||||||
|
|
||||||
|
/** Pushed at date */
|
||||||
|
public static final LongProperty PUSHED_AT = new LongProperty(
|
||||||
|
TABLE, PUSHED_AT_PROPERTY_NAME);
|
||||||
|
|
||||||
|
/** Tag UUID */
|
||||||
|
public static final StringProperty TAG_UUID = new StringProperty(
|
||||||
|
TABLE, "tag_uuid");
|
||||||
|
|
||||||
|
/** Filter id (one of below) */
|
||||||
|
public static final StringProperty FILTER = new StringProperty(
|
||||||
|
TABLE, "filter");
|
||||||
|
|
||||||
|
/** Tree of task ids (serialized to json array) */
|
||||||
|
public static final StringProperty TASK_IDS = new StringProperty(
|
||||||
|
TABLE, "task_ids", Property.PROP_FLAG_JSON);
|
||||||
|
|
||||||
|
/** Sort setting (one of below) */
|
||||||
|
public static final StringProperty SORT = new StringProperty(
|
||||||
|
TABLE, "sort");
|
||||||
|
|
||||||
|
/** Settings hash */
|
||||||
|
public static final StringProperty SETTINGS = new StringProperty(
|
||||||
|
TABLE, "settings", Property.PROP_FLAG_JSON);
|
||||||
|
|
||||||
|
/** Array of child tags (for folders) */
|
||||||
|
public static final StringProperty CHILD_TAG_IDS = new StringProperty(
|
||||||
|
TABLE, "child_tags", Property.PROP_FLAG_JSON);
|
||||||
|
|
||||||
|
/** If the folder is collapsed */
|
||||||
|
public static final IntegerProperty IS_COLLAPSED = new IntegerProperty(
|
||||||
|
TABLE, "is_collapsed");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** List of all properties for this model */
|
||||||
|
public static final Property<?>[] PROPERTIES = generateProperties(TaskListMetadata.class);
|
||||||
|
|
||||||
|
// --- defaults
|
||||||
|
|
||||||
|
/** Default values container */
|
||||||
|
private static final ContentValues defaultValues = new ContentValues();
|
||||||
|
|
||||||
|
static {
|
||||||
|
defaultValues.put(UUID.name, NO_UUID);
|
||||||
|
defaultValues.put(PUSHED_AT.name, 0);
|
||||||
|
defaultValues.put(TAG_UUID.name, NO_UUID);
|
||||||
|
defaultValues.put(FILTER.name, "");
|
||||||
|
defaultValues.put(TASK_IDS.name, "[]");
|
||||||
|
defaultValues.put(SORT.name, "");
|
||||||
|
defaultValues.put(SETTINGS.name, "{}");
|
||||||
|
defaultValues.put(CHILD_TAG_IDS.name, "[]");
|
||||||
|
defaultValues.put(IS_COLLAPSED.name, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentValues getDefaultValues() {
|
||||||
|
return defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- data access boilerplate
|
||||||
|
|
||||||
|
public TaskListMetadata() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaskListMetadata(TodorooCursor<TaskListMetadata> cursor) {
|
||||||
|
this();
|
||||||
|
readPropertiesFromCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromCursor(TodorooCursor<TaskListMetadata> cursor) {
|
||||||
|
super.readPropertiesFromCursor(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return getIdHelper(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUuid() {
|
||||||
|
return getUuidHelper(UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- parcelable helpers
|
||||||
|
|
||||||
|
public static final Creator<TaskListMetadata> CREATOR = new ModelCreator<TaskListMetadata>(TaskListMetadata.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Creator<? extends AbstractModel> getCreator() {
|
||||||
|
return CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
package com.todoroo.astrid.data;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
@SuppressWarnings("nls")
|
||||||
|
public class TaskListMetadataOutstanding extends OutstandingEntry<TaskListMetadata> {
|
||||||
|
|
||||||
|
/** table for this model */
|
||||||
|
public static final Table TABLE = new Table("task_list_metadata_outstanding", TaskListMetadataOutstanding.class);
|
||||||
|
|
||||||
|
// --- properties
|
||||||
|
|
||||||
|
/** ID */
|
||||||
|
public static final LongProperty ID = new LongProperty(
|
||||||
|
TABLE, ID_PROPERTY_NAME);
|
||||||
|
|
||||||
|
public static final LongProperty TASK_LIST_METADATA_ID = new LongProperty(
|
||||||
|
TABLE, ENTITY_ID_PROPERTY_NAME);
|
||||||
|
|
||||||
|
public static final StringProperty COLUMN_STRING = new StringProperty(
|
||||||
|
TABLE, COLUMN_STRING_PROPERTY_NAME);
|
||||||
|
|
||||||
|
public static final StringProperty VALUE_STRING = new StringProperty(
|
||||||
|
TABLE, VALUE_STRING_PROPERTY_NAME);
|
||||||
|
|
||||||
|
public static final LongProperty CREATED_AT = new LongProperty(
|
||||||
|
TABLE, CREATED_AT_PROPERTY_NAME);
|
||||||
|
|
||||||
|
private static final ContentValues defaultValues = new ContentValues();
|
||||||
|
|
||||||
|
static {
|
||||||
|
defaultValues.put(TASK_LIST_METADATA_ID.name, 0);
|
||||||
|
defaultValues.put(COLUMN_STRING.name, "");
|
||||||
|
defaultValues.put(VALUE_STRING.name, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** List of all properties for this model */
|
||||||
|
public static final Property<?>[] PROPERTIES = generateProperties(TaskListMetadataOutstanding.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ContentValues getDefaultValues() {
|
||||||
|
return defaultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
return getIdHelper(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Creator<TaskListMetadataOutstanding> CREATOR = new ModelCreator<TaskListMetadataOutstanding>(TaskListMetadataOutstanding.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Creator<? extends AbstractModel> getCreator() {
|
||||||
|
return CREATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2012 Todoroo Inc
|
||||||
|
*
|
||||||
|
* See the file "LICENSE" for the full license governing this code.
|
||||||
|
*/
|
||||||
|
package com.todoroo.astrid.dao;
|
||||||
|
|
||||||
|
import com.todoroo.andlib.service.Autowired;
|
||||||
|
import com.todoroo.andlib.service.DependencyInjectionService;
|
||||||
|
import com.todoroo.astrid.actfm.sync.messages.NameMaps;
|
||||||
|
import com.todoroo.astrid.data.TagData;
|
||||||
|
import com.todoroo.astrid.data.TaskListMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data Access layer for {@link TagData}-related operations.
|
||||||
|
*
|
||||||
|
* @author Tim Su <tim@todoroo.com>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TaskListMetadataDao extends RemoteModelDao<TaskListMetadata> {
|
||||||
|
|
||||||
|
@Autowired Database database;
|
||||||
|
|
||||||
|
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UR_UNINIT_READ")
|
||||||
|
public TaskListMetadataDao() {
|
||||||
|
super(TaskListMetadata.class);
|
||||||
|
DependencyInjectionService.getInstance().inject(this);
|
||||||
|
setDatabase(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldRecordOutstandingEntry(String columnName) {
|
||||||
|
return NameMaps.shouldRecordOutstandingColumnForTable(NameMaps.TABLE_ID_TASK_LIST_METADATA, columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package com.todoroo.astrid.dao;
|
||||||
|
|
||||||
|
import com.todoroo.astrid.data.TaskListMetadataOutstanding;
|
||||||
|
|
||||||
|
|
||||||
|
public class TaskListMetadataOutstandingDao extends OutstandingEntryDao<TaskListMetadataOutstanding> {
|
||||||
|
|
||||||
|
public TaskListMetadataOutstandingDao() {
|
||||||
|
super(TaskListMetadataOutstanding.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue