Package com.gnizr.db.dao

Examples of com.gnizr.db.dao.Link


  public static void fillId(TagDao tagDao, LinkDao linkDao, LinkTag linkTag)
      throws NoSuchLinkException, NoSuchTagException, MissingIdException,
      NoSuchLinkTagException {
    if (hasMissingId(linkTag) == true) {
      Link link = linkTag.getLink();
      Tag tag = linkTag.getTag();
      fillId(linkDao, link);
      fillId(tagDao, tag);
      LinkTag obj = getLinkTag(tagDao, link, tag);
      if (obj == null) {
View Full Code Here


  public static Link getLink(LinkDao linkDao, String url) {
    if (url == null) {
      throw new NullPointerException("url is NULL");
    }
    Link link = null;
    List<Link> links = linkDao.findLink(url);
    if (links.isEmpty() == false) {
      link = links.get(0);
    }
    return link;
View Full Code Here

      MissingIdException, NoSuchLinkTagException, NoSuchUserException {
    if (hasMissingId(linkTag) == true) {
      fillId(tagDao, linkDao, linkTag);
    }
    LinkTag obj = tagDao.getLinkTag(linkTag.getId());
    Link l = obj.getLink();
    Tag t = obj.getTag();
    fillObject(linkDao, l);
    fillObject(tagDao, t);
    linkTag.setLink(l);
    linkTag.setTag(t);
View Full Code Here

    if (hasMissingId(bmark) == true) {
      fillId(bmarkDao, userDao, linkDao, bmark);
    }
    Bookmark bm = bmarkDao.getBookmark(bmark.getId());
    User u = bm.getUser();
    Link l = bm.getLink();
    fillObject(userDao, u);
    fillObject(linkDao, l);
    bmark.setLink(l);
    bmark.setUser(u);
    bmark.setNotes(bm.getNotes());
View Full Code Here

  }

  public static void fillObject(LinkDao linkDao, Link link)
      throws NoSuchLinkException {
    fillId(linkDao, link);
    Link l = linkDao.getLink(link.getId());
    if (l != null) {
      link.setCount(l.getCount());
      link.setMimeTypeId(l.getMimeTypeId());
      link.setUrl(l.getUrl());
      link.setUrlHash(l.getUrlHash());
    }
  }
View Full Code Here

    Bookmark existBmark = null;
    if (bookmark.getId() > 0) {
      existBmark = bookmarkDao.getBookmark(bookmark.getId());
    } else if (bookmark.getUser() != null && bookmark.getLink() != null) {
      User user = bookmark.getUser();
      Link link = bookmark.getLink();
      try {
        GnizrDaoUtil.fillId(linkDao, link);
        GnizrDaoUtil.fillId(userDao, user);
        existBmark = GnizrDaoUtil.getBookmark(bookmarkDao, user, link);
      } catch (Exception e) {
View Full Code Here

    if (bmark.getTags() == null) {
      bmark.setTags("");
    }

    User user = bmark.getUser();
    Link link = bmark.getLink();

    // we assume the user already exists in the DB
    // if it doesn't exist, an exception will be thrown
    GnizrDaoUtil.fillId(userDao, user);

    // if no link.id is specified, check if it already exists
    // by lookup a link record of the specified URL
    if (GnizrDaoUtil.hasMissingId(link) == true) {
      link = GnizrDaoUtil.getLink(linkDao, link.getUrl());
      // if doesn't already exists, create a new link based
      // the information defined in the bookmark
      if (link == null) {
        link = new Link();
        int linkId = createNewLinkFromBookmark(bmark);
        if (linkId > 0) {
          // if a new link is created successfully,
          // fetch the link object
          link = linkDao.getLink(linkId);
        }
      }
      bmark.setLink(link);
    }else{
      link = linkDao.getLink(link.getId());
      bmark.setLink(link);
    }
    // if no date properties set, we will set them as of now.
    if (bmark.getCreatedOn() == null) {
      bmark.setCreatedOn(GnizrDaoUtil.getNow());
View Full Code Here

  }

  private List<Tag> initTagEntries(Bookmark bmark, List<String> tags) {
    logger.debug("initTagEntries: bmark=" + bmark);
    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));
View Full Code Here

    }
    return tagObj;
  }

  private int createNewLinkFromBookmark(Bookmark bookmark) {
    Link link = bookmark.getLink();
    link.setMimeTypeId(MIMEType.UNKNOWN);
    return linkDao.createLink(link);
  }
View Full Code Here

    }

    // check if the link URL defined in the new bookmark
    // is any different from the existing one. if it's a
    // new URL, then create a new link record for, if necessary.
    Link link = bookmark.getLink();
    String urlHash = Link.computeUrlHash(link.getUrl());
    if (urlHash.equals(oldBookmark.getLink().getUrlHash()) == false) {
      Link ln = GnizrDaoUtil.getLink(linkDao, link.getUrl());
      if (ln != null) {
        // if the link already exists, set the new bookmark
        // to reference it.
        bookmark.setLink(ln);
      } else {
View Full Code Here

TOP

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

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.