Exemplo n.º 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;
  }
Exemplo n.º 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;
 }
Exemplo n.º 3
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;
  }