diff --git a/README.md b/README.md index 83d66c50c89e1e27dd7458269ebb0bb48546e95a..9d614a89de9c15005c82c0b02f093ef4352c3abd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # componente central +Se despliega en miNube de antel en un servidor Wildfly 15.0 \ No newline at end of file diff --git a/backoffice/pom.xml b/backoffice/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a08d24c03efd121ea6173f72f8956a45a8591519 --- /dev/null +++ b/backoffice/pom.xml @@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>central</artifactId> + <groupId>uy.edu.fing.tse</groupId> + <version>1.0.TSE-SNAPSHOT</version> + </parent> + + <artifactId>backoffice</artifactId> + <packaging>war</packaging> + + <name>backoffice: WAR Module</name> + + <dependencies> + <dependency> + <groupId>uy.edu.fing.tse</groupId> + <artifactId>central-dto</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>uy.edu.fing.tse</groupId> + <artifactId>central-ejb</artifactId> + <type>ejb</type> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.jboss.resteasy</groupId> + <artifactId>jaxrs-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.enterprise</groupId> + <artifactId>cdi-api</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.jboss.spec.javax.faces</groupId> + <artifactId>jboss-jsf-api_2.2_spec</artifactId> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <scope>provided</scope> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>4.0.1</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.primefaces</groupId> + <artifactId>primefaces</artifactId> + <version>7.0</version> + </dependency> + + </dependencies> + + <build> + <finalName>${project.artifactId}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>${version.war.plugin}</version> + <configuration> + <failOnMissingWebXml>false</failOnMissingWebXml> + <warName>backoffice</warName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>5</source> + <target>5</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/backoffice/src/main/java/uy/edu/fing/tse/jsf/RequestBean.java b/backoffice/src/main/java/uy/edu/fing/tse/jsf/RequestBean.java new file mode 100644 index 0000000000000000000000000000000000000000..8e0d1185d6746b3faa06c6c2b6d336eceb4c243e --- /dev/null +++ b/backoffice/src/main/java/uy/edu/fing/tse/jsf/RequestBean.java @@ -0,0 +1,109 @@ +package uy.edu.fing.tse.jsf; + +import uy.edu.fing.tse.dto.NoticiaDTO; +import uy.edu.fing.tse.dto.PublicacionDTO; +import uy.edu.fing.tse.practico.business.BusinessLocal; + +import javax.ejb.EJB; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ManagedProperty; +import javax.faces.bean.RequestScoped; +import java.util.List; +import java.util.Optional; + +@RequestScoped +@ManagedBean(name = "noticiaBean") +public class RequestBean { + + @EJB + private BusinessLocal negocio; + + @EJB + private uy.edu.fing.tse.practico.business.jms.JMSProducer jms; + + @ManagedProperty(value = "#{Session}") + private SessionBean session; + + + private Optional<String> tipo = Optional.empty(); + private Optional<String> url = Optional.empty(); + + private Optional<String> titulo = Optional.empty(); + private Optional<String> descripcion = Optional.empty(); + + public List<NoticiaDTO> getNoticias() { + return negocio.getNoticias(); + } + + public String getTipo() { + return tipo.orElse(""); + } + + public void setTipo(String tipo) { + this.tipo = Optional.ofNullable(tipo); + } + + public String getUrl() { + return url.orElse(""); + } + + public void setUrl(String url) { + this.url = Optional.ofNullable(url); + } + + public String getTitulo() { + return titulo.orElse(""); + } + + public void setTitulo(String titulo) { + this.titulo = Optional.ofNullable(titulo); + } + + public String getDescripcion() { + return descripcion.orElse(""); + } + + public void setDescripcion(String descripcion) { + this.descripcion = Optional.ofNullable(descripcion); + } + + public SessionBean getSession() { + return session; + } + + public void setSession(SessionBean session) { + this.session = session; + } + + public String add(long idN) { + final PublicacionDTO dtoP = new PublicacionDTO(null, tipo.get(), url.get()); + final NoticiaDTO noticiaDTO = negocio.addPublicacionANoticia(dtoP, idN); + session.setNoticia(noticiaDTO); + tipo = url = Optional.empty(); + return "noticia"; + } + + public String addNoticia() { + final int cant = negocio.getNoticias().size(); + jms.altaNoticia(new NoticiaDTO(null, titulo.get(), descripcion.get())); + + for (int i = 0; i < 50; i++) { + if (cant == negocio.getNoticias().size()) { + sleep(); + } else { + break; + } + } + + titulo = descripcion = Optional.empty(); + return "getNoticias"; + } + + private void sleep() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } +} diff --git a/backoffice/src/main/java/uy/edu/fing/tse/jsf/SessionBean.java b/backoffice/src/main/java/uy/edu/fing/tse/jsf/SessionBean.java new file mode 100644 index 0000000000000000000000000000000000000000..c780223fbac134fb39bcf60ae1db1076d1d833fd --- /dev/null +++ b/backoffice/src/main/java/uy/edu/fing/tse/jsf/SessionBean.java @@ -0,0 +1,33 @@ +package uy.edu.fing.tse.jsf; + +import uy.edu.fing.tse.dto.NoticiaDTO; + +import javax.annotation.PostConstruct; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; + +@SessionScoped +@ManagedBean(name = "Session") +public class SessionBean { + + private NoticiaDTO selected; + + @PostConstruct + public void init() { + + } + + public NoticiaDTO getNoticia() { + return selected; + } + + public void setNoticia(NoticiaDTO selected) { + this.selected = selected; + } + + public String seleccionar(NoticiaDTO n) { + selected = n; + return "noticia"; + } + +} diff --git a/backoffice/src/main/java/uy/edu/fing/tse/jsp/MyServlet.java b/backoffice/src/main/java/uy/edu/fing/tse/jsp/MyServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..44d8889fff34de2a89f8addd156d13e573768706 --- /dev/null +++ b/backoffice/src/main/java/uy/edu/fing/tse/jsp/MyServlet.java @@ -0,0 +1,77 @@ +package uy.edu.fing.tse.jsp; + +import uy.edu.fing.tse.dto.NoticiaDTO; +import uy.edu.fing.tse.dto.PublicacionDTO; +import uy.edu.fing.tse.practico.business.BusinessLocal; + +import javax.ejb.EJB; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@WebServlet(name = "Controller", urlPatterns = "/jsp/controlador") +public class MyServlet extends HttpServlet { + private static final long serialVersionUID = -964003102417352102L; + + @EJB + private BusinessLocal negocio; + + @EJB + private uy.edu.fing.tse.practico.business.jms.JMSProducer jms; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + final String noticia = req.getParameter("noticia"); + if (noticia == null) { + req.setAttribute("noticias", negocio.getNoticias()); + req.getRequestDispatcher("getNoticias.jsp").forward(req, resp); + } else { + req.setAttribute("noticia", negocio.findNoticia(Long.parseLong(noticia))); + req.getRequestDispatcher("verPublicacionesNoticia.jsp").forward(req, resp); + } + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + final String idNoticia = req.getParameter("idNoticia"); + + if (idNoticia == null) { + + final int cant = negocio.getNoticias().size(); + final String descripcion = req.getParameter("descripcion"); + final String titulo = req.getParameter("titulo"); + + jms.altaNoticia(new NoticiaDTO(null, titulo, descripcion)); + + for (int i = 0; i < 10; i++) { + if (cant == negocio.getNoticias().size()) { + sleep(); + } else { + break; + } + } + + req.setAttribute("noticias", negocio.getNoticias()); + req.getRequestDispatcher("getNoticias.jsp").forward(req, resp); + } else { + final String tipo = req.getParameter("tipo"); + final String url = req.getParameter("url"); + final NoticiaDTO noticia = negocio.addPublicacionANoticia(new PublicacionDTO(null, tipo, url), Long.parseLong(idNoticia)); + + req.setAttribute("noticia", noticia); + req.getRequestDispatcher("verPublicacionesNoticia.jsp").forward(req, resp); + } + + } + + private void sleep() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } +} diff --git a/backoffice/src/main/resources/.keep b/backoffice/src/main/resources/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/backoffice/src/main/webapp/WEB-INF/beans.xml b/backoffice/src/main/webapp/WEB-INF/beans.xml new file mode 100644 index 0000000000000000000000000000000000000000..76426bcac566205e6c414979c639bf1cd7f29d2d --- /dev/null +++ b/backoffice/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Marker file indicating CDI should be enabled --> +<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://xmlns.jcp.org/xml/ns/javaee + http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> +</beans> diff --git a/backoffice/src/main/webapp/WEB-INF/faces-config.xml b/backoffice/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 0000000000000000000000000000000000000000..ffc7e8122b43c698e0e9a855f4637de1bac6a43e --- /dev/null +++ b/backoffice/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,9 @@ +<?xml version="1.0"?> +<!-- Marker file indicating JSF 2.2 should be enabled in the application --> +<faces-config version="2.2" + xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://xmlns.jcp.org/xml/ns/javaee + http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> +</faces-config> diff --git a/backoffice/src/main/webapp/WEB-INF/web.xml b/backoffice/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000000000000000000000000000000000..cb4b2e4e3255c61affb7d042d7f0c71058c15325 --- /dev/null +++ b/backoffice/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee web-app_3_0.xsd" + version="3.0"> + + <display-name>Practico TSE</display-name> + + <!-- Change to "Production" when you are ready to deploy --> + <context-param> + <param-name>javax.faces.PROJECT_STAGE</param-name> + <!--param-value>Development</param-value--> + <param-value>Production</param-value> + </context-param> + + <context-param> + <param-name>javax.faces.STATE_SAVING_METHOD</param-name> + <param-value>client</param-value> + </context-param> + + <context-param> + <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> + <param-value>true</param-value> + </context-param> + + <context-param> + <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name> + <param-value>true</param-value> + </context-param> + + <!-- JSF mapping --> + <servlet> + <servlet-name>Faces Servlet</servlet-name> + <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> + <load-on-startup>1</load-on-startup> + </servlet> + + <!-- Map these files with JSF --> + <servlet-mapping> + <servlet-name>Faces Servlet</servlet-name> + <url-pattern>/faces/*</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>Faces Servlet</servlet-name> + <url-pattern>*.jsf</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>Faces Servlet</servlet-name> + <url-pattern>*.faces</url-pattern> + </servlet-mapping> + <servlet-mapping> + <servlet-name>Faces Servlet</servlet-name> + <url-pattern>*.xhtml</url-pattern> + </servlet-mapping> + + <session-config> + <session-timeout>15</session-timeout> + <cookie-config> + <!-- Prevents session cookie from being read by clientside scripts --> + <!--<http-only>true</http-only>--> + <!--<secure>true</secure>--> + </cookie-config> + <tracking-mode>COOKIE</tracking-mode> + </session-config> +</web-app> \ No newline at end of file diff --git a/backoffice/src/main/webapp/index.html b/backoffice/src/main/webapp/index.html new file mode 100644 index 0000000000000000000000000000000000000000..a5c3cccfcc0f62458c59076efad7cba7b0b0be26 --- /dev/null +++ b/backoffice/src/main/webapp/index.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>TSE 2019 - Práctico</title> +</head> +<body> + +<h1>TSE 2019 - Practico</h1> +<br> +<h3> + <a href="jsp">JSP</a> +</h3> +<br> + +<h3> + <a href="jsf">JSF</a> +</h3> +<br> + +<h3> + <a href="../practico-api/rest/noticias">Rest</a> +</h3> +<br> + +<h3> + <a href="../practico-api/SoapAPI?wsdl">SOAP</a> +</h3> +<br> + +<h3> + <a href="resources/soapui/TSE-API-soapui-project.xml" download>SoapUI</a> +</h3> + +</body> +</html> \ No newline at end of file diff --git a/backoffice/src/main/webapp/jsf/getNoticias.xhtml b/backoffice/src/main/webapp/jsf/getNoticias.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..e5f6fdcc80fb08feb3f92adbfc0118f46f543dff --- /dev/null +++ b/backoffice/src/main/webapp/jsf/getNoticias.xhtml @@ -0,0 +1,52 @@ +<?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"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:p="http://primefaces.org/ui"> + +<h:head> +</h:head> + +<h:body> + + <p:fieldset legend="TSE 2019 - Practico JSF" style="margin-bottom:20px"> + <h:form id="lista"> + <p:growl id="msgs" showDetail="true"/> + + <p:accordionPanel id="noticias" value="#{noticiaBean.noticias}" var="noticia" dynamic="true" cache="true"> + + <p:tab title="#{noticia.titulo}"> + <h:panelGrid columns="2" cellpadding="10"> + <!--<p:graphicImage name="demo/images/godfather/godfather1.jpg"/>--> + <h:outputText value="#{noticia.descripcion}"/> + <br/> + <p:commandButton value="Ver Noticia" action="#{Session.seleccionar(noticia)}"/> + </h:panelGrid> + </p:tab> + </p:accordionPanel> + </h:form> + <h:form> + <p:panel header="Agregar Noticia"> + <p:messages> + <p:autoUpdate/> + </p:messages> + + <h:panelGrid id="grid" columns="4" cellpadding="5"> + <h:outputLabel for="titulo" value="Titulo:" style="font-weight:bold"/> + <p:inputText id="titulo" placeholder="Titulo" value="#{noticiaBean.titulo}" required="true" + label="Titulo"/> + <p:message for="titulo"/> + <br/> + <h:outputLabel for="descripcion" value="Descripcion:" style="font-weight:bold"/> + <p:inputTextarea id="descripcion" placeholder="Descripcion" value="#{noticiaBean.descripcion}"/> + <p:message for="descripcion"/> + </h:panelGrid> + <br/> + <p:commandButton update="lista,grid" value="Agregar" icon="pi pi-check" validateClient="true" + style="margin-right:10px" action="#{noticiaBean.addNoticia()}"/> + </p:panel> + </h:form> + </p:fieldset> +</h:body> +</html> diff --git a/backoffice/src/main/webapp/jsf/index.html b/backoffice/src/main/webapp/jsf/index.html new file mode 100644 index 0000000000000000000000000000000000000000..425f74d6ea6b17ee38d63ce205b64c590b59d260 --- /dev/null +++ b/backoffice/src/main/webapp/jsf/index.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>TSE 2019 - Practico JSF</title> + + <meta http-equiv="refresh" content="0; url=getNoticias.xhtml"> +</head> +<body> +<h1>TSE 2019 - Practico JSF</h1> +<br> + + +<a href="getNoticias.xhtml">getNoticias</a> +</body> +</html> \ No newline at end of file diff --git a/backoffice/src/main/webapp/jsf/noticia.xhtml b/backoffice/src/main/webapp/jsf/noticia.xhtml new file mode 100644 index 0000000000000000000000000000000000000000..8d2ec03fb0a8b9eb8d0cb82dbb129c61f8ff0129 --- /dev/null +++ b/backoffice/src/main/webapp/jsf/noticia.xhtml @@ -0,0 +1,64 @@ +<?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"> +<html xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:p="http://primefaces.org/ui" + xmlns:f="http://xmlns.jcp.org/jsf/core" +> + +<h:head> +</h:head> + +<h:body> + + <p:fieldset legend="TSE 2019 - Practico JSF" style="margin-bottom:20px"> + <h:form> + <p:growl id="msgs" showDetail="true"/> + + + <p:fieldset legend="#{Session.noticia.titulo}" style="margin-bottom:20px"> + <h:panelGrid columns="2" cellpadding="10"> + <!--<p:graphicImage name="demo/images/godfather/godfather1.jpg"/>--> + <h:outputText value="#{Session.noticia.descripcion}"/> + <br/> + <p:dataList id="lista" value="#{Session.noticia.publicaciones}" var="publicacion"> + <f:facet name="header"> + Publicaciones + </f:facet> + <h:outputText value="#{publicacion.tipo} "/> <p:link href="#{publicacion.url}" value="Link"/> + </p:dataList> + <br/> + + <p:panel header="Agregar Publicacion"> + <p:messages> + <p:autoUpdate/> + </p:messages> + + <h:panelGrid id="grid" columns="4" cellpadding="5"> + <h:outputLabel for="tipo" value="Tipo:" style="font-weight:bold"/> + <p:inputText id="tipo" placeholder="tipo" value="#{noticiaBean.tipo}" required="true" + label="Tipo"/> + <p:message for="tipo"/> + <br/> + <h:outputLabel for="url" value="URL:" style="font-weight:bold"/> + <p:inputText id="url" placeholder="http://google.com" value="#{noticiaBean.url}" + validatorMessage="URL Invalida."> + <f:validateRegex + pattern="^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$"/> + </p:inputText> + <p:message for="url"/> + </h:panelGrid> + <br/> + <p:commandButton update="lista" value="Agregar" icon="pi pi-check" validateClient="true" + style="margin-right:10px" action="#{noticiaBean.add(Session.noticia.id)}"/> + </p:panel> + <br/> + + <p:link outcome="getNoticias" value="Volver"/> + </h:panelGrid> + </p:fieldset> + </h:form> + </p:fieldset> +</h:body> +</html> diff --git a/backoffice/src/main/webapp/jsp/getNoticias.jsp b/backoffice/src/main/webapp/jsp/getNoticias.jsp new file mode 100644 index 0000000000000000000000000000000000000000..974dc0a0dbeadfee293dc558d9b6632b4b7f01b2 --- /dev/null +++ b/backoffice/src/main/webapp/jsp/getNoticias.jsp @@ -0,0 +1,38 @@ +<%@ page import="uy.edu.fing.tse.dto.NoticiaDTO" %> +<%@ page import="java.util.List" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<html> +<head> + <title>TSE 2019 - Practico JSP</title> +</head> +<body> +<h1>TSE 2019 - Practico JSP</h1> +<br> + +<% + final List noticias = (List) request.getAttribute("noticias"); + + for (Object noticia : noticias) { + final NoticiaDTO noti = (NoticiaDTO) noticia; +%> +<h2><a href="controlador?noticia=<%= noti.getId()%>"><%= noti.getTitulo()%> +</a></h2> + +<%= noti.getDescripcion()%> +<br/> +<hr/> +<%}%> + +<hr/> + +<form action="controlador" method="post"> + <label for="titulo">Titulo:</label> + <input id="titulo" name="titulo"> + <br/> + <label for="descripcion">Descripcion:</label> + <textarea id="descripcion" name="descripcion"></textarea> + <br/> + <input value="Agregar" type="submit"> +</form> +</body> +</html> diff --git a/backoffice/src/main/webapp/jsp/index.html b/backoffice/src/main/webapp/jsp/index.html new file mode 100644 index 0000000000000000000000000000000000000000..dbfdd688bb1d87ac54964deb5adbb630e26ebe48 --- /dev/null +++ b/backoffice/src/main/webapp/jsp/index.html @@ -0,0 +1,15 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>TSE 2019 - Practico JSP</title> + <meta http-equiv="refresh" content="0; url=controlador"> +</head> +<body> + +<h1>TSE 2019 - Practico JSP</h1> +<br> +<meta> +<a href="controlador">getNoticias</a> +</body> +</html> \ No newline at end of file diff --git a/backoffice/src/main/webapp/jsp/verPublicacionesNoticia.jsp b/backoffice/src/main/webapp/jsp/verPublicacionesNoticia.jsp new file mode 100644 index 0000000000000000000000000000000000000000..2ea3f72d3f4fef6120e21db40b39202d4cb79f12 --- /dev/null +++ b/backoffice/src/main/webapp/jsp/verPublicacionesNoticia.jsp @@ -0,0 +1,43 @@ +<%@ page import="uy.edu.fing.tse.dto.NoticiaDTO" %> +<%@ page import="uy.edu.fing.tse.dto.PublicacionDTO" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<html> +<head> + <title>TSE 2019 - Practico JSP</title> +</head> +<body> +<h1>TSE 2019 - Practico JSP</h1> +<br> + +<% + final NoticiaDTO noticia = (NoticiaDTO) request.getAttribute("noticia"); +%> +<h2><%= noticia.getTitulo()%> +</h2> +<%= noticia.getDescripcion()%> +<br/> +<hr/> + +<% + for (Object pObject : noticia.getPublicaciones()) { + PublicacionDTO publicacion = (PublicacionDTO) pObject; +%> + +Id: <%=publicacion.getId()%> +<br/> +Tipo: <%=publicacion.getTipo()%> +<br/> +<a href="<%=publicacion.getUrl()%>">LINK</a> +<br/> +<%}%> + + +<form action="controlador" method="post"> + <input id="idNoticia" name="idNoticia" type="hidden" value="<%=noticia.getId()%>"> + Tipo: <input id="tipo" name="tipo" placeholder="Tweet"> + URL: <input id="url" name="url" placeholder="www.google.com"> + <input type="submit"> +</form> + +</body> +</html> diff --git a/backoffice/src/main/webapp/resources/.keep b/backoffice/src/main/webapp/resources/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/backoffice/src/main/webapp/resources/soapui/TSE-API-soapui-project.xml b/backoffice/src/main/webapp/resources/soapui/TSE-API-soapui-project.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b4ced18efbda55f4943345c6c9674a0ba2dca82 --- /dev/null +++ b/backoffice/src/main/webapp/resources/soapui/TSE-API-soapui-project.xml @@ -0,0 +1,333 @@ +<?xml version="1.0" encoding="UTF-8"?> +<con:soapui-project id="36d9e2e5-cd71-41e6-a125-aec8926345a8" activeEnvironment="Default" name="TSE API" resourceRoot="" + soapui-version="5.5.0" xmlns:con="http://eviware.com/soapui/config"> + <con:settings/> + <con:interface xsi:type="con:RestService" id="9e519c47-0d19-4949-953a-114533b1ceb5" + wadlVersion="http://wadl.dev.java.net/2009/02" name="http://localhost:8080" type="rest" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings/> + <con:definitionCache/> + <con:endpoints> + <con:endpoint>http://localhost:8080</con:endpoint> + </con:endpoints> + <con:resource name="Publicacion" path="/practico-api/rest/noticia/{id}/publicacion" + id="8f67d9ef-e987-4e58-9f1f-32dd05a7f74a"> + <con:settings/> + <con:parameters> + <con:parameter> + <con:name>tipo</con:name> + <con:value>rest</con:value> + <con:style>QUERY</con:style> + <con:default>rest</con:default> + <con:path xsi:nil="true"/> + <con:description xsi:nil="true"/> + </con:parameter> + <con:parameter> + <con:name>url</con:name> + <con:value>www.sss.fb</con:value> + <con:style>QUERY</con:style> + <con:default>www.sss.fb</con:default> + <con:path xsi:nil="true"/> + <con:description xsi:nil="true"/> + </con:parameter> + <con:parameter> + <con:name>id</con:name> + <con:value/> + <con:style>TEMPLATE</con:style> + <con:default/> + <con:description xsi:nil="true"/> + </con:parameter> + </con:parameters> + <con:method name="Publicacion 1" id="9524c72a-cc60-48be-8834-a98887285109" method="POST"> + <con:settings/> + <con:parameters/> + <con:representation type="RESPONSE"> + <con:mediaType>application/json</con:mediaType> + <con:status>200</con:status> + <con:params/> + <con:element xmlns:pub="http://localhost/practico-api/rest/noticia/1/publicacion">pub:Response + </con:element> + </con:representation> + <con:representation type="REQUEST"> + <con:mediaType>application/json</con:mediaType> + <con:params/> + </con:representation> + <con:request name="Request 1" id="2c322e32-fb13-4f8d-9c99-06c71f6de9af" mediaType="application/json" + postQueryString="false"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/> + </con:setting> + </con:settings> + <con:endpoint>http://localhost:8080</con:endpoint> + <con:request/> + <con:originalUri>http://localhost/practico-api/rest/noticia/1/publicacion</con:originalUri> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <con:entry key="tipo" value="rest"/> + <con:entry key="id" value="1"/> + <con:entry key="url" value="www.sss.fb"/> + </con:parameters> + <con:parameterOrder> + <con:entry>tipo</con:entry> + <con:entry>url</con:entry> + <con:entry>id</con:entry> + </con:parameterOrder> + </con:request> + </con:method> + </con:resource> + <con:resource name="publicaciones" path="/practico-api/rest/noticia/{id}/publicaciones" + id="aaea0758-01a9-40be-9fa0-5ae0fea29651"> + <con:settings/> + <con:parameters> + <con:parameter> + <con:name>id</con:name> + <con:value/> + <con:style>TEMPLATE</con:style> + <con:default/> + <con:description xsi:nil="true"/> + </con:parameter> + </con:parameters> + <con:method name="Method 1" id="087fbea6-05a0-4d26-a699-8e716fc6bb06" method="GET"> + <con:settings/> + <con:parameters/> + <con:representation type="RESPONSE"> + <con:mediaType>application/json</con:mediaType> + <con:status>200</con:status> + <con:params/> + <con:element>Response</con:element> + </con:representation> + <con:request name="Request 1" id="46277185-9bfa-4836-b1b1-008b03bb23b2" mediaType="application/json"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/> + </con:setting> + </con:settings> + <con:endpoint>http://localhost:8080</con:endpoint> + <con:request/> + <con:originalUri>http://localhost/practico-api/rest/noticia/1/publicaciones</con:originalUri> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters> + <entry key="id" value="1" xmlns="http://eviware.com/soapui/config"/> + </con:parameters> + <con:parameterOrder> + <con:entry>id</con:entry> + </con:parameterOrder> + </con:request> + </con:method> + </con:resource> + <con:resource name="noticias" path="/practico-api/rest/noticias" id="9bf57d07-edc8-4794-bed8-8e64e394bba6"> + <con:settings/> + <con:parameters/> + <con:method name="Method 1" id="07302d11-f397-4f3d-853e-c1f918be7c08" method="GET"> + <con:settings/> + <con:parameters/> + <con:representation type="RESPONSE"> + <con:mediaType>application/json</con:mediaType> + <con:status>200</con:status> + <con:params/> + <con:element>Response</con:element> + </con:representation> + <con:request name="Request 1" id="a527c0f7-4f39-49f5-9516-902a14056a2f" mediaType="application/json"> + <con:settings> + <con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers"><xml-fragment/> + </con:setting> + </con:settings> + <con:endpoint>http://localhost:8080</con:endpoint> + <con:request/> + <con:originalUri>http://localhost/practico-api/rest/noticias</con:originalUri> + <con:credentials> + <con:authType>No Authorization</con:authType> + </con:credentials> + <con:jmsConfig JMSDeliveryMode="PERSISTENT"/> + <con:jmsPropertyConfig/> + <con:parameters/> + </con:request> + </con:method> + </con:resource> + </con:interface> + <con:interface xsi:type="con:WsdlInterface" id="06180e4e-0acf-4ad2-a9fc-80d0d8c8a033" wsaVersion="NONE" + name="SoapAPIServiceSoapBinding" type="wsdl" + bindingName="{http://soap.ws.tse.fing.edu.uy/}SoapAPIServiceSoapBinding" soapVersion="1_1" + anonymous="optional" definition="http://localhost:8080/practico-api/SoapAPI?wsdl" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <con:settings/> + <con:definitionCache type="TEXT" rootPart="http://localhost:8080/practico-api/SoapAPI?wsdl"> + <con:part> + <con:url>http://localhost:8080/practico-api/SoapAPI?wsdl</con:url> + <con:content><![CDATA[<wsdl:definitions name="SoapAPIService" targetNamespace="http://soap.ws.tse.fing.edu.uy/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://soap.ws.tse.fing.edu.uy/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http"> + <wsdl:types> + <xs:schema targetNamespace="http://soap.ws.tse.fing.edu.uy/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="noticia" type="tns:noticiaDT"/> + <xs:element name="noticias" type="tns:noticiasDT"/> + <xs:element name="publicacion" type="tns:publicacionDT"/> + <xs:element name="publicaciones" type="tns:publicacionesDT"/> + <xs:complexType final="extension restriction" name="noticiasDT"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="noticia" type="tns:noticiaDT"/> + </xs:sequence> + </xs:complexType> + <xs:complexType final="extension restriction" name="noticiaDT"> + <xs:sequence> + <xs:element minOccurs="0" name="id" type="xs:long"/> + <xs:element minOccurs="0" name="titulo" type="xs:string"/> + <xs:element minOccurs="0" name="descripcion" type="xs:string"/> + <xs:element minOccurs="0" name="publicaciones" type="tns:publicacionesDT"/> + </xs:sequence> + </xs:complexType> + <xs:complexType final="extension restriction" name="publicacionesDT"> + <xs:sequence> + <xs:element maxOccurs="unbounded" minOccurs="0" name="publicacion" type="tns:publicacionDT"/> + </xs:sequence> + </xs:complexType> + <xs:complexType final="extension restriction" name="publicacionDT"> + <xs:sequence> + <xs:element minOccurs="0" name="id" type="xs:long"/> + <xs:element minOccurs="0" name="tipo" type="xs:string"/> + <xs:element minOccurs="0" name="url" type="xs:string"/> + </xs:sequence> + </xs:complexType> + </xs:schema> + </wsdl:types> + <wsdl:message name="getNoticiasResponse"> + <wsdl:part name="return" type="tns:noticiasDT"></wsdl:part> + </wsdl:message> + <wsdl:message name="getPublicaciones"> + <wsdl:part name="idNoticia" type="xsd:long"></wsdl:part> + </wsdl:message> + <wsdl:message name="getNoticias"></wsdl:message> + <wsdl:message name="getPublicacionesResponse"> + <wsdl:part name="return" type="tns:publicacionesDT"></wsdl:part> + </wsdl:message> + <wsdl:message name="addPublicacion"> + <wsdl:part name="tipo" type="xsd:string"></wsdl:part> + <wsdl:part name="url" type="xsd:string"></wsdl:part> + <wsdl:part name="idNoticia" type="xsd:long"></wsdl:part> + </wsdl:message> + <wsdl:portType name="API"> + <wsdl:operation name="getNoticias"> + <wsdl:input message="tns:getNoticias" name="getNoticias"></wsdl:input> + <wsdl:output message="tns:getNoticiasResponse" name="getNoticiasResponse"></wsdl:output> + </wsdl:operation> + <wsdl:operation name="getPublicaciones"> + <wsdl:input message="tns:getPublicaciones" name="getPublicaciones"></wsdl:input> + <wsdl:output message="tns:getPublicacionesResponse" name="getPublicacionesResponse"></wsdl:output> + </wsdl:operation> + <wsdl:operation name="addPublicacion"> + <wsdl:input message="tns:addPublicacion" name="addPublicacion"></wsdl:input> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="SoapAPIServiceSoapBinding" type="tns:API"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="getNoticias"> + <soap:operation soapAction="" style="rpc"/> + <wsdl:input name="getNoticias"> + <soap:body namespace="http://soap.ws.tse.fing.edu.uy/" use="literal"/> + </wsdl:input> + <wsdl:output name="getNoticiasResponse"> + <soap:body namespace="http://soap.ws.tse.fing.edu.uy/" use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="getPublicaciones"> + <soap:operation soapAction="" style="rpc"/> + <wsdl:input name="getPublicaciones"> + <soap:body namespace="http://soap.ws.tse.fing.edu.uy/" use="literal"/> + </wsdl:input> + <wsdl:output name="getPublicacionesResponse"> + <soap:body namespace="http://soap.ws.tse.fing.edu.uy/" use="literal"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="addPublicacion"> + <soap:operation soapAction="" style="rpc"/> + <wsdl:input name="addPublicacion"> + <soap:body namespace="http://soap.ws.tse.fing.edu.uy/" use="literal"/> + </wsdl:input> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="SoapAPIService"> + <wsdl:port binding="tns:SoapAPIServiceSoapBinding" name="APIPort"> + <soap:address location="http://localhost:8080/practico-api/SoapAPI"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions>]]></con:content> + <con:type>http://schemas.xmlsoap.org/wsdl/</con:type> + </con:part> + </con:definitionCache> + <con:endpoints> + <con:endpoint>http://localhost:8080/practico-api/SoapAPI</con:endpoint> + </con:endpoints> + <con:operation id="1f3552e6-5141-4cb5-872d-100142f636e6" isOneWay="false" action="" name="addPublicacion" + bindingOperationName="addPublicacion" type="One-Way" inputName="addPublicacion" + sendsAttachments="false" anonymous="optional"> + <con:settings/> + <con:call id="03c9de75-7570-4189-9db9-5bebdf72fef3" name="Request 1"> + <con:settings/> + <con:encoding>UTF-8</con:encoding> + <con:endpoint>http://localhost:8080/practico-api/SoapAPI</con:endpoint> + <con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.ws.tse.fing.edu.uy/">\r + <soapenv:Header/>\r + <soapenv:Body>\r + <soap:addPublicacion>\r + <tipo>?</tipo>\r + <url>?</url>\r + <idNoticia>?</idNoticia>\r + </soap:addPublicacion>\r + </soapenv:Body>\r +</soapenv:Envelope>]]></con:request> + <con:wsaConfig mustUnderstand="NONE" version="200508" + action="http://soap.ws.tse.fing.edu.uy/API/addPublicacion"/> + </con:call> + </con:operation> + <con:operation id="16734cb9-e5ef-46df-bff1-938e09e09b1a" isOneWay="false" action="" name="getNoticias" + bindingOperationName="getNoticias" type="Request-Response" outputName="getNoticiasResponse" + inputName="getNoticias" receivesAttachments="false" sendsAttachments="false" + anonymous="optional"> + <con:settings/> + <con:call id="31718689-d64c-4c91-937d-5b8ddb75f8ae" name="Request 1"> + <con:settings/> + <con:encoding>UTF-8</con:encoding> + <con:endpoint>http://localhost:8080/practico-api/SoapAPI</con:endpoint> + <con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.ws.tse.fing.edu.uy/">\r + <soapenv:Header/>\r + <soapenv:Body>\r + <soap:getNoticias/>\r + </soapenv:Body>\r +</soapenv:Envelope>]]></con:request> + <con:wsaConfig mustUnderstand="NONE" version="200508" + action="http://soap.ws.tse.fing.edu.uy/API/getNoticias"/> + </con:call> + </con:operation> + <con:operation id="569dba5f-41fc-4946-ab48-986e33d3c621" isOneWay="false" action="" name="getPublicaciones" + bindingOperationName="getPublicaciones" type="Request-Response" + outputName="getPublicacionesResponse" inputName="getPublicaciones" receivesAttachments="false" + sendsAttachments="false" anonymous="optional"> + <con:settings/> + <con:call id="b197d238-991b-462e-8c8c-4880bfad35d3" name="Request 1"> + <con:settings/> + <con:encoding>UTF-8</con:encoding> + <con:endpoint>http://localhost:8080/practico-api/SoapAPI</con:endpoint> + <con:request><![CDATA[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.ws.tse.fing.edu.uy/">\r + <soapenv:Header/>\r + <soapenv:Body>\r + <soap:getPublicaciones>\r + <idNoticia>?</idNoticia>\r + </soap:getPublicaciones>\r + </soapenv:Body>\r +</soapenv:Envelope>]]></con:request> + <con:wsaConfig mustUnderstand="NONE" version="200508" + action="http://soap.ws.tse.fing.edu.uy/API/getPublicaciones"/> + </con:call> + </con:operation> + </con:interface> + <con:properties/> + <con:wssContainer/> + <con:oAuth2ProfileContainer/> + <con:oAuth1ProfileContainer/> + <con:sensitiveInformation/> +</con:soapui-project> \ No newline at end of file diff --git a/backoffice/src/test/java/.keep b/backoffice/src/test/java/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/backoffice/src/test/resources/.keep b/backoffice/src/test/resources/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 new file mode 100644 index 0000000000000000000000000000000000000000..e35d932cd81e4a4745e581bf045946acad49af92 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Calificacion.java @@ -0,0 +1,38 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public final class Calificacion { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + 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-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 new file mode 100644 index 0000000000000000000000000000000000000000..4a09c8446d807242fdeaba2758049694507eb957 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Categoria.java @@ -0,0 +1,48 @@ +package uy.edu.fing.tse.practico.db.entity; + + +import javax.persistence.*; + +@Entity +@NamedQueries({ + @NamedQuery(name = "Periferico.findAll", query = "select c from Categoria c"), + @NamedQuery(name = "Periferico.findByName", query = "select c from Categoria c where c.name = :name") +}) +public final class Categoria { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + 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-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 new file mode 100644 index 0000000000000000000000000000000000000000..26322a994b60867316505df485b5efa3ac5f74c6 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Estado.java @@ -0,0 +1,38 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public final class Estado { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + 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-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 new file mode 100644 index 0000000000000000000000000000000000000000..3e0822a48bd3d38142660cd8a7d60c6ad3d80b41 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Hecho.java @@ -0,0 +1,26 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; + +@Entity +@NamedQueries({ + //@NamedQuery(name = "Periferico.findAll", query = "select c from Categoria c"), + //@NamedQuery(name = "Periferico.findByName", query = "select c from Categoria c where c.name = :name") +}) +public final class Hecho { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String title; + private String description; + + @ManyToOne + private Estado estado; + + @ManyToOne + private Calificacion calificacion; + + +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..de755008598653a2c8af89ebb2833eec9110f215 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Periferico.java @@ -0,0 +1,65 @@ +package uy.edu.fing.tse.practico.db.entity; + +import javax.persistence.*; +import java.util.ArrayList; +import java.util.List; + + +@Entity +@NamedQueries({ + @NamedQuery(name = "Periferico.findAll", query = "select p from Periferico p"), + @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; + + @ManyToMany //todo: verificar que funcione + private List<Categoria> categorias = new ArrayList<>(); + + 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<>(); + } + return categorias; + } + + public void addCategorias(Categoria categoria) { + this.categorias.add(categoria); + } + + public void setCategorias(List<Categoria> categorias) { + this.categorias = categorias; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + 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/Verificacion.java b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Verificacion.java new file mode 100644 index 0000000000000000000000000000000000000000..39c3e84d3c181b593a5f88f8ed09c90e8729c7c6 --- /dev/null +++ b/central-db/src/main/java/uy/edu/fing/tse/practico/db/entity/Verificacion.java @@ -0,0 +1,20 @@ +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/resources/META-INF/persistence.xml b/central-db/src/main/resources/META-INF/persistence.xml index cc9680c277f6fe2f84f3f1e06026f52f36d2f099..002cb41844b347ad4d3d2c0bf99a687b59e82a0b 100644 --- a/central-db/src/main/resources/META-INF/persistence.xml +++ b/central-db/src/main/resources/META-INF/persistence.xml @@ -7,9 +7,9 @@ http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> <persistence-unit name="practico"> <!--OpenShift--> - <!--<jta-data-source>java:jboss/datasources/practicoDS</jta-data-source>--> + <jta-data-source>java:jboss/datasources/centralDS</jta-data-source> <!--Local--> - <jta-data-source>java:jboss/datasources/herokuDS</jta-data-source> + <!-- <jta-data-source>java:jboss/datasources/herokuDS</jta-data-source>--> <properties> <!-- Properties for Hibernate --> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> diff --git a/central-ear/src/main/application/META-INF/practico-ds.xml b/central-ear/src/main/application/META-INF/practico-ds.xml index 4dc62abe2cc89b5decb03d89bb3eb48ca66e7c18..9492e36123cc639e3f1c28039c40778f403a7d10 100644 --- a/central-ear/src/main/application/META-INF/practico-ds.xml +++ b/central-ear/src/main/application/META-INF/practico-ds.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://www.jboss.org/ironjacamar/schema http://docs.jboss.org/ironjacamar/schema/datasources_1_0.xsd"> <!-- The datasource is bound into JNDI at this location. We reference this in META-INF/persistence.xml --> - <datasource jndi-name="java:jboss/datasources/practicoDS" pool-name="practico" + <datasource jndi-name="java:jboss/datasources/centralDS" pool-name="central" enabled="true" use-java-context="true"> - <connection-url>jdbc:h2:mem:practico;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1</connection-url> + <connection-url>jdbc:h2:file:./central</connection-url> <driver>h2</driver> <security> <user-name>sa</user-name> @@ -22,5 +22,6 @@ <password>fd34e142d8d9ae681fb227b74745c498c87f22a65da9681c9653b01af1375557</password> </security> </datasource> + </datasources> diff --git a/pom.xml b/pom.xml index 06594d0c7ad0be1dfaa4d6b18f403fa1931961f1..22f0748bb2629ea351e271fa7a332695f9055e20 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ <module>central-db</module> <module>central-ejb</module> <module>central-ear</module> + <module>backoffice</module> </modules> <properties>