示例#1
0
  /** {@inheritDoc} */
  @Override
  public Hub add(Hub hub, User author) throws DuplicateHubNameException {
    if (hubDao.getByHubName(hub.getName()) != null) {
      throw new DuplicateHubNameException(hub.getName());
    }
    hub.setRating(0);
    hub.setAuthor(author);
    hubDao.save(hub);

    return hub;
  }
示例#2
0
  /** {@inheritDoc} */
  @Override
  public Set<String> getNamesOfHubsAvailableToUser(User user) {
    Set<String> publicHubs = new LinkedHashSet<String>();
    for (Hub hub : hubDao.getAllPublicHubs()) {
      publicHubs.add(hub.getName());
    }
    List<String> ownHubs = new ArrayList<String>();
    for (Hub hub : hubDao.getHubsOfUser(user.getUserName())) {
      ownHubs.add(hub.getName());
    }
    publicHubs.addAll(ownHubs);

    return publicHubs;
  }
示例#3
0
 /** {@inheritDoc} */
 @Override
 public Hub updateRating(Hub hub, VoiceValue voiceValue) {
   hub.setRating(
       VoiceValue.NEGATIVE.equals(voiceValue) ? hub.getRating() - 1 : hub.getRating() + 1);
   return hub;
 }