Package labsis.usuario.model

Examples of labsis.usuario.model.Usuario


    return false;
  }

  @Override
  public boolean delete(Object o) throws SQLException {
    Usuario u = (Usuario) o;
    PreparedStatement st = conn
        .prepareStatement("delete from logusuario where username = ?");
    st.setString(1, u.getUsername());
    st.executeUpdate();
    st = conn.prepareStatement("delete from usuario where username = ?");
    st.setString(1, u.getUsername());
    if (st.executeUpdate() <= 0)
      return false;
    return true;
  }
View Full Code Here


      ResultSet op = st.executeQuery();
      HashSet<Operacao> operacoes = new HashSet<Operacao>();
      while (op.next()) {
        operacoes.add(new Operacao(op.getInt(1), op.getString(2),r.getString(3)));
      }
      l.add(new Usuario(r.getString(1), r.getString(2), r.getString(3),
          new TipoUsuario(r.getInt(4), r.getString(5), operacoes)));
    }
    return l;
  }
View Full Code Here

    return l;
  }

  @Override
  public boolean update(Object o) throws SQLException {
    Usuario u = (Usuario) o;
    PreparedStatement st = conn
        .prepareStatement("update usuario set nome = ?, senha = ?, tipousuarioId = ? where username = ?");
    st.setString(1, u.getNome());
    st.setString(2, u.getSenha());
    st.setInt(3, u.getTipoUsuario().getId());
    st.setString(4, u.getUsername());
    if (st.executeUpdate() > 0)
      return true;
    return false;
  }
View Full Code Here

      conn.close();
  }

  @Override
  public Object find(Object primaryKey) throws SQLException {
    Usuario u = null;
    PreparedStatement st = conn
        .prepareStatement("select u.username, u.senha, u.nome, t.id ,t.descricao from usuario u join tipousuario t on u.tipousuarioId = t.id where username = ? order by u.username");
    st.setString(1, primaryKey.toString());
    ResultSet r = st.executeQuery();
    if (r.next()) {
      st = conn
          .prepareStatement("select o.id, o.descricao, o.comando from tipousuariooperacoes uo join operacao o on uo.operacaoId = o.id where uo.tipousuarioId = ?");
      st.setInt(1, r.getInt(4));
      ResultSet op = st.executeQuery();
      HashSet<Operacao> operacoes = new HashSet<Operacao>();
      while (op.next()) {
        operacoes.add(new Operacao(op.getInt(1), op.getString(2),op.getString(3)));
      }
      u = new Usuario(r.getString(1), r.getString(2), r.getString(3),
          new TipoUsuario(r.getInt(4), r.getString(5), operacoes));
    }
    return u;
  }
View Full Code Here

      ResultSet op = st.executeQuery();
      HashSet<Operacao> operacoes = new HashSet<Operacao>();
      while (op.next()) {
        operacoes.add(new Operacao(op.getInt(1), op.getString(2),r.getString(3)));
      }
      l.add(new Usuario(r.getString(2), r.getString(3), r.getString(4),
          new TipoUsuario(r.getInt(5), r.getString(6), operacoes)));
    }
    st = conn
        .prepareStatement("select ((count(*) - 1) / ? ) + 1 from usuario");
    st.setInt(1, rowsPerPage);
View Full Code Here

    PreparedStatement st = conn
        .prepareStatement("select l.id, o.descricao, u.nome, l.data, o.comando from logusuario l join operacao o on l.operacaoId=o.id join usuario u on l.username = u.username");
    ResultSet r = st.executeQuery();
    while (r.next()) {
      l.add(new LogUsuario(r.getInt(1), new Operacao(0, r.getString(2),r.getString(5)),
          new Usuario("", "", r.getString(3), null), r.getTimestamp(4)));
    }
    return l;
  }
View Full Code Here

    st.setInt(3, pageNum);
    st.setInt(4, rowsPerPage);
    ResultSet r = st.executeQuery();
    while (r.next()) {
      l.add(new LogUsuario(r.getInt(2), new Operacao(0, r.getString(3),r.getString(6)),
          new Usuario("", "", r.getString(4), null), r.getTimestamp(5)));
    }
    st = conn.prepareStatement("select ((count(*) - 1) / ? ) + 1 from logusuario");
    st.setInt(1, rowsPerPage);
    ResultSet t = st.executeQuery();
    if(t.next())l.add(new Integer(t.getInt(1)));
View Full Code Here

TOP

Related Classes of labsis.usuario.model.Usuario

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.