Remove DatabaseDao subclasses

pull/253/head
Alex Baker 10 years ago
parent eb59cde024
commit 85a694b1d1

@ -36,8 +36,10 @@ public class DatabaseDao<TYPE extends AbstractModel> {
private AbstractDatabase database;
public DatabaseDao(Class<TYPE> modelClass) {
public DatabaseDao(AbstractDatabase database, Class<TYPE> modelClass) {
this.modelClass = modelClass;
this.database = database;
table = database.getTable(this.modelClass);
try {
modelClass.getConstructor(); // check for default constructor
} catch (NoSuchMethodException e) {
@ -50,26 +52,13 @@ public class DatabaseDao<TYPE extends AbstractModel> {
return table;
}
/**
* Sets database accessed by this DAO. Used for dependency-injected
* initialization by child classes and unit tests
*/
public void setDatabase(AbstractDatabase database) {
if(database == this.database) {
return;
}
this.database = database;
table = database.getTable(modelClass);
}
// --- listeners
public interface ModelUpdateListener<MTYPE> {
public void onModelUpdated(MTYPE model);
}
private final ArrayList<ModelUpdateListener<TYPE>> listeners =
new ArrayList<>();
private final ArrayList<ModelUpdateListener<TYPE>> listeners = new ArrayList<>();
public void addListener(ModelUpdateListener<TYPE> listener) {
listeners.add(listener);

@ -7,6 +7,7 @@ package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Callback;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Join;
import com.todoroo.andlib.sql.Query;
@ -14,6 +15,8 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -24,12 +27,53 @@ import javax.inject.Singleton;
*
*/
@Singleton
public class MetadataDao extends DatabaseDao<Metadata> {
public class MetadataDao {
private final DatabaseDao<Metadata> dao;
@Inject
public MetadataDao(Database database) {
super(Metadata.class);
setDatabase(database);
dao = new DatabaseDao<>(database, Metadata.class);
}
public void query(Callback<Metadata> callback, Query query) {
query(query, callback);
}
public void query(Query query, Callback<Metadata> callback) {
dao.query(query, callback);
}
public Metadata getFirst(Query query) {
return dao.getFirst(query);
}
public int update(Criterion where, Metadata template) {
return dao.update(where, template);
}
public void createNew(Metadata metadata) {
dao.createNew(metadata);
}
public List<Metadata> toList(Query where) {
return dao.toList(where);
}
public int deleteWhere(Criterion criterion) {
return dao.deleteWhere(criterion);
}
public boolean delete(long id) {
return dao.delete(id);
}
public void saveExisting(Metadata metadata) {
dao.saveExisting(metadata);
}
public Metadata fetch(long id, Property<?>... properties) {
return dao.fetch(id, properties);
}
// --- SQL clause generators
@ -55,7 +99,6 @@ public class MetadataDao extends DatabaseDao<Metadata> {
}
}
@Override
public boolean persist(Metadata item) {
if(!item.containsNonNullValue(Metadata.TASK)) {
throw new IllegalArgumentException("metadata needs to be attached to a task: " + item.getMergedValues()); //$NON-NLS-1$
@ -64,23 +107,23 @@ public class MetadataDao extends DatabaseDao<Metadata> {
item.setCreationDate(DateUtilities.now());
}
return super.persist(item);
return dao.persist(item);
}
/**
* Clean up metadata. Typically called on startup
*/
public void removeDanglingMetadata() {
deleteWhere(Metadata.ID.in(Query.select(Metadata.ID).from(Metadata.TABLE).join(Join.left(Task.TABLE,
dao.deleteWhere(Metadata.ID.in(Query.select(Metadata.ID).from(Metadata.TABLE).join(Join.left(Task.TABLE,
Metadata.TASK.eq(Task.ID))).where(Task.TITLE.isNull())));
}
public void byTask(long taskId, Callback<Metadata> callback) {
query(callback, Query.select(Metadata.PROPERTIES).where(Metadata.TASK.eq(taskId)));
dao.query(callback, Query.select(Metadata.PROPERTIES).where(Metadata.TASK.eq(taskId)));
}
public void byTaskAndKey(long taskId, String key, Callback<Metadata> callback) {
query(callback, Query.select(Metadata.PROPERTIES).where(
dao.query(callback, Query.select(Metadata.PROPERTIES).where(
Criterion.and(Metadata.TASK.eq(taskId), Metadata.KEY.eq(key))));
}
}

@ -1,5 +1,6 @@
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.AbstractDatabase;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.astrid.data.RemoteModel;
import com.todoroo.astrid.helper.UUIDHelper;
@ -15,8 +16,8 @@ import com.todoroo.astrid.helper.UUIDHelper;
*/
public class RemoteModelDao<RTYPE extends RemoteModel> extends DatabaseDao<RTYPE> {
public RemoteModelDao(Class<RTYPE> modelClass) {
super(modelClass);
public RemoteModelDao(AbstractDatabase database, Class<RTYPE> modelClass) {
super(database, modelClass);
}
@Override

@ -17,32 +17,31 @@ import com.todoroo.astrid.gtasks.GtasksList;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Lists.newArrayList;
import static com.todoroo.andlib.sql.Criterion.and;
import static com.todoroo.andlib.sql.Query.select;
@Singleton
public class StoreObjectDao extends DatabaseDao<StoreObject> {
public class StoreObjectDao {
private final DatabaseDao<StoreObject> dao;
private static Criterion isSavedFilter = StoreObject.TYPE.eq(SavedFilter.TYPE);
@Inject
public StoreObjectDao(Database database) {
super(StoreObject.class);
setDatabase(database);
dao = new DatabaseDao<>(database, StoreObject.class);
}
public void getSavedFilters(Callback<StoreObject> callback) {
query(callback, select(StoreObject.PROPERTIES)
dao.query(callback, select(StoreObject.PROPERTIES)
.where(isSavedFilter)
.orderBy(Order.asc(SavedFilter.NAME)));
}
public GtasksList getGtasksList(long id) {
StoreObject result = fetch(id, StoreObject.PROPERTIES);
StoreObject result = dao.fetch(id, StoreObject.PROPERTIES);
if (!result.getType().equals(GtasksList.TYPE)) {
throw new RuntimeException("Not a google task list");
}
@ -58,18 +57,30 @@ public class StoreObjectDao extends DatabaseDao<StoreObject> {
}));
}
public void persist(StoreObject storeObject) {
dao.persist(storeObject);
}
public void persist(GtasksList list) {
persist(list.getStoreObject());
}
public List<StoreObject> getByType(String type) {
return toList(select(StoreObject.PROPERTIES)
return dao.toList(select(StoreObject.PROPERTIES)
.where(StoreObject.TYPE.eq(type)));
}
public StoreObject getSavedFilterByName(String title) {
return getFirst(select(StoreObject.ID)
return dao.getFirst(select(StoreObject.ID)
.where(and(isSavedFilter, SavedFilter.NAME.eq(title))));
}
public void delete(long id) {
dao.delete(id);
}
public void createNew(StoreObject storeObject) {
dao.createNew(storeObject);
}
}

@ -6,6 +6,7 @@
package com.todoroo.astrid.dao;
import com.todoroo.andlib.data.Callback;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Functions;
@ -23,41 +24,70 @@ import javax.inject.Singleton;
* @author Tim Su <tim@todoroo.com>
*/
@Singleton
public class TagDataDao extends RemoteModelDao<TagData> {
public class TagDataDao {
private final RemoteModelDao<TagData> dao;
@Inject
public TagDataDao(Database database) {
super(TagData.class);
setDatabase(database);
dao = new RemoteModelDao<>(database, TagData.class);
}
/**
* Fetch a model object by UUID
*/
public TagData fetch(String uuid, Property<?>... properties) {
return getFirst(Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid)));
return dao.getFirst(Query.select(properties).where(RemoteModel.UUID_PROPERTY.eq(uuid)));
}
public TagData fetch(long id, Property<?>... properties) {
return dao.fetch(id, properties);
}
public TagData getTagByName(String name, Property<?>... properties) {
return getFirst(Query.select(properties).where(TagData.NAME.eqCaseInsensitive(name)));
return dao.getFirst(Query.select(properties).where(TagData.NAME.eqCaseInsensitive(name)));
}
public void allTags(Callback<TagData> callback) {
// TODO: does this need to be ordered?
query(callback, Query.select(TagData.PROPERTIES)
dao.query(callback, Query.select(TagData.PROPERTIES)
.where(TagData.DELETION_DATE.eq(0))
.orderBy(Order.asc(TagData.ID)));
}
public TagData getByUuid(String uuid, Property<?>... properties) {
return getFirst(Query.select(properties).where(TagData.UUID.eq(uuid)));
return dao.getFirst(Query.select(properties).where(TagData.UUID.eq(uuid)));
}
public void tagDataOrderedByName(Callback<TagData> callback) {
query(callback, Query.select(TagData.PROPERTIES).where(Criterion.and(
dao.query(callback, Query.select(TagData.PROPERTIES).where(Criterion.and(
TagData.DELETION_DATE.eq(0),
TagData.NAME.isNotNull())
).orderBy(Order.asc(Functions.upper(TagData.NAME))));
}
public void persist(TagData tagData) {
dao.persist(tagData);
}
public void update(Criterion where, TagData template) {
dao.update(where, template);
}
public void saveExisting(TagData tagData) {
dao.saveExisting(tagData);
}
public void addListener(DatabaseDao.ModelUpdateListener<TagData> modelUpdateListener) {
dao.addListener(modelUpdateListener);
}
public void delete(long id) {
dao.delete(id);
}
public void createNew(TagData tag) {
dao.createNew(tag);
}
}

@ -12,23 +12,22 @@ import com.todoroo.andlib.sql.Query;
import com.todoroo.astrid.data.TaskAttachment;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class TaskAttachmentDao extends RemoteModelDao<TaskAttachment> {
public class TaskAttachmentDao {
private final RemoteModelDao<TaskAttachment> dao;
@Inject
public TaskAttachmentDao(Database database) {
super(TaskAttachment.class);
setDatabase(database);
dao = new RemoteModelDao<>(database, TaskAttachment.class);
}
public boolean taskHasAttachments(String taskUuid) {
return count(byUuid(taskUuid, TaskAttachment.TASK_UUID).limit(1)) > 0;
return dao.count(byUuid(taskUuid, TaskAttachment.TASK_UUID).limit(1)) > 0;
}
public void getAttachments(String taskUuid, Callback<TaskAttachment> callback) {
query(callback, byUuid(taskUuid, TaskAttachment.PROPERTIES));
dao.query(callback, byUuid(taskUuid, TaskAttachment.PROPERTIES));
}
private static Query byUuid(String taskUuid, Property<?>... properties) {
@ -37,5 +36,17 @@ public class TaskAttachmentDao extends RemoteModelDao<TaskAttachment> {
TaskAttachment.DELETED_AT.eq(0))
);
}
public void createNew(TaskAttachment attachment) {
dao.createNew(attachment);
}
public void delete(long id) {
dao.delete(id);
}
public void saveExisting(TaskAttachment m) {
dao.saveExisting(m);
}
}

@ -9,6 +9,7 @@ import android.content.ContentValues;
import android.database.sqlite.SQLiteConstraintException;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.sql.Criterion;
@ -28,6 +29,9 @@ import org.tasks.R;
import org.tasks.notifications.NotificationManager;
import org.tasks.preferences.Preferences;
import java.io.ByteArrayOutputStream;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -38,10 +42,12 @@ import javax.inject.Singleton;
*
*/
@Singleton
public class TaskDao extends RemoteModelDao<Task> {
public class TaskDao {
private static final Logger log = LoggerFactory.getLogger(TaskDao.class);
private final RemoteModelDao<Task> dao;
private final MetadataDao metadataDao;
private final Broadcaster broadcaster;
private final ReminderService reminderService;
@ -52,8 +58,7 @@ public class TaskDao extends RemoteModelDao<Task> {
public TaskDao(Database database, MetadataDao metadataDao, Broadcaster broadcaster,
ReminderService reminderService, NotificationManager notificationManager,
Preferences preferences) {
super(Task.class);
setDatabase(database);
dao = new RemoteModelDao<>(database, Task.class);
this.preferences = preferences;
this.metadataDao = metadataDao;
this.broadcaster = broadcaster;
@ -61,6 +66,42 @@ public class TaskDao extends RemoteModelDao<Task> {
this.notificationManager = notificationManager;
}
public TodorooCursor<Task> query(Query query) {
return dao.query(query);
}
public Task fetch(long id, Property<?>... properties) {
return dao.fetch(id, properties);
}
public int count(Query query) {
return dao.count(query);
}
public TodorooCursor<Task> rawQuery(String selection, String[] selectionArgs, Property.LongProperty id) {
return dao.rawQuery(selection, selectionArgs, id);
}
public int update(Criterion where, Task template) {
return dao.update(where, template);
}
public int deleteWhere(Criterion criterion) {
return dao.deleteWhere(criterion);
}
public void addListener(DatabaseDao.ModelUpdateListener<Task> modelUpdateListener) {
dao.addListener(modelUpdateListener);
}
public List<Task> toList(Query query) {
return dao.toList(query);
}
public void persist(Task task) {
dao.persist(task);
}
// --- SQL clause generators
/**
@ -103,7 +144,7 @@ public class TaskDao extends RemoteModelDao<Task> {
}
public String uuidFromLocalId(long localId) {
TodorooCursor<Task> cursor = query(Query.select(RemoteModel.UUID_PROPERTY).where(AbstractModel.ID_PROPERTY.eq(localId)));
TodorooCursor<Task> cursor = dao.query(Query.select(RemoteModel.UUID_PROPERTY).where(AbstractModel.ID_PROPERTY.eq(localId)));
try {
if (cursor.getCount() == 0) {
return RemoteModel.NO_UUID;
@ -122,9 +163,8 @@ public class TaskDao extends RemoteModelDao<Task> {
*
* @return true if delete was successful
*/
@Override
public boolean delete(long id) {
boolean result = super.delete(id);
boolean result = dao.delete(id);
if(!result) {
return false;
}
@ -158,7 +198,7 @@ public class TaskDao extends RemoteModelDao<Task> {
}
public void handleSQLiteConstraintException(Task task) {
TodorooCursor<Task> cursor = query(Query.select(Task.ID).where(
TodorooCursor<Task> cursor = dao.query(Query.select(Task.ID).where(
Task.UUID.eq(task.getUUID())));
if (cursor.getCount() > 0) {
cursor.moveToFirst();
@ -167,7 +207,6 @@ public class TaskDao extends RemoteModelDao<Task> {
}
}
@Override
public boolean createNew(Task item) {
if(!item.containsValue(Task.CREATION_DATE)) {
item.setCreationDate(DateUtilities.now());
@ -189,7 +228,7 @@ public class TaskDao extends RemoteModelDao<Task> {
setDefaultReminders(preferences, item);
ContentValues values = item.getSetValues();
boolean result = super.createNew(item);
boolean result = dao.createNew(item);
if(result) {
afterSave(item, values);
}
@ -222,7 +261,6 @@ public class TaskDao extends RemoteModelDao<Task> {
}
}
@Override
public boolean saveExisting(Task item) {
ContentValues values = item.getSetValues();
if(values == null || values.size() == 0) {
@ -233,7 +271,7 @@ public class TaskDao extends RemoteModelDao<Task> {
item.setModificationDate(DateUtilities.now());
}
}
boolean result = super.saveExisting(item);
boolean result = dao.saveExisting(item);
if(result) {
afterSave(item, values);
}
@ -259,7 +297,7 @@ public class TaskDao extends RemoteModelDao<Task> {
} catch (SQLiteConstraintException e) {
log.error(e.getMessage(), e);
String uuid = item.getUUID();
TodorooCursor<Task> tasksWithUUID = query(Query.select(
TodorooCursor<Task> tasksWithUUID = dao.query(Query.select(
SQL_CONSTRAINT_MERGE_PROPERTIES).where(
Task.UUID.eq(uuid)));
try {
@ -270,7 +308,7 @@ public class TaskDao extends RemoteModelDao<Task> {
continue;
}
compareAndMergeAfterConflict(curr, fetch(item.getId(),
compareAndMergeAfterConflict(curr, dao.fetch(item.getId(),
tasksWithUUID.getProperties()));
return;
}

@ -19,18 +19,26 @@ import javax.inject.Singleton;
*
* @author Tim Su <tim@todoroo.com>
*/
@Singleton
public class TaskListMetadataDao extends RemoteModelDao<TaskListMetadata> {
public class TaskListMetadataDao {
private final RemoteModelDao<TaskListMetadata> dao;
@Inject
public TaskListMetadataDao(Database database) {
super(TaskListMetadata.class);
setDatabase(database);
dao = new RemoteModelDao<>(database, TaskListMetadata.class);
}
public TaskListMetadata fetchByTagId(String tagUuid, Property<?>... properties) {
return getFirst(Query.select(properties).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
return dao.getFirst(Query.select(properties).where(Criterion.or(TaskListMetadata.TAG_UUID.eq(tagUuid),
TaskListMetadata.FILTER.eq(tagUuid))));
}
public void createNew(TaskListMetadata taskListMetadata) {
dao.createNew(taskListMetadata);
}
public void saveExisting(TaskListMetadata list) {
dao.saveExisting(list);
}
}

@ -10,36 +10,33 @@ import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.data.UserActivity;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class UserActivityDao extends RemoteModelDao<UserActivity> {
public class UserActivityDao {
private final RemoteModelDao<UserActivity> dao;
@Inject
public UserActivityDao(Database database) {
super(UserActivity.class);
setDatabase(database);
dao = new RemoteModelDao<>(database, UserActivity.class);
}
@Override
public boolean createNew(UserActivity item) {
if (!item.containsValue(UserActivity.CREATED_AT)) {
item.setCreatedAt(DateUtilities.now());
}
return super.createNew(item);
return dao.createNew(item);
}
@Override
public boolean saveExisting(UserActivity item) {
ContentValues values = item.getSetValues();
if (values == null || values.size() == 0) {
return false;
}
return super.saveExisting(item);
return dao.saveExisting(item);
}
public void getCommentsForTask(String taskUuid, Callback<UserActivity> callback) {
query(callback, Query.select(UserActivity.PROPERTIES).where(
dao.query(callback, Query.select(UserActivity.PROPERTIES).where(
Criterion.and(UserActivity.ACTION.eq(UserActivity.ACTION_TASK_COMMENT),
UserActivity.TARGET_ID.eq(taskUuid),
UserActivity.DELETED_AT.eq(0))

@ -50,6 +50,7 @@ public class GtasksSyncService {
private final GtasksPreferenceService gtasksPreferenceService;
private final GtasksTokenValidator gtasksTokenValidator;
private final GtasksMetadata gtasksMetadataFactory;
private final LinkedBlockingQueue<SyncOnSaveOperation> operationQueue = new LinkedBlockingQueue<>();
@Inject
public GtasksSyncService(MetadataDao metadataDao, GtasksMetadataService gtasksMetadataService,
@ -63,8 +64,6 @@ public class GtasksSyncService {
this.gtasksMetadataFactory = gtasksMetadataFactory;
}
private final LinkedBlockingQueue<SyncOnSaveOperation> operationQueue = new LinkedBlockingQueue<>();
private abstract class SyncOnSaveOperation {
abstract public void op(GtasksInvoker invoker) throws IOException;
}
@ -121,16 +120,14 @@ public class GtasksSyncService {
if(model.checkAndClearTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC)) {
return;
}
if (gtasksPreferenceService.isOngoing() && !model.checkTransitory(TaskService.TRANS_REPEAT_COMPLETE)) //Don't try and sync changes that occur during a normal sync
{
if (gtasksPreferenceService.isOngoing() && !model.checkTransitory(TaskService.TRANS_REPEAT_COMPLETE)) { //Don't try and sync changes that occur during a normal sync
return;
}
final ContentValues setValues = model.getSetValues();
if(setValues == null || !checkForToken()) {
return;
}
if (!checkValuesForProperties(setValues, TASK_PROPERTIES)) //None of the properties we sync were updated
{
if (!checkValuesForProperties(setValues, TASK_PROPERTIES)) { //None of the properties we sync were updated
return;
}

@ -16,15 +16,12 @@ import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.text.TextUtils;
import com.todoroo.andlib.data.AbstractDatabase;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.DatabaseDao;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.Database;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.StoreObjectDao;
import com.todoroo.astrid.dao.RemoteModelDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.UserActivityDao;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.StoreObject;
import com.todoroo.astrid.data.Task;
@ -80,16 +77,13 @@ public class Astrid3ContentProvider extends InjectingContentProvider {
private static final UriMatcher uriMatcher;
private static AbstractDatabase databaseOverride;
private static Database databaseOverride;
// --- instance variables
private boolean open;
@Inject Lazy<Database> database;
@Inject Lazy<TaskDao> taskDao;
@Inject Lazy<MetadataDao> metadataDao;
@Inject Lazy<StoreObjectDao> storeObjectDao;
@Inject Lazy<UserActivityDao> userActivityDao;
static {
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
@ -150,41 +144,37 @@ public class Astrid3ContentProvider extends InjectingContentProvider {
}
private UriHelper<?> generateHelper(Uri uri, boolean populateModel) {
AbstractDatabase db = getDatabase();
final Database db = getDatabase();
if(uri.toString().startsWith(Task.CONTENT_URI.toString())) {
UriHelper<Task> helper = new UriHelper<>();
helper.model = populateModel ? new Task() : null;
helper.dao = taskDao.get();
helper.dao.setDatabase(db);
helper.dao = new RemoteModelDao<>(db, Task.class);
return helper;
} else if(uri.toString().startsWith(Metadata.CONTENT_URI.toString())) {
UriHelper<Metadata> helper = new UriHelper<>();
helper.model = populateModel ? new Metadata() : null;
helper.dao = metadataDao.get();
helper.dao.setDatabase(db);
helper.dao = new DatabaseDao<>(db, Metadata.class);
return helper;
} else if(uri.toString().startsWith(StoreObject.CONTENT_URI.toString())) {
UriHelper<StoreObject> helper = new UriHelper<>();
helper.model = populateModel ? new StoreObject() : null;
helper.dao = storeObjectDao.get();
helper.dao.setDatabase(db);
helper.dao = new DatabaseDao<>(db, StoreObject.class);
return helper;
} else if(uri.toString().startsWith(UserActivity.CONTENT_URI.toString())) {
UriHelper<UserActivity> helper = new UriHelper<>();
helper.model = populateModel ? new UserActivity() : null;
helper.dao = userActivityDao.get();
helper.dao.setDatabase(db);
helper.dao = new RemoteModelDao<>(db, UserActivity.class);
return helper;
}
throw new UnsupportedOperationException("Unknown URI " + uri);
}
public static void setDatabaseOverride(AbstractDatabase override) {
public static void setDatabaseOverride(Database override) {
databaseOverride = override;
}
private AbstractDatabase getDatabase() {
private Database getDatabase() {
if (!open) {
database.get().openForWriting();
open = true;

Loading…
Cancel
Save