Commit 4e7e473f by Rebecca Arzamendia

Creado filtro de bootcamp

parent 3bd0957d
......@@ -10,7 +10,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
......@@ -120,6 +120,7 @@ public class BootcampDao {
PreparedStatement ps=con.prepareStatement("select * from bootcamp where id=?");
ps.setInt(1,id);
ResultSet rs=ps.executeQuery();
System.out.println();
if(rs.next()){
b.setId(rs.getInt("id"));
b.setActivo(rs.getBoolean("activo"));
......@@ -136,4 +137,57 @@ public class BootcampDao {
return b;
}
public static List<Bootcamp> filtrar(String lenguaje){
ArrayList<Bootcamp> list = new ArrayList<>();
// String sql = "select a.id, a.titulo, a.descripcion, a.fecha_inicio, a.fecha_fin, b.nombre_lenguaje, c.nombre,c.apellido, a.activo\n" +
// "\tfrom bootcamp a\n" +
// "\tinner join lenguaje b on b.id=a.id_lenguaje\n" +
// "\tinner join profesor c on c.id=a.id_profesor\n" +
// "\twhere a.fecha_inicio ilike ? and\n" +
// "\ta.fecha_fin ilike ? and b.nombre_lenguaje ilike ?";
try{
Connection con= DataBase.getConnection();
//PreparedStatement ps=con.prepareStatement("");
// PreparedStatement ps = con.prepareStatement("select a.id, a.titulo, a.descripcion, cast (a.fecha_inicio AS varchar) as fecha_inicio, cast (a.fecha_fin AS varchar) as fecha_fin, b.nombre_lenguaje, c.nombre,c.apellido, a.activo\n" +
// "\tfrom bootcamp a\n" +
// "\tinner join lenguaje b on b.id=a.id_lenguaje\n" +
// "\tinner join profesor c on c.id=a.id_profesor\n" +
// "\twhere a.fecha_inicio = ? and\n" +
// "\ta.fecha_fin = ? and b.nombre_lenguaje = ?");
PreparedStatement ps = con.prepareStatement("select a.id, a.titulo, a.descripcion, cast (a.fecha_inicio AS varchar) as fecha_inicio, cast (a.fecha_fin AS varchar) as fecha_fin, b.nombre_lenguaje, c.nombre,c.apellido, a.activo\n" +
"\tfrom bootcamp a\n" +
"\tinner join lenguaje b on b.id=a.id_lenguaje\n" +
"\tinner join profesor c on c.id=a.id_profesor\n" +
" where b.nombre_lenguaje = ?");
// ps.setString(1, fecha_inicio);
// ps.setString(2, fecha_fin);
ps.setString(1, lenguaje);
ResultSet rs = ps.executeQuery();
while(rs.next()){
Bootcamp boot = new Bootcamp();
boot.setId(rs.getInt("id"));
boot.setActivo(rs.getBoolean("activo"));
boot.setDescripcion(rs.getString("descripcion"));
boot.setTitulo(rs.getString("titulo"));
boot.setFecha_fin(rs.getString("fecha_fin"));
boot.setFecha_inicio(rs.getString("fecha_inicio"));
boot.setNombre_profesor(rs.getString("nombre"));
boot.setApellido_profesor(rs.getString("apellido"));
boot.setNombre_lenguaje(rs.getString("nombre_lenguaje"));
list.add(boot);
}
con.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
return list;
}
}
......@@ -12,6 +12,7 @@ public class DeleteServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String sid=request.getParameter("id");
int id=Integer.parseInt(sid);
System.out.println("Este es el id " + id);
BootcampDao.delete(id);
......
......@@ -27,6 +27,7 @@ public class EditServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int id_lenguaje= Integer.parseInt(request.getParameter("id_lenguaje2"));
int id_profesor= Integer.parseInt(request.getParameter("id_profesor2"));
String fecha_inicio=request.getParameter("fecha_inicio2");
......
......@@ -25,15 +25,12 @@ public class Filtros extends HttpServlet {
System.out.println(apellido);
if(nombre!=null || apellido!=null){
profesores = buscarPorNombre(nombre, apellido);
}
req.getServletContext().setAttribute("profesores", profesores);
RequestDispatcher reqDisp= req.getRequestDispatcher("profesor-consulta.jsp");
reqDisp.forward(req,resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
List<Profesor > nombre = listarProfesor();
......
......@@ -58,7 +58,7 @@ public class ProfesorDao {
Profesor profesorObject = new Profesor();
try{
Connection con= DataBase.getConnection();
PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo from profesor a " +
PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apelli do, a.nro_cedula, a.correo from profesor a " +
" where a.nombre ilike ? and a.apellido ilike ? ");
......
......@@ -540,7 +540,7 @@ pageEncoding="UTF-8"%>
<%=rs.getString("fecha_fin")%>
</p>
<form action="formulario.jsp">
<input name="bootcamp" type="hidden" value=<%=rs.getInt( "id") %>>
<input name="bootcamp" type="hidden" value=<%=rs.getInt("id") %>>
<button type="submit">POSTULAR</button>
</form>
</div>
......
<%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.entity.Bootcamp, com.roshka.proyectofinal.lenguaje.LenguajeDao, com.roshka.proyectofinal.bootcamp.BootcampDao, com.roshka.proyectofinal.entity.Profesor, com.roshka.proyectofinal.profesor.ProfesorDao, java.util.List,java.util.Iterator, java.util.ArrayList, jakarta.servlet.http.* , java.lang.Object" %>
<%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.entity.Bootcamp, com.roshka.proyectofinal.lenguaje.LenguajeDao, com.roshka.proyectofinal.bootcamp.BootcampDao, com.roshka.proyectofinal.entity.Profesor, com.roshka.proyectofinal.profesor.ProfesorDao, java.util.List,java.util.Iterator, java.util.ArrayList, jakarta.servlet.http.* , java.lang.Object,jakarta.servlet.http.HttpServlet,jakarta.servlet.http.HttpServletRequest,java.sql.ResultSet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
......@@ -77,17 +77,46 @@
<button type="submit">
Crear Bootcamp
</button>
</form>
<%@page import="jakarta.servlet.http.HttpServlet,jakarta.servlet.http.HttpServletRequest,com.roshka.proyectofinal.bootcamp.BootcampDao"%>
<%
int nahuel = 0;
if(request.getParameter("filtraryovan")!=null){
if(request.getParameter("lenguaje") != null){
nahuel=1;
}
}
BootcampDao bootDao = new BootcampDao();
List<Bootcamp> listBoot;
listBoot = bootDao.listar();
String lenguaje = request.getParameter("lenguaje");
//String inicio = request.getParameter("fecha_inicio");
//String fin = request.getParameter("fecha_fin");
switch(nahuel){
case 1:
lenguaje = request.getParameter("lenguaje");
//inicio = request.getParameter("fecha_inicio");
//fin = request.getParameter("fecha_fin");
listBoot = bootDao.filtrar(lenguaje);
break;
case 0:
listBoot = bootDao.listar();
break;
}
Iterator<Bootcamp> iterBoot = listBoot.iterator();
Bootcamp boot = null;
%>
<form method="get" action ="#" >
<input name="lenguaje" type="search" placeholder="Buscar por lenguaje"></input>
<input type="submit" name="filtraryovan" value= "Filtrar"></input>
</form>
</div>
<p><%=nahuel%> <%=lenguaje%> </p>
<div>
<%
BootcampDao bootDao = new BootcampDao();
List<Bootcamp> listBoot = bootDao.listar();
Iterator<Bootcamp> iterBoot = listBoot.iterator();
Bootcamp boot = null;
%>
<table>
<thead>
<tr>
......@@ -129,6 +158,10 @@
</tbody>
</table>
</form>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment