diff --git a/db/mysql-with-inserts.sql b/db/mysql-with-inserts.sql index 9444668b00ca9bed9fbcf4551d6f8628cecd38d0..f488a88589b31e0319be56b255c727fb1e049ab0 100644 --- a/db/mysql-with-inserts.sql +++ b/db/mysql-with-inserts.sql @@ -15,14 +15,13 @@ CREATE TABLE `daaexample`.`users` ( PRIMARY KEY (`login`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `daaexample`.`pet` ( +CREATE TABLE `daaexample`.`pets` ( `id` int NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, - `breed` varchar(50) NOT NULL, + `specie` varchar(50) NOT NULL, `idOwner` int NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`idOwner`) REFERENCES `people`(`id`) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; GRANT ALL ON `daaexample`.* TO 'daa'@'localhost' IDENTIFIED BY 'daa'; @@ -42,6 +41,8 @@ VALUES ('admin', '713bfda78870bf9d1b261f565286f85e97ee614efe5f0faf7c34e7ca4f65ba INSERT INTO `daaexample`.`users` (`login`,`password`,`role`) VALUES ('normal', '7bf24d6ca2242430343ab7e3efb89559a47784eea1123be989c1b2fb2ef66e83','USER'); -INSERT INTO `daaexample`.`pet` (`id`,`name`,`breed`,`idOwner`) VALUES (0,'Rex','Pastor Aleman',1); -INSERT INTO `daaexample`.`pet` (`id`,`name`,`breed`,`idOwner`) VALUES (0,'Idefix','Terrier',2); -INSERT INTO `daaexample`.`pet` (`id`,`name`,`breed`,`idOwner`) VALUES (0,'Snoopy','Beagle',3); \ No newline at end of file +INSERT INTO `daaexample`.`pets` (`id`,`name`,`specie`,`idOwner`) VALUES (0,'Rex','Dog',1); +INSERT INTO `daaexample`.`pets` (`id`,`name`,`specie`,`idOwner`) VALUES (0,'Doraemon','Cat',2); +INSERT INTO `daaexample`.`pets` (`id`,`name`,`specie`,`idOwner`) VALUES (0,'Yogui','Bear',3); +INSERT INTO `daaexample`.`pets` (`id`,`name`,`specie`,`idOwner`) VALUES (0,'Prueba1','pet',4); +INSERT INTO `daaexample`.`pets` (`id`,`name`,`specie`,`idOwner`) VALUES (0,'Prueba2','pet',5); \ No newline at end of file diff --git a/db/mysql.sql b/db/mysql.sql index c1026070d981f998470333092918ac964d4b8af9..4ef9671f8c6473b5b4c1dca31ad658aff39f6a92 100644 --- a/db/mysql.sql +++ b/db/mysql.sql @@ -15,10 +15,10 @@ CREATE TABLE `daaexample`.`users` ( PRIMARY KEY (`login`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE `daaexample`.`pet` ( +CREATE TABLE `daaexample`.`pets` ( `id` int NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, - `breed` varchar(50) NOT NULL, + `specie` varchar(50) NOT NULL, `idOwner` int NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`idOwner`) REFERENCES `people`(`id`) diff --git a/src/main/java/es/uvigo/esei/daa/entities/Pet.java b/src/main/java/es/uvigo/esei/daa/entities/Pet.java index f806a6821b849d2bffaa4a7d3c350e65ad76614e..7d27902de6c67686a39a041ba5e26866d34a0423 100644 --- a/src/main/java/es/uvigo/esei/daa/entities/Pet.java +++ b/src/main/java/es/uvigo/esei/daa/entities/Pet.java @@ -10,7 +10,7 @@ import static java.util.Objects.requireNonNull; public class Pet { private int id; private String name; - private String breed; + private String specie; private int idOwner; // Constructor needed for the JSON conversion @@ -21,13 +21,13 @@ public class Pet { * * @param id identifier of the pet. * @param name name of the pet. - * @param breed breed of the pet. + * @param specie specie of the pet. * @param idOwner owner of the pet */ - public Pet(int id, String name, String breed, int idOwner) { + public Pet(int id, String name, String specie, int idOwner) { this.id = id; this.setName(name); - this.setBreed(breed); + this.setSpecie(specie); this.setIdOwner(idOwner); } @@ -57,21 +57,21 @@ public class Pet { this.name = requireNonNull(name, "Name can't be null"); } /** - * Returns the breed of the pet. + * Returns the specie of the pet. * - * @return the breed of the pet. + * @return the specie of the pet. */ - public String getBreed() { - return breed; + public String getSpecie() { + return specie; } /** - * Set the breed of this pet. + * Set the specie of this pet. * - * @param breed the new breed of the person. - * @throws NullPointerException if the {@code breed} is {@code null}. + * @param specie the new specie of the pet. + * @throws NullPointerException if the {@code specie} is {@code null}. */ - public void setBreed(String breed) { - this.breed = requireNonNull(breed, "Name can't be null"); + public void setSpecie(String specie) { + this.specie = requireNonNull(specie, "specie can't be null"); } /** @@ -89,14 +89,14 @@ public class Pet { * @throws NullPointerException if the {@code idOwner} is {@code null}. */ public void setIdOwner(int idOwner) { - this.idOwner = requireNonNull(idOwner, "Name can't be null"); + this.idOwner = requireNonNull(idOwner, "idOwner can't be null"); } @Override public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((breed == null) ? 0 : breed.hashCode()); + result = prime * result + ((specie == null) ? 0 : specie.hashCode()); result = prime * result + id; result = prime * result + idOwner; result = prime * result + ((name == null) ? 0 : name.hashCode()); @@ -112,10 +112,10 @@ public class Pet { if (getClass() != obj.getClass()) return false; Pet other = (Pet) obj; - if (breed == null) { - if (other.breed != null) + if (specie == null) { + if (other.specie != null) return false; - } else if (!breed.equals(other.breed)) + } else if (!specie.equals(other.specie)) return false; if (id != other.id) return false;