Search in sources :

Example 1 with TodoListHeaderDAOConverter

use of de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter 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);
}
Also used : TodoListHeaderDAOConverter(de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) TodoListItem(de.djuelg.neuronizer.domain.model.todolist.TodoListItem) TodoListPreview(de.djuelg.neuronizer.domain.model.preview.TodoListPreview) TodoList(de.djuelg.neuronizer.domain.model.preview.TodoList)

Example 2 with TodoListHeaderDAOConverter

use of de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter in project Neuronizer by djuelg.

the class TodoListRepositoryImpl method getHeaderById.

@Override
public Optional<TodoListHeader> getHeaderById(String uuid) {
    Realm realm = Realm.getInstance(configuration);
    Optional<TodoListHeaderDAO> headerDAO = Optional.fromNullable(realm.where(TodoListHeaderDAO.class).equalTo("uuid", uuid).findFirst());
    Optional<TodoListHeader> header = headerDAO.transform(new TodoListHeaderDAOConverter());
    realm.close();
    return header;
}
Also used : TodoListHeaderDAOConverter(de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter) TodoListHeader(de.djuelg.neuronizer.domain.model.todolist.TodoListHeader) TodoListHeaderDAO(de.djuelg.neuronizer.storage.model.TodoListHeaderDAO) Realm(io.realm.Realm)

Aggregations

TodoListHeader (de.djuelg.neuronizer.domain.model.todolist.TodoListHeader)2 TodoListHeaderDAOConverter (de.djuelg.neuronizer.storage.converter.TodoListHeaderDAOConverter)2 TodoListHeaderDAO (de.djuelg.neuronizer.storage.model.TodoListHeaderDAO)2 TodoList (de.djuelg.neuronizer.domain.model.preview.TodoList)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 TodoListItem (de.djuelg.neuronizer.domain.model.todolist.TodoListItem)1 Realm (io.realm.Realm)1