Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Tag


      }
    } else {
      checkNull(defaultUser);
      tagParsed = new UserTag(defaultUser.getUsername(), tag);
    }
    Tag tagObj = new Tag();
    User userObj = new User();

    // fills the id of the tag
    int tagId = createTagIfNotExist(tagDao, tagParsed.getTag().getLabel());
    tagObj.setId(tagId);

    // fills the id of the user
    userObj.setUsername(tagParsed.getUser().getUsername());
    GnizrDaoUtil.fillId(userDao, userObj);
    if (tagObj.getId() > 0 && userObj.getId() > 0) {
      List<UserTag> ut = tagDao.findUserTag(userObj, tagObj);
      if (ut.isEmpty()) {
        userTagId = tagDao.createUserTag(new UserTag(userObj, tagObj));
      } else {
        UserTag userTag = ut.get(0);
View Full Code Here


  private List<Tag> getTags(List<String> tagList) {
    logger.debug("getTags: tagList=" + tagList);
    List<Tag> tags = new ArrayList<Tag>();
    for (String t : tagList) {
      Tag aTag = GnizrDaoUtil.getTag(tagDao, t);
      if (aTag != null) {
        tags.add(aTag);
      }
    }
    return tags;
View Full Code Here

    List<Tag> tagObj = new ArrayList<Tag>();
    Link link = bmark.getLink();
    User user = bmark.getUser();
    int pos = 1;
    for (String t : tags) {
      Tag tag = new Tag(t);
      tag.setId(tagDao.createTag(tag));
      tagObj.add(tag);

      int id = 0;
      id = tagDao.createUserTag(new UserTag(user, tag));
      logger.debug("userTag id = " + id);
View Full Code Here

   * @param newTags one or more new tags
   * @return Returns <code>true</code> if tag renaming is successful. Returns <code>false</code>, otherwise.
   */
  public boolean renameTag(User user, String oldTag, String[] newTags) { 
    boolean isOkay = false;
    Tag oldTagObj = GnizrDaoUtil.getTag(tagDao,oldTag);
    UserTag userTagObj = null;
    try {
      userTagObj = GnizrDaoUtil.getUserTag(tagDao, user, oldTagObj);
    } catch (MissingIdException e) {
      logger.debug("no such user tag: " + user.getUsername() + "/" + oldTag);   
   
    if (oldTagObj != null && userTagObj != null && userTagObj.getCount() > 0) {
      DaoResult<Bookmark> result = null;
      List<Bookmark> oldBookmarks = null;
      List<Bookmark> newBookmarks = null;
      result = bookmarkDao.pageBookmarks(user, oldTagObj, 0, oldTagObj
          .getCount());
      oldBookmarks = result.getResult();
      List<String> safeNewTags = getSafeTagsList(Arrays.asList(newTags));
      for (Bookmark bm : oldBookmarks) {
        initTagEntries(bm, safeNewTags);
View Full Code Here

    return new FlatXmlDataSet(TestBookmarkPager.class
        .getResourceAsStream("/TestBookmarkPager2-input.xml"));
  }
 
  public void testPageBookmarkByTag() throws Exception{
    Tag webTag = new Tag("web");
    List<Bookmark> results = bookmarkPager.pageBookmark(webTag, 0,100);
    assertEquals(2,results.size());
    Bookmark bookmark = results.get(0);
    assertEquals("http://www.housingmaps.com/",bookmark.getLink().getUrl());
  }
View Full Code Here

    assertEquals(1,results.size());
  }

  public void testPageAllBookmarkUserTag() throws Exception{
    User user = new User("hchen1");
    Tag tag = new Tag("web");
    List<Bookmark> results = bookmarkPager.pageAllBookmark(user, tag).getResult();
    assertEquals(2,results.size());
  }
View Full Code Here

    List<Bookmark> results = bookmarkPager.pageAllBookmark(user, tag).getResult();
    assertEquals(2,results.size());
  }
 
  public void testPageAllBookmarkTag() throws Exception{
    Tag tag = new Tag("timfinin");
    List<Bookmark> results = bookmarkPager.pageAllBookmark(tag).getResult();
    assertEquals(1,results.size());
  }
View Full Code Here

    assertTrue(manager.updateBookmark(bm));
   
    bm = bookmarkDao.getBookmark(300);
    GnizrDaoUtil.fillObject(bookmarkDao, userDao, linkDao, bm);
    assertEquals("foobar",bm.getTags());
    Tag cnn = tagDao.findTag("cnn").get(0);
    assertEquals(0,cnn.getCount());
    Tag news = tagDao.findTag("news").get(0);
    assertEquals(0,news.getCount());
    Tag foobar = tagDao.findTag("foobar").get(0);
    assertEquals(1,foobar.getCount());
    UserTag foobar_u = tagDao.findUserTag(new User(1), foobar).get(0);
    assertEquals(1,foobar_u.getCount());
   
    Link bmLink = bm.getLink();
    assertEquals(ln.getUrl(),bmLink.getUrl());
View Full Code Here

  public void testUpdateBookmark2() throws Exception{
    Bookmark bm = manager.getBookmark(300);
    bm.setTags("news foobar abdc");
    assertTrue(manager.updateBookmark(bm));
   
    UserTag ut = tagDao.findUserTag(bm.getUser(),new Tag(5)).get(0);
    assertEquals(1,ut.getCount());
   
    Tag foobar = tagDao.findTag("foobar").get(0);
    assertEquals(1,foobar.getCount());
    Tag abdc = tagDao.findTag("abdc").get(0);
    assertEquals(1,abdc.getCount());
   
    Tag cnn = tagDao.findTag("cnn").get(0);
    assertEquals(0,cnn.getCount());
   
    UserTag userCnn = tagDao.findUserTag(bm.getUser(),cnn).get(0);
    assertEquals(0,userCnn.getCount());
   
    UserTag userFoobar = tagDao.findUserTag(bm.getUser(),foobar).get(0);
    assertEquals(1,userFoobar.getCount());
   
    bm.setTags("");
    assertTrue(manager.updateBookmark(bm));
   
    ut = tagDao.findUserTag(bm.getUser(),new Tag(5)).get(0);
    assertEquals(0,ut.getCount());
  }
View Full Code Here

    bm2 = manager.getBookmark(id2);
   
    bm1.setTags("tag1");
    assertTrue(manager.updateBookmark(bm1));
     
    Tag tag1 = tagDao.findTag("tag1").get(0);
    assertEquals(2,tag1.getCount());
   
    UserTag user1tag1 = tagDao.findUserTag(new User(2), tag1).get(0);
    assertEquals(1,user1tag1.getCount());
 
    bm2.setTags("");;
    assertTrue(manager.updateBookmark(bm2));
    Tag tag2 = tagDao.findTag("tag2").get(0);
    assertEquals(0,tag2.getCount());
  }
View Full Code Here

TOP

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

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.