Package de.paulwein.notes.pojo

Examples of de.paulwein.notes.pojo.NoteList


    EntityManager em = mEmf.createEntityManager();
    Key parentKey = note.getKey().getParent();
    try{
      em.getTransaction().begin();

      NoteList notesList = em.find(NoteList.class, parentKey);
      notesList.getNotes().remove(note);
      notesList.getNotes().add(note);

      em.getTransaction().commit();
    }catch (Exception ex) {
      em.getTransaction().rollback();
      throw new DAOException();
View Full Code Here


  }

  @Override
  public NoteList loadNotesList(Key key) throws DAOException {
    EntityManager em = mEmf.createEntityManager();
    NoteList notesList = null;
    try{
      notesList = em.find(NoteList.class, key);
      notesList.getNotes(); // lazy loading
      em.detach(notesList);
    } catch (Exception e) {
      e.printStackTrace();
      throw new DAOException();
    } finally {
View Full Code Here

    return Note.class.getName();
  }

  @Override
  public Key createNotesList(String userId, String name) throws DAOException {
    NoteList notesList = new NoteList();
    notesList.setUserId(userId);
    notesList.setName(name);
   
    Entity entity = Transformer.notesList2Entity(notesList);
   
    Key key = datastore.put(entity);
   
View Full Code Here

  public void addNote(Key listId, Note note) throws DAOException {
    try {
      Transaction tx = datastore.beginTransaction();
     
      Entity entity = datastore.get(listId);
      NoteList notesList = Transformer.entity2NotesList(entity);
     
      Entity noteEntity = Transformer.note2Entity(note,listId);
      Key key = datastore.put(noteEntity);
     
      List<Key> keyList = notesList.getNoteKeys();
      if(keyList == null)
        keyList = new ArrayList<Key>();
      keyList.add(key);
      notesList.setNoteKeys(keyList);
      entity = Transformer.notesList2Entity(notesList);
      datastore.put(entity);
      tx.commit();
     
    } catch (EntityNotFoundException e) {
View Full Code Here

    try {
      Transaction tx = datastore.beginTransaction();
      Key noteKey = note.getKey();
      Key parentKey = noteKey.getParent();
      Entity entity = datastore.get(parentKey);
      NoteList notesList = Transformer.entity2NotesList(entity);

      datastore.delete(noteKey);
     
      List<Key> keyList = notesList.getNoteKeys();
      if(keyList == null)
        keyList = new ArrayList<Key>();
      keyList.remove(noteKey);
      notesList.setNoteKeys(keyList);
     
      entity = Transformer.notesList2Entity(notesList);
      datastore.put(entity);
      tx.commit();
     
View Full Code Here

    PreparedQuery pq = datastore.prepare(query);
   
    List<Entity> entities = pq.asList(FetchOptions.Builder.withDefaults());
    List<NoteList> notesLists = new ArrayList<NoteList>();
    for(Entity e : entities){
      NoteList notesList = Transformer.entity2NotesList(e);
      notesLists.add(notesList);
    }
   
    return notesLists;
  }
View Full Code Here

  @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!");
View Full Code Here

    Key key = entity.getKey();
    String userId = (String) entity.getProperty(NotesDAO.PROPERTY_USERID);
    String name = (String) entity.getProperty(NotesDAO.PROPERTY_NAME);
    List<Key> notesKeys = (List<Key>) entity.getProperty(NotesDAO.PROPERTY_NOTES);

    NoteList notesList = new NoteList();
    notesList.setKey(key);
    notesList.setUserId(userId);
    notesList.setName(name);
    notesList.setNoteKeys(notesKeys);
   
    return notesList;
  }
View Full Code Here

TOP

Related Classes of de.paulwein.notes.pojo.NoteList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.