Added UI (JSF) and JPA to bayesian network entities.
authorMichele Silva <michele.silva@gmail.com>
Tue, 17 Jan 2012 22:32:42 +0000 (20:32 -0200)
committerMichele Silva <michele.silva@gmail.com>
Tue, 17 Jan 2012 22:32:42 +0000 (20:32 -0200)
38 files changed:
nbproject/project.properties
src/conf/persistence.xml
src/java/org/ufcspa/simdecs/bn/Bundle.properties [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/AnswerJpaController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/BayesianNetworkJpaController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/NodeJpaController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/QuestionJpaController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/exceptions/IllegalOrphanException.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/exceptions/NonexistentEntityException.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/exceptions/PreexistingEntityException.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/jpa/exceptions/RollbackFailureException.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/FileUploadController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/NodeController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/util/JsfUtil.java [new file with mode: 0644]
src/java/org/ufcspa/simdecs/bn/ui/util/PaginationHelper.java [new file with mode: 0644]
web/WEB-INF/faces-config.xml
web/bn/answer/Create.xhtml [new file with mode: 0644]
web/bn/answer/Edit.xhtml [new file with mode: 0644]
web/bn/answer/List.xhtml [new file with mode: 0644]
web/bn/answer/View.xhtml [new file with mode: 0644]
web/bn/bayesianNetwork/Create.xhtml [new file with mode: 0644]
web/bn/bayesianNetwork/Edit.xhtml [new file with mode: 0644]
web/bn/bayesianNetwork/List.xhtml [new file with mode: 0644]
web/bn/bayesianNetwork/View.xhtml [new file with mode: 0644]
web/bn/node/Create.xhtml [new file with mode: 0644]
web/bn/node/Edit.xhtml [new file with mode: 0644]
web/bn/node/List.xhtml [new file with mode: 0644]
web/bn/node/View.xhtml [new file with mode: 0644]
web/bn/question/Create.xhtml [new file with mode: 0644]
web/bn/question/Edit.xhtml [new file with mode: 0644]
web/bn/question/List.xhtml [new file with mode: 0644]
web/bn/question/View.xhtml [new file with mode: 0644]
web/index.xhtml
web/resources/css/jsfcrud.css [new file with mode: 0644]
web/template.xhtml [new file with mode: 0644]

index 4656a63..d1c5ee5 100644 (file)
-annotation.processing.enabled=true\r
-annotation.processing.enabled.in.editor=true\r
-annotation.processing.processor.options=-Aeclipselink.canonicalmodel.use_static_factory=false\r
-annotation.processing.processors.list=\r
-annotation.processing.run.all.processors=true\r
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output\r
-auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets\r
-build.classes.dir=${build.web.dir}/WEB-INF/classes\r
-build.classes.excludes=**/*.java,**/*.form\r
-build.dir=build\r
-build.generated.dir=${build.dir}/generated\r
-build.generated.sources.dir=${build.dir}/generated-sources\r
-build.test.classes.dir=${build.dir}/test/classes\r
-build.test.results.dir=${build.dir}/test/results\r
-build.web.dir=${build.dir}/web\r
-build.web.excludes=${build.classes.excludes}\r
-client.urlPart=\r
-compile.jsps=false\r
-conf.dir=${source.root}/conf\r
-debug.classpath=${build.classes.dir}:${javac.classpath}\r
-debug.test.classpath=\\r
-    ${run.test.classpath}\r
-display.browser=true\r
-dist.dir=dist\r
-dist.ear.war=${dist.dir}/${war.ear.name}\r
-dist.javadoc.dir=${dist.dir}/javadoc\r
-dist.war=${dist.dir}/${war.name}\r
-endorsed.classpath=\r
-excludes=\r
-file.reference.avalon-framework-4.1.3.jar=lib/avalon-framework-4.1.3.jar\r
-file.reference.commons-lang3-3.1.jar=lib/commons-lang3-3.1.jar\r
-file.reference.commons-logging-1.1.jar=lib/commons-logging-1.1.jar\r
-file.reference.icu4j-3.8.jar=lib/icu4j-3.8.jar\r
-file.reference.javahelp-2.0.02.jar=lib/javahelp-2.0.02.jar\r
-file.reference.jaxme2-0.5.1.jar=lib/jaxme2-0.5.1.jar\r
-file.reference.jaxme2-rt-0.5.1.jar=lib/jaxme2-rt-0.5.1.jar\r
-file.reference.jaxmeapi-0.5.1.jar=lib/jaxmeapi-0.5.1.jar\r
-file.reference.jaxmejs-0.5.1.jar=lib/jaxmejs-0.5.1.jar\r
-file.reference.jaxmexs-0.5.1.jar=lib/jaxmexs-0.5.1.jar\r
-file.reference.jpf-1.5.jar=lib/jpf-1.5.jar\r
-file.reference.junit-4.1.jar=lib/junit-4.1.jar\r
-file.reference.log4j-1.2.12.jar=lib/log4j-1.2.12.jar\r
-file.reference.logkit-1.0.1.jar=lib/logkit-1.0.1.jar\r
-file.reference.servlet-api-2.3.jar=lib/servlet-api-2.3.jar\r
-file.reference.unbbayes-4.10.4-1s.jar=lib/unbbayes-4.10.4-1s.jar\r
-file.reference.xalan-2.7.0.jar=lib/xalan-2.7.0.jar\r
-file.reference.xml-apis-1.0.b2.jar=lib/xml-apis-1.0.b2.jar\r
-includes=**\r
-j2ee.compile.on.save=true\r
-j2ee.deploy.on.save=true\r
-j2ee.platform=1.5\r
-j2ee.platform.classpath=${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/javax.jms.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/jersey-core.jar:${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.servlet.jar\r
-j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar\r
-j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar\r
-j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar\r
-j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar\r
-j2ee.platform.wsit.classpath=\r
-j2ee.server.type=gfv3ee6\r
-jar.compress=false\r
-javac.classpath=\\r
-    ${libs.primefaces.classpath}:\\r
-    ${libs.hibernate-support.classpath}:\\r
-    ${file.reference.avalon-framework-4.1.3.jar}:\\r
-    ${file.reference.commons-logging-1.1.jar}:\\r
-    ${file.reference.icu4j-3.8.jar}:\\r
-    ${file.reference.javahelp-2.0.02.jar}:\\r
-    ${file.reference.jaxme2-0.5.1.jar}:\\r
-    ${file.reference.jaxme2-rt-0.5.1.jar}:\\r
-    ${file.reference.jaxmeapi-0.5.1.jar}:\\r
-    ${file.reference.jaxmejs-0.5.1.jar}:\\r
-    ${file.reference.jaxmexs-0.5.1.jar}:\\r
-    ${file.reference.jpf-1.5.jar}:\\r
-    ${file.reference.junit-4.1.jar}:\\r
-    ${file.reference.log4j-1.2.12.jar}:\\r
-    ${file.reference.logkit-1.0.1.jar}:\\r
-    ${file.reference.servlet-api-2.3.jar}:\\r
-    ${file.reference.unbbayes-4.10.4-1s.jar}:\\r
-    ${file.reference.xalan-2.7.0.jar}:\\r
-    ${file.reference.xml-apis-1.0.b2.jar}:\\r
-    ${file.reference.commons-lang3-3.1.jar}\r
-# Space-separated list of extra javac options\r
-javac.compilerargs=\r
-javac.debug=true\r
-javac.deprecation=false\r
-javac.processorpath=\\r
-    ${javac.classpath}\r
-javac.source=1.5\r
-javac.target=1.5\r
-javac.test.classpath=\\r
-    ${javac.classpath}:\\r
-    ${build.classes.dir}\r
-javac.test.processorpath=\\r
-    ${javac.test.classpath}\r
-javadoc.additionalparam=\r
-javadoc.author=false\r
-javadoc.encoding=${source.encoding}\r
-javadoc.noindex=false\r
-javadoc.nonavbar=false\r
-javadoc.notree=false\r
-javadoc.preview=true\r
-javadoc.private=false\r
-javadoc.splitindex=true\r
-javadoc.use=true\r
-javadoc.version=false\r
-javadoc.windowtitle=\r
-lib.dir=${web.docbase.dir}/WEB-INF/lib\r
-persistence.xml.dir=${conf.dir}\r
-platform.active=default_platform\r
-resource.dir=setup\r
-run.test.classpath=\\r
-    ${javac.test.classpath}:\\r
-    ${build.test.classes.dir}\r
-# Space-separated list of JVM arguments used when running a class with a main method or a unit test\r
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):\r
-runmain.jvmargs=\r
-source.encoding=UTF-8\r
-source.root=src\r
-src.dir=${source.root}/java\r
-test.src.dir=test\r
-war.content.additional=\r
-war.ear.name=simdecs.war\r
-war.name=simdecs.war\r
-web.docbase.dir=web\r
-webinf.dir=web/WEB-INF\r
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=true
+annotation.processing.processor.options=-Aeclipselink.canonicalmodel.use_static_factory=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+auxiliary.org-netbeans-modules-projectapi.jsf_2e_language=Facelets
+build.classes.dir=${build.web.dir}/WEB-INF/classes
+build.classes.excludes=**/*.java,**/*.form
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+build.web.dir=${build.dir}/web
+build.web.excludes=${build.classes.excludes}
+client.urlPart=
+compile.jsps=false
+conf.dir=${source.root}/conf
+debug.classpath=${build.classes.dir}:${javac.classpath}
+debug.test.classpath=\
+    ${run.test.classpath}
+display.browser=true
+dist.dir=dist
+dist.ear.war=${dist.dir}/${war.ear.name}
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.war=${dist.dir}/${war.name}
+endorsed.classpath=
+excludes=
+file.reference.avalon-framework-4.1.3.jar=lib/avalon-framework-4.1.3.jar
+file.reference.commons-lang3-3.1.jar=lib/commons-lang3-3.1.jar
+file.reference.commons-logging-1.1.jar=lib/commons-logging-1.1.jar
+file.reference.icu4j-3.8.jar=lib/icu4j-3.8.jar
+file.reference.javahelp-2.0.02.jar=lib/javahelp-2.0.02.jar
+file.reference.jaxme2-0.5.1.jar=lib/jaxme2-0.5.1.jar
+file.reference.jaxme2-rt-0.5.1.jar=lib/jaxme2-rt-0.5.1.jar
+file.reference.jaxmeapi-0.5.1.jar=lib/jaxmeapi-0.5.1.jar
+file.reference.jaxmejs-0.5.1.jar=lib/jaxmejs-0.5.1.jar
+file.reference.jaxmexs-0.5.1.jar=lib/jaxmexs-0.5.1.jar
+file.reference.jpf-1.5.jar=lib/jpf-1.5.jar
+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.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
+includes=**
+j2ee.compile.on.save=true
+j2ee.deploy.on.save=true
+j2ee.platform=1.5
+j2ee.platform.classpath=${j2ee.server.home}/modules/jstl-impl.jar:${j2ee.server.home}/modules/javax.resource.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/javax.ejb.jar:${j2ee.server.home}/modules/jsf-impl.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/javax.annotation.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.home}/modules/javax.security.auth.message.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/javax.management.j2ee.jar:${j2ee.server.home}/modules/jsf-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/javax.enterprise.deploy.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.security.jacc.jar:${j2ee.server.home}/modules/javax.transaction.jar:${j2ee.server.home}/modules/jersey-core.jar:${j2ee.server.home}/modules/javax.servlet.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.jms.jar
+j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
+j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
+j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar
+j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api-osgi.jar:${j2ee.server.home}/modules/javax.ejb.jar
+j2ee.platform.wsit.classpath=
+j2ee.server.type=gfv3ee6
+jar.compress=false
+javac.classpath=\
+    ${libs.primefaces.classpath}:\
+    ${libs.hibernate-support.classpath}:\
+    ${file.reference.avalon-framework-4.1.3.jar}:\
+    ${file.reference.commons-logging-1.1.jar}:\
+    ${file.reference.icu4j-3.8.jar}:\
+    ${file.reference.javahelp-2.0.02.jar}:\
+    ${file.reference.jaxme2-0.5.1.jar}:\
+    ${file.reference.jaxme2-rt-0.5.1.jar}:\
+    ${file.reference.jaxmeapi-0.5.1.jar}:\
+    ${file.reference.jaxmejs-0.5.1.jar}:\
+    ${file.reference.jaxmexs-0.5.1.jar}:\
+    ${file.reference.jpf-1.5.jar}:\
+    ${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}:\
+    ${file.reference.commons-lang3-3.1.jar}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.debug=true
+javac.deprecation=false
+javac.processorpath=\
+    ${javac.classpath}:\
+    ${libs.eclipselink.classpath}:\
+    ${libs.eclipselinkmodelgen.classpath}
+javac.source=1.5
+javac.target=1.5
+javac.test.classpath=\
+    ${javac.classpath}:\
+    ${build.classes.dir}
+javac.test.processorpath=\
+    ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.preview=true
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+lib.dir=${web.docbase.dir}/WEB-INF/lib
+persistence.xml.dir=${conf.dir}
+platform.active=default_platform
+resource.dir=setup
+run.test.classpath=\
+    ${javac.test.classpath}:\
+    ${build.test.classes.dir}
+# Space-separated list of JVM arguments used when running a class with a main method or a unit test
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
+runmain.jvmargs=
+source.encoding=UTF-8
+source.root=src
+src.dir=${source.root}/java
+test.src.dir=test
+war.content.additional=
+war.ear.name=simdecs.war
+war.name=simdecs.war
+web.docbase.dir=web
+webinf.dir=web/WEB-INF
index 6d7420e..8af6f9d 100644 (file)
       <property name="hibernate.hbm2ddl.auto" value="update"/>
     </properties>
   </persistence-unit>
+  <persistence-unit name="simdecsEclipseLinkPU" transaction-type="JTA">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>pg</jta-data-source>
+    <class>org.ufcspa.simdecs.bn.entity.Answer</class>
+    <class>org.ufcspa.simdecs.bn.entity.BayesianNetwork</class>
+    <class>org.ufcspa.simdecs.bn.entity.Node</class>
+    <class>org.ufcspa.simdecs.bn.entity.Question</class>
+    <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    <properties>
+      <property name="eclipselink.ddl-generation" value="create-tables"/>
+    </properties>
+  </persistence-unit>
 </persistence>
diff --git a/src/java/org/ufcspa/simdecs/bn/Bundle.properties b/src/java/org/ufcspa/simdecs/bn/Bundle.properties
new file mode 100644 (file)
index 0000000..d76d0fb
--- /dev/null
@@ -0,0 +1,209 @@
+PersistenceErrorOccured=A persistence error occurred.
+Previous=Previous
+Next=Next
+
+AnswerCreated=Answer was successfully created.
+AnswerUpdated=Answer was successfully updated.
+AnswerDeleted=Answer was successfully deleted.
+CreateAnswerTitle=Create New Answer
+CreateAnswerSaveLink=Save
+CreateAnswerShowAllLink=Show All Answer Items
+CreateAnswerIndexLink=Index
+CreateAnswerLabel_id=Id:
+CreateAnswerTitle_id=Id
+CreateAnswerLabel_text=Text:
+CreateAnswerTitle_text=Text
+CreateAnswerLabel_likelihood=Likelihood:
+CreateAnswerTitle_likelihood=Likelihood
+CreateAnswerLabel_question=Question:
+CreateAnswerTitle_question=Question
+EditAnswerTitle=Edit Answer
+EditAnswerSaveLink=Save
+EditAnswerViewLink=View
+EditAnswerShowAllLink=Show All Answer Items
+EditAnswerIndexLink=Index
+EditAnswerLabel_id=Id:
+EditAnswerTitle_id=Id
+EditAnswerLabel_text=Text:
+EditAnswerTitle_text=Text
+EditAnswerLabel_likelihood=Likelihood:
+EditAnswerTitle_likelihood=Likelihood
+EditAnswerLabel_question=Question:
+EditAnswerTitle_question=Question
+ViewAnswerTitle=View
+ViewAnswerDestroyLink=Destroy
+ViewAnswerEditLink=Edit
+ViewAnswerCreateLink=Create New Answer
+ViewAnswerShowAllLink=Show All Answer Items
+ViewAnswerIndexLink=Index
+ViewAnswerLabel_id=Id:
+ViewAnswerTitle_id=Id
+ViewAnswerLabel_text=Text:
+ViewAnswerTitle_text=Text
+ViewAnswerLabel_likelihood=Likelihood:
+ViewAnswerTitle_likelihood=Likelihood
+ViewAnswerLabel_question=Question:
+ViewAnswerTitle_question=Question
+ListAnswerTitle=List
+ListAnswerEmpty=(No Answer Items Found)
+ListAnswerDestroyLink=Destroy
+ListAnswerEditLink=Edit
+ListAnswerViewLink=View
+ListAnswerCreateLink=Create New Answer
+ListAnswerIndexLink=Index
+ListAnswerTitle_id=Id
+ListAnswerTitle_text=Text
+ListAnswerTitle_likelihood=Likelihood
+ListAnswerTitle_question=Question
+BayesianNetworkCreated=BayesianNetwork was successfully created.
+BayesianNetworkUpdated=BayesianNetwork was successfully updated.
+BayesianNetworkDeleted=BayesianNetwork was successfully deleted.
+CreateBayesianNetworkTitle=Create New BayesianNetwork
+CreateBayesianNetworkSaveLink=Save
+CreateBayesianNetworkShowAllLink=Show All BayesianNetwork Items
+CreateBayesianNetworkIndexLink=Index
+CreateBayesianNetworkLabel_id=Id:
+CreateBayesianNetworkTitle_id=Id
+CreateBayesianNetworkLabel_name=Name:
+CreateBayesianNetworkTitle_name=Name
+EditBayesianNetworkTitle=Edit BayesianNetwork
+EditBayesianNetworkSaveLink=Save
+EditBayesianNetworkViewLink=View
+EditBayesianNetworkShowAllLink=Show All BayesianNetwork Items
+EditBayesianNetworkIndexLink=Index
+EditBayesianNetworkLabel_id=Id:
+EditBayesianNetworkTitle_id=Id
+EditBayesianNetworkLabel_name=Name:
+EditBayesianNetworkTitle_name=Name
+ViewBayesianNetworkTitle=View
+ViewBayesianNetworkDestroyLink=Destroy
+ViewBayesianNetworkEditLink=Edit
+ViewBayesianNetworkCreateLink=Create New BayesianNetwork
+ViewBayesianNetworkShowAllLink=Show All BayesianNetwork Items
+ViewBayesianNetworkIndexLink=Index
+ViewBayesianNetworkLabel_id=Id:
+ViewBayesianNetworkTitle_id=Id
+ViewBayesianNetworkLabel_name=Name:
+ViewBayesianNetworkTitle_name=Name
+ListBayesianNetworkTitle=List
+ListBayesianNetworkEmpty=(No BayesianNetwork Items Found)
+ListBayesianNetworkDestroyLink=Destroy
+ListBayesianNetworkEditLink=Edit
+ListBayesianNetworkViewLink=View
+ListBayesianNetworkCreateLink=Create New BayesianNetwork
+ListBayesianNetworkIndexLink=Index
+ListBayesianNetworkTitle_id=Id
+ListBayesianNetworkTitle_name=Name
+NodeCreated=Node was successfully created.
+NodeUpdated=Node was successfully updated.
+NodeDeleted=Node was successfully deleted.
+CreateNodeTitle=Create New Node
+CreateNodeSaveLink=Save
+CreateNodeShowAllLink=Show All Node Items
+CreateNodeIndexLink=Index
+CreateNodeLabel_id=Id:
+CreateNodeTitle_id=Id
+CreateNodeLabel_name=Name:
+CreateNodeTitle_name=Name
+CreateNodeLabel_nodeType=NodeType:
+CreateNodeTitle_nodeType=NodeType
+CreateNodeLabel_time=Time:
+CreateNodeTitle_time=Time
+CreateNodeLabel_cost=Cost:
+CreateNodeTitle_cost=Cost
+CreateNodeLabel_bayesianNetwork=BayesianNetwork:
+CreateNodeTitle_bayesianNetwork=BayesianNetwork
+EditNodeTitle=Edit Node
+EditNodeSaveLink=Save
+EditNodeViewLink=View
+EditNodeShowAllLink=Show All Node Items
+EditNodeIndexLink=Index
+EditNodeLabel_id=Id:
+EditNodeTitle_id=Id
+EditNodeLabel_name=Name:
+EditNodeTitle_name=Name
+EditNodeLabel_nodeType=NodeType:
+EditNodeTitle_nodeType=NodeType
+EditNodeLabel_time=Time:
+EditNodeTitle_time=Time
+EditNodeLabel_cost=Cost:
+EditNodeTitle_cost=Cost
+EditNodeLabel_bayesianNetwork=BayesianNetwork:
+EditNodeTitle_bayesianNetwork=BayesianNetwork
+ViewNodeTitle=View
+ViewNodeDestroyLink=Destroy
+ViewNodeEditLink=Edit
+ViewNodeCreateLink=Create New Node
+ViewNodeShowAllLink=Show All Node Items
+ViewNodeIndexLink=Index
+ViewNodeLabel_id=Id:
+ViewNodeTitle_id=Id
+ViewNodeLabel_name=Name:
+ViewNodeTitle_name=Name
+ViewNodeLabel_nodeType=NodeType:
+ViewNodeTitle_nodeType=NodeType
+ViewNodeLabel_time=Time:
+ViewNodeTitle_time=Time
+ViewNodeLabel_cost=Cost:
+ViewNodeTitle_cost=Cost
+ViewNodeLabel_bayesianNetwork=BayesianNetwork:
+ViewNodeTitle_bayesianNetwork=BayesianNetwork
+ListNodeTitle=List
+ListNodeEmpty=(No Node Items Found)
+ListNodeDestroyLink=Destroy
+ListNodeEditLink=Edit
+ListNodeViewLink=View
+ListNodeCreateLink=Create New Node
+ListNodeIndexLink=Index
+ListNodeTitle_id=Id
+ListNodeTitle_name=Name
+ListNodeTitle_nodeType=NodeType
+ListNodeTitle_time=Time
+ListNodeTitle_cost=Cost
+ListNodeTitle_bayesianNetwork=BayesianNetwork
+QuestionCreated=Question was successfully created.
+QuestionUpdated=Question was successfully updated.
+QuestionDeleted=Question was successfully deleted.
+CreateQuestionTitle=Create New Question
+CreateQuestionSaveLink=Save
+CreateQuestionShowAllLink=Show All Question Items
+CreateQuestionIndexLink=Index
+CreateQuestionLabel_id=Id:
+CreateQuestionTitle_id=Id
+CreateQuestionLabel_text=Text:
+CreateQuestionTitle_text=Text
+CreateQuestionLabel_node=Node:
+CreateQuestionTitle_node=Node
+EditQuestionTitle=Edit Question
+EditQuestionSaveLink=Save
+EditQuestionViewLink=View
+EditQuestionShowAllLink=Show All Question Items
+EditQuestionIndexLink=Index
+EditQuestionLabel_id=Id:
+EditQuestionTitle_id=Id
+EditQuestionLabel_text=Text:
+EditQuestionTitle_text=Text
+EditQuestionLabel_node=Node:
+EditQuestionTitle_node=Node
+ViewQuestionTitle=View
+ViewQuestionDestroyLink=Destroy
+ViewQuestionEditLink=Edit
+ViewQuestionCreateLink=Create New Question
+ViewQuestionShowAllLink=Show All Question Items
+ViewQuestionIndexLink=Index
+ViewQuestionLabel_id=Id:
+ViewQuestionTitle_id=Id
+ViewQuestionLabel_text=Text:
+ViewQuestionTitle_text=Text
+ViewQuestionLabel_node=Node:
+ViewQuestionTitle_node=Node
+ListQuestionTitle=List
+ListQuestionEmpty=(No Question Items Found)
+ListQuestionDestroyLink=Destroy
+ListQuestionEditLink=Edit
+ListQuestionViewLink=View
+ListQuestionCreateLink=Create New Question
+ListQuestionIndexLink=Index
+ListQuestionTitle_id=Id
+ListQuestionTitle_text=Text
+ListQuestionTitle_node=Node
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/AnswerJpaController.java b/src/java/org/ufcspa/simdecs/bn/jpa/AnswerJpaController.java
new file mode 100644 (file)
index 0000000..4dd2bcb
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.bn.jpa;
+
+import java.io.Serializable;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Query;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+import javax.transaction.UserTransaction;
+import org.ufcspa.simdecs.bn.entity.Answer;
+import org.ufcspa.simdecs.bn.entity.Question;
+import org.ufcspa.simdecs.bn.jpa.exceptions.NonexistentEntityException;
+import org.ufcspa.simdecs.bn.jpa.exceptions.RollbackFailureException;
+
+/**
+ *
+ * @author mchelem
+ */
+public class AnswerJpaController implements Serializable {
+
+    public AnswerJpaController(UserTransaction utx, EntityManagerFactory emf) {
+        this.utx = utx;
+        this.emf = emf;
+    }
+    private UserTransaction utx = null;
+    private EntityManagerFactory emf = null;
+
+    public EntityManager getEntityManager() {
+        return emf.createEntityManager();
+    }
+
+    public void create(Answer answer) throws RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Question question = answer.getQuestion();
+            if (question != null) {
+                question = em.getReference(question.getClass(), question.getId());
+                answer.setQuestion(question);
+            }
+            em.persist(answer);
+            if (question != null) {
+                question.getAnswers().add(answer);
+                question = em.merge(question);
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void edit(Answer answer) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Answer persistentAnswer = em.find(Answer.class, answer.getId());
+            Question questionOld = persistentAnswer.getQuestion();
+            Question questionNew = answer.getQuestion();
+            if (questionNew != null) {
+                questionNew = em.getReference(questionNew.getClass(), questionNew.getId());
+                answer.setQuestion(questionNew);
+            }
+            answer = em.merge(answer);
+            if (questionOld != null && !questionOld.equals(questionNew)) {
+                questionOld.getAnswers().remove(answer);
+                questionOld = em.merge(questionOld);
+            }
+            if (questionNew != null && !questionNew.equals(questionOld)) {
+                questionNew.getAnswers().add(answer);
+                questionNew = em.merge(questionNew);
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            String msg = ex.getLocalizedMessage();
+            if (msg == null || msg.length() == 0) {
+                Long id = answer.getId();
+                if (findAnswer(id) == null) {
+                    throw new NonexistentEntityException("The answer with id " + id + " no longer exists.");
+                }
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void destroy(Long id) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Answer answer;
+            try {
+                answer = em.getReference(Answer.class, id);
+                answer.getId();
+            } catch (EntityNotFoundException enfe) {
+                throw new NonexistentEntityException("The answer with id " + id + " no longer exists.", enfe);
+            }
+            Question question = answer.getQuestion();
+            if (question != null) {
+                question.getAnswers().remove(answer);
+                question = em.merge(question);
+            }
+            em.remove(answer);
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public List<Answer> findAnswerEntities() {
+        return findAnswerEntities(true, -1, -1);
+    }
+
+    public List<Answer> findAnswerEntities(int maxResults, int firstResult) {
+        return findAnswerEntities(false, maxResults, firstResult);
+    }
+
+    private List<Answer> findAnswerEntities(boolean all, int maxResults, int firstResult) {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            cq.select(cq.from(Answer.class));
+            Query q = em.createQuery(cq);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+        } finally {
+            em.close();
+        }
+    }
+
+    public Answer findAnswer(Long id) {
+        EntityManager em = getEntityManager();
+        try {
+            return em.find(Answer.class, id);
+        } finally {
+            em.close();
+        }
+    }
+
+    public int getAnswerCount() {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            Root<Answer> rt = cq.from(Answer.class);
+            cq.select(em.getCriteriaBuilder().count(rt));
+            Query q = em.createQuery(cq);
+            return ((Long) q.getSingleResult()).intValue();
+        } finally {
+            em.close();
+        }
+    }
+    
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/BayesianNetworkJpaController.java b/src/java/org/ufcspa/simdecs/bn/jpa/BayesianNetworkJpaController.java
new file mode 100644 (file)
index 0000000..68ec8df
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.bn.jpa;
+
+import java.io.Serializable;
+import javax.persistence.Query;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+import org.ufcspa.simdecs.bn.entity.Node;
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.UserTransaction;
+import org.ufcspa.simdecs.bn.entity.BayesianNetwork;
+import org.ufcspa.simdecs.bn.jpa.exceptions.NonexistentEntityException;
+import org.ufcspa.simdecs.bn.jpa.exceptions.RollbackFailureException;
+
+/**
+ *
+ * @author mchelem
+ */
+public class BayesianNetworkJpaController implements Serializable {
+
+    public BayesianNetworkJpaController(UserTransaction utx, EntityManagerFactory emf) {
+        this.utx = utx;
+        this.emf = emf;
+    }
+    private UserTransaction utx = null;
+    private EntityManagerFactory emf = null;
+
+    public EntityManager getEntityManager() {
+        return emf.createEntityManager();
+    }
+
+    public void create(BayesianNetwork bayesianNetwork) throws RollbackFailureException, Exception {
+        if (bayesianNetwork.getNodes() == null) {
+            bayesianNetwork.setNodes(new ArrayList<Node>());
+        }
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            List<Node> attachedNodes = new ArrayList<Node>();
+            for (Node nodesNodeToAttach : bayesianNetwork.getNodes()) {
+                nodesNodeToAttach = em.getReference(nodesNodeToAttach.getClass(), nodesNodeToAttach.getId());
+                attachedNodes.add(nodesNodeToAttach);
+            }
+            bayesianNetwork.setNodes(attachedNodes);
+            em.persist(bayesianNetwork);
+            for (Node nodesNode : bayesianNetwork.getNodes()) {
+                BayesianNetwork oldBayesianNetworkOfNodesNode = nodesNode.getBayesianNetwork();
+                nodesNode.setBayesianNetwork(bayesianNetwork);
+                nodesNode = em.merge(nodesNode);
+                if (oldBayesianNetworkOfNodesNode != null) {
+                    oldBayesianNetworkOfNodesNode.getNodes().remove(nodesNode);
+                    oldBayesianNetworkOfNodesNode = em.merge(oldBayesianNetworkOfNodesNode);
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void edit(BayesianNetwork bayesianNetwork) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            BayesianNetwork persistentBayesianNetwork = em.find(BayesianNetwork.class, bayesianNetwork.getId());
+            List<Node> nodesOld = persistentBayesianNetwork.getNodes();
+            List<Node> nodesNew = bayesianNetwork.getNodes();
+            List<Node> attachedNodesNew = new ArrayList<Node>();
+            for (Node nodesNewNodeToAttach : nodesNew) {
+                nodesNewNodeToAttach = em.getReference(nodesNewNodeToAttach.getClass(), nodesNewNodeToAttach.getId());
+                attachedNodesNew.add(nodesNewNodeToAttach);
+            }
+            nodesNew = attachedNodesNew;
+            bayesianNetwork.setNodes(nodesNew);
+            bayesianNetwork = em.merge(bayesianNetwork);
+            for (Node nodesOldNode : nodesOld) {
+                if (!nodesNew.contains(nodesOldNode)) {
+                    nodesOldNode.setBayesianNetwork(null);
+                    nodesOldNode = em.merge(nodesOldNode);
+                }
+            }
+            for (Node nodesNewNode : nodesNew) {
+                if (!nodesOld.contains(nodesNewNode)) {
+                    BayesianNetwork oldBayesianNetworkOfNodesNewNode = nodesNewNode.getBayesianNetwork();
+                    nodesNewNode.setBayesianNetwork(bayesianNetwork);
+                    nodesNewNode = em.merge(nodesNewNode);
+                    if (oldBayesianNetworkOfNodesNewNode != null && !oldBayesianNetworkOfNodesNewNode.equals(bayesianNetwork)) {
+                        oldBayesianNetworkOfNodesNewNode.getNodes().remove(nodesNewNode);
+                        oldBayesianNetworkOfNodesNewNode = em.merge(oldBayesianNetworkOfNodesNewNode);
+                    }
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            String msg = ex.getLocalizedMessage();
+            if (msg == null || msg.length() == 0) {
+                Long id = bayesianNetwork.getId();
+                if (findBayesianNetwork(id) == null) {
+                    throw new NonexistentEntityException("The bayesianNetwork with id " + id + " no longer exists.");
+                }
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void destroy(Long id) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            BayesianNetwork bayesianNetwork;
+            try {
+                bayesianNetwork = em.getReference(BayesianNetwork.class, id);
+                bayesianNetwork.getId();
+            } catch (EntityNotFoundException enfe) {
+                throw new NonexistentEntityException("The bayesianNetwork with id " + id + " no longer exists.", enfe);
+            }
+            List<Node> nodes = bayesianNetwork.getNodes();
+            for (Node nodesNode : nodes) {
+                nodesNode.setBayesianNetwork(null);
+                nodesNode = em.merge(nodesNode);
+            }
+            em.remove(bayesianNetwork);
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public List<BayesianNetwork> findBayesianNetworkEntities() {
+        return findBayesianNetworkEntities(true, -1, -1);
+    }
+
+    public List<BayesianNetwork> findBayesianNetworkEntities(int maxResults, int firstResult) {
+        return findBayesianNetworkEntities(false, maxResults, firstResult);
+    }
+
+    private List<BayesianNetwork> findBayesianNetworkEntities(boolean all, int maxResults, int firstResult) {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            cq.select(cq.from(BayesianNetwork.class));
+            Query q = em.createQuery(cq);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+        } finally {
+            em.close();
+        }
+    }
+
+    public BayesianNetwork findBayesianNetwork(Long id) {
+        EntityManager em = getEntityManager();
+        try {
+            return em.find(BayesianNetwork.class, id);
+        } finally {
+            em.close();
+        }
+    }
+
+    public int getBayesianNetworkCount() {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            Root<BayesianNetwork> rt = cq.from(BayesianNetwork.class);
+            cq.select(em.getCriteriaBuilder().count(rt));
+            Query q = em.createQuery(cq);
+            return ((Long) q.getSingleResult()).intValue();
+        } finally {
+            em.close();
+        }
+    }
+    
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/NodeJpaController.java b/src/java/org/ufcspa/simdecs/bn/jpa/NodeJpaController.java
new file mode 100644 (file)
index 0000000..54ec341
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.bn.jpa;
+
+import java.io.Serializable;
+import javax.persistence.Query;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+import org.ufcspa.simdecs.bn.entity.BayesianNetwork;
+import org.ufcspa.simdecs.bn.entity.Question;
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.UserTransaction;
+import org.ufcspa.simdecs.bn.entity.Node;
+import org.ufcspa.simdecs.bn.jpa.exceptions.NonexistentEntityException;
+import org.ufcspa.simdecs.bn.jpa.exceptions.RollbackFailureException;
+
+/**
+ *
+ * @author mchelem
+ */
+public class NodeJpaController implements Serializable {
+
+    public NodeJpaController(UserTransaction utx, EntityManagerFactory emf) {
+        this.utx = utx;
+        this.emf = emf;
+    }
+    private UserTransaction utx = null;
+    private EntityManagerFactory emf = null;
+
+    public EntityManager getEntityManager() {
+        return emf.createEntityManager();
+    }
+
+    public void create(Node node) throws RollbackFailureException, Exception {
+        if (node.getQuestions() == null) {
+            node.setQuestions(new ArrayList<Question>());
+        }
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            BayesianNetwork bayesianNetwork = node.getBayesianNetwork();
+            if (bayesianNetwork != null) {
+                bayesianNetwork = em.getReference(bayesianNetwork.getClass(), bayesianNetwork.getId());
+                node.setBayesianNetwork(bayesianNetwork);
+            }
+            List<Question> attachedQuestions = new ArrayList<Question>();
+            for (Question questionsQuestionToAttach : node.getQuestions()) {
+                questionsQuestionToAttach = em.getReference(questionsQuestionToAttach.getClass(), questionsQuestionToAttach.getId());
+                attachedQuestions.add(questionsQuestionToAttach);
+            }
+            node.setQuestions(attachedQuestions);
+            em.persist(node);
+            if (bayesianNetwork != null) {
+                bayesianNetwork.getNodes().add(node);
+                bayesianNetwork = em.merge(bayesianNetwork);
+            }
+            for (Question questionsQuestion : node.getQuestions()) {
+                Node oldNodeOfQuestionsQuestion = questionsQuestion.getNode();
+                questionsQuestion.setNode(node);
+                questionsQuestion = em.merge(questionsQuestion);
+                if (oldNodeOfQuestionsQuestion != null) {
+                    oldNodeOfQuestionsQuestion.getQuestions().remove(questionsQuestion);
+                    oldNodeOfQuestionsQuestion = em.merge(oldNodeOfQuestionsQuestion);
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void edit(Node node) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Node persistentNode = em.find(Node.class, node.getId());
+            BayesianNetwork bayesianNetworkOld = persistentNode.getBayesianNetwork();
+            BayesianNetwork bayesianNetworkNew = node.getBayesianNetwork();
+            List<Question> questionsOld = persistentNode.getQuestions();
+            List<Question> questionsNew = node.getQuestions();
+            if (bayesianNetworkNew != null) {
+                bayesianNetworkNew = em.getReference(bayesianNetworkNew.getClass(), bayesianNetworkNew.getId());
+                node.setBayesianNetwork(bayesianNetworkNew);
+            }
+            List<Question> attachedQuestionsNew = new ArrayList<Question>();
+            for (Question questionsNewQuestionToAttach : questionsNew) {
+                questionsNewQuestionToAttach = em.getReference(questionsNewQuestionToAttach.getClass(), questionsNewQuestionToAttach.getId());
+                attachedQuestionsNew.add(questionsNewQuestionToAttach);
+            }
+            questionsNew = attachedQuestionsNew;
+            node.setQuestions(questionsNew);
+            node = em.merge(node);
+            if (bayesianNetworkOld != null && !bayesianNetworkOld.equals(bayesianNetworkNew)) {
+                bayesianNetworkOld.getNodes().remove(node);
+                bayesianNetworkOld = em.merge(bayesianNetworkOld);
+            }
+            if (bayesianNetworkNew != null && !bayesianNetworkNew.equals(bayesianNetworkOld)) {
+                bayesianNetworkNew.getNodes().add(node);
+                bayesianNetworkNew = em.merge(bayesianNetworkNew);
+            }
+            for (Question questionsOldQuestion : questionsOld) {
+                if (!questionsNew.contains(questionsOldQuestion)) {
+                    questionsOldQuestion.setNode(null);
+                    questionsOldQuestion = em.merge(questionsOldQuestion);
+                }
+            }
+            for (Question questionsNewQuestion : questionsNew) {
+                if (!questionsOld.contains(questionsNewQuestion)) {
+                    Node oldNodeOfQuestionsNewQuestion = questionsNewQuestion.getNode();
+                    questionsNewQuestion.setNode(node);
+                    questionsNewQuestion = em.merge(questionsNewQuestion);
+                    if (oldNodeOfQuestionsNewQuestion != null && !oldNodeOfQuestionsNewQuestion.equals(node)) {
+                        oldNodeOfQuestionsNewQuestion.getQuestions().remove(questionsNewQuestion);
+                        oldNodeOfQuestionsNewQuestion = em.merge(oldNodeOfQuestionsNewQuestion);
+                    }
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            String msg = ex.getLocalizedMessage();
+            if (msg == null || msg.length() == 0) {
+                Long id = node.getId();
+                if (findNode(id) == null) {
+                    throw new NonexistentEntityException("The node with id " + id + " no longer exists.");
+                }
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void destroy(Long id) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Node node;
+            try {
+                node = em.getReference(Node.class, id);
+                node.getId();
+            } catch (EntityNotFoundException enfe) {
+                throw new NonexistentEntityException("The node with id " + id + " no longer exists.", enfe);
+            }
+            BayesianNetwork bayesianNetwork = node.getBayesianNetwork();
+            if (bayesianNetwork != null) {
+                bayesianNetwork.getNodes().remove(node);
+                bayesianNetwork = em.merge(bayesianNetwork);
+            }
+            List<Question> questions = node.getQuestions();
+            for (Question questionsQuestion : questions) {
+                questionsQuestion.setNode(null);
+                questionsQuestion = em.merge(questionsQuestion);
+            }
+            em.remove(node);
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public List<Node> findNodeEntities() {
+        return findNodeEntities(true, -1, -1);
+    }
+
+    public List<Node> findNodeEntities(int maxResults, int firstResult) {
+        return findNodeEntities(false, maxResults, firstResult);
+    }
+
+    private List<Node> findNodeEntities(boolean all, int maxResults, int firstResult) {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            cq.select(cq.from(Node.class));
+            Query q = em.createQuery(cq);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+        } finally {
+            em.close();
+        }
+    }
+
+    public Node findNode(Long id) {
+        EntityManager em = getEntityManager();
+        try {
+            return em.find(Node.class, id);
+        } finally {
+            em.close();
+        }
+    }
+
+    public int getNodeCount() {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            Root<Node> rt = cq.from(Node.class);
+            cq.select(em.getCriteriaBuilder().count(rt));
+            Query q = em.createQuery(cq);
+            return ((Long) q.getSingleResult()).intValue();
+        } finally {
+            em.close();
+        }
+    }
+    
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/QuestionJpaController.java b/src/java/org/ufcspa/simdecs/bn/jpa/QuestionJpaController.java
new file mode 100644 (file)
index 0000000..6d649ca
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.bn.jpa;
+
+import java.io.Serializable;
+import javax.persistence.Query;
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Root;
+import org.ufcspa.simdecs.bn.entity.Node;
+import org.ufcspa.simdecs.bn.entity.Answer;
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.UserTransaction;
+import org.ufcspa.simdecs.bn.entity.Question;
+import org.ufcspa.simdecs.bn.jpa.exceptions.NonexistentEntityException;
+import org.ufcspa.simdecs.bn.jpa.exceptions.RollbackFailureException;
+
+/**
+ *
+ * @author mchelem
+ */
+public class QuestionJpaController implements Serializable {
+
+    public QuestionJpaController(UserTransaction utx, EntityManagerFactory emf) {
+        this.utx = utx;
+        this.emf = emf;
+    }
+    private UserTransaction utx = null;
+    private EntityManagerFactory emf = null;
+
+    public EntityManager getEntityManager() {
+        return emf.createEntityManager();
+    }
+
+    public void create(Question question) throws RollbackFailureException, Exception {
+        if (question.getAnswers() == null) {
+            question.setAnswers(new ArrayList<Answer>());
+        }
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Node node = question.getNode();
+            if (node != null) {
+                node = em.getReference(node.getClass(), node.getId());
+                question.setNode(node);
+            }
+            List<Answer> attachedAnswers = new ArrayList<Answer>();
+            for (Answer answersAnswerToAttach : question.getAnswers()) {
+                answersAnswerToAttach = em.getReference(answersAnswerToAttach.getClass(), answersAnswerToAttach.getId());
+                attachedAnswers.add(answersAnswerToAttach);
+            }
+            question.setAnswers(attachedAnswers);
+            em.persist(question);
+            if (node != null) {
+                node.getQuestions().add(question);
+                node = em.merge(node);
+            }
+            for (Answer answersAnswer : question.getAnswers()) {
+                Question oldQuestionOfAnswersAnswer = answersAnswer.getQuestion();
+                answersAnswer.setQuestion(question);
+                answersAnswer = em.merge(answersAnswer);
+                if (oldQuestionOfAnswersAnswer != null) {
+                    oldQuestionOfAnswersAnswer.getAnswers().remove(answersAnswer);
+                    oldQuestionOfAnswersAnswer = em.merge(oldQuestionOfAnswersAnswer);
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void edit(Question question) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Question persistentQuestion = em.find(Question.class, question.getId());
+            Node nodeOld = persistentQuestion.getNode();
+            Node nodeNew = question.getNode();
+            List<Answer> answersOld = persistentQuestion.getAnswers();
+            List<Answer> answersNew = question.getAnswers();
+            if (nodeNew != null) {
+                nodeNew = em.getReference(nodeNew.getClass(), nodeNew.getId());
+                question.setNode(nodeNew);
+            }
+            List<Answer> attachedAnswersNew = new ArrayList<Answer>();
+            for (Answer answersNewAnswerToAttach : answersNew) {
+                answersNewAnswerToAttach = em.getReference(answersNewAnswerToAttach.getClass(), answersNewAnswerToAttach.getId());
+                attachedAnswersNew.add(answersNewAnswerToAttach);
+            }
+            answersNew = attachedAnswersNew;
+            question.setAnswers(answersNew);
+            question = em.merge(question);
+            if (nodeOld != null && !nodeOld.equals(nodeNew)) {
+                nodeOld.getQuestions().remove(question);
+                nodeOld = em.merge(nodeOld);
+            }
+            if (nodeNew != null && !nodeNew.equals(nodeOld)) {
+                nodeNew.getQuestions().add(question);
+                nodeNew = em.merge(nodeNew);
+            }
+            for (Answer answersOldAnswer : answersOld) {
+                if (!answersNew.contains(answersOldAnswer)) {
+                    answersOldAnswer.setQuestion(null);
+                    answersOldAnswer = em.merge(answersOldAnswer);
+                }
+            }
+            for (Answer answersNewAnswer : answersNew) {
+                if (!answersOld.contains(answersNewAnswer)) {
+                    Question oldQuestionOfAnswersNewAnswer = answersNewAnswer.getQuestion();
+                    answersNewAnswer.setQuestion(question);
+                    answersNewAnswer = em.merge(answersNewAnswer);
+                    if (oldQuestionOfAnswersNewAnswer != null && !oldQuestionOfAnswersNewAnswer.equals(question)) {
+                        oldQuestionOfAnswersNewAnswer.getAnswers().remove(answersNewAnswer);
+                        oldQuestionOfAnswersNewAnswer = em.merge(oldQuestionOfAnswersNewAnswer);
+                    }
+                }
+            }
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            String msg = ex.getLocalizedMessage();
+            if (msg == null || msg.length() == 0) {
+                Long id = question.getId();
+                if (findQuestion(id) == null) {
+                    throw new NonexistentEntityException("The question with id " + id + " no longer exists.");
+                }
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public void destroy(Long id) throws NonexistentEntityException, RollbackFailureException, Exception {
+        EntityManager em = null;
+        try {
+            utx.begin();
+            em = getEntityManager();
+            Question question;
+            try {
+                question = em.getReference(Question.class, id);
+                question.getId();
+            } catch (EntityNotFoundException enfe) {
+                throw new NonexistentEntityException("The question with id " + id + " no longer exists.", enfe);
+            }
+            Node node = question.getNode();
+            if (node != null) {
+                node.getQuestions().remove(question);
+                node = em.merge(node);
+            }
+            List<Answer> answers = question.getAnswers();
+            for (Answer answersAnswer : answers) {
+                answersAnswer.setQuestion(null);
+                answersAnswer = em.merge(answersAnswer);
+            }
+            em.remove(question);
+            utx.commit();
+        } catch (Exception ex) {
+            try {
+                utx.rollback();
+            } catch (Exception re) {
+                throw new RollbackFailureException("An error occurred attempting to roll back the transaction.", re);
+            }
+            throw ex;
+        } finally {
+            if (em != null) {
+                em.close();
+            }
+        }
+    }
+
+    public List<Question> findQuestionEntities() {
+        return findQuestionEntities(true, -1, -1);
+    }
+
+    public List<Question> findQuestionEntities(int maxResults, int firstResult) {
+        return findQuestionEntities(false, maxResults, firstResult);
+    }
+
+    private List<Question> findQuestionEntities(boolean all, int maxResults, int firstResult) {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            cq.select(cq.from(Question.class));
+            Query q = em.createQuery(cq);
+            if (!all) {
+                q.setMaxResults(maxResults);
+                q.setFirstResult(firstResult);
+            }
+            return q.getResultList();
+        } finally {
+            em.close();
+        }
+    }
+
+    public Question findQuestion(Long id) {
+        EntityManager em = getEntityManager();
+        try {
+            return em.find(Question.class, id);
+        } finally {
+            em.close();
+        }
+    }
+
+    public int getQuestionCount() {
+        EntityManager em = getEntityManager();
+        try {
+            CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
+            Root<Question> rt = cq.from(Question.class);
+            cq.select(em.getCriteriaBuilder().count(rt));
+            Query q = em.createQuery(cq);
+            return ((Long) q.getSingleResult()).intValue();
+        } finally {
+            em.close();
+        }
+    }
+    
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/IllegalOrphanException.java b/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/IllegalOrphanException.java
new file mode 100644 (file)
index 0000000..15115fd
--- /dev/null
@@ -0,0 +1,20 @@
+package org.ufcspa.simdecs.bn.jpa.exceptions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class IllegalOrphanException extends Exception {
+    private List<String> messages;
+    public IllegalOrphanException(List<String> messages) {
+        super((messages != null && messages.size() > 0 ? messages.get(0) : null));
+        if (messages == null) {
+            this.messages = new ArrayList<String>();
+        }
+        else {
+            this.messages = messages;
+        }
+    }
+    public List<String> getMessages() {
+        return messages;
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/NonexistentEntityException.java b/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/NonexistentEntityException.java
new file mode 100644 (file)
index 0000000..647c6a8
--- /dev/null
@@ -0,0 +1,10 @@
+package org.ufcspa.simdecs.bn.jpa.exceptions;
+
+public class NonexistentEntityException extends Exception {
+    public NonexistentEntityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    public NonexistentEntityException(String message) {
+        super(message);
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/PreexistingEntityException.java b/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/PreexistingEntityException.java
new file mode 100644 (file)
index 0000000..4239666
--- /dev/null
@@ -0,0 +1,10 @@
+package org.ufcspa.simdecs.bn.jpa.exceptions;
+
+public class PreexistingEntityException extends Exception {
+    public PreexistingEntityException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    public PreexistingEntityException(String message) {
+        super(message);
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/RollbackFailureException.java b/src/java/org/ufcspa/simdecs/bn/jpa/exceptions/RollbackFailureException.java
new file mode 100644 (file)
index 0000000..10227e5
--- /dev/null
@@ -0,0 +1,10 @@
+package org.ufcspa.simdecs.bn.jpa.exceptions;
+
+public class RollbackFailureException extends Exception {
+    public RollbackFailureException(String message, Throwable cause) {
+        super(message, cause);
+    }
+    public RollbackFailureException(String message) {
+        super(message);
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java b/src/java/org/ufcspa/simdecs/bn/ui/AnswerController.java
new file mode 100644 (file)
index 0000000..ccd3712
--- /dev/null
@@ -0,0 +1,236 @@
+package org.ufcspa.simdecs.bn.ui;
+
+import org.ufcspa.simdecs.bn.entity.Answer;
+import org.ufcspa.simdecs.bn.ui.util.JsfUtil;
+import org.ufcspa.simdecs.bn.ui.util.PaginationHelper;
+import org.ufcspa.simdecs.bn.jpa.AnswerJpaController;
+
+import java.io.Serializable;
+import java.util.ResourceBundle;
+import javax.annotation.Resource;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.SelectItem;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.UserTransaction;
+
+@ManagedBean(name = "answerController")
+@SessionScoped
+public class AnswerController implements Serializable {
+
+    @Resource
+    private UserTransaction utx = null;
+    @PersistenceUnit(unitName = "simdecsEclipseLinkPU")
+    private EntityManagerFactory emf = null;
+    private Answer current;
+    private DataModel items = null;
+    private AnswerJpaController jpaController = null;
+    private PaginationHelper pagination;
+    private int selectedItemIndex;
+
+    public AnswerController() {
+    }
+
+    public Answer getSelected() {
+        if (current == null) {
+            current = new Answer();
+            selectedItemIndex = -1;
+        }
+        return current;
+    }
+
+    private AnswerJpaController getJpaController() {
+        if (jpaController == null) {
+            jpaController = new AnswerJpaController(utx, emf);
+        }
+        return jpaController;
+    }
+
+    public PaginationHelper getPagination() {
+        if (pagination == null) {
+            pagination = new PaginationHelper(10) {
+
+                @Override
+                public int getItemsCount() {
+                    return getJpaController().getAnswerCount();
+                }
+
+                @Override
+                public DataModel createPageDataModel() {
+                    return new ListDataModel(getJpaController().findAnswerEntities(getPageSize(), getPageFirstItem()));
+                }
+            };
+        }
+        return pagination;
+    }
+
+    public String prepareList() {
+        recreateModel();
+        return "List";
+    }
+
+    public String prepareView() {
+        current = (Answer) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "View";
+    }
+
+    public String prepareCreate() {
+        current = new Answer();
+        selectedItemIndex = -1;
+        return "Create";
+    }
+
+    public String create() {
+        try {
+            getJpaController().create(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("AnswerCreated"));
+            return prepareCreate();
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String prepareEdit() {
+        current = (Answer) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "Edit";
+    }
+
+    public String update() {
+        try {
+            getJpaController().edit(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("AnswerUpdated"));
+            return "View";
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String destroy() {
+        current = (Answer) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        performDestroy();
+        recreatePagination();
+        recreateModel();
+        return "List";
+    }
+
+    public String destroyAndView() {
+        performDestroy();
+        recreateModel();
+        updateCurrentItem();
+        if (selectedItemIndex >= 0) {
+            return "View";
+        } else {
+            // all items were removed - go back to list
+            recreateModel();
+            return "List";
+        }
+    }
+
+    private void performDestroy() {
+        try {
+            getJpaController().destroy(current.getId());
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("AnswerDeleted"));
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+        }
+    }
+
+    private void updateCurrentItem() {
+        int count = getJpaController().getAnswerCount();
+        if (selectedItemIndex >= count) {
+            // selected index cannot be bigger than number of items:
+            selectedItemIndex = count - 1;
+            // go to previous page if last page disappeared:
+            if (pagination.getPageFirstItem() >= count) {
+                pagination.previousPage();
+            }
+        }
+        if (selectedItemIndex >= 0) {
+            current = getJpaController().findAnswerEntities(1, selectedItemIndex).get(0);
+        }
+    }
+
+    public DataModel getItems() {
+        if (items == null) {
+            items = getPagination().createPageDataModel();
+        }
+        return items;
+    }
+
+    private void recreateModel() {
+        items = null;
+    }
+
+    private void recreatePagination() {
+        pagination = null;
+    }
+
+    public String next() {
+        getPagination().nextPage();
+        recreateModel();
+        return "List";
+    }
+
+    public String previous() {
+        getPagination().previousPage();
+        recreateModel();
+        return "List";
+    }
+
+    public SelectItem[] getItemsAvailableSelectMany() {
+        return JsfUtil.getSelectItems(getJpaController().findAnswerEntities(), false);
+    }
+
+    public SelectItem[] getItemsAvailableSelectOne() {
+        return JsfUtil.getSelectItems(getJpaController().findAnswerEntities(), true);
+    }
+
+    @FacesConverter(forClass = Answer.class)
+    public static class AnswerControllerConverter implements Converter {
+
+        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+            if (value == null || value.length() == 0) {
+                return null;
+            }
+            AnswerController controller = (AnswerController) facesContext.getApplication().getELResolver().
+                    getValue(facesContext.getELContext(), null, "answerController");
+            return controller.getJpaController().findAnswer(getKey(value));
+        }
+
+        java.lang.Long getKey(String value) {
+            java.lang.Long key;
+            key = Long.valueOf(value);
+            return key;
+        }
+
+        String getStringKey(java.lang.Long value) {
+            StringBuffer sb = new StringBuffer();
+            sb.append(value);
+            return sb.toString();
+        }
+
+        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+            if (object == null) {
+                return null;
+            }
+            if (object instanceof Answer) {
+                Answer o = (Answer) object;
+                return getStringKey(o.getId());
+            } else {
+                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + AnswerController.class.getName());
+            }
+        }
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java b/src/java/org/ufcspa/simdecs/bn/ui/BayesianNetworkController.java
new file mode 100644 (file)
index 0000000..9dbe96f
--- /dev/null
@@ -0,0 +1,236 @@
+package org.ufcspa.simdecs.bn.ui;
+
+import org.ufcspa.simdecs.bn.entity.BayesianNetwork;
+import org.ufcspa.simdecs.bn.ui.util.JsfUtil;
+import org.ufcspa.simdecs.bn.ui.util.PaginationHelper;
+import org.ufcspa.simdecs.bn.jpa.BayesianNetworkJpaController;
+
+import java.io.Serializable;
+import java.util.ResourceBundle;
+import javax.annotation.Resource;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.SelectItem;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.UserTransaction;
+
+@ManagedBean(name = "bayesianNetworkController")
+@SessionScoped
+public class BayesianNetworkController implements Serializable {
+
+    @Resource
+    private UserTransaction utx = null;
+    @PersistenceUnit(unitName = "simdecsEclipseLinkPU")
+    private EntityManagerFactory emf = null;
+    private BayesianNetwork current;
+    private DataModel items = null;
+    private BayesianNetworkJpaController jpaController = null;
+    private PaginationHelper pagination;
+    private int selectedItemIndex;
+
+    public BayesianNetworkController() {
+    }
+
+    public BayesianNetwork getSelected() {
+        if (current == null) {
+            current = new BayesianNetwork();
+            selectedItemIndex = -1;
+        }
+        return current;
+    }
+
+    private BayesianNetworkJpaController getJpaController() {
+        if (jpaController == null) {
+            jpaController = new BayesianNetworkJpaController(utx, emf);
+        }
+        return jpaController;
+    }
+
+    public PaginationHelper getPagination() {
+        if (pagination == null) {
+            pagination = new PaginationHelper(10) {
+
+                @Override
+                public int getItemsCount() {
+                    return getJpaController().getBayesianNetworkCount();
+                }
+
+                @Override
+                public DataModel createPageDataModel() {
+                    return new ListDataModel(getJpaController().findBayesianNetworkEntities(getPageSize(), getPageFirstItem()));
+                }
+            };
+        }
+        return pagination;
+    }
+
+    public String prepareList() {
+        recreateModel();
+        return "List";
+    }
+
+    public String prepareView() {
+        current = (BayesianNetwork) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "View";
+    }
+
+    public String prepareCreate() {
+        current = new BayesianNetwork();
+        selectedItemIndex = -1;
+        return "Create";
+    }
+
+    public String create() {
+        try {
+            getJpaController().create(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("BayesianNetworkCreated"));
+            return prepareCreate();
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String prepareEdit() {
+        current = (BayesianNetwork) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "Edit";
+    }
+
+    public String update() {
+        try {
+            getJpaController().edit(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("BayesianNetworkUpdated"));
+            return "View";
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String destroy() {
+        current = (BayesianNetwork) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        performDestroy();
+        recreatePagination();
+        recreateModel();
+        return "List";
+    }
+
+    public String destroyAndView() {
+        performDestroy();
+        recreateModel();
+        updateCurrentItem();
+        if (selectedItemIndex >= 0) {
+            return "View";
+        } else {
+            // all items were removed - go back to list
+            recreateModel();
+            return "List";
+        }
+    }
+
+    private void performDestroy() {
+        try {
+            getJpaController().destroy(current.getId());
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("BayesianNetworkDeleted"));
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+        }
+    }
+
+    private void updateCurrentItem() {
+        int count = getJpaController().getBayesianNetworkCount();
+        if (selectedItemIndex >= count) {
+            // selected index cannot be bigger than number of items:
+            selectedItemIndex = count - 1;
+            // go to previous page if last page disappeared:
+            if (pagination.getPageFirstItem() >= count) {
+                pagination.previousPage();
+            }
+        }
+        if (selectedItemIndex >= 0) {
+            current = getJpaController().findBayesianNetworkEntities(1, selectedItemIndex).get(0);
+        }
+    }
+
+    public DataModel getItems() {
+        if (items == null) {
+            items = getPagination().createPageDataModel();
+        }
+        return items;
+    }
+
+    private void recreateModel() {
+        items = null;
+    }
+
+    private void recreatePagination() {
+        pagination = null;
+    }
+
+    public String next() {
+        getPagination().nextPage();
+        recreateModel();
+        return "List";
+    }
+
+    public String previous() {
+        getPagination().previousPage();
+        recreateModel();
+        return "List";
+    }
+
+    public SelectItem[] getItemsAvailableSelectMany() {
+        return JsfUtil.getSelectItems(getJpaController().findBayesianNetworkEntities(), false);
+    }
+
+    public SelectItem[] getItemsAvailableSelectOne() {
+        return JsfUtil.getSelectItems(getJpaController().findBayesianNetworkEntities(), true);
+    }
+
+    @FacesConverter(forClass = BayesianNetwork.class)
+    public static class BayesianNetworkControllerConverter implements Converter {
+
+        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+            if (value == null || value.length() == 0) {
+                return null;
+            }
+            BayesianNetworkController controller = (BayesianNetworkController) facesContext.getApplication().getELResolver().
+                    getValue(facesContext.getELContext(), null, "bayesianNetworkController");
+            return controller.getJpaController().findBayesianNetwork(getKey(value));
+        }
+
+        java.lang.Long getKey(String value) {
+            java.lang.Long key;
+            key = Long.valueOf(value);
+            return key;
+        }
+
+        String getStringKey(java.lang.Long value) {
+            StringBuffer sb = new StringBuffer();
+            sb.append(value);
+            return sb.toString();
+        }
+
+        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+            if (object == null) {
+                return null;
+            }
+            if (object instanceof BayesianNetwork) {
+                BayesianNetwork o = (BayesianNetwork) object;
+                return getStringKey(o.getId());
+            } else {
+                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + BayesianNetworkController.class.getName());
+            }
+        }
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/FileUploadController.java b/src/java/org/ufcspa/simdecs/bn/ui/FileUploadController.java
new file mode 100644 (file)
index 0000000..aa5f25e
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ufcspa.simdecs.bn.ui;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.annotation.Resource;
+import javax.faces.application.FacesMessage;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.UserTransaction;
+import javax.xml.bind.JAXBException;
+import org.primefaces.event.FileUploadEvent;
+import org.primefaces.model.UploadedFile;
+import org.ufcspa.simdecs.bn.entity.BayesianNetwork;
+import org.ufcspa.simdecs.bn.entity.Node;
+import unbbayes.io.exception.LoadException;
+import unbbayes.io.xmlbif.version6.XMLBIFIO;
+import unbbayes.prs.bn.ProbabilisticNetwork;
+
+/**
+ *
+ * @author mchelem
+ */
+@ManagedBean(name = "fileUploadController")
+@ApplicationScoped
+public class FileUploadController implements Serializable {
+    @Resource
+    private UserTransaction utx = null;
+    @PersistenceUnit(unitName = "simdecsEclipseLinkPU")
+    private EntityManagerFactory emf = null;
+    EntityManager em = null;
+    
+    private static final Logger logger = Logger.getLogger("" + FileUploadController.class);
+
+    private File saveUploadedFile(UploadedFile uploadedFile) throws IOException{
+        InputStream in = new BufferedInputStream(uploadedFile.getInputstream()); 
+        File file = new File(uploadedFile.getFileName());           
+        FileOutputStream fout = new FileOutputStream(file);
+        while(in.available() != 0){ 
+            fout.write(in.read());
+        }
+        logger.log(Level.INFO, "Uploaded file saved in: {0}", file.getAbsolutePath());
+        return file;            
+    }
+    
+    private void persist(BayesianNetwork bayesianNetwork){
+        em = emf.createEntityManager();
+        try {
+            utx.begin();
+            em.persist(bayesianNetwork);           
+            utx.commit();
+            } catch (Exception e) {
+                try {
+                    utx.rollback();
+                } catch (Exception ex) {
+                    Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
+                } 
+                Logger.getLogger(FileUploadController.class.getName()).log(Level.INFO, null, e);
+            }
+        logger.log(Level.INFO, "Bayesian Network {0} persisted.", bayesianNetwork.getName());
+
+    }
+    
+    
+    public void handleFileUpload(FileUploadEvent event) {
+        try {
+            File file = this.saveUploadedFile(event.getFile());            
+            // required to run unbbayes gui classes on server
+            System.setProperty("java.awt.headless", "false"); 
+            
+            ProbabilisticNetwork bn = new ProbabilisticNetwork(null);
+            XMLBIFIO.loadXML(new File(file.getAbsolutePath()), bn);             
+            BayesianNetwork bayesianNetwork = new BayesianNetwork();
+            bayesianNetwork.setName(bn.getName());                        
+            
+            ArrayList<Node> nodes = new ArrayList<Node>();
+            for (unbbayes.prs.Node prs_node: bn.getNodes()){
+                Node node = new Node();
+                node.setName(prs_node.getName());
+                node.setBayesianNetwork(bayesianNetwork);
+                nodes.add(node);                
+            }
+            bayesianNetwork.setNodes(nodes);                                          
+            persist(bayesianNetwork);
+            
+            FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName() + " is uploaded.");
+            FacesContext.getCurrentInstance().addMessage(null, msg);
+        } catch (LoadException ex) {
+            Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (IOException ex) {
+            Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
+        } catch (JAXBException ex) {
+            Logger.getLogger(FileUploadController.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+}
+        
\ No newline at end of file
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java b/src/java/org/ufcspa/simdecs/bn/ui/NodeController.java
new file mode 100644 (file)
index 0000000..bd24dd9
--- /dev/null
@@ -0,0 +1,236 @@
+package org.ufcspa.simdecs.bn.ui;
+
+import org.ufcspa.simdecs.bn.entity.Node;
+import org.ufcspa.simdecs.bn.ui.util.JsfUtil;
+import org.ufcspa.simdecs.bn.ui.util.PaginationHelper;
+import org.ufcspa.simdecs.bn.jpa.NodeJpaController;
+
+import java.io.Serializable;
+import java.util.ResourceBundle;
+import javax.annotation.Resource;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.SelectItem;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.UserTransaction;
+
+@ManagedBean(name = "nodeController")
+@SessionScoped
+public class NodeController implements Serializable {
+
+    @Resource
+    private UserTransaction utx = null;
+    @PersistenceUnit(unitName = "simdecsEclipseLinkPU")
+    private EntityManagerFactory emf = null;
+    private Node current;
+    private DataModel items = null;
+    private NodeJpaController jpaController = null;
+    private PaginationHelper pagination;
+    private int selectedItemIndex;
+
+    public NodeController() {
+    }
+
+    public Node getSelected() {
+        if (current == null) {
+            current = new Node();
+            selectedItemIndex = -1;
+        }
+        return current;
+    }
+
+    private NodeJpaController getJpaController() {
+        if (jpaController == null) {
+            jpaController = new NodeJpaController(utx, emf);
+        }
+        return jpaController;
+    }
+
+    public PaginationHelper getPagination() {
+        if (pagination == null) {
+            pagination = new PaginationHelper(10) {
+
+                @Override
+                public int getItemsCount() {
+                    return getJpaController().getNodeCount();
+                }
+
+                @Override
+                public DataModel createPageDataModel() {
+                    return new ListDataModel(getJpaController().findNodeEntities(getPageSize(), getPageFirstItem()));
+                }
+            };
+        }
+        return pagination;
+    }
+
+    public String prepareList() {
+        recreateModel();
+        return "List";
+    }
+
+    public String prepareView() {
+        current = (Node) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "View";
+    }
+
+    public String prepareCreate() {
+        current = new Node();
+        selectedItemIndex = -1;
+        return "Create";
+    }
+
+    public String create() {
+        try {
+            getJpaController().create(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("NodeCreated"));
+            return prepareCreate();
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String prepareEdit() {
+        current = (Node) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "Edit";
+    }
+
+    public String update() {
+        try {
+            getJpaController().edit(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("NodeUpdated"));
+            return "View";
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String destroy() {
+        current = (Node) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        performDestroy();
+        recreatePagination();
+        recreateModel();
+        return "List";
+    }
+
+    public String destroyAndView() {
+        performDestroy();
+        recreateModel();
+        updateCurrentItem();
+        if (selectedItemIndex >= 0) {
+            return "View";
+        } else {
+            // all items were removed - go back to list
+            recreateModel();
+            return "List";
+        }
+    }
+
+    private void performDestroy() {
+        try {
+            getJpaController().destroy(current.getId());
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("NodeDeleted"));
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+        }
+    }
+
+    private void updateCurrentItem() {
+        int count = getJpaController().getNodeCount();
+        if (selectedItemIndex >= count) {
+            // selected index cannot be bigger than number of items:
+            selectedItemIndex = count - 1;
+            // go to previous page if last page disappeared:
+            if (pagination.getPageFirstItem() >= count) {
+                pagination.previousPage();
+            }
+        }
+        if (selectedItemIndex >= 0) {
+            current = getJpaController().findNodeEntities(1, selectedItemIndex).get(0);
+        }
+    }
+
+    public DataModel getItems() {
+        if (items == null) {
+            items = getPagination().createPageDataModel();
+        }
+        return items;
+    }
+
+    private void recreateModel() {
+        items = null;
+    }
+
+    private void recreatePagination() {
+        pagination = null;
+    }
+
+    public String next() {
+        getPagination().nextPage();
+        recreateModel();
+        return "List";
+    }
+
+    public String previous() {
+        getPagination().previousPage();
+        recreateModel();
+        return "List";
+    }
+
+    public SelectItem[] getItemsAvailableSelectMany() {
+        return JsfUtil.getSelectItems(getJpaController().findNodeEntities(), false);
+    }
+
+    public SelectItem[] getItemsAvailableSelectOne() {
+        return JsfUtil.getSelectItems(getJpaController().findNodeEntities(), true);
+    }
+
+    @FacesConverter(forClass = Node.class)
+    public static class NodeControllerConverter implements Converter {
+
+        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+            if (value == null || value.length() == 0) {
+                return null;
+            }
+            NodeController controller = (NodeController) facesContext.getApplication().getELResolver().
+                    getValue(facesContext.getELContext(), null, "nodeController");
+            return controller.getJpaController().findNode(getKey(value));
+        }
+
+        java.lang.Long getKey(String value) {
+            java.lang.Long key;
+            key = Long.valueOf(value);
+            return key;
+        }
+
+        String getStringKey(java.lang.Long value) {
+            StringBuffer sb = new StringBuffer();
+            sb.append(value);
+            return sb.toString();
+        }
+
+        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+            if (object == null) {
+                return null;
+            }
+            if (object instanceof Node) {
+                Node o = (Node) object;
+                return getStringKey(o.getId());
+            } else {
+                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + NodeController.class.getName());
+            }
+        }
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java b/src/java/org/ufcspa/simdecs/bn/ui/QuestionController.java
new file mode 100644 (file)
index 0000000..711712f
--- /dev/null
@@ -0,0 +1,236 @@
+package org.ufcspa.simdecs.bn.ui;
+
+import org.ufcspa.simdecs.bn.entity.Question;
+import org.ufcspa.simdecs.bn.ui.util.JsfUtil;
+import org.ufcspa.simdecs.bn.ui.util.PaginationHelper;
+import org.ufcspa.simdecs.bn.jpa.QuestionJpaController;
+
+import java.io.Serializable;
+import java.util.ResourceBundle;
+import javax.annotation.Resource;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.SelectItem;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.UserTransaction;
+
+@ManagedBean(name = "questionController")
+@SessionScoped
+public class QuestionController implements Serializable {
+
+    @Resource
+    private UserTransaction utx = null;
+    @PersistenceUnit(unitName = "simdecsEclipseLinkPU")
+    private EntityManagerFactory emf = null;
+    private Question current;
+    private DataModel items = null;
+    private QuestionJpaController jpaController = null;
+    private PaginationHelper pagination;
+    private int selectedItemIndex;
+
+    public QuestionController() {
+    }
+
+    public Question getSelected() {
+        if (current == null) {
+            current = new Question();
+            selectedItemIndex = -1;
+        }
+        return current;
+    }
+
+    private QuestionJpaController getJpaController() {
+        if (jpaController == null) {
+            jpaController = new QuestionJpaController(utx, emf);
+        }
+        return jpaController;
+    }
+
+    public PaginationHelper getPagination() {
+        if (pagination == null) {
+            pagination = new PaginationHelper(10) {
+
+                @Override
+                public int getItemsCount() {
+                    return getJpaController().getQuestionCount();
+                }
+
+                @Override
+                public DataModel createPageDataModel() {
+                    return new ListDataModel(getJpaController().findQuestionEntities(getPageSize(), getPageFirstItem()));
+                }
+            };
+        }
+        return pagination;
+    }
+
+    public String prepareList() {
+        recreateModel();
+        return "List";
+    }
+
+    public String prepareView() {
+        current = (Question) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "View";
+    }
+
+    public String prepareCreate() {
+        current = new Question();
+        selectedItemIndex = -1;
+        return "Create";
+    }
+
+    public String create() {
+        try {
+            getJpaController().create(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("QuestionCreated"));
+            return prepareCreate();
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String prepareEdit() {
+        current = (Question) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        return "Edit";
+    }
+
+    public String update() {
+        try {
+            getJpaController().edit(current);
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("QuestionUpdated"));
+            return "View";
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+            return null;
+        }
+    }
+
+    public String destroy() {
+        current = (Question) getItems().getRowData();
+        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
+        performDestroy();
+        recreatePagination();
+        recreateModel();
+        return "List";
+    }
+
+    public String destroyAndView() {
+        performDestroy();
+        recreateModel();
+        updateCurrentItem();
+        if (selectedItemIndex >= 0) {
+            return "View";
+        } else {
+            // all items were removed - go back to list
+            recreateModel();
+            return "List";
+        }
+    }
+
+    private void performDestroy() {
+        try {
+            getJpaController().destroy(current.getId());
+            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("QuestionDeleted"));
+        } catch (Exception e) {
+            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("org/ufcspa/simdecs/bn/Bundle").getString("PersistenceErrorOccured"));
+        }
+    }
+
+    private void updateCurrentItem() {
+        int count = getJpaController().getQuestionCount();
+        if (selectedItemIndex >= count) {
+            // selected index cannot be bigger than number of items:
+            selectedItemIndex = count - 1;
+            // go to previous page if last page disappeared:
+            if (pagination.getPageFirstItem() >= count) {
+                pagination.previousPage();
+            }
+        }
+        if (selectedItemIndex >= 0) {
+            current = getJpaController().findQuestionEntities(1, selectedItemIndex).get(0);
+        }
+    }
+
+    public DataModel getItems() {
+        if (items == null) {
+            items = getPagination().createPageDataModel();
+        }
+        return items;
+    }
+
+    private void recreateModel() {
+        items = null;
+    }
+
+    private void recreatePagination() {
+        pagination = null;
+    }
+
+    public String next() {
+        getPagination().nextPage();
+        recreateModel();
+        return "List";
+    }
+
+    public String previous() {
+        getPagination().previousPage();
+        recreateModel();
+        return "List";
+    }
+
+    public SelectItem[] getItemsAvailableSelectMany() {
+        return JsfUtil.getSelectItems(getJpaController().findQuestionEntities(), false);
+    }
+
+    public SelectItem[] getItemsAvailableSelectOne() {
+        return JsfUtil.getSelectItems(getJpaController().findQuestionEntities(), true);
+    }
+
+    @FacesConverter(forClass = Question.class)
+    public static class QuestionControllerConverter implements Converter {
+
+        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+            if (value == null || value.length() == 0) {
+                return null;
+            }
+            QuestionController controller = (QuestionController) facesContext.getApplication().getELResolver().
+                    getValue(facesContext.getELContext(), null, "questionController");
+            return controller.getJpaController().findQuestion(getKey(value));
+        }
+
+        java.lang.Long getKey(String value) {
+            java.lang.Long key;
+            key = Long.valueOf(value);
+            return key;
+        }
+
+        String getStringKey(java.lang.Long value) {
+            StringBuffer sb = new StringBuffer();
+            sb.append(value);
+            return sb.toString();
+        }
+
+        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+            if (object == null) {
+                return null;
+            }
+            if (object instanceof Question) {
+                Question o = (Question) object;
+                return getStringKey(o.getId());
+            } else {
+                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + QuestionController.class.getName());
+            }
+        }
+    }
+}
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/util/JsfUtil.java b/src/java/org/ufcspa/simdecs/bn/ui/util/JsfUtil.java
new file mode 100644 (file)
index 0000000..8a83a97
--- /dev/null
@@ -0,0 +1,59 @@
+package org.ufcspa.simdecs.bn.ui.util;
+
+import java.util.List;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.model.SelectItem;
+
+public class JsfUtil {
+
+    public static SelectItem[] getSelectItems(List<?> entities, boolean selectOne) {
+        int size = selectOne ? entities.size() + 1 : entities.size();
+        SelectItem[] items = new SelectItem[size];
+        int i = 0;
+        if (selectOne) {
+            items[0] = new SelectItem("", "---");
+            i++;
+        }
+        for (Object x : entities) {
+            items[i++] = new SelectItem(x, x.toString());
+        }
+        return items;
+    }
+
+    public static void addErrorMessage(Exception ex, String defaultMsg) {
+        String msg = ex.getLocalizedMessage();
+        if (msg != null && msg.length() > 0) {
+            addErrorMessage(msg);
+        } else {
+            addErrorMessage(defaultMsg);
+        }
+    }
+
+    public static void addErrorMessages(List<String> messages) {
+        for (String message : messages) {
+            addErrorMessage(message);
+        }
+    }
+
+    public static void addErrorMessage(String msg) {
+        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
+        FacesContext.getCurrentInstance().addMessage(null, facesMsg);
+    }
+
+    public static void addSuccessMessage(String msg) {
+        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
+        FacesContext.getCurrentInstance().addMessage("successInfo", facesMsg);
+    }
+
+    public static String getRequestParameter(String key) {
+        return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(key);
+    }
+
+    public static Object getObjectFromRequestParameter(String requestParameterName, Converter converter, UIComponent component) {
+        String theId = JsfUtil.getRequestParameter(requestParameterName);
+        return converter.getAsObject(FacesContext.getCurrentInstance(), component, theId);
+    }
+}
\ No newline at end of file
diff --git a/src/java/org/ufcspa/simdecs/bn/ui/util/PaginationHelper.java b/src/java/org/ufcspa/simdecs/bn/ui/util/PaginationHelper.java
new file mode 100644 (file)
index 0000000..c9da86b
--- /dev/null
@@ -0,0 +1,57 @@
+package org.ufcspa.simdecs.bn.ui.util;
+
+import javax.faces.model.DataModel;
+
+public abstract class PaginationHelper {
+
+    private int pageSize;
+    private int page;
+
+    public PaginationHelper(int pageSize) {
+        this.pageSize = pageSize;
+    }
+
+    public abstract int getItemsCount();
+
+    public abstract DataModel createPageDataModel();
+
+    public int getPageFirstItem() {
+        return page * pageSize;
+    }
+
+    public int getPageLastItem() {
+        int i = getPageFirstItem() + pageSize - 1;
+        int count = getItemsCount() - 1;
+        if (i > count) {
+            i = count;
+        }
+        if (i < 0) {
+            i = 0;
+        }
+        return i;
+    }
+
+    public boolean isHasNextPage() {
+        return (page + 1) * pageSize + 1 <= getItemsCount();
+    }
+
+    public void nextPage() {
+        if (isHasNextPage()) {
+            page++;
+        }
+    }
+
+    public boolean isHasPreviousPage() {
+        return page > 0;
+    }
+
+    public void previousPage() {
+        if (isHasPreviousPage()) {
+            page--;
+        }
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+}
index 662799e..6f0498f 100755 (executable)
         <message-bundle>\r
                        org.ufcspa.simdecs.resources.messages\r
         </message-bundle>\r
+        <resource-bundle>\r
+            <base-name>org/ufcspa/simdecs/bn/Bundle</base-name>\r
+            <var>bundle</var>\r
+        </resource-bundle>\r
     </application>\r
     <managed-bean>\r
         <managed-bean-name>editActor</managed-bean-name>\r
diff --git a/web/bn/answer/Create.xhtml b/web/bn/answer/Create.xhtml
new file mode 100644 (file)
index 0000000..90e700c
--- /dev/null
@@ -0,0 +1,41 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.CreateAnswerTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.CreateAnswerLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{answerController.selected.id}" title="#{bundle.CreateAnswerTitle_id}" />
+                    <h:outputLabel value="#{bundle.CreateAnswerLabel_text}" for="text" />
+                    <h:inputText id="text" value="#{answerController.selected.text}" title="#{bundle.CreateAnswerTitle_text}" />
+                    <h:outputLabel value="#{bundle.CreateAnswerLabel_likelihood}" for="likelihood" />
+                    <h:inputText id="likelihood" value="#{answerController.selected.likelihood}" title="#{bundle.CreateAnswerTitle_likelihood}" />
+                    <h:outputLabel value="#{bundle.CreateAnswerLabel_question}" for="question" />
+                    <h:selectOneMenu id="question" value="#{answerController.selected.question}" title="#{bundle.CreateAnswerTitle_question}" >
+                        <f:selectItems value="#{questionController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{answerController.create}" value="#{bundle.CreateAnswerSaveLink}" />
+                <br />
+                <br />
+                <h:commandLink action="#{answerController.prepareList}" value="#{bundle.CreateAnswerShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.CreateAnswerIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/answer/Edit.xhtml b/web/bn/answer/Edit.xhtml
new file mode 100644 (file)
index 0000000..e45407b
--- /dev/null
@@ -0,0 +1,42 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.EditAnswerTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.EditAnswerLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{answerController.selected.id}" title="#{bundle.EditAnswerTitle_id}" />
+                    <h:outputLabel value="#{bundle.EditAnswerLabel_text}" for="text" />
+                    <h:inputText id="text" value="#{answerController.selected.text}" title="#{bundle.EditAnswerTitle_text}" />
+                    <h:outputLabel value="#{bundle.EditAnswerLabel_likelihood}" for="likelihood" />
+                    <h:inputText id="likelihood" value="#{answerController.selected.likelihood}" title="#{bundle.EditAnswerTitle_likelihood}" />
+                    <h:outputLabel value="#{bundle.EditAnswerLabel_question}" for="question" />
+                    <h:selectOneMenu id="question" value="#{answerController.selected.question}" title="#{bundle.EditAnswerTitle_question}" >
+                        <f:selectItems value="#{questionController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <h:commandLink action="#{answerController.update}" value="#{bundle.EditAnswerSaveLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="View" value="#{bundle.EditAnswerViewLink}" immediate="true"/>
+                <br />
+                <h:commandLink action="#{answerController.prepareList}" value="#{bundle.EditAnswerShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.EditAnswerIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/answer/List.xhtml b/web/bn/answer/List.xhtml
new file mode 100644 (file)
index 0000000..1378c38
--- /dev/null
@@ -0,0 +1,68 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ListAnswerTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:form styleClass="jsfcrud_list_form">
+                <h:panelGroup id="messagePanel" layout="block">
+                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+                </h:panelGroup>
+                <h:outputText escape="false" value="#{bundle.ListAnswerEmpty}" rendered="#{answerController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{answerController.items.rowCount > 0}">
+                    <h:outputText value="#{answerController.pagination.pageFirstItem + 1}..#{answerController.pagination.pageLastItem + 1}/#{answerController.pagination.itemsCount}"/>&nbsp;
+                    <h:commandLink action="#{answerController.previous}" value="#{bundle.Previous} #{answerController.pagination.pageSize}" rendered="#{answerController.pagination.hasPreviousPage}"/>&nbsp;
+                    <h:commandLink action="#{answerController.next}" value="#{bundle.Next} #{answerController.pagination.pageSize}" rendered="#{answerController.pagination.hasNextPage}"/>&nbsp;
+                    <h:dataTable value="#{answerController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListAnswerTitle_id}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.id}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListAnswerTitle_text}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.text}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListAnswerTitle_likelihood}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.likelihood}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListAnswerTitle_question}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.question}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="&nbsp;"/>
+                            </f:facet>
+                            <h:commandLink action="#{answerController.prepareView}" value="#{bundle.ListAnswerViewLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{answerController.prepareEdit}" value="#{bundle.ListAnswerEditLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{answerController.destroy}" value="#{bundle.ListAnswerDestroyLink}"/>
+                        </h:column>
+                    </h:dataTable>
+                </h:panelGroup>
+                <br />
+                <h:commandLink action="#{answerController.prepareCreate}" value="#{bundle.ListAnswerCreateLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ListAnswerIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/answer/View.xhtml b/web/bn/answer/View.xhtml
new file mode 100644 (file)
index 0000000..119c531
--- /dev/null
@@ -0,0 +1,44 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ViewAnswerTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputText value="#{bundle.ViewAnswerLabel_id}"/>
+                    <h:outputText value="#{answerController.selected.id}" title="#{bundle.ViewAnswerTitle_id}"/>
+                    <h:outputText value="#{bundle.ViewAnswerLabel_text}"/>
+                    <h:outputText value="#{answerController.selected.text}" title="#{bundle.ViewAnswerTitle_text}"/>
+                    <h:outputText value="#{bundle.ViewAnswerLabel_likelihood}"/>
+                    <h:outputText value="#{answerController.selected.likelihood}" title="#{bundle.ViewAnswerTitle_likelihood}"/>
+                    <h:outputText value="#{bundle.ViewAnswerLabel_question}"/>
+                    <h:outputText value="#{answerController.selected.question}" title="#{bundle.ViewAnswerTitle_question}"/>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{answerController.destroyAndView}" value="#{bundle.ViewAnswerDestroyLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="Edit" value="#{bundle.ViewAnswerEditLink}"/>
+                <br />
+                <h:commandLink action="#{answerController.prepareCreate}" value="#{bundle.ViewAnswerCreateLink}" />
+                <br />
+                <h:commandLink action="#{answerController.prepareList}" value="#{bundle.ViewAnswerShowAllLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ViewAnswerIndexLink}" action="/index" immediate="true" />
+
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/bayesianNetwork/Create.xhtml b/web/bn/bayesianNetwork/Create.xhtml
new file mode 100644 (file)
index 0000000..7219a62
--- /dev/null
@@ -0,0 +1,35 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.CreateBayesianNetworkTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.CreateBayesianNetworkLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{bayesianNetworkController.selected.id}" title="#{bundle.CreateBayesianNetworkTitle_id}" />
+                    <h:outputLabel value="#{bundle.CreateBayesianNetworkLabel_name}" for="name" />
+                    <h:inputText id="name" value="#{bayesianNetworkController.selected.name}" title="#{bundle.CreateBayesianNetworkTitle_name}" />
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.create}" value="#{bundle.CreateBayesianNetworkSaveLink}" />
+                <br />
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.prepareList}" value="#{bundle.CreateBayesianNetworkShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.CreateBayesianNetworkIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/bayesianNetwork/Edit.xhtml b/web/bn/bayesianNetwork/Edit.xhtml
new file mode 100644 (file)
index 0000000..e2fe5d4
--- /dev/null
@@ -0,0 +1,36 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.EditBayesianNetworkTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.EditBayesianNetworkLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{bayesianNetworkController.selected.id}" title="#{bundle.EditBayesianNetworkTitle_id}" />
+                    <h:outputLabel value="#{bundle.EditBayesianNetworkLabel_name}" for="name" />
+                    <h:inputText id="name" value="#{bayesianNetworkController.selected.name}" title="#{bundle.EditBayesianNetworkTitle_name}" />
+                </h:panelGrid>
+                <h:commandLink action="#{bayesianNetworkController.update}" value="#{bundle.EditBayesianNetworkSaveLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="View" value="#{bundle.EditBayesianNetworkViewLink}" immediate="true"/>
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.prepareList}" value="#{bundle.EditBayesianNetworkShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.EditBayesianNetworkIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/bayesianNetwork/List.xhtml b/web/bn/bayesianNetwork/List.xhtml
new file mode 100644 (file)
index 0000000..8d00def
--- /dev/null
@@ -0,0 +1,56 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ListBayesianNetworkTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:form styleClass="jsfcrud_list_form">
+                <h:panelGroup id="messagePanel" layout="block">
+                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+                </h:panelGroup>
+                <h:outputText escape="false" value="#{bundle.ListBayesianNetworkEmpty}" rendered="#{bayesianNetworkController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{bayesianNetworkController.items.rowCount > 0}">
+                    <h:outputText value="#{bayesianNetworkController.pagination.pageFirstItem + 1}..#{bayesianNetworkController.pagination.pageLastItem + 1}/#{bayesianNetworkController.pagination.itemsCount}"/>&nbsp;
+                    <h:commandLink action="#{bayesianNetworkController.previous}" value="#{bundle.Previous} #{bayesianNetworkController.pagination.pageSize}" rendered="#{bayesianNetworkController.pagination.hasPreviousPage}"/>&nbsp;
+                    <h:commandLink action="#{bayesianNetworkController.next}" value="#{bundle.Next} #{bayesianNetworkController.pagination.pageSize}" rendered="#{bayesianNetworkController.pagination.hasNextPage}"/>&nbsp;
+                    <h:dataTable value="#{bayesianNetworkController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListBayesianNetworkTitle_id}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.id}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListBayesianNetworkTitle_name}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.name}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="&nbsp;"/>
+                            </f:facet>
+                            <h:commandLink action="#{bayesianNetworkController.prepareView}" value="#{bundle.ListBayesianNetworkViewLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{bayesianNetworkController.prepareEdit}" value="#{bundle.ListBayesianNetworkEditLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{bayesianNetworkController.destroy}" value="#{bundle.ListBayesianNetworkDestroyLink}"/>
+                        </h:column>
+                    </h:dataTable>
+                </h:panelGroup>
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.prepareCreate}" value="#{bundle.ListBayesianNetworkCreateLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ListBayesianNetworkIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/bayesianNetwork/View.xhtml b/web/bn/bayesianNetwork/View.xhtml
new file mode 100644 (file)
index 0000000..390f2b6
--- /dev/null
@@ -0,0 +1,40 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ViewBayesianNetworkTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputText value="#{bundle.ViewBayesianNetworkLabel_id}"/>
+                    <h:outputText value="#{bayesianNetworkController.selected.id}" title="#{bundle.ViewBayesianNetworkTitle_id}"/>
+                    <h:outputText value="#{bundle.ViewBayesianNetworkLabel_name}"/>
+                    <h:outputText value="#{bayesianNetworkController.selected.name}" title="#{bundle.ViewBayesianNetworkTitle_name}"/>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.destroyAndView}" value="#{bundle.ViewBayesianNetworkDestroyLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="Edit" value="#{bundle.ViewBayesianNetworkEditLink}"/>
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.prepareCreate}" value="#{bundle.ViewBayesianNetworkCreateLink}" />
+                <br />
+                <h:commandLink action="#{bayesianNetworkController.prepareList}" value="#{bundle.ViewBayesianNetworkShowAllLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ViewBayesianNetworkIndexLink}" action="/index" immediate="true" />
+
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/node/Create.xhtml b/web/bn/node/Create.xhtml
new file mode 100644 (file)
index 0000000..9c8ad32
--- /dev/null
@@ -0,0 +1,45 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.CreateNodeTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{nodeController.selected.id}" title="#{bundle.CreateNodeTitle_id}" />
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_name}" for="name" />
+                    <h:inputText id="name" value="#{nodeController.selected.name}" title="#{bundle.CreateNodeTitle_name}" />
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_nodeType}" for="nodeType" />
+                    <h:inputText id="nodeType" value="#{nodeController.selected.nodeType}" title="#{bundle.CreateNodeTitle_nodeType}" />
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_time}" for="time" />
+                    <h:inputText id="time" value="#{nodeController.selected.time}" title="#{bundle.CreateNodeTitle_time}" />
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_cost}" for="cost" />
+                    <h:inputText id="cost" value="#{nodeController.selected.cost}" title="#{bundle.CreateNodeTitle_cost}" />
+                    <h:outputLabel value="#{bundle.CreateNodeLabel_bayesianNetwork}" for="bayesianNetwork" />
+                    <h:selectOneMenu id="bayesianNetwork" value="#{nodeController.selected.bayesianNetwork}" title="#{bundle.CreateNodeTitle_bayesianNetwork}" >
+                        <f:selectItems value="#{bayesianNetworkController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{nodeController.create}" value="#{bundle.CreateNodeSaveLink}" />
+                <br />
+                <br />
+                <h:commandLink action="#{nodeController.prepareList}" value="#{bundle.CreateNodeShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.CreateNodeIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/node/Edit.xhtml b/web/bn/node/Edit.xhtml
new file mode 100644 (file)
index 0000000..076c337
--- /dev/null
@@ -0,0 +1,46 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.EditNodeTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.EditNodeLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{nodeController.selected.id}" title="#{bundle.EditNodeTitle_id}" />
+                    <h:outputLabel value="#{bundle.EditNodeLabel_name}" for="name" />
+                    <h:inputText id="name" value="#{nodeController.selected.name}" title="#{bundle.EditNodeTitle_name}" />
+                    <h:outputLabel value="#{bundle.EditNodeLabel_nodeType}" for="nodeType" />
+                    <h:inputText id="nodeType" value="#{nodeController.selected.nodeType}" title="#{bundle.EditNodeTitle_nodeType}" />
+                    <h:outputLabel value="#{bundle.EditNodeLabel_time}" for="time" />
+                    <h:inputText id="time" value="#{nodeController.selected.time}" title="#{bundle.EditNodeTitle_time}" />
+                    <h:outputLabel value="#{bundle.EditNodeLabel_cost}" for="cost" />
+                    <h:inputText id="cost" value="#{nodeController.selected.cost}" title="#{bundle.EditNodeTitle_cost}" />
+                    <h:outputLabel value="#{bundle.EditNodeLabel_bayesianNetwork}" for="bayesianNetwork" />
+                    <h:selectOneMenu id="bayesianNetwork" value="#{nodeController.selected.bayesianNetwork}" title="#{bundle.EditNodeTitle_bayesianNetwork}" >
+                        <f:selectItems value="#{bayesianNetworkController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <h:commandLink action="#{nodeController.update}" value="#{bundle.EditNodeSaveLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="View" value="#{bundle.EditNodeViewLink}" immediate="true"/>
+                <br />
+                <h:commandLink action="#{nodeController.prepareList}" value="#{bundle.EditNodeShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.EditNodeIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/node/List.xhtml b/web/bn/node/List.xhtml
new file mode 100644 (file)
index 0000000..65b92bf
--- /dev/null
@@ -0,0 +1,80 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ListNodeTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:form styleClass="jsfcrud_list_form">
+                <h:panelGroup id="messagePanel" layout="block">
+                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+                </h:panelGroup>
+                <h:outputText escape="false" value="#{bundle.ListNodeEmpty}" rendered="#{nodeController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{nodeController.items.rowCount > 0}">
+                    <h:outputText value="#{nodeController.pagination.pageFirstItem + 1}..#{nodeController.pagination.pageLastItem + 1}/#{nodeController.pagination.itemsCount}"/>&nbsp;
+                    <h:commandLink action="#{nodeController.previous}" value="#{bundle.Previous} #{nodeController.pagination.pageSize}" rendered="#{nodeController.pagination.hasPreviousPage}"/>&nbsp;
+                    <h:commandLink action="#{nodeController.next}" value="#{bundle.Next} #{nodeController.pagination.pageSize}" rendered="#{nodeController.pagination.hasNextPage}"/>&nbsp;
+                    <h:dataTable value="#{nodeController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_id}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.id}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_name}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.name}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_nodeType}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.nodeType}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_time}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.time}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_cost}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.cost}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListNodeTitle_bayesianNetwork}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.bayesianNetwork}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="&nbsp;"/>
+                            </f:facet>
+                            <h:commandLink action="#{nodeController.prepareView}" value="#{bundle.ListNodeViewLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{nodeController.prepareEdit}" value="#{bundle.ListNodeEditLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{nodeController.destroy}" value="#{bundle.ListNodeDestroyLink}"/>
+                        </h:column>
+                    </h:dataTable>
+                </h:panelGroup>
+                <br />
+                <h:commandLink action="#{nodeController.prepareCreate}" value="#{bundle.ListNodeCreateLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ListNodeIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/node/View.xhtml b/web/bn/node/View.xhtml
new file mode 100644 (file)
index 0000000..883acb5
--- /dev/null
@@ -0,0 +1,48 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ViewNodeTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputText value="#{bundle.ViewNodeLabel_id}"/>
+                    <h:outputText value="#{nodeController.selected.id}" title="#{bundle.ViewNodeTitle_id}"/>
+                    <h:outputText value="#{bundle.ViewNodeLabel_name}"/>
+                    <h:outputText value="#{nodeController.selected.name}" title="#{bundle.ViewNodeTitle_name}"/>
+                    <h:outputText value="#{bundle.ViewNodeLabel_nodeType}"/>
+                    <h:outputText value="#{nodeController.selected.nodeType}" title="#{bundle.ViewNodeTitle_nodeType}"/>
+                    <h:outputText value="#{bundle.ViewNodeLabel_time}"/>
+                    <h:outputText value="#{nodeController.selected.time}" title="#{bundle.ViewNodeTitle_time}"/>
+                    <h:outputText value="#{bundle.ViewNodeLabel_cost}"/>
+                    <h:outputText value="#{nodeController.selected.cost}" title="#{bundle.ViewNodeTitle_cost}"/>
+                    <h:outputText value="#{bundle.ViewNodeLabel_bayesianNetwork}"/>
+                    <h:outputText value="#{nodeController.selected.bayesianNetwork}" title="#{bundle.ViewNodeTitle_bayesianNetwork}"/>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{nodeController.destroyAndView}" value="#{bundle.ViewNodeDestroyLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="Edit" value="#{bundle.ViewNodeEditLink}"/>
+                <br />
+                <h:commandLink action="#{nodeController.prepareCreate}" value="#{bundle.ViewNodeCreateLink}" />
+                <br />
+                <h:commandLink action="#{nodeController.prepareList}" value="#{bundle.ViewNodeShowAllLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ViewNodeIndexLink}" action="/index" immediate="true" />
+
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/question/Create.xhtml b/web/bn/question/Create.xhtml
new file mode 100644 (file)
index 0000000..cdcbc6e
--- /dev/null
@@ -0,0 +1,39 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.CreateQuestionTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.CreateQuestionLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{questionController.selected.id}" title="#{bundle.CreateQuestionTitle_id}" />
+                    <h:outputLabel value="#{bundle.CreateQuestionLabel_text}" for="text" />
+                    <h:inputText id="text" value="#{questionController.selected.text}" title="#{bundle.CreateQuestionTitle_text}" />
+                    <h:outputLabel value="#{bundle.CreateQuestionLabel_node}" for="node" />
+                    <h:selectOneMenu id="node" value="#{questionController.selected.node}" title="#{bundle.CreateQuestionTitle_node}" >
+                        <f:selectItems value="#{nodeController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{questionController.create}" value="#{bundle.CreateQuestionSaveLink}" />
+                <br />
+                <br />
+                <h:commandLink action="#{questionController.prepareList}" value="#{bundle.CreateQuestionShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.CreateQuestionIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/question/Edit.xhtml b/web/bn/question/Edit.xhtml
new file mode 100644 (file)
index 0000000..d2c8f73
--- /dev/null
@@ -0,0 +1,40 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.EditQuestionTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputLabel value="#{bundle.EditQuestionLabel_id}" for="id" />
+                    <h:inputText id="id" value="#{questionController.selected.id}" title="#{bundle.EditQuestionTitle_id}" />
+                    <h:outputLabel value="#{bundle.EditQuestionLabel_text}" for="text" />
+                    <h:inputText id="text" value="#{questionController.selected.text}" title="#{bundle.EditQuestionTitle_text}" />
+                    <h:outputLabel value="#{bundle.EditQuestionLabel_node}" for="node" />
+                    <h:selectOneMenu id="node" value="#{questionController.selected.node}" title="#{bundle.EditQuestionTitle_node}" >
+                        <f:selectItems value="#{nodeController.itemsAvailableSelectOne}"/>
+                    </h:selectOneMenu>
+                </h:panelGrid>
+                <h:commandLink action="#{questionController.update}" value="#{bundle.EditQuestionSaveLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="View" value="#{bundle.EditQuestionViewLink}" immediate="true"/>
+                <br />
+                <h:commandLink action="#{questionController.prepareList}" value="#{bundle.EditQuestionShowAllLink}" immediate="true"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.EditQuestionIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/question/List.xhtml b/web/bn/question/List.xhtml
new file mode 100644 (file)
index 0000000..e4e827c
--- /dev/null
@@ -0,0 +1,62 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ListQuestionTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:form styleClass="jsfcrud_list_form">
+                <h:panelGroup id="messagePanel" layout="block">
+                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+                </h:panelGroup>
+                <h:outputText escape="false" value="#{bundle.ListQuestionEmpty}" rendered="#{questionController.items.rowCount == 0}"/>
+                <h:panelGroup rendered="#{questionController.items.rowCount > 0}">
+                    <h:outputText value="#{questionController.pagination.pageFirstItem + 1}..#{questionController.pagination.pageLastItem + 1}/#{questionController.pagination.itemsCount}"/>&nbsp;
+                    <h:commandLink action="#{questionController.previous}" value="#{bundle.Previous} #{questionController.pagination.pageSize}" rendered="#{questionController.pagination.hasPreviousPage}"/>&nbsp;
+                    <h:commandLink action="#{questionController.next}" value="#{bundle.Next} #{questionController.pagination.pageSize}" rendered="#{questionController.pagination.hasNextPage}"/>&nbsp;
+                    <h:dataTable value="#{questionController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListQuestionTitle_id}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.id}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListQuestionTitle_text}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.text}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="#{bundle.ListQuestionTitle_node}"/>
+                            </f:facet>
+                            <h:outputText value="#{item.node}"/>
+                        </h:column>
+                        <h:column>
+                            <f:facet name="header">
+                                <h:outputText value="&nbsp;"/>
+                            </f:facet>
+                            <h:commandLink action="#{questionController.prepareView}" value="#{bundle.ListQuestionViewLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{questionController.prepareEdit}" value="#{bundle.ListQuestionEditLink}"/>
+                            <h:outputText value=" "/>
+                            <h:commandLink action="#{questionController.destroy}" value="#{bundle.ListQuestionDestroyLink}"/>
+                        </h:column>
+                    </h:dataTable>
+                </h:panelGroup>
+                <br />
+                <h:commandLink action="#{questionController.prepareCreate}" value="#{bundle.ListQuestionCreateLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ListQuestionIndexLink}" action="/index" immediate="true" />
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
diff --git a/web/bn/question/View.xhtml b/web/bn/question/View.xhtml
new file mode 100644 (file)
index 0000000..a116cdf
--- /dev/null
@@ -0,0 +1,42 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html"
+      xmlns:f="http://java.sun.com/jsf/core">
+
+    <ui:composition template="/template.xhtml">
+        <ui:define name="title">
+            <h:outputText value="#{bundle.ViewQuestionTitle}"></h:outputText>
+        </ui:define>
+        <ui:define name="body">
+            <h:panelGroup id="messagePanel" layout="block">
+                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
+            </h:panelGroup>
+            <h:form>
+                <h:panelGrid columns="2">
+                    <h:outputText value="#{bundle.ViewQuestionLabel_id}"/>
+                    <h:outputText value="#{questionController.selected.id}" title="#{bundle.ViewQuestionTitle_id}"/>
+                    <h:outputText value="#{bundle.ViewQuestionLabel_text}"/>
+                    <h:outputText value="#{questionController.selected.text}" title="#{bundle.ViewQuestionTitle_text}"/>
+                    <h:outputText value="#{bundle.ViewQuestionLabel_node}"/>
+                    <h:outputText value="#{questionController.selected.node}" title="#{bundle.ViewQuestionTitle_node}"/>
+                </h:panelGrid>
+                <br />
+                <h:commandLink action="#{questionController.destroyAndView}" value="#{bundle.ViewQuestionDestroyLink}"/>
+                <br />
+                <br />
+                <h:commandLink action="Edit" value="#{bundle.ViewQuestionEditLink}"/>
+                <br />
+                <h:commandLink action="#{questionController.prepareCreate}" value="#{bundle.ViewQuestionCreateLink}" />
+                <br />
+                <h:commandLink action="#{questionController.prepareList}" value="#{bundle.ViewQuestionShowAllLink}"/>
+                <br />
+                <br />
+                <h:commandLink value="#{bundle.ViewQuestionIndexLink}" action="/index" immediate="true" />
+
+            </h:form>
+        </ui:define>
+    </ui:composition>
+
+</html>
index 0acf6cf..9a5d5f9 100755 (executable)
@@ -5,14 +5,25 @@
       xmlns:h="http://java.sun.com/jsf/html">
     <h:head>
         <title>Facelet Title</title>
+        <h:outputStylesheet name="css/jsfcrud.css"/>
     </h:head>
-    <h:body>
+    <h:body>       
         <h:form>
-            <p:commandButton value="Hello from PrimeFaces" onclick="dlg1.show();" type="button" />
-            <p:dialog header="PrimeFaces Dialog" widgetVar="dlg1" width="500">
-                For more information visit <a href="http://primefaces.org">http://primefaces.org</a>.
-            </p:dialog>
+            <h:commandLink action="/bn/answer/List" value="Show All Answer Items"/>
+        </h:form>
+        <h:form>
+            <h:commandLink action="/bn/bayesianNetwork/List" value="Show All BayesianNetwork Items"/>
+        </h:form>
+        <h:form>
+            <h:commandLink action="/bn/node/List" value="Show All Node Items"/>
+        </h:form>
+        <h:form>
+            <h:commandLink action="/bn/question/List" value="Show All Question Items"/>
         </h:form>
     </h:body>
+
+
+
+
 </html>
 
diff --git a/web/resources/css/jsfcrud.css b/web/resources/css/jsfcrud.css
new file mode 100644 (file)
index 0000000..4cf3660
--- /dev/null
@@ -0,0 +1,87 @@
+root { 
+    display: block;
+}
+
+body {
+    font-family: Arial, Helvetica, sans-serif;
+    color: #000000;
+    background-color: #ffffff;
+    font-size: small;
+}
+
+a {
+    color: #000000;
+}
+
+table {
+    empty-cells: show;
+}
+
+form.jsfcrud_list_form th, td th {
+    font-size: x-small;
+    color: #000000;
+    border-top-style: solid;
+    border-bottom-style: solid;
+    border-left-style: solid;
+    border-right-style: solid;
+    border-top-width: 1px;
+    border-bottom-width: 1px;
+    border-left-width: 1px;
+    border-right-width: 1px;
+    border-top-color: #404040;
+    border-bottom-color: #404040;
+    border-left-color: #404040;
+    border-right-color: #404040;
+    letter-spacing: 3px;
+    text-align: left;
+    padding-top: 6px;
+    padding-bottom: 6px;
+    padding-left: 6px;
+    padding-right: 6px;
+    background-color: #909090;
+}
+
+td {
+    vertical-align: top;
+    padding-bottom: 8px;
+    font-size: small;
+}
+
+form.jsfcrud_list_form td, td td {
+    border-top-style: solid;
+    border-bottom-style: solid;
+    border-left-style: solid;
+    border-right-style: solid;
+    border-top-width: 1px;
+    border-bottom-width: 1px;
+    border-left-width: 1px;
+    border-right-width: 1px;
+    border-top-color: #404040;
+    border-bottom-color: #404040;
+    border-left-color: #404040;
+    border-right-color: #404040;
+    vertical-align: baseline;
+    padding-bottom: 0px;
+}
+
+tr.jsfcrud_odd_row {
+    background-color: #fefeff;
+    color: #303030;
+}
+
+
+tr.jsfcrud_even_row {
+    background-color: #eff5fa;
+    color: #303030;
+}
+
+#busyImage {
+    position: absolute;
+    left: 50%;
+    top: 50%;
+}
+
+.removeImage {
+       
+background-image: url(‘/img/bayesianNetwork/remove.png’) !important;
+}
diff --git a/web/template.xhtml b/web/template.xhtml
new file mode 100644 (file)
index 0000000..f83ce2e
--- /dev/null
@@ -0,0 +1,21 @@
+<?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:ui="http://java.sun.com/jsf/facelets"
+      xmlns:h="http://java.sun.com/jsf/html">
+    <h:head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+        <title><ui:insert name="title">Default Title</ui:insert></title>
+<h:outputStylesheet name="css/jsfcrud.css"/>
+    </h:head>
+
+    <h:body>
+        <h1>
+            <ui:insert name="title">Default Title</ui:insert>
+        </h1>
+        <p>
+            <ui:insert name="body">Default Body</ui:insert>
+        </p>
+    </h:body>
+
+</html>