--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<diagram model-entity="SeamPagesDiagram">
+ <item ID="*" NAME="*" PATH="*" SHAPE="24,17,0,0" TYPE="page" model-entity="SeamPagesDiagramItem">
+ <output ID="/home.xhtml" NAME="output" PATH="/home.xhtml"
+ TARGET="#xhome.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="org.jboss.seam.framework.EntityNotFoundException"
+ NAME="exception:org.jboss.seam.framework.EntityNotFoundException"
+ PATH="org.jboss.seam.framework.EntityNotFoundException"
+ SHAPE="24,121,0,0" TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="javax.persistence.EntityNotFoundException"
+ NAME="exception:javax.persistence.EntityNotFoundException"
+ PATH="javax.persistence.EntityNotFoundException" SHAPE="24,225,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="javax.persistence.EntityExistsException"
+ NAME="exception:javax.persistence.EntityExistsException"
+ PATH="javax.persistence.EntityExistsException" SHAPE="24,329,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="javax.persistence.OptimisticLockException"
+ NAME="exception:javax.persistence.OptimisticLockException"
+ PATH="javax.persistence.OptimisticLockException" SHAPE="24,433,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="org.jboss.seam.security.AuthorizationException"
+ NAME="exception:org.jboss.seam.security.AuthorizationException"
+ PATH="org.jboss.seam.security.AuthorizationException"
+ SHAPE="24,537,0,0" TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="org.jboss.seam.security.NotLoggedInException"
+ NAME="exception:org.jboss.seam.security.NotLoggedInException"
+ PATH="org.jboss.seam.security.NotLoggedInException" SHAPE="24,849,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/login.xhtml" NAME="output" PATH="/login.xhtml"
+ TARGET="#xlogin.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="javax.faces.application.ViewExpiredException"
+ NAME="exception:javax.faces.application.ViewExpiredException"
+ PATH="javax.faces.application.ViewExpiredException" SHAPE="24,641,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item ID="org.jboss.seam.ConcurrentRequestTimeoutException"
+ NAME="exception:org.jboss.seam.ConcurrentRequestTimeoutException"
+ PATH="org.jboss.seam.ConcurrentRequestTimeoutException"
+ SHAPE="24,953,0,0" TYPE="exception" model-entity="SeamPagesDiagramItem"/>
+ <item NAME="exception:" SHAPE="24,745,0,0" TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+ <item NAME="#xhome.xhtml" PATH="/home.xhtml" SHAPE="344,17,0,0"
+ TYPE="page" model-entity="SeamPagesDiagramItem"/>
+ <item NAME="#xlogin.xhtml" PATH="/login.xhtml" SHAPE="344,849,0,0"
+ TYPE="page" model-entity="SeamPagesDiagramItem"/>
+ <item NAME="#xerror.xhtml" PATH="/error.xhtml" SHAPE="472,121,0,0"
+ TYPE="page" model-entity="SeamPagesDiagramItem"/>
+ <item ID="org.jboss.seam.web.FileUploadException"
+ NAME="exception:org.jboss.seam.web.FileUploadException"
+ PATH="org.jboss.seam.web.FileUploadException" SHAPE="24,1057,0,0"
+ TYPE="exception" model-entity="SeamPagesDiagramItem">
+ <output ID="/error.xhtml" NAME="output" PATH="/error.xhtml"
+ TARGET="#xerror.xhtml" model-entity="SeamPagesDiagramItemOutput"/>
+ </item>
+</diagram>
--- /dev/null
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich" template="/layout/template.xhtml">
+
+ <ui:define name="body">
+
+ <h:messages globalOnly="true" styleClass="message" />
+
+ <h:form enctype="multipart/form-data">
+
+ <rich:panel>
+ <f:facet name="header">Upload de Rede Bayesiana</f:facet>
+
+ <s:decorate id="fileUploadDecoration" template="/layout/edit.xhtml">
+ <ui:define name="label">Arquivo</ui:define>
+ <s:fileUpload id="file"
+ data="#{arquivoRedeHome.instance.data}"
+ contentType="#{arquivoRedeHome.instance.contentType}"
+ fileName="#{arquivoRedeHome.instance.nome}"
+ fileSize="#{arquivoRedeHome.instance.tamanho}" />
+ </s:decorate>
+
+ <s:decorate id="nameDecoration" template="/layout/display.xhtml">
+ <ui:define name="label">Nome</ui:define>
+ <h:outputText value="#{arquivoRedeHome.instance.nome}"/>
+ </s:decorate>
+
+ <s:decorate id="contentTypeDecoration" template="/layout/display.xhtml">
+ <ui:define name="label">Tipo</ui:define>
+ <h:outputText value="#{attachmentHome.instance.contentType}"/>
+ </s:decorate>
+
+ <s:decorate id="sizeDecoration" template="/layout/display.xhtml">
+ <ui:define name="label">Tamanho</ui:define>
+ <h:outputText value="#{arquivoRedeHome.instance.tamanho}"/>
+ </s:decorate>
+
+ <div style="clear: both" />
+ </rich:panel>
+
+ <div class="actionButtons">
+ <h:commandButton value="Upload"
+ action="#{arquivoRedeHome.persist}"
+ rendered="#{!arquivoRedeHome.managed}"/>
+ <h:commandButton value="Delete"
+ action="#{arquivoRedeHome.remove}"
+ immediate="true"
+ rendered="#{arquivoRedeHome.managed}">
+ <s:conversationPropagation type="end" />
+ </h:commandButton>
+ <s:button propagation="end"
+ id="done"
+ value="Concluído"
+ view="/seguro/admin/rede/ArquivoRedeList.xhtml"/>
+ </div>
+
+ </h:form>
+
+ </ui:define>
+
+</ui:composition>
\ No newline at end of file
--- /dev/null
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ template="/layout/template.xhtml">
+
+ <ui:define name="body">
+
+ <h:messages globalOnly="true" styleClass="message"/>
+
+ <rich:panel>
+ <f:facet name="header">Redes Bayesianas Cadastradas</f:facet>
+
+ <div class="results">
+
+ <h:outputText value="Não existem redes cadastradas" rendered="#{empty arquivoRedeList.resultList}"/>
+
+ <rich:dataTable id="arquivoRedeList"
+ var="arquivoRede"
+ value="#{arquivoRedeList.resultList}"
+ rendered="#{not empty arquivoRedeList.resultList}">
+ <rich:column>
+ <f:facet name="header">Arquivo</f:facet>
+ <s:link value="#{arquivoRede.nome}" view="/seguro/admin/rede/ArquivoRede.xhtml">
+ <f:param name="arquivoRedeId" value="${arquivoRede.id}" />
+ </s:link>
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">Tipo</f:facet>
+ #{arquivoRede.contentType}
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">Tamanho (bytes)</f:facet>
+ #{arquivoRede.tamanho}
+ </rich:column>
+ <rich:column>
+ <f:facet name="header">Ações</f:facet>
+ <s:link value="Download" action="#{downloadArquivoRede.download}">
+ <f:param name="arquivoRedeId" value="${arquivoRede.id}" />
+ </s:link>
+ <br></br>
+ <s:link value="Delete" action="#{arquivoRedeHome.remove}">
+ <f:param name="arquivoRedeId" value="${arquivoRede.id}" />
+ </s:link>
+ </rich:column>
+ </rich:dataTable>
+
+ </div>
+
+ </rich:panel>
+
+ <div class="actionButtons">
+ <s:button id="done"
+ value="Upload de Rede Bayesiana"
+ view="/seguro/admin/rede/ArquivoRede.xhtml"/>
+ </div>
+
+ </ui:define>
+
+</ui:composition>
\ No newline at end of file
--- /dev/null
+package org.ufcspa.simdecs.session.crud.admin;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.framework.EntityHome;
+
+import org.ufcspa.simdecs.entities.ArquivoRede;
+
+@Name("arquivoRedeHome")
+public class ArquivoRedeHome extends EntityHome<ArquivoRede>
+{
+ @RequestParameter Long arquivoRedeId;
+
+ @Override
+ public Object getId()
+ {
+ if (arquivoRedeId == null)
+ {
+ return super.getId();
+ }
+ else
+ {
+ return arquivoRedeId;
+ }
+ }
+
+ @Override @Begin
+ public void create() {
+ super.create();
+ }
+
+}
--- /dev/null
+package org.ufcspa.simdecs.session.crud.admin;
+
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.framework.EntityQuery;
+import org.ufcspa.simdecs.entities.ArquivoRede;
+
+@Name("arquivoRedeList")
+public class ArquivoRedeList extends EntityQuery<ArquivoRede>
+{
+ public ArquivoRedeList()
+ {
+ setEjbql("select arquivoRede from ArquivoRede arquivoRede");
+ }
+}
--- /dev/null
+package org.ufcspa.simdecs.session.crud.admin;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.log.Log;
+
+import org.ufcspa.simdecs.entities.ArquivoRede;
+
+@Name("downloadArquivoRede")
+public class DownloadArquivoRede {
+
+ @Logger
+ private Log log;
+
+ @In
+ private EntityManager entityManager;
+
+ @In(value="#{facesContext.externalContext}")
+ private ExternalContext extCtx;
+
+ @In(value="#{facesContext}")
+ FacesContext facesContext;
+
+ @RequestParameter
+ private Long arquivoRedeId;
+
+ public String download() {
+ ArquivoRede arquivoRede = entityManager.find(ArquivoRede.class, arquivoRedeId);
+ HttpServletResponse response = (HttpServletResponse)extCtx.getResponse();
+ response.setContentType(arquivoRede.getContentType());
+ response.addHeader("Content-disposition", "attachment; filename=\"" + arquivoRede.getNome() +"\"");
+ try {
+ ServletOutputStream os = response.getOutputStream();
+ os.write(arquivoRede.getData());
+ os.flush();
+ os.close();
+ facesContext.responseComplete();
+ } catch(Exception e) {
+ log.error("\nFailure : " + e.toString() + "\n");
+ }
+
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.ufcspa.simdecs.entities;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+
+@Entity
+public class ArquivoRede implements java.io.Serializable {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+ public Long getId() { return this.id; }
+ public void setId(Long id) { this.id = id; }
+
+ private String nome;
+ public String getNome() { return this.nome; }
+ public void setNome(String name) { this.nome = name; }
+
+ private long tamanho;
+ public long getTamanho() { return this.tamanho; }
+ public void setTamanho(long size) { this.tamanho = size; }
+
+ private String contentType;
+ public String getContentType() { return this.contentType; }
+ public void setContentType(String contentType) { this.contentType = contentType; }
+
+ @Lob
+ @Column(length = 2147483647)
+ @Basic(fetch = FetchType.LAZY)
+ private byte[] data;
+ public byte[] getData() { return this.data; }
+ public void setData(byte[] data) { this.data = data; }
+
+}
\ No newline at end of file