/** * Get Provider Account Id. * * @param accountId * @param provider * @return * @throws EnMeNoResultsFoundException */ public Long getProviderAccountId(String accountId, SocialProvider provider) throws EnMeNoResultsFoundException { final SocialAccount ac = this.getAccountConnection(accountId, provider); if (ac != null) { return ac.getId(); } else { throw new EnMeNoResultsFoundException("connection not found"); } }
/** * Get social accounts stats. * * @param socialAccount {@link SocialAccount}. * @return */ @SuppressWarnings("unchecked") public HashMap<String, Long> getSocialAccountStats(final SocialAccount socialAccount) { final HashMap<String, Long> stats = new HashMap<String, Long>(); log.debug("getSocialAccountStats " + socialAccount.getId()); final DetachedCriteria criteria = DetachedCriteria.forClass(TweetPollSavedPublishedStatus.class); criteria.add(Restrictions.eq("socialAccount", socialAccount)); criteria.setProjection(Projections.rowCount()); final List tweetPollstats = getHibernateTemplate().findByCriteria(criteria); log.debug("getSocialAccountStats " + tweetPollstats.size()); log.debug("getSocialAccountStats " + tweetPollstats); if (tweetPollstats.size() > 0) { stats.put("tweetpoll", Long.valueOf(tweetPollstats.get(0).toString())); } else { stats.put("tweetpoll", 0L); } // TODO: in the future we can add another stats. stats.put("poll", 0L); stats.put("survey", 0L); log.debug("getSocialAccountStats stats" + stats); return stats; }