Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Bookmark


        .getResourceAsStream("/TestForUserManager-input.xml"));
  }
 
  public void testAddForUser() throws Exception{
    User jsmith = new User(2);
    Bookmark bm = new Bookmark(300);
    Date date = GnizrDaoUtil.getNow();
    ForUser forUser = new ForUser(jsmith,bm,"helloworld",date);
    int id = manager.addForUser(forUser);
    assertTrue((id > 0));
  }
View Full Code Here


    assertTrue((id > 0));
  }
 
  public void testHasForUser() throws Exception{
    User jsmith = new User(2);
    Bookmark bm = new Bookmark(301);
    assertTrue(manager.hasForUser(bm, jsmith));
    assertFalse(manager.hasForUser(new Bookmark(4000), jsmith));
  }
View Full Code Here

      logger.debug("SaveBookmarkEntryRunnable run() starts");
      try{       
        boolean doReplace = shouldRepalceOnChange(srcFeed);
        logger.debug("On Change Do Repalce: " + doReplace + " feed: " + srcFeed.getBookmark().getLink().getUrl());
        for(BookmarkEntry entry : entries){
          Bookmark bm = entry.getBookmark();
          int oldBmId = bookmarkManager.getBookmarkId(bm.getUser(),bm.getLink().getUrl())
          if(oldBmId > 0 && doReplace == true){
            logger.debug("old bookmark exists.");
            Bookmark oldBm = bookmarkManager.getBookmark(oldBmId);
            Date oldBmLastUpdated = oldBm.getLastUpdated();
            Date newBmLastUpdated = bm.getLastUpdated();
            if(oldBmLastUpdated != null && newBmLastUpdated != null &&
               oldBmLastUpdated.before(newBmLastUpdated) == true){
              if(bookmarkManager.deleteBookmark(new Bookmark(oldBmId)) == false){
                logger.error("unable to delete bookmark of id: " + oldBmId);
                continue;
             
              logger.debug("deleted on old bookmark before add it as a new");
              oldBmId = 0;
View Full Code Here

  }

  public static FeedSubscription createFeedSubscriptionObject(ResultSet rs) throws SQLException{
    if(rs == null) return null;
    FeedSubscription feed = new FeedSubscription();
    Bookmark bookmark = BookmarkDBDao.createBookmarkObject2(rs);
    feed.setId(rs.getInt(FeedSubscriptionSchema.ID));
    feed.setAutoImport(rs.getBoolean(FeedSubscriptionSchema.AUTO_IMPORT));
    feed.setLastSync(rs.getTimestamp(FeedSubscriptionSchema.LAST_SYNC));
    feed.setMatchText(rs.getString(FeedSubscriptionSchema.MATCH_TEXT));
    feed.setPubDate(rs.getTimestamp(FeedSubscriptionSchema.PUB_DATE));
View Full Code Here

  }

  public void testFillIdBookmark() throws Exception{
    User user = new User(1);
    Link link = new Link("http://zirr.us/");
    Bookmark bmark = new Bookmark(user,link);
    GnizrDaoUtil.fillId(bookmarkDao, userDao, linkDao, bmark);
    assertEquals((300),bmark.getId());
    assertEquals((1),bmark.getUser().getId());
    assertEquals((202),bmark.getLink().getId());
  }
View Full Code Here

    }
    assertTrue(caughtException);
  }
 
  public void testFillObjectBookmark() throws Exception{
    Bookmark bm = new Bookmark(300);
    GnizrDaoUtil.fillObject(bookmarkDao, userDao, linkDao, bm);
    assertEquals("zirrus",bm.getTitle());
    assertEquals("cnn news",bm.getTags());
    assertEquals("hchen1",bm.getUser().getUsername());
    assertEquals("http://zirr.us/",bm.getLink().getUrl());
  }
View Full Code Here

  protected IDataSet getDataSet() throws Exception {
    return new FlatXmlDataSet(TestUpdateMIMETypeListener.class.getResourceAsStream("/TestUpdateMIMETypeListener-input.xml"));
  }
 
  public void testAddBookmark() throws Exception{
    Bookmark bm = new Bookmark();
    bm.setUser(new User(3));
    bm.setLink(new Link("http://www.google.com"));
    bm.setTitle("google");
   
    int id = manager.addBookmark(bm);
    assertTrue(id > 0);
   
    manager.shutdown();
   
    bm = getGnizrDao().getBookmarkDao().getBookmark(id);
    assertEquals(MIMEType.TEXT_HTML,bm.getLink().getMimeTypeId());
  }
View Full Code Here

    bm = getGnizrDao().getBookmarkDao().getBookmark(id);
    assertEquals(MIMEType.TEXT_HTML,bm.getLink().getMimeTypeId());
  }
 
  public void testUpdateBookmark() throws Exception{
    Bookmark bm = manager.getBookmark(300);
    assertTrue(manager.updateBookmark(bm));
   
    manager.shutdown();
    bm = getGnizrDao().getBookmarkDao().getBookmark(300);
    assertEquals(MIMEType.TEXT_HTML,bm.getLink().getMimeTypeId());
  }
View Full Code Here

  public void testDeleteBookmark() throws Exception{
    ForUser record = forUserManager.getForUser(400);
    assertNotNull(record);
   
    assertTrue(bookmarkManager.deleteBookmark(new Bookmark(300)));
   
    record = forUserManager.getForUser(400);
    assertNull(record);   
  }
View Full Code Here

    int cnt = forUserManager.getForUserCount(new User(2));
    assertEquals(1,cnt);
    cnt = forUserManager.getForUserCount(new User(3));
    assertEquals(0,cnt);
   
    Bookmark b = new Bookmark();
    b.setTitle("example site");
    b.setLink(new Link("http://example.org/foobar"));
    b.setTags("abc 123 for:jsmith for:hchen1");
    b.setUser(new User(1));
   
    int id = bookmarkManager.addBookmark(b);
    assertTrue((id > 0));
   
    // must call shutdown() to wait for all threads that
View Full Code Here

TOP

Related Classes of com.gnizr.db.dao.Bookmark

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.