Example #1
0
  public MealDTO(
      Long id,
      Date date,
      Time time,
      String description,
      String categoryName,
      String imageName,
      String userName,
      String nickName,
      long userId,
      int gender,
      Collection<Rank> ranks) {
    this.id = id;
    this.date = date;
    this.time = time;
    this.description = description;
    this.categoryName = categoryName;
    this.imageName = imageName;
    this.userName = userName;
    this.nickName = nickName;

    this.userId = userId;
    this.gender = gender;
    this.ranks = mapFromRanksEntitiesC(ranks, userId);

    float ave = 0.0F;
    for (Rank rank : ranks) {
      ave += rank.getValue();
    }
    this.averageRank = ave / ranks.size();
  }
Example #2
0
  public MealDTO(
      Long id,
      Date date,
      Time time,
      String description,
      String categoryName,
      String imageName,
      String userName,
      String nickName,
      long userId,
      Collection<Rank> ranks,
      long currentUserId,
      int gender) {
    this.id = id;
    this.date = date;
    this.time = time;
    this.description = description;
    this.categoryName = categoryName;
    this.imageName = imageName;
    this.userName = userName;
    this.nickName = nickName;

    this.userId = userId;
    this.gender = gender;
    this.ranks = mapFromRanksEntitiesC(ranks, userId);

    float ave = 0.0F;
    for (Rank rank : ranks) {
      ave += rank.getValue();
      //		System.out.println(rank.getOwnerId() + "  " + currentUserId);
      if (rank.getOwnerId() == currentUserId) this.hasVoted = true;
    }
    this.averageRank = ave / ranks.size();
  }
Example #3
0
 public static RankCompactDTO mapFromRankEntity(Rank rank, long currentUserId) {
   return new RankCompactDTO(
       rank.getMeal().getUser().getId(), rank.getValue(), rank.getDescription());
 }