From: Michele Silva Date: Wed, 2 Nov 2011 22:02:32 +0000 (-0200) Subject: Upload de rede bayesiana. X-Git-Url: http://200.18.67.61/gitweb/?a=commitdiff_plain;h=6f43ba4a40cee40822c38e34d90ebbabfb44d49d;p=simdecs_seam.git Upload de rede bayesiana. --- diff --git a/SimDeCS/WebContent/WEB-INF/.pages.xml.spdia b/SimDeCS/WebContent/WEB-INF/.pages.xml.spdia new file mode 100644 index 0000000..896e6bb --- /dev/null +++ b/SimDeCS/WebContent/WEB-INF/.pages.xml.spdia @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SimDeCS/WebContent/seguro/admin/rede/ArquivoRede.xhtml b/SimDeCS/WebContent/seguro/admin/rede/ArquivoRede.xhtml new file mode 100644 index 0000000..a92d378 --- /dev/null +++ b/SimDeCS/WebContent/seguro/admin/rede/ArquivoRede.xhtml @@ -0,0 +1,66 @@ + + + + + + + + + + + Upload de Rede Bayesiana + + + Arquivo + + + + + Nome + + + + + Tipo + + + + + Tamanho + + + +
+ + +
+ + + + + +
+ + + + + + \ No newline at end of file diff --git a/SimDeCS/WebContent/seguro/admin/rede/ArquivoRedeList.xhtml b/SimDeCS/WebContent/seguro/admin/rede/ArquivoRedeList.xhtml new file mode 100644 index 0000000..c183bd1 --- /dev/null +++ b/SimDeCS/WebContent/seguro/admin/rede/ArquivoRedeList.xhtml @@ -0,0 +1,64 @@ + + + + + + + + + Redes Bayesianas Cadastradas + +
+ + + + + + Arquivo + + + + + + Tipo + #{arquivoRede.contentType} + + + Tamanho (bytes) + #{arquivoRede.tamanho} + + + Ações + + + +

+ + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeHome.java b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeHome.java new file mode 100644 index 0000000..361c9d4 --- /dev/null +++ b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeHome.java @@ -0,0 +1,33 @@ +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 +{ + @RequestParameter Long arquivoRedeId; + + @Override + public Object getId() + { + if (arquivoRedeId == null) + { + return super.getId(); + } + else + { + return arquivoRedeId; + } + } + + @Override @Begin + public void create() { + super.create(); + } + +} diff --git a/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeList.java b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeList.java new file mode 100644 index 0000000..9a502cf --- /dev/null +++ b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/ArquivoRedeList.java @@ -0,0 +1,14 @@ +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 +{ + public ArquivoRedeList() + { + setEjbql("select arquivoRede from ArquivoRede arquivoRede"); + } +} diff --git a/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/DownloadArquivoRede.java b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/DownloadArquivoRede.java new file mode 100644 index 0000000..61dcbcf --- /dev/null +++ b/SimDeCS/src/hot/org/ufcspa/simdecs/session/crud/admin/DownloadArquivoRede.java @@ -0,0 +1,52 @@ +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 diff --git a/SimDeCS/src/main/org/ufcspa/simdecs/entities/ArquivoRede.java b/SimDeCS/src/main/org/ufcspa/simdecs/entities/ArquivoRede.java new file mode 100644 index 0000000..f72bb19 --- /dev/null +++ b/SimDeCS/src/main/org/ufcspa/simdecs/entities/ArquivoRede.java @@ -0,0 +1,39 @@ +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