use of de.djuelg.neuronizer.storage.model.TodoListHeaderDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testTodoListHeaderInsertTwice.
@Test
public void testTodoListHeaderInsertTwice() {
clearRealm();
TodoListHeader header = createHeader();
repository.insert(header);
boolean success = repository.insert(header);
assertFalse(success);
TodoListHeaderDAO dao = realm.where(TodoListHeaderDAO.class).equalTo("uuid", header.getUuid()).findFirst();
assertNotNull(dao);
fillRealm();
}
use of de.djuelg.neuronizer.storage.model.TodoListHeaderDAO 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.TodoListHeaderDAO in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method constructPreview.
private TodoListPreview constructPreview(Realm realm, TodoListDAO todoListDAO, ItemsPerPreview itemsPerPreview) {
TodoList todoList = RealmConverter.convert(todoListDAO);
Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", todoListDAO.getUuid()).findAllSorted("position", Sort.DESCENDING).where().findFirst());
TodoListHeader header = headerDAO.transform(new TodoListHeaderDAOConverter()).orNull();
List<TodoListItem> items = getItemPreviewOfHeader(realm, header, itemsPerPreview);
return new TodoListPreview(todoList, header, items);
}
use of de.djuelg.neuronizer.storage.model.TodoListHeaderDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getHeadersOfTodoListId.
@Override
public List<TodoListHeader> getHeadersOfTodoListId(String uuid) {
Realm realm = Realm.getInstance(configuration);
RealmResults<TodoListHeaderDAO> headerDAOs = realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", uuid).findAll();
List<TodoListHeader> headers = new ArrayList<>(headerDAOs.size());
for (TodoListHeaderDAO dao : headerDAOs) {
headers.add(RealmConverter.convert(dao));
}
realm.close();
return headers;
}
use of de.djuelg.neuronizer.storage.model.TodoListHeaderDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method getSectionsOfTodoListId.
@Override
public List<TodoListSection> getSectionsOfTodoListId(String uuid) {
Realm realm = Realm.getInstance(configuration);
RealmResults<TodoListHeaderDAO> headerDAOs = realm.where(TodoListHeaderDAO.class).equalTo("parentTodoListUuid", uuid).findAll();
List<TodoListSection> sections = new ArrayList<>(headerDAOs.size());
for (TodoListHeaderDAO dao : headerDAOs) {
sections.add(constructSection(realm, dao));
}
realm.close();
return sections;
}
Aggregations