Package user

Examples of user.User


      return rep.get(0);
    return null;
  }

  public User subscribe(String mail, String pseudo, String password) {
    User user = new User(mail, pseudo, password);
    if(create(user))
      return findOne(mail);
    return null;
  }
View Full Code Here


    }
    return null;
  }

  public Boolean addBetToUser(Pari pari, String mail){
    User user = findOne(mail);
    if(user == null){
      return false;
    }
    if(user.getPoints() - pari.getMontant() >= 0){
      Session session = HibernateUtil.openSession();
      Transaction tr = null;
      try{
        tr = session.beginTransaction();
       
        /*Hibernate.initialize(user.getParis());*/
       
        pari.setUser(user);
        user.addPari(pari);
        user.setNbParisTotal(user.getNbParisTotal() + 1);
        user.setPoints(user.getPoints() - pari.getMontant());
        session.update(user);
        tr.commit();
        return true;
      }catch (Exception e) {
        tr.rollback();
View Full Code Here

    }
  }


  public Boolean delBetToUser(Pari pari, String mail){
    User user = findOne(mail);
    if(user == null){
      return false;
    }
    Session session = HibernateUtil.openSession();
    Transaction tr = null;
    try{
      tr = session.beginTransaction();
      // ajout dans les pariHistorique avant de supprimer le pari
      PariHistorique pariHisto = new PariHistorique(pari, user.getId_user(), pari.getId_train().getStationDUA(),
          pari.getId_train().getNum_TheoricalTrainData());

      session.save(pariHisto);
      // supression du pari chez le user mais avant je check si je le credite ou pas d'un montant
      if(pari.getEtatPari() == 1){
        user.setNbParisJustes(user.getNbParisJustes() +1);
        user.setScore(user.getScore() + pari.getGainPossible());
        user.setPoints(user.getPoints() + pari.getGainPossible());

      }
      user.dellPari(pari);
      session.update(user);

      tr.commit();
      return true;
    }catch (Exception e) {
View Full Code Here

    }
    return true;
  }
 
  public List<User> getFriends(String mail){
    User user = findOne(mail);
    List<User> rep = new ArrayList<User>();
    for(int i = 0; i < user.friendship.size(); i++){
      if(user.friendship.get(i).getOwner().equals(user)){
        rep.add(user.friendship.get(i).getTarget());
      }else{
View Full Code Here

    return null;
  }
 
  public Boolean newFriend(String mail_owner, String mail_target){
   
    User target = findOne(mail_target);
   
    Session session = HibernateUtil.openSession();
    Transaction tr = null;;
    try{
      tr = session.beginTransaction();
      User owner = findOne(mail_owner);
      /*Hibernate.initialize(owner.getFriends());*/
      owner.addFriend(new Friendship(owner, target, 0));
      session.update(owner);
      tr.commit();
    }catch (Exception e) {
      tr.rollback();
      e.printStackTrace();
View Full Code Here

  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("html");
    DaoUser dao = new DaoUser();
    User user = dao.login(request.getParameter("mail"), request.getParameter("password"));
    if(user != null) {
      request.getSession().setAttribute("user", user);
    }
    else {
      response.setStatus(599);
View Full Code Here

  //@SuppressWarnings("unchecked")
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("json");
    PrintWriter out = response.getWriter();
    User user = (User) request.getSession().getAttribute("user");
    List<Pari> paris = user.getParis();
    DaoPariHistorique daoParisHistorique = new DaoPariHistorique();
    List<PariHistorique> paris_historique = daoParisHistorique.getBetsHistory(user.getMail());
    List<List<Paris_S>> json = new ArrayList<List<Paris_S>>();
    if(paris != null && !paris.isEmpty()) {
      List<GareSelection> selection = (List<GareSelection>) request.getAttribute("gares_selection");
      List<Paris_S> json_p = new ArrayList<Paris_S>();
      for(Pari p : paris) {
View Full Code Here

  @Override
  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("html");
    DaoUser dao = new DaoUser();
    User user = dao.subscribe(request.getParameter("mail"), request.getParameter("pseudo"), request.getParameter("password"));
    if(user != null) {
      request.getSession().setAttribute("user", user);
    }
    else {
      response.setStatus(599);
View Full Code Here

  }

  public void update(List<GareSelection> gs, PariHistorique p) {
    if(p != null) {
      user_id = p.getId_owner();
      User u = new DaoUser().findWithId(user_id);
     
     
      mise = p.getMontant();
      min_retard = p.getMinRetard();
      gain_potentiel = p.getGain();
View Full Code Here

        Employee e1 = new Employee();
        Employee e2 = new Employee();
       
        e1.setId(45);
        User user = new User("baba","baba","ho");
        /*
        user.setMail("freggg");
        user.setNbParisJustes(5);*/
        session.save(user);
View Full Code Here

TOP

Related Classes of user.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.