Commit 06edf8e1 authored by Breixo Senra's avatar Breixo Senra

Modificación de nombre de vacuna funcionando

parent af0c608f
...@@ -10,11 +10,13 @@ import javax.persistence.GeneratedValue; ...@@ -10,11 +10,13 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity @Entity(name="Identifier")
@XmlRootElement(name = "identifier", namespace = "http://entities.domain.xcs.esei.uvigo.es")
public class Identifier { public class Identifier {
@Id @Id
@Column(length = 32, nullable = false) @Column(length = 32, nullable = false)
......
...@@ -35,7 +35,7 @@ import javax.xml.bind.annotation.XmlTransient; ...@@ -35,7 +35,7 @@ import javax.xml.bind.annotation.XmlTransient;
@Entity(name = "Pet") @Entity(name = "Pet")
@XmlRootElement(name = "pett", namespace = "http://entities.domain.xcs.esei.uvigo.es") @XmlRootElement(name = "pet", namespace = "http://entities.domain.xcs.esei.uvigo.es")
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class Pet implements Serializable { public class Pet implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -13,11 +13,13 @@ import javax.persistence.Id; ...@@ -13,11 +13,13 @@ import javax.persistence.Id;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity @Entity(name="Vaccination")
@XmlRootElement(name = "vaccination", namespace = "http://entities.domain.xcs.esei.uvigo.es")
public class Vaccination implements Serializable { public class Vaccination implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -12,9 +12,11 @@ import javax.persistence.DiscriminatorValue; ...@@ -12,9 +12,11 @@ import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.ManyToMany; import javax.persistence.ManyToMany;
import javax.xml.bind.annotation.XmlRootElement;
@Entity @Entity
@DiscriminatorValue("VET") @DiscriminatorValue("VET")
@XmlRootElement(name = "vet", namespace = "http://entities.domain.xcs.esei.uvigo.es")
public class Vet extends User implements Serializable { public class Vet extends User implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
package es.uvigo.esei.xcs.jsf; package es.uvigo.esei.xcs.jsf;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
......
...@@ -37,6 +37,7 @@ public class VaccineManagedBean{ ...@@ -37,6 +37,7 @@ public class VaccineManagedBean{
vaccineService.remove(id); vaccineService.remove(id);
vaccines = vaccineService.list(0, 100); vaccines = vaccineService.list(0, 100);
} }
private void clearForm() { private void clearForm() {
name = null; name = null;
......
<?xml version='1.0' encoding='UTF-8' ?> w<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:h="http://xmlns.jcp.org/jsf/html"
......
...@@ -43,6 +43,15 @@ public class VaccineResource { ...@@ -43,6 +43,15 @@ public class VaccineResource {
URI uri = uriInfo.getAbsolutePathBuilder().path(String.valueOf(vaccine.getId())).build(); URI uri = uriInfo.getAbsolutePathBuilder().path(String.valueOf(vaccine.getId())).build();
return Response.created(uri).build(); return Response.created(uri).build();
} }
@PUT
@Path("{id}/name")
public Response updateName(@PathParam("id") Long id, String newName) {
requireNonNull(newName, "newName can't be null");
Vaccine updated = vaccineService.updateName(id, newName);
return Response.ok(updated).build();
}
@PUT @PUT
@Path("{id}") @Path("{id}")
......
...@@ -76,6 +76,19 @@ public class VaccineService { ...@@ -76,6 +76,19 @@ public class VaccineService {
return em.merge(vaccine); return em.merge(vaccine);
} }
public Vaccine updateName(Long id, String newName) {
if (id == null || newName == null || newName.trim().isEmpty())
throw new IllegalArgumentException("Id o nombre inválido");
Vaccine vaccine = em.find(Vaccine.class, id);
if (vaccine == null)
throw new IllegalArgumentException("Vacuna no encontrada");
vaccine.setName(newName);
return em.merge(vaccine);
}
public void remove(Long id) { public void remove(Long id) {
final Vaccine vaccine = this.get(id); final Vaccine vaccine = this.get(id);
......
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