Commit 3f752435 authored by cyanide4all's avatar cyanide4all

Working. Dynamic owner in progress

parent f2341cbc
...@@ -11,6 +11,7 @@ import javax.ws.rs.ApplicationPath; ...@@ -11,6 +11,7 @@ import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application; import javax.ws.rs.core.Application;
import es.uvigo.esei.daa.rest.PeopleResource; import es.uvigo.esei.daa.rest.PeopleResource;
import es.uvigo.esei.daa.rest.PetResource;
import es.uvigo.esei.daa.rest.UsersResource; import es.uvigo.esei.daa.rest.UsersResource;
/** /**
...@@ -26,7 +27,8 @@ public class DAAExampleApplication extends Application { ...@@ -26,7 +27,8 @@ public class DAAExampleApplication extends Application {
public Set<Class<?>> getClasses() { public Set<Class<?>> getClasses() {
return Stream.of( return Stream.of(
PeopleResource.class, PeopleResource.class,
UsersResource.class UsersResource.class,
PetResource.class
).collect(toSet()); ).collect(toSet());
} }
......
...@@ -105,10 +105,11 @@ public class PetDAO extends DAO { ...@@ -105,10 +105,11 @@ public class PetDAO extends DAO {
} }
try (Connection conn = this.getConnection()) { try (Connection conn = this.getConnection()) {
final String query = "INSERT INTO pet VALUES(null, ?)"; final String query = "INSERT INTO pet VALUES(null, ?, ?)";
try (PreparedStatement statement = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)) { try (PreparedStatement statement = conn.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, name); statement.setString(1, name);
statement.setInt(2,ownerID);
if (statement.executeUpdate() == 1) { if (statement.executeUpdate() == 1) {
try (ResultSet resultKeys = statement.getGeneratedKeys()) { try (ResultSet resultKeys = statement.getGeneratedKeys()) {
......
...@@ -19,7 +19,7 @@ var PetView = (function() { ...@@ -19,7 +19,7 @@ var PetView = (function() {
this.init = function() { this.init = function() {
dao.listPets(function(pet) { dao.listPets(function(pet) {
$.each(pets, function(key, pet) { $.each(pet, function(key, pet) {
appendToTable(pet); appendToTable(pet);
}); });
}); });
......
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