Search in sources :

Example 6 with TodoListDAO

use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImpl method update.

@Override
public void update(TodoList updatedTodoList) {
    Realm realm = Realm.getInstance(configuration);
    final TodoListDAO todoListDAO = RealmConverter.convert(updatedTodoList);
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.copyToRealmOrUpdate(todoListDAO);
        }
    });
    realm.close();
}
Also used : Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO)

Example 7 with TodoListDAO

use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.

the class TodoListRepositoryImpl method delete.

@Override
public void delete(final TodoList deletedTodoList) {
    Realm realm = Realm.getInstance(configuration);
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.where(TodoListItemDAO.class).equalTo("parentTodoListUuid", deletedTodoList.getUuid()).findAll().deleteAllFromRealm();
            realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", deletedTodoList.getUuid()).findAll().deleteAllFromRealm();
            TodoListDAO dao = realm.where(TodoListDAO.class).equalTo("uuid", deletedTodoList.getUuid()).findFirst();
            if (dao != null)
                dao.deleteFromRealm();
        }
    });
    realm.close();
}
Also used : Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO)

Example 8 with TodoListDAO

use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.

the class PreviewRepositoryImplTest method fillRealm.

private void fillRealm() {
    final TodoListDAO todoListDAO = new TodoListDAO("uuid0", "Todo List 1", 0, 0, 0, 0);
    final TodoListHeaderDAO headerDAO = new TodoListHeaderDAO("uuid1", "Header 1", 0, 0, 0, false, "uuid0");
    final TodoListItemDAO itemDAO = new TodoListItemDAO("uuid2", "Item 1", 0, 0, 0, false, "", false, "uuid0", "uuid1");
    final TodoListHeaderDAO headerDAO2 = new TodoListHeaderDAO("uuid3", "Header 2", 0, 0, 0, false, "uuid3");
    final TodoListItemDAO itemDAO2 = new TodoListItemDAO("uuid4", "Item 2", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    final TodoListItemDAO itemDAO3 = new TodoListItemDAO("uuid5", "Item 3", 0, 0, 0, false, "", false, "uuid0", "uuid3");
    realm.executeTransaction(new Realm.Transaction() {

        @Override
        public void execute(Realm realm) {
            realm.copyToRealm(todoListDAO);
            realm.copyToRealm(headerDAO);
            realm.copyToRealm(headerDAO2);
            realm.copyToRealm(itemDAO);
            realm.copyToRealm(itemDAO2);
            realm.copyToRealm(itemDAO3);
        }
    });
}
Also used : TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO) TodoListItemDAO(de.djuelg.neuronizer.storage.model.TodoListItemDAO)

Aggregations

TodoListDAO (de.djuelg.neuronizer.storage.model.TodoListDAO)8 Realm (io.realm.Realm)8 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)2 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)2 TodoListItemDAO (de.djuelg.neuronizer.storage.model.TodoListItemDAO)2 ArrayList (java.util.ArrayList)2 ItemsPerPreview (de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview)1 NotePreview (de.djuelg.neuronizer.domain.model.preview.NotePreview)1 Preview (de.djuelg.neuronizer.domain.model.preview.Preview)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 TodoListDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListDAOConverter)1 NoteDAO (de.djuelg.neuronizer.storage.model.NoteDAO)1