Example #1
0
  /**
   * @param ambienteApp
   * @param nombreApp
   * @param usuarioDTO
   * @return
   */
  public UsuarioDTO load(String mail, String pass, String nombreApp, String ambienteApp) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      conn = super.getConnectionMySql();
      ps = conn.prepareStatement(SQL_SELECT_MAIL_PASSWORD);

      ps.setString(1, mail);
      ps.setString(2, pass);
      /**
       * TODO verificar si la busqueda de un usuario se debe o no incluir el ambiente para empalmar
       * los usuario que ocupan distintas aplicaciones y mantenterlos como un mismo usuario
       */
      rs = ps.executeQuery();

      UsuarioDTO bs = new UsuarioDTO();
      if (rs.next()) {

        bs.setMail(rs.getString("mail"));
        bs.setPassword(rs.getString("password"));
        bs.setAutomobil(rs.getString("automobil"));
        bs.setModelo(rs.getString("modelo"));
        bs.setAnioAuto(rs.getInt("anio_auto"));
        bs.setNombre(rs.getString("nombre"));
        bs.setApellido(rs.getString("apellido"));
        bs.setRut(rs.getString("rut"));
        bs.setDv(rs.getString("dv"));

        bs.setFechaNacimiento(rs.getDate("fecha_nacimiento"));
        bs.setFechaInscripcion(rs.getTimestamp("fecha_inscripcion"));
        bs.setKeyAppMobil(rs.getString("key_app_mobil"));

        AppsDTO appsDTO = new AppsDTO();
        appsDTO.setNombreApp(rs.getString("fk_nombre_app"));
        appsDTO.setAmbienteApp(rs.getString("fk_ambiente_app"));

        bs.setConfirmaEnvioMails(rs.getBoolean("confirma_envio_mails"));
      }
      return bs;

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      close(rs, ps, conn);
    }
    return null;
  }
Example #2
0
  /** @return */
  public HashSet<UsuarioDTO> loadAll() {

    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
      conn = super.getConnectionMySql();
      ps = conn.prepareStatement(SQL_SELECT_ALL);
      rs = ps.executeQuery();

      HashSet<UsuarioDTO> hs = new HashSet<UsuarioDTO>();
      while (rs.next()) {

        UsuarioDTO bs = new UsuarioDTO();

        bs.setMail(rs.getString("mail"));
        bs.setPassword(rs.getString("password"));
        bs.setAutomobil(rs.getString("automobil"));
        bs.setModelo(rs.getString("modelo"));
        bs.setAnioAuto(rs.getInt("anio_auto"));
        bs.setNombre(rs.getString("nombre"));
        bs.setApellido(rs.getString("apellido"));
        bs.setRut(rs.getString("rut"));
        bs.setDv(rs.getString("dv"));

        bs.setFechaNacimiento(rs.getDate("fecha_nacimiento"));
        bs.setFechaInscripcion(rs.getTimestamp("fecha_inscripcion"));
        bs.setKeyAppMobil(rs.getString("key_app_mobil"));

        AppsDTO appsDTO = new AppsDTO();
        appsDTO.setNombreApp(rs.getString("fk_nombre_app"));
        appsDTO.setAmbienteApp(rs.getString("fk_ambiente_app"));

        bs.setConfirmaEnvioMails(rs.getBoolean("confirma_envio_mails"));

        hs.add(bs);
      }
      return hs;

    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      close(rs, ps, conn);
    }
    return null;
  }