public Integer getNbTweetsByUser(String login) {
   Long res =
       (Long)
           crudDAO.findUniqueWithNamedQuery(
               Tweet.COUNT_TWEETS_FOR_USER, QueryParameters.with("name", login).parameters());
   return res.intValue();
 }
 public List<Tweet> findMyRecentTweets(Long start, Integer range) {
   User user = securityContext.getUser();
   List<Tweet> result;
   if (start != null) {
     result =
         crudDAO.findMaxResultsWithNamedQuery(
             Tweet.FIND_ALL_RECENT_BY_AUTHOR_WITH_LIMIT,
             QueryParameters.with("author", user.getLogin()).and("id", start).parameters(),
             range);
   } else {
     result =
         crudDAO.findMaxResultsWithNamedQuery(
             Tweet.FIND_ALL_RECENT_BY_AUTHOR,
             QueryParameters.with("author", user.getLogin()).parameters(),
             range);
   }
   return result;
 }
  @Transactional(readOnly = false)
  public Tweet createTweetFromUser(User user, String msg) {
    Assert.notNull(user, "user");
    Assert.notNull(msg, "message");
    Tweet tweet = new Tweet();

    tweet.setTweet(msg);
    Date creationDate = Calendar.getInstance().getTime();
    tweet.setCreationDate(creationDate);
    String author = user.getLogin();
    tweet.setAuthor(author);

    crudDAO.create(tweet);

    return tweet;
  }
 public List<Tweet> findRecentTweets(Integer range) {
   return crudDAO.findMaxResultsWithNamedQuery(Tweet.FIND_ALL_RECENT, range);
 }
 public void updateTweet(Tweet tweet) {
   crudDAO.update(tweet);
 }
 public List<Tweet> listAllTweet() {
   return crudDAO.findWithNamedQuery(Tweet.ALL_ORDER_BY_DATE_DESC);
 }
 public Tweet findTweetById(Long tweetId) {
   return crudDAO.find(Tweet.class, tweetId);
 }
 @Transactional(readOnly = false)
 public void deleteTweet(Long tweetId) {
   crudDAO.delete(Tweet.class, tweetId);
 }
 public List<Tweet> findTweetByKeyword(String keyword) {
   return crudDAO.findWithNamedQuery(
       Tweet.FIND_BY_KEYWORD, QueryParameters.with("keyword", "%" + keyword + "%").parameters());
 }
Exemplo n.º 10
0
 public String getEmailOfTweetOwner(Long tweetId) {
   return (String)
       crudDAO.findUniqueWithNamedQuery(
           Tweet.EMAIL_ADDRESS_OF_TWEET_OWNER,
           QueryParameters.with("tweetId", Long.valueOf(tweetId)).parameters());
 }