Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daaexample
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Martín Vázquez Torres
daaexample
Commits
c07ce0ea
Commit
c07ce0ea
authored
Feb 16, 2017
by
cyanide4all
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
class
parent
3f752435
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
217 deletions
+39
-217
PetDAO.java
src/main/java/es/uvigo/esei/daa/dao/PetDAO.java
+10
-7
PetResource.java
src/main/java/es/uvigo/esei/daa/rest/PetResource.java
+1
-207
pet.js
src/main/webapp/js/dao/pet.js
+25
-1
pet.js
src/main/webapp/js/view/pet.js
+1
-1
pet.html
src/main/webapp/pet.html
+2
-1
No files found.
src/main/java/es/uvigo/esei/daa/dao/PetDAO.java
View file @
c07ce0ea
...
...
@@ -20,17 +20,20 @@ import es.uvigo.esei.daa.entities.Pet;
*/
public
class
PetDAO
extends
DAO
{
private
final
static
Logger
LOG
=
Logger
.
getLogger
(
PetDAO
.
class
.
getName
());
//TODO
junto con lo de justo debajo
//TODO
está puesto a 1 para testeos
private
int
ownerID
=
1
;
public
int
getOwnerID
(){
return
ownerID
;
}
/*//TODO ESTO IGUAL NO FUNCIONA LO TESTEO LUEGO
public PetDAO(int ownerID){
public
void
setOwnerID
(
int
ownerID
)
{
this
.
ownerID
=
ownerID
;}
public
PetDAO
(
int
ownerID
)
{
this
.
ownerID
=
ownerID
;
}
*/
public
PetDAO
(){}
/**
* Returns a pet stored persisted in the system.
*
...
...
@@ -70,9 +73,11 @@ public class PetDAO extends DAO {
*/
public
List
<
Pet
>
list
()
throws
DAOException
{
try
(
final
Connection
conn
=
this
.
getConnection
())
{
final
String
query
=
"SELECT * FROM pet"
;
final
String
query
=
"SELECT * FROM pet
WHERE ownerID=?
"
;
try
(
final
PreparedStatement
statement
=
conn
.
prepareStatement
(
query
))
{
statement
.
setInt
(
1
,
ownerID
);
try
(
final
ResultSet
result
=
statement
.
executeQuery
())
{
final
List
<
Pet
>
petList
=
new
LinkedList
<>();
...
...
@@ -193,9 +198,7 @@ public class PetDAO extends DAO {
return
new
Pet
(
row
.
getInt
(
"id"
),
row
.
getString
(
"name"
),
//TODO EXTREMO ESTO ES PROVISIONAL
ownerID
//TODO REPITO PROVISIONAL MECA
);
}
}
src/main/java/es/uvigo/esei/daa/rest/PetResource.java
View file @
c07ce0ea
This diff is collapsed.
Click to expand it.
src/main/webapp/js/dao/pet.js
View file @
c07ce0ea
var
PetDAO
=
(
function
()
{
var
PetDAO
=
(
function
(
ownerID
)
{
var
resourcePath
=
"rest/pet/"
;
var
requestByAjax
=
function
(
data
,
done
,
fail
,
always
)
{
done
=
typeof
done
!==
'undefined'
?
done
:
function
()
{};
...
...
@@ -11,6 +11,18 @@ var PetDAO = (function() {
.
always
(
always
);
};
var
setOwnerIDPetDAO
=
function
(
ownerID
,
done
,
fail
,
always
)
{
var
query
=
window
.
location
.
search
.
substring
(
1
);
var
split
=
query
.
split
(
"="
);
var
getID
=
decodeURIComponent
(
split
[
1
]);
//alert(getID);
requestByAjax
({
url
:
resourcePath
+
getID
,
type
:
'POST'
,
data
:
getID
},
done
,
fail
,
always
);
}();
function
PetDAO
()
{
this
.
listPets
=
function
(
done
,
fail
,
always
)
{
requestByAjax
({
...
...
@@ -19,6 +31,18 @@ var PetDAO = (function() {
},
done
,
fail
,
always
);
};
this
.
setOwnerIDPetDAO
=
function
(
ownerID
,
done
,
fail
,
always
)
{
var
query
=
window
.
location
.
search
.
substring
(
1
);
var
split
=
query
.
split
(
"="
);
var
getID
=
decodeURIComponent
(
split
[
1
]);
//alert(getID);
requestByAjax
({
url
:
resourcePath
+
getID
,
type
:
'POST'
,
data
:
getID
},
done
,
fail
,
always
);
};
this
.
addPet
=
function
(
pet
,
done
,
fail
,
always
)
{
requestByAjax
({
url
:
resourcePath
,
...
...
src/main/webapp/js/view/pet.js
View file @
c07ce0ea
...
...
@@ -13,7 +13,7 @@ var PetView = (function() {
function
PetView
(
petDao
,
formContainerId
,
listContainerId
)
{
dao
=
petDao
;
self
=
this
;
dao
.
setOwnerIDPetDAO
();
insertPetForm
(
$
(
'#'
+
formContainerId
));
insertPetList
(
$
(
'#'
+
listContainerId
));
...
...
src/main/webapp/pet.html
View file @
c07ce0ea
...
...
@@ -7,7 +7,7 @@
<body>
<div
id=
"pet-container"
>
<h1>
People
</h1>
<a
id=
"#logout"
href=
"logout"
>
Logout
</a>
<a
id=
"#logout"
href=
"logout"
>
Logout
</a>
<a
id=
"#atras"
href=
"main.html"
>
Back
</a>
</div>
<script
type=
"text/javascript"
src=
"http://code.jquery.com/jquery-2.2.0.min.js"
></script>
...
...
@@ -15,6 +15,7 @@
<script
type=
"text/javascript"
src=
"js/view/pet.js"
></script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
var
view
=
new
PetView
(
new
PetDAO
(),
'pet-container'
,
'pet-container'
);
view
.
init
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment