diff --git a/central-db/pom.xml b/central-db/pom.xml index a13032a8f08fecb7463e14fff5cef2321d322a20..855585bc8dd8e22806c2335eec454c2ddbac8573 100644 --- a/central-db/pom.xml +++ b/central-db/pom.xml @@ -45,6 +45,12 @@ <scope>provided</scope> </dependency> + <dependency> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct</artifactId> + </dependency> + + <!-- Test scope dependencies --> <dependency> <groupId>junit</groupId> diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/DataAccessBean.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/DataAccessBean.java index 193b81e6acb08c9ba135d9366bbefe9ba50e7504..e2e4e28e40d831363eb016ba3f6c9a3807379ce3 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/DataAccessBean.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/DataAccessBean.java @@ -4,7 +4,7 @@ import uy.edu.fing.tse.dto.NoticiaDTO; import uy.edu.fing.tse.dto.PublicacionDTO; import uy.edu.fing.tse.practico.db.entity.Noticia; import uy.edu.fing.tse.practico.db.entity.Publicacion; -import uy.edu.fing.tse.practico.db.mapper.Mapper; +import uy.edu.fing.tse.practico.db.mapper.MyMapper; import javax.annotation.PostConstruct; import javax.ejb.Local; @@ -33,16 +33,16 @@ public class DataAccessBean implements DataAccessLocal, DataAccessRemote { @Override public NoticiaDTO alta(NoticiaDTO noticia) { - final Noticia newN = em.merge(Mapper.mapper(noticia)); + final Noticia newN = em.merge(MyMapper.mapper(noticia)); em.flush(); - return Mapper.mapper(newN); + return MyMapper.mapper(newN); } @Override public PublicacionDTO alta(PublicacionDTO publicacion) { - final Publicacion newP = em.merge(Mapper.mapper(publicacion)); + final Publicacion newP = em.merge(MyMapper.mapper(publicacion)); em.flush(); - return Mapper.mapper(newP); + return MyMapper.mapper(newP); } @Override @@ -50,19 +50,19 @@ public class DataAccessBean implements DataAccessLocal, DataAccessRemote { final TypedQuery<Noticia> query = em.createNamedQuery("Noticia.findById", Noticia.class); query.setParameter("id", idNoticia); final Noticia result = query.getSingleResult(); - return Mapper.mapper(result); + return MyMapper.mapper(result); } @Override public List<NoticiaDTO> getNoticias() { final TypedQuery<Noticia> query = em.createNamedQuery("Noticia.findAll", Noticia.class); - return query.getResultList().stream().map(Mapper::mapper).collect(Collectors.toList()); + return query.getResultList().stream().map(MyMapper::mapper).collect(Collectors.toList()); } @Override public List<PublicacionDTO> getPublicaciones() { final TypedQuery<Publicacion> query = em.createNamedQuery("Publicacion.findAll", Publicacion.class); - return query.getResultList().stream().map(Mapper::mapper).collect(Collectors.toList()); + return query.getResultList().stream().map(MyMapper::mapper).collect(Collectors.toList()); } @Override @@ -73,7 +73,7 @@ public class DataAccessBean implements DataAccessLocal, DataAccessRemote { throw new RuntimeException("No existe Noticia"); } - Publicacion publicacion = Mapper.mapper(pub); + Publicacion publicacion = MyMapper.mapper(pub); publicacion = em.merge(publicacion); em.flush(); @@ -81,6 +81,6 @@ public class DataAccessBean implements DataAccessLocal, DataAccessRemote { noticiaManaged = em.merge(noticiaManaged); em.flush(); - return Mapper.mapper(noticiaManaged); + return MyMapper.mapper(noticiaManaged); } } diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Calificacion.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Calificacion.java index e35d932cd81e4a4745e581bf045946acad49af92..acdb4d097fb308a6a2f782f6610abb6a79fe0a48 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Calificacion.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Calificacion.java @@ -1,10 +1,10 @@ package uy.edu.fing.tse.practico.db.entity; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import javax.persistence.*; +/** + * Esta es la que puede ser vergonzosa, verdad a media, verdad, falsa + */ @Entity public final class Calificacion { @@ -12,6 +12,7 @@ public final class Calificacion { @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + @Column(nullable = false) private String value; public Long getId() { diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Categoria.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Categoria.java index 4a09c8446d807242fdeaba2758049694507eb957..8c7099bcc7931c29dea71dffb04ab204912760f2 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Categoria.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Categoria.java @@ -3,6 +3,9 @@ package uy.edu.fing.tse.practico.db.entity; import javax.persistence.*; +/** + * Este es una area tematica + */ @Entity @NamedQueries({ @NamedQuery(name = "Periferico.findAll", query = "select c from Categoria c"), @@ -14,6 +17,7 @@ public final class Categoria { @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + @Column(nullable = false) private String name; private String description; diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Estado.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Estado.java index 26322a994b60867316505df485b5efa3ac5f74c6..5bbd79681bd5420c407af385ec2b08e53faa9261 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Estado.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Estado.java @@ -1,10 +1,10 @@ package uy.edu.fing.tse.practico.db.entity; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import javax.persistence.*; +/** + * Son los estados para los hechos, Nuevo, aComprobar, enProceso, Verificado, Publicado, Cancelado + */ @Entity public final class Estado { @@ -12,6 +12,7 @@ public final class Estado { @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + @Column(nullable = false) private String value; public Long getId() { diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Hecho.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Hecho.java index 3e0822a48bd3d38142660cd8a7d60c6ad3d80b41..3cfaa62024f9190f90849ec5f36acc407b03bb38 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Hecho.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Hecho.java @@ -1,6 +1,8 @@ package uy.edu.fing.tse.practico.db.entity; import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; @Entity @NamedQueries({ @@ -13,14 +15,80 @@ public final class Hecho { @GeneratedValue(strategy = GenerationType.AUTO) private Long id; + @Column(nullable = false) private String title; private String description; @ManyToOne - private Estado estado; + @Column(nullable = false) + private Estado actualState; @ManyToOne - private Calificacion calificacion; + private Calificacion score; + @ManyToOne + private Categoria category; + + @OneToMany + private List<TransicionEstado> history = new ArrayList<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Estado getActualState() { + return actualState; + } + + public void setActualState(Estado actualState) { + this.actualState = actualState; + } + + public Calificacion getScore() { + return score; + } + + public void setScore(Calificacion score) { + this.score = score; + } + + public Categoria getCategory() { + return category; + } + + public void setCategory(Categoria category) { + this.category = category; + } + + public List<TransicionEstado> getHistory() { + return history; + } + + public void setHistory(List<TransicionEstado> history) { + this.history = history; + } + public void addHistory(TransicionEstado history) { + this.history.add(history); + } } diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Mecanismo.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Mecanismo.java new file mode 100644 index 0000000000000000000000000000000000000000..1729e0397a9d640d81bd21bc7910c53fce145124 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Mecanismo.java @@ -0,0 +1,42 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class Mecanismo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private boolean eneable = false; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isEneable() { + return eneable; + } + + public void setEneable(boolean eneable) { + this.eneable = eneable; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/MecanismoInterno.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/MecanismoInterno.java new file mode 100644 index 0000000000000000000000000000000000000000..48adddc6f34ae7829ea8054ae0ebea34bc95d38e --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/MecanismoInterno.java @@ -0,0 +1,8 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.Entity; + +@Entity +public class MecanismoInterno extends Mecanismo { + +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Noticia.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Noticia.java deleted file mode 100644 index 3720d68e222d256bdd45dffe1a4dcdabac1ed8b6..0000000000000000000000000000000000000000 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Noticia.java +++ /dev/null @@ -1,66 +0,0 @@ -package uy.edu.fing.tse.practico.db.entity; - -import javax.persistence.*; -import java.util.ArrayList; -import java.util.List; - -@Entity -@NamedQueries({ - @NamedQuery(name = "Noticia.findAll", query = "select n from Noticia n"), - @NamedQuery(name = "Noticia.findById", query = "select n from Noticia n where n.id = :id") -}) -public class Noticia { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String titulo; - - private String descripcion; - - @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "noticia", orphanRemoval = true) - private List<Publicacion> publicaciones = new ArrayList<>(); - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTitulo() { - return titulo; - } - - public void setTitulo(String titulo) { - this.titulo = titulo; - } - - public String getDescripcion() { - return descripcion; - } - - public void setDescripcion(String descripcion) { - this.descripcion = descripcion; - } - - public List<Publicacion> getPublicaciones() { - return publicaciones; - } - - public void addPublicacion(Publicacion p) { - p.setNoticia(this); - this.publicaciones.add(p); - } - - public void setPublicaciones(List<Publicacion> publicaciones) { - publicaciones.forEach(p -> { - if (p.getNoticia() == null) { - p.setNoticia(this); - } - }); - this.publicaciones = publicaciones; - } -} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Periferico.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Periferico.java index de755008598653a2c8af89ebb2833eec9110f215..e320c728b63ad578eb43bea1304bf39806f06e77 100644 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Periferico.java +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Periferico.java @@ -11,40 +11,27 @@ import java.util.List; @NamedQuery(name = "Periferico.findById", query = "select p from Periferico p where p.id = :id"), @NamedQuery(name = "Periferico.findByCategoria", query = "select p from Periferico p where p.categorias.name = :name") //todo verificar consulta }) -public final class Periferico { - - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; +public final class Periferico extends Mecanismo { @ManyToMany //todo: verificar que funcione - private List<Categoria> categorias = new ArrayList<>(); + private List<Categoria> categories = new ArrayList<>(); + @Column(nullable = false) private String endpoint; - private String name; - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public List<Categoria> getCategorias() { - if (categorias == null) { - categorias = new ArrayList<>(); + public List<Categoria> getCategories() { + if (categories == null) { + categories = new ArrayList<>(); } - return categorias; + return categories; } - public void addCategorias(Categoria categoria) { - this.categorias.add(categoria); + public void addCategory(Categoria categoria) { + this.categories.add(categoria); } - public void setCategorias(List<Categoria> categorias) { - this.categorias = categorias; + public void setCategories(List<Categoria> categorias) { + this.categories = categorias; } public String getEndpoint() { @@ -55,11 +42,4 @@ public final class Periferico { this.endpoint = endpoint; } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } } diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Publicacion.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Publicacion.java deleted file mode 100644 index 09a6e1e587e3184ccaae93b15f749cb6ea9b76a8..0000000000000000000000000000000000000000 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Publicacion.java +++ /dev/null @@ -1,56 +0,0 @@ -package uy.edu.fing.tse.practico.db.entity; - -import javax.persistence.*; - -@Entity -@NamedQueries({ - @NamedQuery(name = "Publicacion.findAll", query = "select p from Publicacion p"), - @NamedQuery(name = "Publicacion.findByNoticiaId", query = "select p from Publicacion p where p.noticia.id = :idN"), - @NamedQuery(name = "Publicacion.findById", query = "select p from Publicacion p where p.id = :id")} -) -public class Publicacion { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - //TODO: potencial ENUM - private String tipo; - - private String url; - - @ManyToOne - private Noticia noticia; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTipo() { - return tipo; - } - - public void setTipo(String tipo) { - this.tipo = tipo; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public Noticia getNoticia() { - return noticia; - } - - public void setNoticia(Noticia noticia) { - this.noticia = noticia; - } -} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Rol.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Rol.java new file mode 100644 index 0000000000000000000000000000000000000000..2f0ab9b88fc670d6dedccf17eb6fb0d65380e28a --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Rol.java @@ -0,0 +1,30 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; + +@Entity +public class Rol { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(nullable = false) + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/TransicionEstado.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/TransicionEstado.java new file mode 100644 index 0000000000000000000000000000000000000000..bb404bf5616080667f5c9e8a559a375d6af3ec3a --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/TransicionEstado.java @@ -0,0 +1,64 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; +import java.util.Date; + +@Entity +public class TransicionEstado { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(nullable = false) + private Estado state; + + @Column(nullable = false) + private Usuario user; + + @Column(nullable = false) + private Hecho fact; + + @Column(nullable = false) + private Date date = new Date(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Estado getState() { + return state; + } + + public void setState(Estado state) { + this.state = state; + } + + public Usuario getUser() { + return user; + } + + public void setUser(Usuario user) { + this.user = user; + } + + public Hecho getFact() { + return fact; + } + + public void setFact(Hecho fact) { + this.fact = fact; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Usuario.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Usuario.java new file mode 100644 index 0000000000000000000000000000000000000000..e9b90cfd7db8276cc86824ab54cee384a4a6644f --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Usuario.java @@ -0,0 +1,30 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public class Usuario { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @Column(nullable = false) + private String mail; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioBO.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioBO.java new file mode 100644 index 0000000000000000000000000000000000000000..c1d5cfbb00e8598952f4715e44f16527a8a06e01 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioBO.java @@ -0,0 +1,39 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; +import java.util.UUID; + +@Entity +public class UsuarioBO extends Usuario { + + @Column(nullable = false) + private String salt = UUID.randomUUID().toString(); + + @Column(nullable = false) + private String password; + + @ManyToOne + private Rol role; + + public String getSalt() { + return salt; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Rol getRole() { + return role; + } + + public void setRole(Rol role) { + this.role = role; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioFO.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioFO.java new file mode 100644 index 0000000000000000000000000000000000000000..a99a7b49d774f13c8e946853c1c55e03bebe6737 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/UsuarioFO.java @@ -0,0 +1,7 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.Entity; + +@Entity +public class UsuarioFO extends Usuario { +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Verificacion.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Verificacion.java deleted file mode 100644 index 39c3e84d3c181b593a5f88f8ed09c90e8729c7c6..0000000000000000000000000000000000000000 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Verificacion.java +++ /dev/null @@ -1,20 +0,0 @@ -package uy.edu.fing.tse.practico.db.entity; - -import javax.persistence.*; - -@Entity -public class Verificacion { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToOne - private Periferico periferico; - - @ManyToOne - private Hecho hecho; - - private Short nota; - private String justificacion; -} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionChecker.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionChecker.java new file mode 100644 index 0000000000000000000000000000000000000000..acfb4205b99e378dd111202019c77e5986dec48b --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionChecker.java @@ -0,0 +1,65 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; + +@Entity +public class VerificacionChecker { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + @Column(nullable = false) + private UsuarioBO checker; + + @ManyToOne + @Column(nullable = false) + private Hecho fact; + + @Column(nullable = false) + private Calificacion score; + + @Column(nullable = false) + private String justification; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public UsuarioBO getChecker() { + return checker; + } + + public void setChecker(UsuarioBO checker) { + this.checker = checker; + } + + public Hecho getFact() { + return fact; + } + + public void setFact(Hecho fact) { + this.fact = fact; + } + + public Calificacion getScore() { + return score; + } + + public void setScore(Calificacion score) { + this.score = score; + } + + public String getJustification() { + return justification; + } + + public void setJustification(String justification) { + this.justification = justification; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionMecanismo.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionMecanismo.java new file mode 100644 index 0000000000000000000000000000000000000000..d1c1e386347b60b7cca3bb29b8f25123f9727c51 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/VerificacionMecanismo.java @@ -0,0 +1,77 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; +import java.util.Date; + +@Entity +public class VerificacionMecanismo { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + @Column(nullable = false) + private Periferico peripheral; + + @ManyToOne + @Column(nullable = false) + private Hecho fact; + + @Column(nullable = false) + private Short grade; + + @Column(nullable = false) + private String justification; + + @Column(nullable = false) + private Date registerDate = new Date(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Periferico getPeripheral() { + return peripheral; + } + + public void setPeripheral(Periferico peripheral) { + this.peripheral = peripheral; + } + + public Hecho getFact() { + return fact; + } + + public void setFact(Hecho fact) { + this.fact = fact; + } + + public Short getGrade() { + return grade; + } + + public void setGrade(Short grade) { + this.grade = grade; + } + + public String getJustification() { + return justification; + } + + public void setJustification(String justification) { + this.justification = justification; + } + + public Date getRegisterDate() { + return registerDate; + } + + public void setRegisterDate(Date registerDate) { + this.registerDate = registerDate; + } +} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/Mapper.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/Mapper.java deleted file mode 100644 index 72e68014fcfce3ed2ef836403891aa069871b483..0000000000000000000000000000000000000000 --- a/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/Mapper.java +++ /dev/null @@ -1,53 +0,0 @@ -package uy.edu.fing.tse.practico.db.mapper; - -import uy.edu.fing.tse.dto.NoticiaDTO; -import uy.edu.fing.tse.dto.PublicacionDTO; -import uy.edu.fing.tse.practico.db.entity.Noticia; -import uy.edu.fing.tse.practico.db.entity.Publicacion; - -import java.util.stream.Collectors; - -public final class Mapper { - private Mapper() { - } - - public static Publicacion mapper(final PublicacionDTO p) { - Publicacion ret = new Publicacion(); - ret.setId(p.getId()); - ret.setTipo(p.getTipo()); - ret.setUrl(p.getUrl()); - return ret; - } - - public static PublicacionDTO mapper(final Publicacion p) { - return new PublicacionDTO(p.getId(), p.getTipo(), p.getUrl()); - } - - public static Noticia mapper(final NoticiaDTO n) { - Noticia ret = new Noticia(); - ret.setTitulo(n.getTitulo()); - ret.setDescripcion(n.getDescripcion()); - n.getPublicaciones().stream().map(Mapper::mapper).forEach(ret::addPublicacion); - return ret; - } - - public static NoticiaDTO mapper(final Noticia n) { - final NoticiaDTO dao = new NoticiaDTO(n.getId(), n.getTitulo(), n.getDescripcion()); - dao.setPublicaciones(n.getPublicaciones() - .stream().map(Mapper::mapper) - .collect(Collectors.toList())); - return dao; - } - - public static void update(final PublicacionDTO p, Publicacion dbP) { - dbP.setTipo(p.getTipo()); - dbP.setUrl(p.getUrl()); - } - - public static void update(final NoticiaDTO n, Noticia dbN) { - dbN.setTitulo(n.getTitulo()); - dbN.setDescripcion(n.getDescripcion()); - //FIXME puede dar inconsistencia - n.getPublicaciones().stream().map(Mapper::mapper).forEach(dbN::addPublicacion); - } -} diff --git a/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/MyMapper.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/MyMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b0c1965cc8b15b0521aece83db2ec38dec0171e9 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/mapper/MyMapper.java @@ -0,0 +1,14 @@ +package uy.edu.fing.tse.practico.db.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import uy.edu.fing.tse.practico.db.entity.Hecho; + +@Mapper +public interface MyMapper { + + MyMapper INSTANCE = Mappers.getMapper(MyMapper.class); + + Hecho convert() + +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Category.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Category.java new file mode 100644 index 0000000000000000000000000000000000000000..194727bb30ffd70a063579262d90b65907783406 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Category.java @@ -0,0 +1,38 @@ +package uy.edu.fing.tse.dto; + +public final class Category { + + private Long id; + private String name; + private String description; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return name; + } +} + diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckChecker.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckChecker.java new file mode 100644 index 0000000000000000000000000000000000000000..59d7463588798eb41e75d2f93e0c5137129f7d9f --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckChecker.java @@ -0,0 +1,50 @@ +package uy.edu.fing.tse.dto; + +public final class CheckChecker { + + private Long id; + private UserBO checker; + private Fact fact; + private Score score; + private String justification; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public UserBO getChecker() { + return checker; + } + + public void setChecker(UserBO checker) { + this.checker = checker; + } + + public Fact getFact() { + return fact; + } + + public void setFact(Fact fact) { + this.fact = fact; + } + + public Score getScore() { + return score; + } + + public void setScore(Score score) { + this.score = score; + } + + public String getJustification() { + return justification; + } + + public void setJustification(String justification) { + this.justification = justification; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckMechanism.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckMechanism.java new file mode 100644 index 0000000000000000000000000000000000000000..64c5a3683fff3d2da68bcce0352d0d253114a2d5 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/CheckMechanism.java @@ -0,0 +1,61 @@ +package uy.edu.fing.tse.dto; + +import java.util.Date; + +public final class CheckMechanism { + + private Long id; + private Peripherical peripheral; + private Fact fact; + private Short grade; + private String justification; + private Date registerDate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Peripherical getPeripheral() { + return peripheral; + } + + public void setPeripheral(Peripherical peripheral) { + this.peripheral = peripheral; + } + + public Fact getFact() { + return fact; + } + + public void setFact(Fact fact) { + this.fact = fact; + } + + public Short getGrade() { + return grade; + } + + public void setGrade(Short grade) { + this.grade = grade; + } + + public String getJustification() { + return justification; + } + + public void setJustification(String justification) { + this.justification = justification; + } + + public Date getRegisterDate() { + return registerDate; + } + + public void setRegisterDate(Date registerDate) { + this.registerDate = registerDate; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Fact.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Fact.java new file mode 100644 index 0000000000000000000000000000000000000000..691ec0e2360ff2f834fc029bcd4fd9d8507bc5a7 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Fact.java @@ -0,0 +1,75 @@ +package uy.edu.fing.tse.dto; + +import java.util.ArrayList; +import java.util.List; + +public final class Fact { + + private Long id; + private String title; + private String description; + private State actualState; + private Score score; + private Category category; + private List<StateHistory> history = new ArrayList<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public State getActualState() { + return actualState; + } + + public void setActualState(State actualState) { + this.actualState = actualState; + } + + public Score getScore() { + return score; + } + + public void setScore(Score score) { + this.score = score; + } + + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public List<StateHistory> getHistory() { + return history; + } + + public void setHistory(List<StateHistory> history) { + this.history = history; + } + + public void addHistory(StateHistory history) { + this.history.add(history); + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Mechanism.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Mechanism.java new file mode 100644 index 0000000000000000000000000000000000000000..65d5835b4dbddde744df78599aa15dbbde252373 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Mechanism.java @@ -0,0 +1,32 @@ +package uy.edu.fing.tse.dto; + +public class Mechanism { + + private Long id; + private String name; + private boolean eneable; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isEneable() { + return eneable; + } + + public void setEneable(boolean eneable) { + this.eneable = eneable; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/MechanismInternal.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/MechanismInternal.java new file mode 100644 index 0000000000000000000000000000000000000000..7f2b03854dc5162261418a59ccb4bc8871825fe4 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/MechanismInternal.java @@ -0,0 +1,6 @@ +package uy.edu.fing.tse.dto; + + +public final class MechanismInternal extends Mechanism { + +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/NoticiaDTO.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/NoticiaDTO.java deleted file mode 100644 index 8629078fc5f6a355ffb51e2eea283e76ba6827ba..0000000000000000000000000000000000000000 --- a/central-dto/src/main/java/uy/edu/fing/tse/dto/NoticiaDTO.java +++ /dev/null @@ -1,58 +0,0 @@ -package uy.edu.fing.tse.dto; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -public final class NoticiaDTO implements Serializable { - - - private static final long serialVersionUID = 4516690446335921631L; - - private final Long id; - - private final String titulo; - - private final String descripcion; - - private final List<PublicacionDTO> publicaciones = new ArrayList<>(); - - public NoticiaDTO(Long id, String titulo, String descripcion) { - this.id = id; - this.titulo = titulo; - this.descripcion = descripcion; - } - - public Long getId() { - return id; - } - - - public String getTitulo() { - return titulo; - } - - - public String getDescripcion() { - return descripcion; - } - - public List<PublicacionDTO> getPublicaciones() { - return publicaciones; - } - - public void setPublicaciones(List<PublicacionDTO> publicaciones) { - this.publicaciones.clear(); - this.publicaciones.addAll(publicaciones); - } - - @Override - public String toString() { - return "NoticiaDTO{" + - "id=" + id + - ", titulo='" + titulo + '\'' + - ", descripcion='" + descripcion + '\'' + - ", publicaciones=" + publicaciones + - '}'; - } -} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Peripherical.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Peripherical.java new file mode 100644 index 0000000000000000000000000000000000000000..91003e0fdca08ca86ee3f93e7003d79af05548ff --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Peripherical.java @@ -0,0 +1,35 @@ +package uy.edu.fing.tse.dto; + +import java.util.ArrayList; +import java.util.List; + + +public final class Peripherical extends Mechanism { + + private List<Category> categories = new ArrayList<>(); + private String endpoint; + + public List<Category> getCategories() { + if (categories == null) { + categories = new ArrayList<>(); + } + return categories; + } + + public void addCategory(Category categoria) { + this.categories.add(categoria); + } + + public void setCategories(List<Category> categorias) { + this.categories = categorias; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/PublicacionDTO.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/PublicacionDTO.java deleted file mode 100644 index e9804f0633ef0cf89f52c47136e0161aae0d3220..0000000000000000000000000000000000000000 --- a/central-dto/src/main/java/uy/edu/fing/tse/dto/PublicacionDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -package uy.edu.fing.tse.dto; - -import java.io.Serializable; - -public final class PublicacionDTO implements Serializable { - - private static final long serialVersionUID = -6800083961746968433L; - private final Long id; - - //TODO: potencial ENUM - private final String tipo; - - private final String url; - - public PublicacionDTO(Long id, String tipo, String url) { - this.id = id; - this.tipo = tipo; - this.url = url; - } - - public Long getId() { - return id; - } - - - public String getTipo() { - return tipo; - } - - - public String getUrl() { - return url; - } - - @Override - public String toString() { - return "PublicacionDTO{" + - "id=" + id + - ", tipo='" + tipo + '\'' + - ", url='" + url + '\'' + - '}'; - } -} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Role.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Role.java new file mode 100644 index 0000000000000000000000000000000000000000..698980b05cde8e240059693fa7fa382602ef546f --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Role.java @@ -0,0 +1,23 @@ +package uy.edu.fing.tse.dto; + +public class Role { + + private Long id; + private String name; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/Score.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/Score.java new file mode 100644 index 0000000000000000000000000000000000000000..770b8ac5ddbf7daecfbb0721bd629b93f9cb170d --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/Score.java @@ -0,0 +1,31 @@ +package uy.edu.fing.tse.dto; + +/** + * Esta es la que puede ser vergonzosa, verdad a media, verdad, falsa + */ +public final class Score { + + private Long id; + private String value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/State.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/State.java new file mode 100644 index 0000000000000000000000000000000000000000..483308de80ce772902fdaeaf7423f86bee79b086 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/State.java @@ -0,0 +1,31 @@ +package uy.edu.fing.tse.dto; + +/** + * Son los estados para los hechos, Nuevo, aComprobar, enProceso, Verificado, Publicado, Cancelado + */ +public final class State { + + private Long id; + private String value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/StateHistory.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/StateHistory.java new file mode 100644 index 0000000000000000000000000000000000000000..9d7ed14a00de6886c3a7a0ce4220b3803032579e --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/StateHistory.java @@ -0,0 +1,52 @@ +package uy.edu.fing.tse.dto; + +import java.util.Date; + +public final class StateHistory { + + private Long id; + private State state; + private User user; + private Fact fact; + private Date date; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public Fact getFact() { + return fact; + } + + public void setFact(Fact fact) { + this.fact = fact; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/User.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/User.java new file mode 100644 index 0000000000000000000000000000000000000000..fd6c050f57ef4aa376e8b81f92b4132a36dc0153 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/User.java @@ -0,0 +1,23 @@ +package uy.edu.fing.tse.dto; + +public class User { + + private Long id; + private String mail; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/UserBO.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/UserBO.java new file mode 100644 index 0000000000000000000000000000000000000000..f378d472eccec97cd91b091514f1f25bd0d7ddcb --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/UserBO.java @@ -0,0 +1,33 @@ +package uy.edu.fing.tse.dto; + + +public final class UserBO extends User { + + private String salt; + private String password; + private Role role; + + public String getSalt() { + return salt; + } + + public void setSalt(String salt) { + this.salt = salt; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Role getRole() { + return role; + } + + public void setRole(Role role) { + this.role = role; + } +} diff --git a/central-dto/src/main/java/uy/edu/fing/tse/dto/UserFO.java b/central-dto/src/main/java/uy/edu/fing/tse/dto/UserFO.java new file mode 100644 index 0000000000000000000000000000000000000000..933fc5e07575125189919b73871b3bcbaf846011 --- /dev/null +++ b/central-dto/src/main/java/uy/edu/fing/tse/dto/UserFO.java @@ -0,0 +1,5 @@ +package uy.edu.fing.tse.dto; + + +public final class UserFO extends User { +} diff --git a/pom.xml b/pom.xml index 22f0748bb2629ea351e271fa7a332695f9055e20..f605bf05e6e86fb7281c0bb0a195385e2ad16f0e 100644 --- a/pom.xml +++ b/pom.xml @@ -201,6 +201,12 @@ <artifactId>javax.annotation-api</artifactId> <version>1.2</version> </dependency> + + <dependency> + <groupId>org.mapstruct</groupId> + <artifactId>mapstruct</artifactId> + <version>1.3.0.Final</version> + </dependency> </dependencies> </dependencyManagement>