示例#1
0
  @Override
  public Boolean addGame(
      String campusSession, String nameGame, int idGame, int idCategory, Date creationDate) {
    try {
      // Add the game if user exists, game does not exists, there is a name, there is a creation
      // date and category exists
      if (sBo.validateSession(campusSession) != null
          && gDao.getGame(idGame) == null
          && cDao.getCategory(idCategory) != null
          && gDao.getGameByName(nameGame) == null
          && !nameGame.equals("")) {
        Game objGame = new Game();
        objGame.setIdGame(idGame);
        objGame.setName(nameGame);
        objGame.setPublicAcces(1);
        objGame.setSecretGame(Security.getIdGame());
        objGame.setPrivateKey(Security.getIdSession());
        objGame.setIdCategory(idCategory);
        objGame.setCreationDate(creationDate);

        gDao.addGame(objGame);
      } else return false;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }
示例#2
0
 @Override
 public Boolean delGame(String campusSession, int idGame) {
   try {
     if (sBo.validateSession(campusSession) != null) {
       // TODO Delete all dependencies: comments, tags, likeGames, instances, records...
       Game objGame = gDao.getGame(idGame);
       gDao.delGame(objGame);
     }
   } catch (Exception e) {
     e.printStackTrace();
     return false;
   }
   return true;
 }
示例#3
0
  @Override
  public List<Game> listGames(String campusSession) {

    if (sBo.validateSession(campusSession) != null) {
      return gDao.getAllGames();
    }

    return null;
  }
示例#4
0
  @Override
  public Game getGame(String idGame, String campusSession) {
    Game objGame = null;

    try {
      if (Security.isIdGame(idGame)) objGame = gDao.getGameUid(idGame);
      else {
        if (sBo.validateSession(campusSession) != null) {
          objGame = gDao.getGame(Integer.parseInt(idGame));
        } else {
          return null;
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
    return objGame;
  }
示例#5
0
  @Override
  public List<Game> listUserGames(String username, String campusSession) {

    if (sBo.validateSession(campusSession) != null) {
      return gDao.getUserGames(username);
    }

    List<Game> list = new ArrayList<Game>();
    Game game = new Game();
    game.setIdGame(1);
    list.add(game);
    return list;
  }
示例#6
0
  @Override
  public Boolean addGame(String campusSession, String nameGame, int idGame) {
    try {
      if (sBo.validateSession(campusSession) != null) {
        Game objGame = new Game();
        objGame.setIdGame(idGame);
        objGame.setName(nameGame);
        objGame.setPublicAcces(1);
        objGame.setSecretGame(Security.getIdGame());
        objGame.setPrivateKey(Security.getIdSession());

        gDao.addGame(objGame);
      }
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }
示例#7
0
 @Override
 public List<GameUserBelonging> getPlayingUsers(int idGame) {
   return gDao.getPlayingUsers(idGame);
 }