diff --git a/.gitignore b/.gitignore index b3a52f7..2936e6b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ target/ *.iws *.iml *.ipr - +/encodings.xml ### Eclipse ### .apt_generated .classpath diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index aa00ffa..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/DataBase.java b/src/main/java/com/roshka/proyectofinal/DataBase.java index 12d2450..f2c742e 100644 --- a/src/main/java/com/roshka/proyectofinal/DataBase.java +++ b/src/main/java/com/roshka/proyectofinal/DataBase.java @@ -11,7 +11,7 @@ public class DataBase { Class.forName("org.postgresql.Driver"); con= DriverManager .getConnection("jdbc:postgresql://localhost:5432/bootcamp_th", - "postgres", "postgres"); + "postgres", "2022roshka"); if(con != null){ System.out.println("---> CONNECTED TO SERVER"); diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java index 5bc30e5..055fcce 100644 --- a/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java +++ b/src/main/java/com/roshka/proyectofinal/Postulante/PostulanteDao.java @@ -1,7 +1,6 @@ package com.roshka.proyectofinal.Postulante; import com.roshka.proyectofinal.DataBase; import com.roshka.proyectofinal.entity.Postulante; - import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -9,245 +8,247 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -public class PostulanteDao { - List postulante = null; + public class PostulanteDao { + public static int save(Postulante postulante) { + int status = 0; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement( + "insert into postulante(nombre,apellido,nro_cedula,correo,telefono,direccion,experiencia_laboral,estudio_universitario,notebook,bootcamp_id,aceptado) values (?,?,?,?,?,?,?,?,?,?,?)"); + ps.setString(1, postulante.getNombre()); + ps.setString(2, postulante.getApellido()); + ps.setInt(3, postulante.getNro_cedula()); + ps.setString(4, postulante.getCorreo()); + ps.setString(5, postulante.getTelefono()); + ps.setString(6, postulante.getDireccion()); + ps.setBoolean(7, postulante.getExpLaboral()); + ps.setBoolean(8, postulante.getEstudioUniversitario()); + ps.setBoolean(9, postulante.getNotebook()); + ps.setInt(10, postulante.getBootcampId()); + ps.setBoolean(11, postulante.getAceptado()); + status = ps.executeUpdate(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } - public static int save(Postulante postulante){ - int status=0; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement( - "insert into postulante(nombre,apellido,nro_cedula,correo,telefono,direccion,experiencia_laboral,estudio_universitario,notebook,bootcamp_id,aceptado) values (?,?,?,?,?,?,?,?,?,?,?)"); - ps.setString(1,postulante.getNombre()); - ps.setString(2,postulante.getApellido()); - ps.setInt(3,postulante.getNro_cedula()); - ps.setString(4,postulante.getCorreo()); - ps.setString(5,postulante.getTelefono()); - ps.setString(6,postulante.getDireccion()); - ps.setBoolean(7,postulante.getExpLaboral()); - ps.setBoolean(8,postulante.getEstudioUniversitario()); - ps.setBoolean(9,postulante.getNotebook()); - ps.setInt(10,postulante.getBootcampId()); - ps.setBoolean(11,postulante.getAceptado()); - status=ps.executeUpdate(); - con.close(); - }catch(Exception ex){ex.printStackTrace();} + return status; + } - return status; - } + public static List listarPostulante() { + List postulante = new ArrayList<>(); + String sql = "select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, a.telefono, a.direccion, " + + "a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, c.nombre_lenguaje as bootcamp, \n" + + "a.aceptado from postulante a\n" + + " inner join bootcamp b on b.id= a.bootcamp_id\n" + + " inner join lenguaje c on c.id=b.id_lenguaje\n" + + " order by a.id;"; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + Postulante postulanteObject = new Postulante(); + postulanteObject.setId(rs.getInt("id")); + postulanteObject.setNombre(rs.getString("nombre")); + postulanteObject.setApellido(rs.getString("apellido")); + postulanteObject.setNroCedula(rs.getInt("nro_cedula")); + postulanteObject.setCorreo(rs.getString("correo")); + postulanteObject.setTelefono(rs.getString("telefono")); + postulanteObject.setDireccion(rs.getString("direccion")); + postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); + postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); + postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); + postulanteObject.setNotebook(rs.getBoolean("notebook")); + postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); + postulanteObject.setAceptado(rs.getBoolean("aceptado")); + postulante.add(postulanteObject); + } - public static List listarPostulante(){ - List postulante = new ArrayList<>(); - String sql = "select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, a.telefono, a.direccion, " + - "a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, c.nombre_lenguaje as bootcamp, \n" + - "a.aceptado from postulante a\n" + - " inner join bootcamp b on b.id= a.bootcamp_id\n" + - " inner join lenguaje c on c.id=b.id_lenguaje\n" + - " order by a.id;"; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement(sql); - ResultSet rs = ps.executeQuery(); - while(rs.next()){ - Postulante postulanteObject = new Postulante(); - postulanteObject.setId(rs.getInt("id")); - postulanteObject.setNombre(rs.getString("nombre")); - postulanteObject.setApellido(rs.getString("apellido")); - postulanteObject.setNroCedula(rs.getInt("nro_cedula")); - postulanteObject.setCorreo(rs.getString("correo")); - postulanteObject.setTelefono(rs.getString("telefono")); - postulanteObject.setDireccion(rs.getString("direccion")); - postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); - postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); - postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); - postulanteObject.setNotebook(rs.getBoolean("notebook")); - postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); - postulanteObject.setAceptado(rs.getBoolean("aceptado")); - postulante.add(postulanteObject); + con.close(); + } catch (SQLException e) { + throw new RuntimeException(e); } - - con.close(); - } catch (SQLException e) { - throw new RuntimeException(e); + return postulante; } - return postulante; - } - public static void update(int id, Boolean valor){ - if(valor==true){ - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("update postulante set aceptado= false\n" + - "where id=?"); - ps.setInt(1,id); - ps.executeUpdate(); - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); - } - }else { - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("update postulante set aceptado= true\n" + - "where id=?"); - ps.setInt(1,id); - ps.executeUpdate(); - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); - } - } + public static void update(int id, Boolean valor) { + if (valor == true) { + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("update postulante set aceptado= false\n" + + "where id=?"); + ps.setInt(1, id); + ps.executeUpdate(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } else { + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("update postulante set aceptado= true\n" + + "where id=?"); + ps.setInt(1, id); + ps.executeUpdate(); + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } - } + } - public static List buscarPorNombre(String nombre){ - List postulante = null; - Postulante postulanteObject = null; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + - "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + - "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + - " inner join bootcamp b on b.id= a.bootcamp_id\n" + - " inner join lenguaje c on c.id=b.id_lenguaje\n" + - " where a.nombre ilike ? "); - ps.setString(1, "%" + nombre + "%"); - System.out.println(nombre); - ResultSet rs = ps.executeQuery(); - postulante = new ArrayList<>(); - postulanteObject= new Postulante(); - while(rs.next()){ + public static List buscarPorNombre(String nombre) { + List postulante = null; + Postulante postulanteObject = null; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + + "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + + "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + + " inner join bootcamp b on b.id= a.bootcamp_id\n" + + " inner join lenguaje c on c.id=b.id_lenguaje\n" + + " where a.nombre ilike ? "); + ps.setString(1, "%" + nombre + "%"); + System.out.println(nombre); + ResultSet rs = ps.executeQuery(); + postulante = new ArrayList<>(); + postulanteObject = new Postulante(); + while (rs.next()) { - postulanteObject.setId(rs.getInt("id")); - postulanteObject.setNombre(rs.getString("nombre")); - postulanteObject.setApellido(rs.getString("apellido")); - postulanteObject.setNroCedula(rs.getInt("nro_cedula")); - postulanteObject.setCorreo(rs.getString("correo")); - postulanteObject.setTelefono(rs.getString("telefono")); - postulanteObject.setDireccion(rs.getString("direccion")); - postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); - postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); - postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); - postulanteObject.setNotebook(rs.getBoolean("notebook")); - postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); - postulanteObject.setAceptado(rs.getBoolean("aceptado")); - postulante.add(postulanteObject); + postulanteObject.setId(rs.getInt("id")); + postulanteObject.setNombre(rs.getString("nombre")); + postulanteObject.setApellido(rs.getString("apellido")); + postulanteObject.setNroCedula(rs.getInt("nro_cedula")); + postulanteObject.setCorreo(rs.getString("correo")); + postulanteObject.setTelefono(rs.getString("telefono")); + postulanteObject.setDireccion(rs.getString("direccion")); + postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); + postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); + postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); + postulanteObject.setNotebook(rs.getBoolean("notebook")); + postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); + postulanteObject.setAceptado(rs.getBoolean("aceptado")); + postulante.add(postulanteObject); + } + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); } - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); + return postulante; } - return postulante; - } - public static List listarPostulanteAceptados(){ - List postulante = null; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + - "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + - "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + - " inner join bootcamp b on b.id= a.bootcamp_id\n" + - " inner join lenguaje c on c.id=b.id_lenguaje\n" + - " where a.aceptado= true "); - ResultSet rs = ps.executeQuery(); - postulante = new ArrayList<>(); - Postulante postulanteObject= new Postulante(); - while(rs.next()){ - postulanteObject.setId(rs.getInt("id")); - postulanteObject.setNombre(rs.getString("nombre")); - postulanteObject.setApellido(rs.getString("apellido")); - postulanteObject.setNroCedula(rs.getInt("nro_cedula")); - postulanteObject.setCorreo(rs.getString("correo")); - postulanteObject.setTelefono(rs.getString("telefono")); - postulanteObject.setDireccion(rs.getString("direccion")); - postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); - postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); - postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); - postulanteObject.setNotebook(rs.getBoolean("notebook")); - postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); - postulanteObject.setAceptado(rs.getBoolean("aceptado")); - postulante.add(postulanteObject); + public static List listarPostulanteAceptados() { + List postulante = null; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + + "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + + "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + + " inner join bootcamp b on b.id= a.bootcamp_id\n" + + " inner join lenguaje c on c.id=b.id_lenguaje\n" + + " where a.aceptado= true "); + ResultSet rs = ps.executeQuery(); + postulante = new ArrayList<>(); + Postulante postulanteObject = new Postulante(); + while (rs.next()) { + postulanteObject.setId(rs.getInt("id")); + postulanteObject.setNombre(rs.getString("nombre")); + postulanteObject.setApellido(rs.getString("apellido")); + postulanteObject.setNroCedula(rs.getInt("nro_cedula")); + postulanteObject.setCorreo(rs.getString("correo")); + postulanteObject.setTelefono(rs.getString("telefono")); + postulanteObject.setDireccion(rs.getString("direccion")); + postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); + postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); + postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); + postulanteObject.setNotebook(rs.getBoolean("notebook")); + postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); + postulanteObject.setAceptado(rs.getBoolean("aceptado")); + postulante.add(postulanteObject); + } + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); } - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); + return postulante; } - return postulante; - } - public static List listarPorBootcamp(String nombre){ - List postulante = null; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, a.telefono, a.direccion, \n" + - " a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, c.nombre_lenguaje as bootcamp, \n" + - " a.aceptado from postulante a\n" + - " inner join bootcamp b on b.id= a.bootcamp_id\n" + - " inner join lenguaje c on c.id=b.id_lenguaje\n" + - " where c.nombre_lenguaje ilike ? "); - ps.setString(1, "%" + nombre + "%"); - ResultSet rs = ps.executeQuery(); - postulante = new ArrayList<>(); - Postulante postulanteObject= new Postulante(); - while(rs.next()){ - postulanteObject.setId(rs.getInt("id")); - postulanteObject.setNombre(rs.getString("nombre")); - postulanteObject.setApellido(rs.getString("apellido")); - postulanteObject.setNroCedula(rs.getInt("nro_cedula")); - postulanteObject.setCorreo(rs.getString("correo")); - postulanteObject.setTelefono(rs.getString("telefono")); - postulanteObject.setDireccion(rs.getString("direccion")); - postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); - postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); - postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); - postulanteObject.setNotebook(rs.getBoolean("notebook")); - postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); - postulanteObject.setAceptado(rs.getBoolean("aceptado")); - postulante.add(postulanteObject); + public static List listarPorBootcamp(String nombre) { + List postulante = null; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, a.telefono, a.direccion, \n" + + " a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, c.nombre_lenguaje as bootcamp, \n" + + " a.aceptado from postulante a\n" + + " inner join bootcamp b on b.id= a.bootcamp_id\n" + + " inner join lenguaje c on c.id=b.id_lenguaje\n" + + " where c.nombre_lenguaje ilike ? "); + ps.setString(1, "%" + nombre + "%"); + ResultSet rs = ps.executeQuery(); + postulante = new ArrayList<>(); + Postulante postulanteObject = new Postulante(); + while (rs.next()) { + postulanteObject.setId(rs.getInt("id")); + postulanteObject.setNombre(rs.getString("nombre")); + postulanteObject.setApellido(rs.getString("apellido")); + postulanteObject.setNroCedula(rs.getInt("nro_cedula")); + postulanteObject.setCorreo(rs.getString("correo")); + postulanteObject.setTelefono(rs.getString("telefono")); + postulanteObject.setDireccion(rs.getString("direccion")); + postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); + postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); + postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); + postulanteObject.setNotebook(rs.getBoolean("notebook")); + postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); + postulanteObject.setAceptado(rs.getBoolean("aceptado")); + postulante.add(postulanteObject); + } + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); } - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); + return postulante; } - return postulante; - } - public static List buscarPorNoteBook(){ - List postulante = null; - Postulante postulanteObject = null; - try{ - Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + - "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + - "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + - " inner join bootcamp b on b.id= a.bootcamp_id\n" + - " inner join lenguaje c on c.id=b.id_lenguaje\n" + - " where a.notebook=true "); - ResultSet rs = ps.executeQuery(); - postulante = new ArrayList<>(); - postulanteObject= new Postulante(); - while(rs.next()){ + public static List buscarPorNoteBook() { + List postulante = null; + Postulante postulanteObject = null; + try { + Connection con = DataBase.getConnection(); + PreparedStatement ps = con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo, " + + "a.telefono, a.direccion, a.experiencia_laboral, a.estudio_universitario, a.bootcamp_id, a.notebook, " + + "c.nombre_lenguaje as bootcamp, \n" + "a.aceptado from postulante a\n" + + " inner join bootcamp b on b.id= a.bootcamp_id\n" + + " inner join lenguaje c on c.id=b.id_lenguaje\n" + + " where a.notebook=true "); + ResultSet rs = ps.executeQuery(); + postulante = new ArrayList<>(); + postulanteObject = new Postulante(); + while (rs.next()) { - postulanteObject.setId(rs.getInt("id")); - postulanteObject.setNombre(rs.getString("nombre")); - postulanteObject.setApellido(rs.getString("apellido")); - postulanteObject.setNroCedula(rs.getInt("nro_cedula")); - postulanteObject.setCorreo(rs.getString("correo")); - postulanteObject.setTelefono(rs.getString("telefono")); - postulanteObject.setDireccion(rs.getString("direccion")); - postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); - postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); - postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); - postulanteObject.setNotebook(rs.getBoolean("notebook")); - postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); - postulanteObject.setAceptado(rs.getBoolean("aceptado")); - postulante.add(postulanteObject); + postulanteObject.setId(rs.getInt("id")); + postulanteObject.setNombre(rs.getString("nombre")); + postulanteObject.setApellido(rs.getString("apellido")); + postulanteObject.setNroCedula(rs.getInt("nro_cedula")); + postulanteObject.setCorreo(rs.getString("correo")); + postulanteObject.setTelefono(rs.getString("telefono")); + postulanteObject.setDireccion(rs.getString("direccion")); + postulanteObject.setExpLaboral(rs.getBoolean("experiencia_laboral")); + postulanteObject.setEstudioUniversitario(rs.getBoolean("estudio_universitario")); + postulanteObject.setBootcampId(rs.getInt("bootcamp_id")); + postulanteObject.setNotebook(rs.getBoolean("notebook")); + postulanteObject.setNombreBootcamp(rs.getString("bootcamp")); + postulanteObject.setAceptado(rs.getBoolean("aceptado")); + postulante.add(postulanteObject); + } + con.close(); + } catch (Exception ex) { + ex.printStackTrace(); } - con.close(); - }catch(Exception ex){ - ex.printStackTrace(); + return postulante; } - return postulante; } -} + + diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java index 45e5814..211b1b8 100644 --- a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java +++ b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java @@ -3,6 +3,7 @@ package com.roshka.proyectofinal.Postulante; import com.roshka.proyectofinal.DataBase; import com.roshka.proyectofinal.entity.Postulante; import com.roshka.proyectofinal.entity.Bootcamp; +import com.roshka.proyectofinal.entity.PostulanteLenguaje; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; @@ -15,57 +16,66 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; - @WebServlet("/SaveServlet") public class SaveServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); - PrintWriter out=response.getWriter(); + PrintWriter out = response.getWriter(); boolean rechazarDatos = false; - int bootcampActual = 3; + int bootcampActual = Integer.parseInt(request.getParameter("bootcamp_id")); try { Connection con = DataBase.getConnection(); - // Statement stmt = con.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT correo,bootcamp_id FROM postulante WHERE postulante.bootcamp_id =" + bootcampActual); - // - String nombre=request.getParameter("nombre"); - String apellido=request.getParameter("apellido"); - int cedula=Integer.parseInt(request.getParameter("cedula")); - String correo=request.getParameter("correo"); - //BUCLE PARA VERIFICAR EL CORREO EN EL BOOTCAMP ACTUAL - while (rs.next()){ - String correoBase =rs.getString("correo"); + ResultSet rs = stmt.executeQuery( + "SELECT correo,bootcamp_id FROM postulante WHERE postulante.bootcamp_id =" + bootcampActual); + + String nombre = request.getParameter("nombre"); + String apellido = request.getParameter("apellido"); + int cedula = Integer.parseInt(request.getParameter("cedula")); + String correo = request.getParameter("correo"); + // BUCLE PARA VERIFICAR EL CORREO EN EL BOOTCAMP ACTUAL + while (rs.next()) { + String correoBase = rs.getString("correo"); int bootcampIdBase = rs.getInt("bootcamp_id"); - if(correo.equals(correoBase) && (bootcampIdBase==bootcampActual)){ + if (correo.equals(correoBase) && (bootcampIdBase == bootcampActual)) { rechazarDatos = true; } } - String telefono=request.getParameter("telefono"); - String direccion=request.getParameter("direccion"); - boolean experienciaProgramando = false; + rs = stmt.executeQuery("SELECT * FROM lenguaje"); + int contador = 0; + while (rs.next()) { + String nombreLenguaje = rs.getString("nombre_lenguaje"); + if (request.getParameter(nombreLenguaje) != null) { + contador++; + } + } + if (contador == 0) { + rechazarDatos = true; + } + String telefono = request.getParameter("telefono"); + String direccion = request.getParameter("direccion"); boolean experienciaLaboral = false; boolean universidad = false; boolean notebook = false; - if (request.getParameter("experiencia_laboral") != null){ + if (request.getParameter("experiencia_laboral") != null) { experienciaLaboral = true; } - if (request.getParameter("experiencia_programando") != null) { - experienciaProgramando = true; - } - if (request.getParameter("notebook") != null){ + if (request.getParameter("notebook") != null) { notebook = true; } - if (request.getParameter("universidad") != null){ + if (request.getParameter("universidad") != null) { universidad = true; } - Bootcamp bootcamp = new Bootcamp(); - Postulante postulante=new Postulante(); - //SI LOS DATOS SON CORRECTOS NO SE RECHAZAN ENTONCES CARGA A LA BASE - if (!rechazarDatos){ + + Postulante postulante = new Postulante(); + PostulanteLenguaje cargarLenguaje = new PostulanteLenguaje(); + int status = 0; + int statusLenguaje = 0; + // SI LOS DATOS SON CORRECTOS NO SE RECHAZAN ENTONCES CARGA A LA BASE + if (!rechazarDatos) { postulante.setNombre(nombre); postulante.setApellido(apellido); postulante.setNro_cedula(cedula); @@ -77,35 +87,53 @@ public class SaveServlet extends HttpServlet { postulante.setNotebook(notebook); postulante.setBootcampId(bootcampActual); postulante.setAceptado(false); + status = PostulanteDao.save(postulante); + + rs = stmt.executeQuery("SELECT id FROM postulante WHERE postulante.nro_cedula=" + cedula + + " AND postulante.bootcamp_id=" + bootcampActual + " ORDER BY id DESC LIMIT 1"); + int idUltimoPostulante = 0; + while (rs.next()) { + idUltimoPostulante = rs.getInt("id"); + } + rs = stmt.executeQuery("SELECT * FROM lenguaje"); + while (rs.next()) { + int idLenguaje = rs.getInt("id"); + String nombreLenguaje = rs.getString("nombre_lenguaje"); + if (request.getParameter(nombreLenguaje) != null) { + cargarLenguaje.setIdLenguaje(idLenguaje); + cargarLenguaje.setIdPostulante(idUltimoPostulante); + statusLenguaje = PostulanteLenguajeDao.save(cargarLenguaje); + } + } } - int status=PostulanteDao.save(postulante); - if(status>0){ - //out.print("

Record saved successfully!

"); - out.print("
\n" + - " × \n" + - " Formulario Cargado! EXITOSAMENTE CARGADO\n" + + if (status > 0) { + // out.print("

Record saved successfully!

"); + out.print("
\n" + + " × \n" + + + " Formulario Cargado! EXITOSAMENTE CARGADO\n" + + "
"); + request.getRequestDispatcher("formulario.jsp").include(request, response); + } else { + if (rechazarDatos) { + out.print("
\n" + + " × \n" + + + " Formulario ya Cargado! YA EXISTE EL FORMULARIO\n" + + "
"); + request.getRequestDispatcher("formulario.jsp").include(request, response); + } else { + out.println("Error al cargar datos"); + out.print("
\n" + + " × \n" + + + " Formulario ya Cargado! YA EXISTE EL FORMULARIO\n" + "
"); request.getRequestDispatcher("formulario.jsp").include(request, response); - }else{ - if (rechazarDatos){ - - out.print("
\n" + - " × \n" + - " Formulario ya Cargado! YA EXISTE EL FORMULARIO\n" + - "
"); - request.getRequestDispatcher("formulario.jsp").include(request, response); - }else { - out.println("Error al cargar datos"); - out.print("
\n" + - " × \n" + - " Formulario ya Cargado! YA EXISTE EL FORMULARIO\n" + - "
"); - request.getRequestDispatcher("formulario.jsp").include(request, response); - } } - - }catch (Exception ex){ - ex.printStackTrace(); + } + } catch (Exception ex) { + ex.printStackTrace(); } out.close(); } diff --git a/src/main/java/com/roshka/proyectofinal/entity/Postulante.java b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java index dd21dc7..2f77c87 100644 --- a/src/main/java/com/roshka/proyectofinal/entity/Postulante.java +++ b/src/main/java/com/roshka/proyectofinal/entity/Postulante.java @@ -44,9 +44,34 @@ public class Postulante { this.aceptado = aceptado; } + public int getNroCedula() { + return nroCedula; + } + + public String getNombreBootcamp() { + return nombreBootcamp; + } + + public boolean isExpLaboral() { + return expLaboral; + } + + public boolean isEstudioUniversitario() { + return estudioUniversitario; + } + + public boolean isNotebook() { + return notebook; + } + + public boolean isAceptado() { + return aceptado; + } + public int getId() { return id; } + public int getNro_cedula() { return nroCedula; } @@ -118,35 +143,13 @@ public class Postulante { this.id = id; } - public int getNroCedula() { - return nroCedula; - } - public void setNroCedula(int nroCedula) { this.nroCedula = nroCedula; } - public String getNombreBootcamp() { - return nombreBootcamp; - } - public void setNombreBootcamp(String nombreBootcamp) { this.nombreBootcamp = nombreBootcamp; } - public boolean isExpLaboral() { - return expLaboral; - } - public boolean isEstudioUniversitario() { - return estudioUniversitario; - } - - public boolean isNotebook() { - return notebook; - } - - public boolean isAceptado() { - return aceptado; - } } diff --git a/src/main/webapp/Javascript.js b/src/main/webapp/Javascript.js index e69de29..b40dba6 100644 --- a/src/main/webapp/Javascript.js +++ b/src/main/webapp/Javascript.js @@ -0,0 +1,29 @@ +(function() { + const form = document.querySelector('#agarraunolaputa'); + const checkboxes = form.querySelectorAll('input[type=checkbox]'); + const checkboxLength = checkboxes.length; + const firstCheckbox = checkboxLength > 0 ? checkboxes[0] : null; + + function init() { + if (firstCheckbox) { + for (let i = 0; i < checkboxLength; i++) { + checkboxes[i].addEventListener('change', checkValidity); + } + + checkValidity(); + } + } + + function isChecked() { + for (let i = 0; i < checkboxLength; i++) { + if (checkboxes[i].checked) return true; + } + return false; + } + + function checkValidity() { + const errorMessage = !isChecked() ? 'Debe seleccionar al menos un lenguaje que conozca' : ''; + firstCheckbox.setCustomValidity(errorMessage); + } + init(); +})(); \ No newline at end of file diff --git a/src/main/webapp/bootcamp.html b/src/main/webapp/bootcamp.html deleted file mode 100644 index c05df6a..0000000 --- a/src/main/webapp/bootcamp.html +++ /dev/null @@ -1,204 +0,0 @@ - - - - - - Bootcamp - - - - - - - - - - - - - - - - - - -
-

¿QUE ES UN BOOTCAMP?

-
-
ES UN CAMPO DE ENTRENAMIENTO INTENSIVO Y GRATUITO PARA PRINCIPIANTES QUE YA PROGRAMAN Y QUIEREN SER PARTE DE LA EMPRESA
-
-

¿CUANTOS MESES DURA EL ENTRENAMIENTO Y CUAL ES SU HORARIO?

-
-
AL SER INTENSIVO Y TENIENDO EN CUENTA QUE LOS ASPIRANTES DEBEN FINALIZARLO CON UN CONOCIMIENTO APTO PARA REALIZAR UN PROYECTO DEL ÁREA, SE DA COMO LAPSO DE TIEMPO UN MES CON UN HORARIO DE 8:00 A 18:00 HS
- - -
-
- - - - -
-

REQUISITOS

-
-
- -
-
-

1. DISPOSICION DE TIEMPO

-
-
-
- -
-
-

2. DISPONER DE UNA NOTEBOOK

-
-
-
- -
-
-

3. APROBAR EXAMENES

-
-
-
- -
-
-

4. FIRMAR CARTA DE COMPROMISO

-
-
- - - - - - - -
-

EDICIONES DE BOOTCAMP

- -
- - - - -
- - - -
-
- -
-

BOOTCAMP JAVA

-

Inicio: 18/04/2023

-

Fin: 18/05/2023

-
- -
-
-
- -
-
-Learning Web Design: A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics -
-

BOOTCAMP ANDROID

-

Inicio: 18/06/2023

-

Fin: 18/07/2023

-
- -
-
-
- -
-
- -
-

BOOTCAMP iOS

-

Inicio: 18/08/2023

-

Fin: 18/09/2023

-
- -
-
-
-
- - - - - - - - - - - - diff --git a/src/main/webapp/bootcamp.jsp b/src/main/webapp/bootcamp.jsp new file mode 100644 index 0000000..fbb0800 --- /dev/null +++ b/src/main/webapp/bootcamp.jsp @@ -0,0 +1,562 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" +pageEncoding="UTF-8"%> + <%@ page import="java.sql.*,java.sql.Connection,java.sql.ResultSet,com.roshka.proyectofinal.DataBase"%> + + + + + + + Bootcamp + + + + + + + + + + + + + + + + + + +
+

¿QUE ES UN BOOTCAMP?

+
+
ES UN CAMPO DE ENTRENAMIENTO INTENSIVO Y GRATUITO PARA PRINCIPIANTES QUE YA PROGRAMAN Y QUIEREN SER PARTE DE LA EMPRESA
+
+

¿CUANTOS MESES DURA EL ENTRENAMIENTO Y CUAL ES SU HORARIO?

+
+
AL SER INTENSIVO Y TENIENDO EN CUENTA QUE LOS ASPIRANTES DEBEN FINALIZARLO CON UN CONOCIMIENTO APTO PARA REALIZAR UN PROYECTO DEL ÁREA, SE DA COMO LAPSO DE TIEMPO UN MES CON UN HORARIO DE 8:00 A 18:00 HS
+ + +
+ + + + + + + +
+

REQUISITOS

+
+
+ +
+
+

1. DISPOSICION DE TIEMPO

+
+
+
+ +
+
+

2. DISPONER DE UNA NOTEBOOK

+
+
+
+ +
+
+

3. APROBAR EXAMENES

+
+
+
+ +
+
+

4. FIRMAR CARTA DE COMPROMISO

+
+
+ + + + + + + + + +
+

EDICIONES DE BOOTCAMP

+ +
+ + + + + +
+ <% + Connection con = DataBase.getConnection(); + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM bootcamp WHERE activo=true"); + while(rs.next()){ + %> +
+
+ <%=rs.getString(> +
+

+ <%= rs.getString("titulo") %> +

+

Inicio: + <%=rs.getString("fecha_inicio")%> +

+

Fin: + <%=rs.getString("fecha_fin")%> +

+
+ > + +
+
+
+
+ <% + } + %> +
+ + + + + + + + + + + \ No newline at end of file diff --git a/src/main/webapp/formulario.jsp b/src/main/webapp/formulario.jsp index 205093e..92aed46 100644 --- a/src/main/webapp/formulario.jsp +++ b/src/main/webapp/formulario.jsp @@ -1,101 +1,138 @@ - <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> - - - - - - - - - - - Formulario Postulante - - - -
- -
-
-
-
-

Si sigues interesado y cumples con los requisitos, completa el siguiente formulario:

- -
- - -
- - -
- - -
- - -
- - -
- - -
- - - <%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %> - + <%@ page import="java.sql.*,java.sql.Connection,java.sql.ResultSet,com.roshka.proyectofinal.DataBase,jakarta.servlet.http.HttpServlet,jakarta.servlet.http.HttpServletRequest"%> + + + + + + + + + + + + + + + Formulario Postulante + + + + +
+ +
+
+
+
<% - LenguajeDao lenDao = new LenguajeDao(); - List listLenguaje = lenDao.listar(); - Iterator iter = listLenguaje.iterator(); - Lenguaje len = null; - - - %> -
    - <% while(iter.hasNext()){ - len = iter.next(); - + int id =Integer.parseInt(request.getParameter("bootcamp")); + Connection con = DataBase.getConnection(); + Statement stmt = con.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM bootcamp WHERE id= "+id+ " LIMIT 1" ); + rs.next(); %> -
  • - id= - <%=len.getNombre_lenguaje() %> name= - <%=len.getNombre_lenguaje() %> type="checkbox">
    -
  • - - <% } %> - -
-
  • - -
  • - -
    -

    Lenguajes de programacion que conoces:

    - - -
    - - -
    - - -
    - - - volver - - - -
    - - -
    - - - +

    Descripcion:

    +

    + <%= rs.getString("descripcion") %> +

    +

    Si sigues interesado y cumples con los requisitos, completa el siguiente formulario:

    + +
    + + + "> + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + + +
    + + + +
    + + +
    + +

    Lenguajes de programacion que conoces:

    + + <%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %> + <% + LenguajeDao lenDao = new LenguajeDao(); + List listLenguaje = lenDao.listar(); + Iterator iter = listLenguaje.iterator(); + Lenguaje len = null; + %> +
      + <% while(iter.hasNext()){ + len = iter.next(); + %> +
    • + + id= + <%=len.getNombre_lenguaje() %> name= + <%=len.getNombre_lenguaje() %> type="checkbox" > +
    • + <% } %> +
    + +
    + volver + +
    +
    + + + \ No newline at end of file diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index 3f45275..3f8c3c9 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -26,6 +26,10 @@ diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 1e89b6c..a941402 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -1,5 +1,3 @@ -<<<<<<< HEAD -======= <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> @@ -22,5 +20,4 @@ - ->>>>>>> origin/develop + \ No newline at end of file