Corrigidos erros no upload (nullpointer).
authorMichele Silva <michele.silva@gmail.com>
Wed, 8 Feb 2012 17:28:35 +0000 (15:28 -0200)
committerMichele Silva <michele.silva@gmail.com>
Wed, 8 Feb 2012 17:28:35 +0000 (15:28 -0200)
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/ufcspa/simdecs/mb/bn/CharacterEncodingFilter.java
src/java/org/ufcspa/simdecs/mb/bn/FileUploadController.java
src/java/org/ufcspa/simdecs/mb/bn/RedeEditBean.java
src/java/org/ufcspa/simdecs/mb/bn/RedeUploadBean.java
web/WEB-INF/web.xml

index 28fab05..f534b70 100644 (file)
@@ -691,7 +691,6 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.junit-4.1.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.log4j-1.2.12.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.logkit-1.0.1.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.servlet-api-2.3.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.unbbayes-4.10.4-1s.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.xalan-2.7.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.xml-apis-1.0.b2.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
@@ -717,7 +716,6 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.junit-4.1.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.log4j-1.2.12.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.logkit-1.0.1.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.servlet-api-2.3.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.unbbayes-4.10.4-1s.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.xalan-2.7.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.xml-apis-1.0.b2.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
index 7c59915..dc32fd1 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=2c4c42bc
+build.xml.data.CRC32=aed63b6a
 build.xml.script.CRC32=9f680c47
 build.xml.stylesheet.CRC32=651128d4@1.36.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=2c4c42bc
-nbproject/build-impl.xml.script.CRC32=d3f674de
+nbproject/build-impl.xml.data.CRC32=aed63b6a
+nbproject/build-impl.xml.script.CRC32=da75e33b
 nbproject/build-impl.xml.stylesheet.CRC32=b7883b1f@1.36.1.1
index 8781252..00bfdb4 100644 (file)
@@ -45,7 +45,6 @@ file.reference.junit-4.1.jar=lib/junit-4.1.jar
 file.reference.log4j-1.2.12.jar=lib/log4j-1.2.12.jar
 file.reference.logkit-1.0.1.jar=lib/logkit-1.0.1.jar
 file.reference.primefaces-3.1-SNAPSHOT.jar=lib/primefaces-3.1-SNAPSHOT.jar
-file.reference.servlet-api-2.3.jar=lib/servlet-api-2.3.jar
 file.reference.unbbayes-4.10.4-1s.jar=lib/unbbayes-4.10.4-1s.jar
 file.reference.xalan-2.7.0.jar=lib/xalan-2.7.0.jar
 file.reference.xml-apis-1.0.b2.jar=lib/xml-apis-1.0.b2.jar
@@ -80,7 +79,6 @@ javac.classpath=\
     ${file.reference.junit-4.1.jar}:\
     ${file.reference.log4j-1.2.12.jar}:\
     ${file.reference.logkit-1.0.1.jar}:\
-    ${file.reference.servlet-api-2.3.jar}:\
     ${file.reference.unbbayes-4.10.4-1s.jar}:\
     ${file.reference.xalan-2.7.0.jar}:\
     ${file.reference.xml-apis-1.0.b2.jar}
index c7c6a47..33ba691 100644 (file)
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
                 <library dirs="200">
-                    <file>${file.reference.servlet-api-2.3.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
-                <library dirs="200">
                     <file>${file.reference.unbbayes-4.10.4-1s.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
index 59e382b..eec00b0 100644 (file)
@@ -15,7 +15,7 @@ public class CharacterEncodingFilter implements Filter, Serializable
     @Override
     public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
         req.setCharacterEncoding("UTF-8");
-        //resp.setCharacterEncoding("UTF-8");
+        resp.setCharacterEncoding("UTF-8");
         chain.doFilter(req, resp);
     }
 
index 7415116..47fc3b3 100644 (file)
@@ -14,6 +14,7 @@ import javax.xml.bind.JAXBException;
 import org.primefaces.event.FileUploadEvent;
 import org.primefaces.model.UploadedFile;
 import org.ufcspa.simdecs.entities.Nodo;
+import org.ufcspa.simdecs.entities.PerguntaNodo;
 import org.ufcspa.simdecs.entities.Rede;
 import org.ufcspa.simdecs.mb.DefaultManagedBean;
 import unbbayes.io.exception.LoadException;
@@ -68,6 +69,7 @@ public class FileUploadController extends DefaultManagedBean {
                 Nodo nodo = new Nodo();
                 nodo.setNome(prs_node.getName());                
                 nodo.setRede(rede);
+                nodo.setPerguntas(new ArrayList<PerguntaNodo>());
                 nodes.add(nodo);                
             }
             rede.setNodos(nodes);             
index dc1a5d3..15b4be3 100644 (file)
@@ -88,18 +88,23 @@ public class RedeEditBean extends DefaultManagedBean {
     }
 
     public void addPergunta() {
-        try {
-            em.getTransaction().begin();
-        } finally {
-            PerguntaNodo pergunta = new PerguntaNodo();
-            pergunta.setTexto("");
-            pergunta.setNodo(selectedNodo);
-            pergunta.setRespostas(new ArrayList());
-            selectedNodo.getPerguntas().add(pergunta);
-            em.persist(pergunta);
-            em.getTransaction().commit();
+        if (selectedNodo != null) {
+            try {
+                em.getTransaction().begin();
+            } finally {
+                PerguntaNodo pergunta = new PerguntaNodo();
+                pergunta.setTexto("");
+                pergunta.setNodo(selectedNodo);
+                pergunta.setRespostas(new ArrayList());
+                selectedNodo.getPerguntas().add(pergunta);
+                em.persist(pergunta);
+                em.getTransaction().commit();
+            }
+            addInfoMessage("Pergunta Adicionada", "Pergunta adicionada com sucesso.");
+        } else {
+            addErrorMessage("Pergunta não adicionada", "Não existe nodo selecionado.");
         }
-        addInfoMessage("Pergunta Adicionada", "Pergunta adicionada com sucesso.");
+
     }
 
     public void removePergunta(PerguntaNodo pergunta) {
@@ -114,19 +119,23 @@ public class RedeEditBean extends DefaultManagedBean {
     }
 
     public void addResposta() {
-        try {
-            em.getTransaction().begin();
-        } finally {
-            RespostaNodo resposta = new RespostaNodo();
-            resposta.setTexto("");
-            resposta.setPergunta(selectedPergunta);
-            resposta.setPesoMinimo(0);
-            resposta.setPesoMaximo(1);
-            selectedPergunta.getRespostas().add(resposta);
-            em.persist(resposta);
-            em.getTransaction().commit();
+        if (selectedPergunta != null) {
+            try {
+                em.getTransaction().begin();
+            } finally {
+                RespostaNodo resposta = new RespostaNodo();
+                resposta.setTexto("");
+                resposta.setPergunta(selectedPergunta);
+                resposta.setPesoMinimo(0);
+                resposta.setPesoMaximo(1);
+                selectedPergunta.getRespostas().add(resposta);
+                em.persist(resposta);
+                em.getTransaction().commit();
+            }
+            addInfoMessage("Resposta adicionada", "Resposta adicionada com sucesso.");
+        } else {
+            addErrorMessage("Resposta não adicionada", "Não existe pergunta selecionada.");
         }
-        addInfoMessage("Resposta adicionada", "Resposta adicionada com sucesso.");
     }
 
     public void removeResposta(RespostaNodo resposta) {
@@ -141,18 +150,22 @@ public class RedeEditBean extends DefaultManagedBean {
     }
 
     public void addNodo() {
-        try {
-            em.getTransaction().begin();
-        } finally {
-            Nodo nodo = new Nodo();
-            nodo.setNome("");
-            nodo.setRede(rede);
-            nodo.setPerguntas(new ArrayList());
-            rede.getNodos().add(nodo);
-            em.persist(nodo);
-            em.getTransaction().commit();
+        if (rede != null) {
+            try {
+                em.getTransaction().begin();
+            } finally {
+                Nodo nodo = new Nodo();
+                nodo.setNome("");
+                nodo.setRede(rede);
+                nodo.setPerguntas(new ArrayList());
+                rede.getNodos().add(nodo);
+                em.persist(nodo);
+                em.getTransaction().commit();
+            }
+            addInfoMessage("Nodo adicionado", "Nodo adicionado com sucesso.");
+        } else {
+            addErrorMessage("Nodo não adicionado", "Não existe rede selecionada.");
         }
-        addInfoMessage("Nodo adicionado", "Nodo adicionado com sucesso.");
 
     }
 
index 98707d6..c683379 100644 (file)
@@ -6,8 +6,6 @@ package org.ufcspa.simdecs.mb.bn;
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import javax.faces.bean.ManagedBean;
 import javax.faces.bean.SessionScoped;
 import javax.persistence.Query;
@@ -44,7 +42,6 @@ public class RedeUploadBean extends DefaultManagedBean {
 
     public void setSelectedItems(Rede[] selectedItems) {
         this.selectedItems = selectedItems;
-        Logger.getLogger(RedeUploadBean.class.getName()).log(Level.INFO, "Set selected items.");
     }
 
     public SimdecsDataModel getSelectableItems() {
@@ -59,7 +56,7 @@ public class RedeUploadBean extends DefaultManagedBean {
             for (Rede item : selectedItems) {
                 em.remove(item);
             }
-            addInfoMessage("Rede removida!", "Rede Bayesiana removida com sucesso!");
+            addInfoMessage("Rede removida", "Rede Bayesiana removida com sucesso.");
             em.getTransaction().commit();
         }
     }    
index 6233712..9f0863d 100644 (file)
@@ -2,7 +2,7 @@
 <web-app version="3.0" 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 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
     <context-param>
         <param-name>javax.faces.PROJECT_STAGE</param-name>
-        <param-value>Release</param-value>
+        <param-value>Production</param-value>
     </context-param>
     <servlet>
         <servlet-name>Faces Servlet</servlet-name>