Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FileNook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sanblas
FileNook
Commits
9511f68b
Commit
9511f68b
authored
May 20, 2019
by
Usuario
Browse files
Options
Downloads
Patches
Plain Diff
cambios en buscar
parent
7caf4b8e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Source Packages/conexionDB/nookDB.java
+14
-9
14 additions, 9 deletions
Source Packages/conexionDB/nookDB.java
Source Packages/servlet/buscarSV.java
+19
-5
19 additions, 5 deletions
Source Packages/servlet/buscarSV.java
web/busqueda.jsp
+1
-1
1 addition, 1 deletion
web/busqueda.jsp
with
34 additions
and
15 deletions
Source Packages/conexionDB/nookDB.java
+
14
−
9
View file @
9511f68b
...
...
@@ -191,20 +191,19 @@ public class nookDB {
Connection
connection
=
pool
.
getConnection
();
ArrayList
<
Nook
>
listanooks
=
null
;
String
consulta
=
"SELECT * FROM Nook N, ClasificacionCategorias C "
+
"WHERE (N.idNook=C.idNook AND "
+
"N.nombre = ?"
+
"OR N.autor = ?"
+
"OR C.categoria = ?)"
;
String
consulta
=
"SELECT * FROM Nook WHERE nombre = ?"
;
//OR autor LIKE ?";
System
.
out
.
println
(
"ESTOES LO QUE SE BUSCA :"
+
"Consulta "
+
consulta
+
" "
+
busqueda
);
ResultSet
rs
=
null
;
try
{
PreparedStatement
ps
=
connection
.
prepareStatement
(
consulta
);
rs
=
ps
.
executeQuery
();
ps
.
setString
(
1
,
busqueda
);
ps
.
setString
(
2
,
busqueda
);
ps
.
setString
(
3
,
busqueda
);
rs
=
ps
.
executeQuery
();
// ps.setString(2,"%" + busqueda + "%");
//ps.setString(3,"%" + busqueda + "%");
while
(
rs
.
next
()){
Nook
nook
=
new
Nook
();
nook
.
setIdNook
(
rs
.
getInt
(
"idNook"
));
...
...
@@ -215,7 +214,13 @@ public class nookDB {
nook
.
setFechaModificacion
(
rs
.
getDate
(
"fechaModificacion"
));
nook
.
setDescargas
(
rs
.
getInt
(
"descargas"
));
nook
.
setValoracionMedia
(
rs
.
getDouble
(
"valoracionmedia"
));
System
.
out
.
println
(
"DATOS NOOK: "
+
rs
.
getInt
(
"idNook"
)+
rs
.
getString
(
"nombre"
)+
rs
.
getString
(
"resumen"
)+
rs
.
getString
(
"autor"
)+
rs
.
getDate
(
"fechaCreacion"
)+
rs
.
getDate
(
"fechaModificacion"
)+
rs
.
getInt
(
"descargas"
)+
rs
.
getDouble
(
"valoracionmedia"
));
System
.
out
.
println
(
nook
);
listanooks
.
add
(
nook
);
System
.
out
.
println
(
listanooks
.
size
());
}
rs
.
close
();
...
...
This diff is collapsed.
Click to expand it.
Source Packages/servlet/buscarSV.java
+
19
−
5
View file @
9511f68b
...
...
@@ -7,6 +7,7 @@ package servlet;
import
conexionDB.clasificacionCategoriasDB
;
import
conexionDB.nookDB
;
import
conexionDB.valoracionesNookDB
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.ArrayList
;
...
...
@@ -16,6 +17,7 @@ import javax.servlet.annotation.WebServlet;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
import
modelo.Nook
;
/**
...
...
@@ -38,15 +40,26 @@ public class buscarSV extends HttpServlet {
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/html;charset=UTF-8"
);
String
nombre
=
""
;
HttpSession
session
=
request
.
getSession
(
false
);
if
(
session
!=
null
){
nombre
=
(
String
)
session
.
getAttribute
(
"usuario"
);
}
String
busqueda
=
request
.
getParameter
(
"search"
);
ArrayList
<
String
>
categoriasNook
;
ArrayList
<
String
>
categorias
=
new
ArrayList
<>();
ArrayList
<
Nook
>
listNook
=
nookDB
.
getNooksDescargas
();
System
.
out
.
println
(
"ESTOES LO QUE SE BUSCA SV :"
+
busqueda
);
ArrayList
<
Nook
>
listNook
=
nookDB
.
buscarNook
(
busqueda
);
//ArrayList<Nook> listNook=nookDB.getNooksDescargas();
System
.
out
.
println
(
"11111111111111111111111111111"
);
ArrayList
<
Integer
>
valoracionesNook
=
new
ArrayList
<>();
StringBuilder
str
;
System
.
out
.
println
(
"2222222222222222222222222"
);
for
(
int
i
=
0
;
i
<
listNook
.
size
();
i
++){
str
=
new
StringBuilder
();
categoriasNook
=
clasificacionCategoriasDB
.
getCategoriasNook
(
listNook
.
get
(
i
).
getIdNook
());
valoracionesNook
.
add
(
valoracionesNookDB
.
getValoracionUsuarioNook
(
nombre
,
listNook
.
get
(
i
).
getIdNook
()));
for
(
int
j
=
0
;
j
<
categoriasNook
.
size
();
j
++
){
str
.
append
(
categoriasNook
.
get
(
j
));
str
.
append
(
','
);
...
...
@@ -58,10 +71,11 @@ public class buscarSV extends HttpServlet {
categorias
.
add
(
null
);
}
}
System
.
out
.
println
(
"ESTOES LO QUE SE BUSCA :"
+
listNook
.
toString
());
request
.
setAttribute
(
"nooks
B
"
,
listNook
);
request
.
setAttribute
(
"nooks"
,
listNook
);
request
.
setAttribute
(
"categorias"
,
categorias
);
request
.
setAttribute
(
"valoraciones"
,
valoracionesNook
);
...
...
This diff is collapsed.
Click to expand it.
web/busqueda.jsp
+
1
−
1
View file @
9511f68b
...
...
@@ -43,7 +43,7 @@
</div>
<div
class=
"pag-nook_n"
>
<%
ArrayList
<
Nook
>
nooks
=
(
ArrayList
<
Nook
>
)
request
.
getAttribute
(
"nooks
B
"
);
ArrayList
<
Nook
>
nooks
=
(
ArrayList
<
Nook
>
)
request
.
getAttribute
(
"nooks"
);
ArrayList
<
String
>
nooksCategorias
=
(
ArrayList
<
String
>
)
request
.
getAttribute
(
"categorias"
);
for
(
int
i
=
0
;
i
<
nooks
.
size
();
i
++){
double
valoracion
=
Math
.
round
(
nooks
.
get
(
i
).
getValoracionMedia
());
...
...
This diff is collapsed.
Click to expand it.
rafhige
@rafhige
mentioned in commit
d557388a
·
May 20, 2019
mentioned in commit
d557388a
mentioned in commit d557388a3b9bf531dacf89e4b7d93334d1ba4a07
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment