Exemplo n.º 1
0
  @Transactional
  public void importTeamMembers(GitHub gitHub) {
    GitHubUser[] users = getGitHubUsers(gitHub);
    List<Long> userIds = new ArrayList<>();
    for (GitHubUser user : users) {
      userIds.add(user.getId());
      String userName = getNameForUser(user.getLogin());

      teamService.createOrUpdateMemberProfile(
          user.getId(), user.getLogin(), user.getAvatarUrl(), userName);
    }
    teamService.showOnlyTeamMembersWithIds(userIds);
  }
 @RequestMapping(value = "/manager/teams/schedule/create", method = RequestMethod.POST)
 public String createSchedule(
     @ModelAttribute("schedBean") ScheduleBean scheduleBean, Model model) {
   System.out.println("scheduleBean.isEveryMod() = " + scheduleBean.isEveryMod());
   teamService.createGames(scheduleBean);
   return "redirect:/manager/teams/" + scheduleBean.getId() + "/games";
 }
 @RequestMapping(value = "/manager/imanage", method = RequestMethod.GET)
 public String imanage(Model model) {
   String fbId = facebook.userOperations().getUserProfile().getId();
   List<Team> teams = teamService.findTeamsByManager(fbId);
   model.addAttribute("teams", teams);
   return "showteams";
 }
 @RequestMapping(value = "/player/games/{id}/ava", method = RequestMethod.POST)
 public String editAva(
     @ModelAttribute("availability") Availability availability,
     @PathVariable("id") long id,
     Model model) {
   Availability savedAvailability = teamService.saveAvailability(availability);
   return "redirect:/player/games/" + id;
 }
 @RequestMapping(value = "/manager/teams/{id}/schedule", method = RequestMethod.GET)
 public String scheduleGames(@PathVariable("id") long id, Model model) {
   Team team = teamService.find(id);
   ScheduleBean scheduleBean = new ScheduleBean();
   scheduleBean.setId(id);
   model.addAttribute("schedBean", scheduleBean);
   model.addAttribute("team", team);
   return "scheduling";
 }
 private Team createTeam(Client client) {
   Team team = new Team();
   team.setName("Test Team" + RandomStringUtils.randomAlphanumeric(18));
   team.setDescription("Test Team description");
   team.setActive(true);
   team.setClient(client);
   team.setSalesForceAccount(new TeamSalesForce(RandomStringUtils.randomAlphanumeric(18)));
   teamService.create(team);
   return team;
 }
 @RequestMapping(value = "/player/games", method = RequestMethod.GET)
 public String getAvailabilities(Model model) {
   Player player = teamService.getPlayerByFbId(facebook.userOperations().getUserProfile().getId());
   List<Team> teams = player.getTeam();
   List<Game> games = new ArrayList<>();
   teams.forEach((team) -> games.addAll(team.getGames()));
   Collections.sort(games, (x1, x2) -> x1.getDate().compareTo(x2.getDate()));
   model.addAttribute("fbid", facebook.userOperations().getUserProfile().getId());
   model.addAttribute("games", games);
   model.addAttribute("player", player);
   return "showplayergames";
 }
 @RequestMapping(value = "/player/games/{id}", method = RequestMethod.GET)
 public String getGameForPlayer(@PathVariable("id") long id, Model model) {
   Game game = teamService.findGameWithAvailability(id);
   Availability availability = new Availability();
   List<String> statuses = new ArrayList<>();
   statuses.add(TeamService.UNDEFINED);
   statuses.add(TeamService.NOTSURE);
   statuses.add(TeamService.THERE);
   statuses.add(TeamService.CANT);
   model.addAttribute("availability", availability);
   model.addAttribute("statuses", statuses);
   model.addAttribute("fbId", facebook.userOperations().getUserProfile().getId());
   model.addAttribute("game", game);
   return "showplayeravailability";
 }
Exemplo n.º 9
0
  @Test
  public void getOneTeamBBSDetailTest() {
    String teamBBSId = "39";

    ModelAndView view = teamService.getOneTeamBBSDetail(teamBBSId);

    assertNotNull(view);

    if (view != null) {
      String viewName = view.getViewName();
      assertNotNull(viewName);
      assertEquals(viewName, "team/teamBBSDetail");
    } else {
      fail("fail...");
    }
  }
Exemplo n.º 10
0
  @Test
  public void getAllTeamByMemberIdTest() {
    String memberId = "test04";

    ModelAndView view = teamService.getAllTeamByMemberId(memberId);

    assertNotNull(view);

    if (view != null) {
      String viewName = view.getViewName();
      assertNotNull(viewName);
      assertEquals(viewName, "team/otherTeams");
    } else {
      fail("fail...");
    }
  }
Exemplo n.º 11
0
  @Test
  public void getAllTeamsTest() {

    TeamSearchVO teamSearchVO = new TeamSearchVO();
    int pageNo = 0;

    ModelAndView view = teamService.getAllTeams(teamSearchVO, pageNo);

    assertNotNull(view);

    if (view != null) {
      String viewName = view.getViewName();
      assertNotNull(viewName);
      assertEquals(viewName, "/team/teamList");
    } else {
      fail("fail...");
    }
  }
Exemplo n.º 12
0
 /**
  * Fill a group and returns the group filled but not saved.
  *
  * @param aGroup a group to fill
  * @return the group with real participants
  */
 public GroupEntity fillGroup(final GroupEntity aGroup) {
   if (aGroup != null) {
     // First get the tournament
     final TournamentEntity theTournament = aGroup.getStage().getTournament();
     final boolean isTeam = theTournament.getIsTeamTournament();
     // Get players or teams list
     List<TeamEntity> teamsTournament = null;
     List<PlayerEntity> playersTournament = null;
     if (isTeam) {
       teamsTournament =
           teamService.getSortedListTeam(theTournament.getTeams(), SortType.RANKING_POINTS);
     } else {
       playersTournament =
           playerService.getSortedListPlayer(theTournament.getPlayers(), SortType.RANKING_POINTS);
     }
     // Loop over the participant of the group
     for (final EffectiveParticipantEntity aParticipant : aGroup.getParticipants()) {
       final GroupRankReference theReference = aParticipant.getInitialReference();
       final GroupEntity groupReference = theReference.getGroup();
       final StageEntity stageReference = theReference.getStage();
       final Integer rank = theReference.getRank();
       if (groupReference == null && stageReference == null) {
         // Get the real participant from tournament
         ParticipantEntity realParticipant = null;
         if (isTeam) {
           realParticipant = teamsTournament.get(rank - 1);
         } else {
           realParticipant = playersTournament.get(rank - 1);
         }
         aParticipant.setParticipant(realParticipant);
       } else if (groupReference == null && stageReference != null) {
         // Get from stage
         if (stageReference.getGroups() != null) {
           for (final GroupEntity groupReferenceStage : stageReference.getGroups()) {
             final List<EffectiveParticipantEntity> participants =
                 groupReferenceStage.getParticipants();
             for (final EffectiveParticipantEntity previousParticipant : participants) {
               final Integer finalRankStage =
                   previousParticipant.getFinalRankStage() != null
                       ? previousParticipant.getFinalRankStage()
                       : 0;
               if (finalRankStage == rank) {
                 aParticipant.setParticipant(previousParticipant.getParticipant());
                 break;
               }
             }
           }
         }
       } else {
         // Get from group
         final List<EffectiveParticipantEntity> participants = groupReference.getParticipants();
         for (final EffectiveParticipantEntity previousParticipant : participants) {
           final Integer finalRank =
               previousParticipant.getFinalRank() != null ? previousParticipant.getFinalRank() : 0;
           if (finalRank == rank) {
             aParticipant.setParticipant(previousParticipant.getParticipant());
             break;
           }
         }
       }
     }
   } else {
     final GroupEntity emptyGroup = new GroupEntity();
     emptyGroup.setParticipants(new ArrayList<EffectiveParticipantEntity>());
     return emptyGroup;
   }
   return aGroup;
 }
 @RequestMapping(value = "/manager/teams/{id}/games", method = RequestMethod.GET)
 public String getGames(@PathVariable("id") long id, Model model) {
   Team team = teamService.find(id);
   model.addAttribute("team", team);
   return "games";
 }
 @RequestMapping(value = "/manager/teams/add", method = RequestMethod.POST)
 public String addTeam(@ModelAttribute("Team") Team team) {
   Team savedteam = teamService.save(team, facebook.userOperations().getUserProfile());
   return "redirect:/manager/teams/" + savedteam.getId();
 }
 @RequestMapping(value = "/player/teams/join", method = RequestMethod.POST)
 public String joinTeam(@ModelAttribute("Team") Team myTeam, Model model) {
   FacebookProfile userProfile = facebook.userOperations().getUserProfile();
   Team team = teamService.joinPlayer(userProfile, myTeam);
   return "redirect:/player/games";
 }
 @RequestMapping(value = "/manager/games/{id}/edit", method = RequestMethod.GET)
 public String findGame(@PathVariable("id") long id, Model model) {
   Game game = teamService.getGame(id);
   model.addAttribute("game", game);
   return "editgame";
 }
 @RequestMapping(value = "/manager/games/{id}/editgame", method = RequestMethod.POST)
 public String editGame(@ModelAttribute("game") Game game, Model model) {
   teamService.saveGame(game);
   return "redirect:/manager/teams/" + game.getTeam().getId() + "/games";
 }