@Override
public NoteList loadNotesList(Key key) throws DAOException {
try {
Entity entity = datastore.get(key);
NoteList notesList = Transformer.entity2NotesList(entity);
Query query = new Query(ENTITY_KIND_NOTE).setAncestor(notesList.getKey());
PreparedQuery pq = datastore.prepare(query);
List<Entity> entities = pq.asList(FetchOptions.Builder.withDefaults());
List<Note> notes = new ArrayList<Note>();
for(Entity e : entities){
Note note = Transformer.entity2Note(e);
notes.add(note);
}
notesList.setNotes(notes);
return notesList;
} catch (EntityNotFoundException e) {
e.printStackTrace();
throw new DAOException("Entity not found!");