Examples of UserTag


Examples of com.gnizr.db.dao.UserTag

      MissingIdException {
    if (hasMissingId(assertion) == true) {
      fillId(tagAssertionDao, tagPrptDao, tagDao, userDao, assertion);
    }
    TagAssertion ta = tagAssertionDao.getTagAssertion(assertion.getId());
    UserTag s = ta.getSubject();
    TagProperty p = ta.getProperty();
    UserTag o = ta.getObject();
    User u = ta.getUser();
    fillObject(tagDao, userDao, s);
    fillObject(tagDao, userDao, o);
    fillObject(tagPrptDao, p);
    fillObject(userDao, u);
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

  public static int createTagIfNotExist(TagDao tagDao, String tag)
      throws ParseTagException {
    Tag tagObj = null;
    String tagLabel = null;
    if (TagUtil.isPrefixedUserTag(tag) == true) {
      UserTag ut = TagUtil.parsePrefixedUserTag(tag);
      if (ut != null) {
        tagLabel = ut.getTag().getLabel();
      } else {
        throw new ParseTagException("unable to parse tag: " + tag);
      }
    } else {
      tagLabel = tag;
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

      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);
      id = tagDao.createLinkTag(new LinkTag(link, tag));
      logger.debug("linkTag id = " + id);
      id = tagDao.getBookmarkTagId(bmark, tag);
      if (id <= 0) {
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

  public static final int createUserTagIfNotExist(TagDao tagDao,
      UserDao userDao, String tag, User defaultUser)
      throws ParseTagException, NoSuchUserException {
    int userTagId = 0;
    UserTag tagParsed = null;
    if (TagUtil.isPrefixedUserTag(tag)) {
      tagParsed = TagUtil.parsePrefixedUserTag(tag);
      if (tagParsed == null) {
        throw new ParseTagException("unable to parse tag: " + 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);
        userTagId = userTag.getId();
      }
    }
    return userTagId;
  }
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

   * @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);
      }
      List<Tag> tagsObjs = getTags(safeNewTags);
      newBookmarks = tagDao.expandTag(user, oldTagObj, tagsObjs.toArray(new Tag[0]));
      if (safeNewTags.contains(oldTag) == false) {
        newBookmarks = tagDao.reduceTag(user, new Tag[] { oldTagObj });
      }
      Map<Integer, Bookmark> newBookmarksMap = GnizrDaoUtil
          .getBookmarksMap(newBookmarks);
      for (Bookmark oldBookmark : oldBookmarks) {
        Bookmark newBookmark = newBookmarksMap.get(oldBookmark.getId());
        if (newBookmark != null) {
          try {
            listenerExecutor.execute(new RunBookmarkUpdatedNotify(oldBookmark, newBookmark));
          } catch (Exception e) {
            logger.error("Error notifying BookmarkListeners", e);
          }
        } else {
          logger
              .error("After renaming a tag, bookmark "
                  + oldBookmark.getId()
                  + " doesn't appear in the expected list of updated bookmarks");
        }
      }
      if(oldBookmarks.size() == newBookmarks.size()){
        isOkay = true;
      }
    }
    try {
      userTagObj = GnizrDaoUtil.getUserTag(tagDao, user, oldTagObj);
      if(userTagObj != null && userTagObj.getCount() == 0){
        isOkay = tagDao.deleteUserTag(userTagObj.getId());
      }
    } catch (MissingIdException e) {
      logger.debug("no such user tag: " + user.getUsername() + "/" + oldTag);   
    }     
    return isOkay;
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

   * @return Returns <code>true</code> if tag deletion is successful. Returns <code>false</code>, otherwise.
   */
  public boolean deleteTag(User user, String tag) {       
    boolean isOkay = false
    Tag tagObj = GnizrDaoUtil.getTag(tagDao, tag);
    UserTag userTagObj = null;
    try {
      userTagObj = GnizrDaoUtil.getUserTag(tagDao, user, tagObj);
    } catch (MissingIdException e) {
      logger.debug("no such user tag: " + user.getUsername() + "/" + tag);   
    }     
    if (tagObj != null && userTagObj != null && userTagObj.getCount() > 0) {
      List<Bookmark> oldBookmarks = bookmarkDao.pageBookmarks(user,
          tagObj, 0, tagObj.getCount()).getResult();
      List<Bookmark> newBookmarks = tagDao.reduceTag(user,
          new Tag[] { tagObj });
      Map<Integer, Bookmark> newBookmarksMap = GnizrDaoUtil
          .getBookmarksMap(newBookmarks);
      for (Bookmark oldBookmark : oldBookmarks) {
        Bookmark newBookmark = newBookmarksMap.get(oldBookmark.getId());
        if (newBookmark != null) {
          try {
            listenerExecutor.execute(new RunBookmarkUpdatedNotify(
                oldBookmark, newBookmark));
          } catch (Exception e) {
            logger.error("Error notifying BookmarkListeners", e);
          }
        } else {
          logger
          .error("After deleting a tag, bookmark "
              + oldBookmark.getId()
              + " doesn't appear in the expected list of updated bookmarks");
        }
      }
      if(oldBookmarks.size() == newBookmarks.size()){
        isOkay = true;
      }
    }
    try {
      userTagObj = GnizrDaoUtil.getUserTag(tagDao, user, tagObj);
      if(userTagObj != null && userTagObj.getCount() == 0){
        isOkay = tagDao.deleteUserTag(userTagObj.getId());
      }
    } catch (MissingIdException e) {
      logger.debug("no such user tag: " + user.getUsername() + "/" + tagObj);   
    }   
    return isOkay;
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

  public int getMaxPageNumber(UserTag tag, Integer perPageCount) throws NoSuchUserException, NoSuchTagException, NoSuchUserTagException, MissingIdException{
    logger.debug("getMaxPageNumber: userTag=" + tag
        + ",perPageCount=" + perPageCount);
    int max = 1;
    GnizrDaoUtil.checkNull(tag);
    UserTag userTag = new UserTag(tag);
    GnizrDaoUtil.fillId(tagDao,userDao,userTag);
    GnizrDaoUtil.fillObject(tagDao,userDao,userTag);
    if (userTag != null) {
      int numOfBmarks = userTag.getCount();
      if (numOfBmarks > 0) {
        if (perPageCount != null && perPageCount > 0) {
          int tnp = numOfBmarks / perPageCount;
          if ((numOfBmarks % perPageCount) > 0) {
            tnp++;
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

    assertTrue(caughtException);
  }
 
  public void testFillIdTagAssertion() throws Exception{
    User user = new User("hchen1");
    UserTag subject = new UserTag("hchen1","webwork");
    TagProperty property = new TagProperty(3);
    UserTag object = new UserTag(2);
    TagAssertion asrt = new TagAssertion(subject,property,object,user);
    GnizrDaoUtil.fillId(tagAssertionDao, tagPrptDao, tagDao, userDao,asrt);
    assertEquals((1),asrt.getUser().getId());
    assertEquals((1),asrt.getSubject().getId());
    assertEquals((2),asrt.getObject().getId());
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

    assertEquals("hchen1",user.getUsername());
    assertNull(user.getEmail());
  }
 
  public void testFillIdUserTag() throws Exception{
    UserTag userTag = new UserTag();
    userTag.setTag(new Tag("webwork",(0)));
    userTag.setUser(new User("hchen1"));
    GnizrDaoUtil.fillId(tagDao,userDao,userTag);
    assertEquals((1),userTag.getId());
    assertEquals((1),userTag.getUser().getId());
    assertEquals((1),userTag.getTag().getId());
   
    boolean caughtException = false;
    try{
      userTag.setId(-1);
      userTag.setUser(new User("jfdkslf"));
      GnizrDaoUtil.fillId(tagDao,userDao,userTag);
    }catch(Exception e){
      caughtException = true;
    }
    assertTrue(caughtException);
View Full Code Here

Examples of com.gnizr.db.dao.UserTag

    assertEquals("webwork",tag.getLabel());   
  }
 
  public void testFillObjectTagAssertion() throws Exception{
    User u = new User((1));
    UserTag s = new UserTag((1));
    UserTag o = new UserTag((2));
    TagProperty p = new TagProperty((3));
    TagAssertion ta = new TagAssertion(s,p,o,u);
    GnizrDaoUtil.fillObject(tagAssertionDao, tagPrptDao, tagDao, userDao,ta);
    assertEquals("hchen1",ta.getUser().getUsername());
    assertEquals("webwork",ta.getSubject().getTag().getLabel());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.