Package de.paulwein.notes.pojo

Examples of de.paulwein.notes.pojo.NoteList


    Key listKey = KeyFactory.stringToKey(keyString);
   
    try {
      DAOFactory df = DAOFactory.getInstance();
      NotesDAO nDao = df.getDAO(Note.class, NotesDAO.class);
      NoteList notesList = nDao.loadNotesList(listKey);
      req.setAttribute("key", keyString);
      req.setAttribute("list", notesList.getNotes());
      RequestDispatcher requestDispatcher = req.getRequestDispatcher(NOTELIST_SERVLET + ".jsp");
      requestDispatcher.forward(req, resp);
    } catch (DAOException e) {
      errorOccured(resp);
    } catch (ServletException e) {
View Full Code Here


      }
     
      else if(action.equals("delete")){
        String keyString = req.getParameter("key");
        Key notesListKey = KeyFactory.stringToKey(keyString);
        NoteList nl = new NoteList();
        nl.setKey(notesListKey);
        nDao.deleteNotesList(nl);
      }
     
      resp.sendRedirect(NOTELISTS_SERVLET);
    } catch (DAOException e) {
View Full Code Here

  @Override
  public Key createNotesList(String userId, String name) throws DAOException {
    PersistenceManager pm = mPmf.getPersistenceManager();

    NoteList notesList = new NoteList();
    notesList.setName(name);
    notesList.setUserId(userId);
   
    try{
      notesList = pm.makePersistent(notesList);
    } finally{
      pm.close();
    }
   
    return notesList.getKey();
  }
View Full Code Here

    PersistenceManager pm = mPmf.getPersistenceManager();

    try {
      pm.currentTransaction().begin();
     
      NoteList notesList = pm.getObjectById(NoteList.class, listId);
      List<Note> notes = notesList.getNotes();     
      if(notes == null){
        notes = new ArrayList<Note>();
      }
      notes.add(note);
      notesList.setNotes(notes);
      pm.makePersistent(notesList)
     
      pm.currentTransaction().commit();
    } catch (Exception ex) {
      pm.currentTransaction().rollback();
View Full Code Here

    PersistenceManager pm = mPmf.getPersistenceManager();
    Key parentKey = note.getKey().getParent();
    try{
      pm.currentTransaction().begin();

      NoteList notesList = pm.getObjectById(NoteList.class, parentKey);
      note = pm.getObjectById(Note.class, note.getKey());
      notesList.getNotes().remove(note);
      pm.makePersistent(notesList);

      pm.currentTransaction().commit();
    }catch (Exception ex) {
      pm.currentTransaction().rollback();
View Full Code Here

    PersistenceManager pm = mPmf.getPersistenceManager();
    Key parentKey = note.getKey().getParent();
    try{
      pm.currentTransaction().begin();

      NoteList notesList = pm.getObjectById(NoteList.class, parentKey);
      notesList.getNotes().remove(note);
      notesList.getNotes().add(note); // TODO maybe findObjectById(note.getKey) before add/remove
      pm.makePersistent(notesList);

      pm.currentTransaction().commit();
    }catch (Exception ex) {
      pm.currentTransaction().rollback();
View Full Code Here

  }

  @Override
  public NoteList loadNotesList(Key key) throws DAOException {
    PersistenceManager pm = mPmf.getPersistenceManager();
    NoteList notesList = null;
    try {
      notesList = pm.getObjectById(NoteList.class, key);
      notesList.getNotes(); // lazyfetch
    } catch (Exception ex) {
      throw new DAOException();
    } finally {
      pm.close()
    }
View Full Code Here

  @Override
  public Key createNotesList(String userId, String name) throws DAOException {
    EntityManager em = mEmf.createEntityManager();
   
    NoteList notesList = new NoteList();
    notesList.setName(name);
    notesList.setUserId(userId);
   
    try{
      em.getTransaction().begin();
      em.persist(notesList);
      em.getTransaction().commit();
    } finally {
      em.close();
    }
   
    return notesList.getKey();
  }
View Full Code Here

  public void addNote(Key listId, Note note) throws DAOException {
    EntityManager em = mEmf.createEntityManager();
   
    try {
      em.getTransaction().begin();
      NoteList notesList = em.find(NoteList.class, listId);
     
      List<Note> notes = notesList.getNotes();     
      if(notes == null){
        notes = new ArrayList<Note>();
      }
      notes.add(note);
      notesList.setNotes(notes);
      em.getTransaction().commit();
     
    } catch (Exception ex) {
      em.getTransaction().rollback();
      ex.printStackTrace();
View Full Code Here

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

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

      em.getTransaction().commit();
    }catch (Exception ex) {
      em.getTransaction().rollback();
      throw new DAOException();
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.