use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest 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);
}
});
}
use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method insert.
@Override
public boolean insert(TodoList todoList) {
Realm realm = Realm.getInstance(configuration);
final TodoListDAO dao = RealmConverter.convert(todoList);
realm.beginTransaction();
try {
realm.copyToRealm(dao);
realm.commitTransaction();
} catch (Throwable throwable) {
realm.cancelTransaction();
realm.close();
return false;
}
realm.close();
return true;
}
use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getTodoListById.
@Override
public Optional<TodoList> getTodoListById(String uuid) {
Realm realm = Realm.getInstance(configuration);
Optional<TodoListDAO> todoListDAO = Optional.fromNullable(realm.where(TodoListDAO.class).equalTo("uuid", uuid).findFirst());
Optional<TodoList> todoList = todoListDAO.transform(new TodoListDAOConverter());
realm.close();
return todoList;
}
use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getAll.
@Override
public List<TodoList> getAll() {
Realm realm = Realm.getInstance(configuration);
RealmResults<TodoListDAO> todoListDAOs = realm.where(TodoListDAO.class).findAll();
List<TodoList> todoLists = new ArrayList<>(todoListDAOs.size());
for (TodoListDAO dao : todoListDAOs) {
todoLists.add(RealmConverter.convert(dao));
}
realm.close();
return todoLists;
}
use of de.djuelg.neuronizer.storage.model.TodoListDAO in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method getAll.
@Override
public Iterable<Preview> getAll(ItemsPerPreview itemsPerPreview) {
Realm realm = Realm.getInstance(configuration);
RealmResults<TodoListDAO> allTodoListDAO = realm.where(TodoListDAO.class).findAllSorted("position", Sort.DESCENDING);
RealmResults<NoteDAO> allNoteDAO = realm.where(NoteDAO.class).findAllSorted("position", Sort.DESCENDING);
List<Preview> previews = new ArrayList<>(allTodoListDAO.size() + allNoteDAO.size());
for (TodoListDAO todoListDAO : allTodoListDAO) {
previews.add(constructPreview(realm, todoListDAO, itemsPerPreview));
}
for (NoteDAO noteDAO : allNoteDAO) {
previews.add(new NotePreview(RealmConverter.convert(noteDAO)));
}
realm.close();
return previews;
}
Aggregations