use of de.djuelg.neuronizer.storage.model.TodoListItemDAO 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.TodoListItemDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImplTest method testTodoListItemInsert.
@Test
public void testTodoListItemInsert() {
TodoListItem item = createItem();
boolean success = repository.insert(item);
assertTrue(success);
TodoListItemDAO dao = realm.where(TodoListItemDAO.class).equalTo("uuid", item.getUuid()).findFirst();
assertNotNull(dao);
}
use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.
the class PreviewRepositoryImpl method getItemPreviewOfHeader.
private List<TodoListItem> getItemPreviewOfHeader(Realm realm, TodoListHeader header, ItemsPerPreview itemsPerPreview) {
if (header == null || itemsPerPreview.areZero())
return new ArrayList<>(0);
RealmResults<TodoListItemDAO> itemDAOs = realm.where(TodoListItemDAO.class).equalTo("parentTodoListUuid", header.getParentTodoListUuid()).equalTo("parentHeaderUuid", header.getUuid()).findAllSorted("position", Sort.DESCENDING);
int size = Math.min(itemDAOs.size(), itemsPerPreview.getCount());
List<TodoListItem> items = new ArrayList<>(size);
if (size > 0) {
for (TodoListItemDAO itemDAO : itemDAOs.subList(0, size)) {
items.add(RealmConverter.convert(itemDAO));
}
}
return items;
}
use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method delete.
@Override
public void delete(final TodoListItem deletedItem) {
Realm realm = Realm.getInstance(configuration);
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
TodoListItemDAO dao = realm.where(TodoListItemDAO.class).equalTo("uuid", deletedItem.getUuid()).findFirst();
if (dao != null)
dao.deleteFromRealm();
}
});
realm.close();
}
use of de.djuelg.neuronizer.storage.model.TodoListItemDAO in project Neuronizer by djuelg.
the class TodoListRepositoryImpl method constructSection.
private TodoListSection constructSection(Realm realm, TodoListHeaderDAO headerDAO) {
RealmResults<TodoListItemDAO> itemDAOs = realm.where(TodoListItemDAO.class).equalTo("parentTodoListUuid", headerDAO.getParentTodoListUuid()).equalTo("parentHeaderUuid", headerDAO.getUuid()).findAll();
List<TodoListItem> items = new ArrayList<>(itemDAOs.size());
TodoListHeader header = RealmConverter.convert(headerDAO);
for (TodoListItemDAO dao : itemDAOs) {
items.add(RealmConverter.convert(dao));
}
return new TodoListSection(header, items);
}
Aggregations