Skip to content
Snippets Groups Projects
Commit f166abea authored by andres's avatar andres
Browse files

Merge origin/master

parents 69ca61fd 90837d2d
No related branches found
No related tags found
No related merge requests found
......@@ -228,8 +228,39 @@ public class nookDB {
return null;
}
}
public static Nook ultimoNook(String autor) {
ConnectionPool pool = ConnectionPool.getInstance();
Connection connection = pool.getConnection();
Nook nook = new Nook();
ResultSet rs = null;
String consulta = "SELECT * FROM Nook WHERE autor = ?";
try {
PreparedStatement ps = connection.prepareStatement(consulta);
ps.setString(1,autor);
rs = ps.executeQuery();
while (rs.next()) {
nook.setIdNook(rs.getInt("idNook"));
nook.setNombre(rs.getString("nombre"));
nook.setResumen(rs.getString("resumen"));
nook.setAutor(rs.getString("autor"));
nook.setFechaCreacion(rs.getDate("fechaCreacion"));
nook.setFechaModificacion(rs.getDate("fechaModificacion"));
nook.setDescargas(rs.getInt("descargas"));
nook.setValoracionMedia(rs.getDouble("valoracionmedia"));
}
rs.close();
ps.close();
pool.freeConnection(connection);
return nook;
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
public static double valoracionMediaAutor(String autor){
ConnectionPool pool = ConnectionPool.getInstance();
......
......@@ -5,6 +5,7 @@
*/
package servlet;
import conexionDB.clasificacionCategoriasDB;
import conexionDB.nookDB;
import conexionDB.usuarioDB;
import java.io.IOException;
......@@ -18,6 +19,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import modelo.ClasificacionCategorias;
import modelo.Nook;
/**
......@@ -39,8 +41,6 @@ public class crearNookSV extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//response.setContentType("text/html;charset=UTF-8");
String nombre = request.getParameter("nombre");
String etiquetas = request.getParameter("etiquetas");
String resumen = request.getParameter("resumen");
......@@ -48,7 +48,6 @@ public class crearNookSV extends HttpServlet {
java.util.Date date = new java.util.Date();
Date fecha = new Date(date.getTime());
Nook nook = new Nook();
nook.setNombre(nombre);
......@@ -57,7 +56,7 @@ public class crearNookSV extends HttpServlet {
HttpSession sesion = request.getSession();
String userName = (String) sesion.getAttribute("usuario");
nook.setAutor(userName); //AQUI VA EL USUARIO LOGUEADO
nook.setAutor(userName);
nook.setFechaCreacion(fecha);
nook.setFechaModificacion(fecha);
nook.setDescargas(0);
......@@ -65,6 +64,17 @@ public class crearNookSV extends HttpServlet {
nookDB.insert(nook);
Nook nookCreado = nookDB.ultimoNook(userName);
int idNook = nookCreado.getIdNook();
ClasificacionCategorias categoria = new ClasificacionCategorias();
categoria.setIdNook(idNook);
categoria.setCategoria(etiquetas);
clasificacionCategoriasDB.insert(categoria);
String url = "/misNooksSV";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
dispatcher.forward(request, response);
......@@ -109,4 +119,8 @@ public class crearNookSV extends HttpServlet {
return "Short description";
}// </editor-fold>
private ClasificacionCategorias ClasificacionCategorias() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
......@@ -45,7 +45,8 @@ and open the template in the editor.
<div class="perfil">
<ul>
<li><img src="recuperarImagenesSV?userName=<%=autor%>"
style="width:90px; height:90px; border-radius: 50px;" alt="Imagen del perfil de usuario"></li>
class="imagenesUsuarios"
alt="Imagen del perfil de usuario"></li>
<li><h1><%=autor%></h1></li>
<li>
<button type="submit" class="enviar_mensaje" onclick="window.location.href='crearMensaje.jsp'">Enviar mensaje</button>
......@@ -70,7 +71,7 @@ and open the template in the editor.
<%if(nooksCategorias.get(i)!=null){%>
<h4>Categoria: <%=nooksCategorias.get(i)%></h4>
<%}else{%>
<h4>Categoria: none<h4>
<h4>Categoria: Ninguna<h4>
<%}%>
<p><%=nooks.get(i).getResumen()%></p>
......
......@@ -59,7 +59,7 @@
<%if(nooksCategorias.get(i)!=null){%>
<h4>Categoria: <%=nooksCategorias.get(i)%></h4>
<%}else{%>
<h4>Categoria: none<h4>
<h4>Categoria: Ninguna<h4>
<%}%>
<p><%=nooks.get(i).getResumen()%></p>
......
......@@ -121,7 +121,7 @@ CREATE TABLE ValoracionesComentario(
CREATE TABLE ClasificacionCategorias(
idNook INTEGER NOT NULL,
categoria VARCHAR(30) NOT NULL,
categoria VARCHAR(60) NOT NULL,
PRIMARY KEY (idNook, categoria),
CONSTRAINT FK_CLASCATEGORIAS FOREIGN KEY (idNook)
REFERENCES Nook (idNook)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment