public DaoResult<Bookmark> pageLinkHistory(Link link, int offset, int count) throws NoSuchLinkException { logger.debug("getHistory: link=" + link); GnizrDaoUtil.checkNull(link); Link aLink = new Link(link); GnizrDaoUtil.fillId(linkDao, aLink); return bookmarkDao.pageBookmarks(aLink, offset, count); }
/** * Returns a list of class tags. A class tag is <code>UserTag</code> that is the "object" in a tag * assertion, in which the "predict" is "type". * * @param user * @return a list of <code>UserTag</code> objects that are class tags. * @throws NoSuchUserException the input user doesn't exist in the system */ public List<UserTag> findUserTagClass(User user) throws NoSuchUserException { logger.debug("findUserTagClass: user=" + user); if (GnizrDaoUtil.hasMissingId(user)) { GnizrDaoUtil.fillId(userDao, user); } List<TagAssertion> asrts = null; List<UserTag> classTags = new ArrayList<UserTag>(); asrts = tagAssertionDao.findTagAssertion(user, null, rdfTypePrpt, null); if (asrts != null && !asrts.isEmpty()) { addUserTagObjectToList(asrts, classTags, -1); } return classTags; }
public List<UserTag> findSKOSNarrower(User user, UserTag userTag) throws NoSuchUserException, NoSuchTagException, NoSuchUserTagException, MissingIdException { logger.debug("findSKOSNarrower: user="******",userTag=" + userTag); if (GnizrDaoUtil.hasMissingId(user)) { GnizrDaoUtil.fillId(userDao, user); } if (GnizrDaoUtil.hasMissingId(userTag)) { GnizrDaoUtil.fillId(tagDao, userDao, userTag); } List<UserTag> result = new ArrayList<UserTag>(); seekNarrower(user, userTag, result, userTag.getId()); return result; }
public List<UserTag> findUserTagInstance(User user, UserTag classTag) throws NoSuchUserException, NoSuchTagException, NoSuchUserTagException, MissingIdException { logger.debug("findUserTagInstance: user="******",classTag=" + classTag); if (GnizrDaoUtil.hasMissingId(user)) { GnizrDaoUtil.fillId(userDao, user); } if (GnizrDaoUtil.hasMissingId(classTag)) { GnizrDaoUtil.fillId(tagDao, userDao, classTag); } List<UserTag> instanceTag = new ArrayList<UserTag>(); List<TagAssertion> asrts = tagAssertionDao.findTagAssertion(user, null, rdfTypePrpt, classTag); if (asrts != null && !asrts.isEmpty()) { addUserTagSubjectToList(asrts, instanceTag, classTag.getId()); } return instanceTag; }
public TagPager(GnizrDao gnizrDao) { this.userDao = gnizrDao.getUserDao(); this.tagDao = gnizrDao.getTagDao(); this.tagPropertyDao = gnizrDao.getTagPropertyDao(); this.tagAssertionDao = gnizrDao.getTagAssertionDao(); this.gnizrUser = GnizrDaoUtil.getUser(userDao, UserSchema.GNIZR_USER); initTagProperty(); }
public Link getInfo(String urlHash) { logger.debug("getInfo: urlHash=" + urlHash); Link aLink = GnizrDaoUtil.getLinkByUrlHash(linkDao, urlHash); if (aLink != null) { return aLink; } return null; }
public Bookmark getFirstMatchedBookmark(String url) { logger.debug("getFirstMatchedBookmark: url" + url); Link aLink = GnizrDaoUtil.getLink(linkDao, url); if (aLink != null) { DaoResult<Bookmark> result = bookmarkDao.pageBookmarks(aLink, 0, 1); if (result.getSize() > 0) { return result.getResult().get(0); } } return null; }
public List<UserTag> findSKOSRelated(User user, UserTag userTag) throws NoSuchUserException, NoSuchTagException, NoSuchUserTagException, MissingIdException { logger.debug("findSKOSRelated: user="******",userTag=" + userTag); if (GnizrDaoUtil.hasMissingId(user)) { GnizrDaoUtil.fillId(userDao, user); } if (GnizrDaoUtil.hasMissingId(userTag)) { GnizrDaoUtil.fillId(tagDao, userDao, userTag); } List<TagAssertion> asrts = null; List<UserTag> relatedTags = new ArrayList<UserTag>(); asrts = tagAssertionDao.findTagAssertion(user, userTag, skosRelatedPrpt, null); if (asrts != null && !asrts.isEmpty()) { addUserTagObjectToList(asrts, relatedTags, userTag.getId()); } asrts = tagAssertionDao.findTagAssertion(user, null, skosRelatedPrpt, userTag); if (asrts != null && !asrts.isEmpty()) { addUserTagSubjectToList(asrts, relatedTags, userTag.getId()); } return relatedTags; }
/** * @deprecated Since 2.4 * @param link * @return */ public List<Bookmark> getHistory(Link link) { logger.debug("getHistory: link=" + link); List<Bookmark> result = new ArrayList<Bookmark>(); GnizrDaoUtil.checkNull(link); Link aLink = new Link(link); try { GnizrDaoUtil.fillId(linkDao, aLink); int totalBmCount = bookmarkDao.getBookmarkCount(aLink); if (totalBmCount > 0) { List<Bookmark> bmarks = bookmarkDao.pageBookmarks(aLink, 0, totalBmCount).getResult(); for (Iterator<Bookmark> it = bmarks.iterator(); it.hasNext(); ) { Bookmark bm = it.next(); GnizrDaoUtil.fillObject(bookmarkDao, userDao, linkDao, bm); result.add(bm); } } return result; } catch (Exception e) { logger.debug(e); } return result; }
public List<Tag> getPopularNarrowerTagsByGnizrUser(String tag, int minFreq) throws MissingIdException, NoSuchUserException, NoSuchTagException, NoSuchUserTagException { int mf = 1; if (minFreq > mf) { mf = minFreq; } List<Tag> tags = new ArrayList<Tag>(); Tag tagObj = GnizrDaoUtil.getTag(tagDao, tag); if (tagObj != null && gnizrUser != null) { UserTag userTagObj = GnizrDaoUtil.getUserTag(tagDao, gnizrUser, tagObj); if (userTagObj != null) { List<UserTag> relTags = findSKOSNarrower(gnizrUser, userTagObj); for (UserTag ut : relTags) { if (ut.getTag().getCount() >= mf) { tags.add(new Tag(ut.getTag())); } } } } else if (gnizrUser == null) { throw new NoSuchUserException("missing superuser: " + UserSchema.GNIZR_USER); } return tags; }
public Map<String, List<UserTag>> getRDFTypeTagGroups(User user) throws NoSuchUserException { GnizrDaoUtil.fillId(userDao, user); Map<String, List<UserTag>> map = new HashMap<String, List<UserTag>>(); List<TagAssertion> result = tagAssertionDao.findTagAssertion(user, null, rdfTypePrpt, null); for (TagAssertion t : result) { String tagGroupName = t.getObject().getTag().getLabel(); List<UserTag> memberList = map.get(tagGroupName); if (memberList == null) { memberList = new ArrayList<UserTag>(); map.put(tagGroupName, memberList); } memberList.add(t.getSubject()); } return map; }
public List<Bookmark> getTop10AllTime() { logger.debug("getTop10AllTime popular bookmarks."); List<Bookmark> bmarks = null; lockOfAllTime.readLock().lock(); if (isCacheValid(ALL_TIME) == false) { lockOfAllTime.readLock().unlock(); lockOfAllTime.writeLock().lock(); if (isCacheValid(ALL_TIME) == false) { Date start = new GregorianCalendar(1900, 1, 1).getTime(); Date end = GnizrDaoUtil.getNow(); bmarks = this.bookmarkDao.getPopularCommunityBookmarks(start, end, 10); Cache cache = new Cache(bmarks, end); cacheMap.put(ALL_TIME, cache); } lockOfAllTime.readLock().lock(); lockOfAllTime.writeLock().unlock(); } bmarks = cacheMap.get(ALL_TIME).getBookmarks(); lockOfAllTime.readLock().unlock(); return bmarks; }