diff --git a/trunk/AnaliseAcidentesTrabalho/.classpath b/trunk/AnaliseAcidentesTrabalho/.classpath
index d118c4fd..1e95162f 100644
--- a/trunk/AnaliseAcidentesTrabalho/.classpath
+++ b/trunk/AnaliseAcidentesTrabalho/.classpath
@@ -1,77 +1,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
diff --git a/trunk/AnaliseAcidentesTrabalho/.settings/org.eclipse.wst.common.project.facet.core.xml b/trunk/AnaliseAcidentesTrabalho/.settings/org.eclipse.wst.common.project.facet.core.xml
index ba69a57e..8d1fe9cf 100644
--- a/trunk/AnaliseAcidentesTrabalho/.settings/org.eclipse.wst.common.project.facet.core.xml
+++ b/trunk/AnaliseAcidentesTrabalho/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -1,6 +1,6 @@
-
+
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-common.xml
new file mode 100644
index 00000000..ab030ae8
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-common.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-obfuscate-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-obfuscate-common.xml
new file mode 100644
index 00000000..1c844aae
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-build-obfuscate-common.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -printseeds
+ -verbose
+ -dontskipnonpubliclibraryclasses
+
+ -keepclasseswithmembers public class * {
+ public static void main(java.lang.String[]);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-compile-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-compile-common.xml
new file mode 100644
index 00000000..747dfbcd
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-compile-common.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-deploy-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-deploy-common.xml
new file mode 100644
index 00000000..4f583da5
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-deploy-common.xml
@@ -0,0 +1,950 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Deploy cancelled
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-load-properties.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-load-properties.xml
new file mode 100644
index 00000000..dc69ec77
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-load-properties.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-multiple-client-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-multiple-client-common.xml
new file mode 100644
index 00000000..e06185d8
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-app-multiple-client-common.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-build-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-build-common.xml
new file mode 100644
index 00000000..4234cb1b
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-build-common.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-compile-common.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-compile-common.xml
new file mode 100644
index 00000000..901af496
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-compile-common.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-load-properties.xml b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-load-properties.xml
new file mode 100644
index 00000000..7c1a1f61
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/common/evo-web-load-properties.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-java5.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-java5.xml
new file mode 100644
index 00000000..df781c23
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-java5.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-jdo.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-jdo.xml
new file mode 100644
index 00000000..d9d46f46
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-jdo.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate-jdo.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate-jdo.xml
new file mode 100644
index 00000000..3b1f2ba1
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate-jdo.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate.xml
new file mode 100644
index 00000000..168357f6
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build-obfuscate.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build.xml
new file mode 100644
index 00000000..099651cb
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-build.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-build.xml
new file mode 100644
index 00000000..e50cb65f
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-build.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-obfuscated-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-obfuscated-build.xml
new file mode 100644
index 00000000..aaf21aed
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-multiple-client-obfuscated-build.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-app-ws-client-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-ws-client-build.xml
new file mode 100644
index 00000000..9c9e3e96
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-app-ws-client-build.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-gwt-library-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-gwt-library-build.xml
new file mode 100644
index 00000000..925b756e
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-gwt-library-build.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-library-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-library-build.xml
new file mode 100644
index 00000000..545cbb40
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-library-build.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-tool-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-tool-build.xml
new file mode 100644
index 00000000..043576b7
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-tool-build.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evo-web-build.xml b/trunk/AnaliseAcidentesTrabalho/ant/evo-web-build.xml
new file mode 100644
index 00000000..10e8c1e6
--- /dev/null
+++ b/trunk/AnaliseAcidentesTrabalho/ant/evo-web-build.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/trunk/AnaliseAcidentesTrabalho/ant/evolute.keystore b/trunk/AnaliseAcidentesTrabalho/ant/evolute.keystore
new file mode 100644
index 00000000..63ce35f1
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/ant/evolute.keystore differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-classloadertask.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-classloadertask.jar
new file mode 100644
index 00000000..d2f58d9f
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-classloadertask.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-contrib-1.0b3.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-contrib-1.0b3.jar
new file mode 100644
index 00000000..42f3178e
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-contrib-1.0b3.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-jsch.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-jsch.jar
new file mode 100644
index 00000000..59f5fd1e
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-jsch.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-launcher.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-launcher.jar
new file mode 100644
index 00000000..939abb57
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant-launcher.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/ant.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant.jar
new file mode 100644
index 00000000..7f5be4a4
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/ant.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/el-api.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/el-api.jar
new file mode 100644
index 00000000..1635111e
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/el-api.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/evo-ant.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/evo-ant.jar
new file mode 100644
index 00000000..ebefc423
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/evo-ant.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/evoservices.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/evoservices.jar
new file mode 100644
index 00000000..3697e897
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/evoservices.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/jaxen-1.1.1.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/jaxen-1.1.1.jar
new file mode 100644
index 00000000..b6336311
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/jaxen-1.1.1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/jdom.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/jdom.jar
new file mode 100644
index 00000000..288e64cb
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/jdom.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/jsch-0.1.41.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/jsch-0.1.41.jar
new file mode 100644
index 00000000..eb1e7647
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/jsch-0.1.41.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/jsp-api.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/jsp-api.jar
new file mode 100644
index 00000000..d416e2b4
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/jsp-api.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/proguard.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/proguard.jar
new file mode 100644
index 00000000..3a9aebcf
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/proguard.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/servlet-api.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/servlet-api.jar
new file mode 100644
index 00000000..216c68c3
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/servlet-api.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/svnClientAdapter.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnClientAdapter.jar
new file mode 100644
index 00000000..ed37ba46
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnClientAdapter.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/svnant.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnant.jar
new file mode 100644
index 00000000..af52be0d
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnant.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/svnjavahl.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnjavahl.jar
new file mode 100644
index 00000000..71873057
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnjavahl.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/svnkit.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnkit.jar
new file mode 100644
index 00000000..2f53f492
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/svnkit.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/truelicense.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/truelicense.jar
new file mode 100644
index 00000000..8c56bd12
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/truelicense.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib.tools/truexml.jar b/trunk/AnaliseAcidentesTrabalho/lib.tools/truexml.jar
new file mode 100644
index 00000000..6ce23e31
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib.tools/truexml.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar b/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar
index d68c41b6..ec566036 100644
Binary files a/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar and b/trunk/AnaliseAcidentesTrabalho/lib/evolute.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib/postgresql-9.3-1100-jdbc4.jar b/trunk/AnaliseAcidentesTrabalho/lib/postgresql-9.3-1100-jdbc4.jar
new file mode 100644
index 00000000..f00ee16a
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/lib/postgresql-9.3-1100-jdbc4.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/lib/shst.jar b/trunk/AnaliseAcidentesTrabalho/lib/shst.jar
index 5905b22f..21931d58 100644
Binary files a/trunk/AnaliseAcidentesTrabalho/lib/shst.jar and b/trunk/AnaliseAcidentesTrabalho/lib/shst.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/src/analiseacidentestrabalho/GestaoUtilizadores.java b/trunk/AnaliseAcidentesTrabalho/src/analiseacidentestrabalho/GestaoUtilizadores.java
index 5af0c4d9..b6473dd7 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/analiseacidentestrabalho/GestaoUtilizadores.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/analiseacidentestrabalho/GestaoUtilizadores.java
@@ -881,7 +881,8 @@ public class GestaoUtilizadores extends AbstractPageBean
public void prerender()
{
Utilizador u = getSessionBean1().getCurrentUser();
- FacesContext fc = getFacesContext().getCurrentInstance();
+ getFacesContext();
+ FacesContext fc = FacesContext.getCurrentInstance();
if(u.getTipo().intValue() != Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP && u.getTipo().intValue() != Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH)
{
try
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Acidentado.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Acidentado.java
index eda87b0b..e8b50b8c 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Acidentado.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Acidentado.java
@@ -9,7 +9,10 @@
package beans;
+import db.data.siprp.outer.AcidentadosData;
+
import java.io.Serializable;
+import java.sql.Date;
/**
*
@@ -33,12 +36,155 @@ public class Acidentado implements Serializable
private String nome_superior_hierarquico;
private String email_superior_hierarquico;
private String estabelecimento_origem;
- private java.sql.Date data_email_superior_hierarquico;
+ private java.sql.Date data_email_superior_hierarquico;
+
/** Creates a new instance of Acidentado */
public Acidentado() {
}
- public Integer getId() {
+ public Acidentado( AcidentadosData acidentadosData )
+ {
+ this
+ .withBilhete_identidade( acidentadosData.getBilhete_identidade() )
+ .withCod_postal( acidentadosData.getCod_postal() )
+ .withContacto_telefonico( acidentadosData.getContacto_telefonico() )
+ .withEmail_superior_hierarquico( acidentadosData.getEmail_superior_hierarquico() )
+ .withEstabelecimento_origem( acidentadosData.getEstabelecimento_origem() )
+ .withFuncao( acidentadosData.getFuncao() )
+ .withId( acidentadosData.getId() )
+ .withLocalidade( acidentadosData.getLocalidade() )
+ .withMorada( acidentadosData.getMorada() )
+ .withNome( acidentadosData.getNome() )
+ .withNome_superior_hierarquico( acidentadosData.getNome_superior_hierarquico() )
+ .withNumero_mecanografico( acidentadosData.getNumero_mecanografico() )
+ .withTrabalhador_id( acidentadosData.getTrabalhador_id() )
+ .withTurno( acidentadosData.getTurno() );
+
+ Date date;
+ if( acidentadosData.getData_admissao() != null )
+ {
+ date = new Date( acidentadosData.getData_admissao().getTime() );
+ this.setData_admissao( date );
+ }
+
+ if( acidentadosData.getData_email_superior_hierarquico() != null )
+ {
+ date = new Date( acidentadosData.getData_email_superior_hierarquico().getTime() );
+ this.setData_email_superior_hierarquico( date );
+ }
+
+ if( acidentadosData.getData_nascimento() != null )
+ {
+ date = new Date( acidentadosData.getData_nascimento().getTime() );
+ this.setData_nascimento( date );
+ }
+
+ }
+
+ public Acidentado withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Acidentado withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Acidentado withData_nascimento( final java.sql.Date data_nascimento )
+ {
+ this.data_nascimento = data_nascimento;
+ return this;
+ }
+
+ public Acidentado withBilhete_identidade( final String bilhete_identidade )
+ {
+ this.bilhete_identidade = bilhete_identidade;
+ return this;
+ }
+
+ public Acidentado withMorada( final String morada )
+ {
+ this.morada = morada;
+ return this;
+ }
+
+ public Acidentado withCod_postal( final String cod_postal )
+ {
+ this.cod_postal = cod_postal;
+ return this;
+ }
+
+ public Acidentado withLocalidade( final String localidade )
+ {
+ this.localidade = localidade;
+ return this;
+ }
+
+ public Acidentado withContacto_telefonico( final String contacto_telefonico )
+ {
+ this.contacto_telefonico = contacto_telefonico;
+ return this;
+ }
+
+ public Acidentado withData_admissao( final java.sql.Date data_admissao )
+ {
+ this.data_admissao = data_admissao;
+ return this;
+ }
+
+ public Acidentado withFuncao( final String funcao )
+ {
+ this.funcao = funcao;
+ return this;
+ }
+
+ public Acidentado withTurno( final String turno )
+ {
+ this.turno = turno;
+ return this;
+ }
+
+ public Acidentado withTrabalhador_id( final Integer trabalhador_id )
+ {
+ this.trabalhador_id = trabalhador_id;
+ return this;
+ }
+
+ public Acidentado withNumero_mecanografico( final String numero_mecanografico )
+ {
+ this.numero_mecanografico = numero_mecanografico;
+ return this;
+ }
+
+ public Acidentado withNome_superior_hierarquico( final String nome_superior_hierarquico )
+ {
+ this.nome_superior_hierarquico = nome_superior_hierarquico;
+ return this;
+ }
+
+ public Acidentado withEmail_superior_hierarquico( final String email_superior_hierarquico )
+ {
+ this.email_superior_hierarquico = email_superior_hierarquico;
+ return this;
+ }
+
+ public Acidentado withEstabelecimento_origem( final String estabelecimento_origem )
+ {
+ this.estabelecimento_origem = estabelecimento_origem;
+ return this;
+ }
+
+ public Acidentado withData_email_superior_hierarquico( final java.sql.Date data_email_superior_hierarquico )
+ {
+ this.data_email_superior_hierarquico = data_email_superior_hierarquico;
+ return this;
+ }
+
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/AnaliseAcidente.java b/trunk/AnaliseAcidentesTrabalho/src/beans/AnaliseAcidente.java
index 858b065a..5df9a17e 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/AnaliseAcidente.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/AnaliseAcidente.java
@@ -148,7 +148,7 @@ public class AnaliseAcidente implements Serializable
private String comentario_desactivacao;
private Boolean participado;
- private String participado_str;
+ //private String participado_str;
private String nomeResponsavelParticipacao;
private java.util.Date dataParticipacao;
@@ -157,7 +157,705 @@ public class AnaliseAcidente implements Serializable
public AnaliseAcidente() {
}
- public Integer getId() {
+ //fluent interface
+
+ public static AnaliseAcidente build( )
+ {
+ return new AnaliseAcidente( );
+ }
+
+ public AnaliseAcidente end( )
+ {
+ return this;
+ }
+
+ public AnaliseAcidente withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public AnaliseAcidente withNr( final Integer nr )
+ {
+ this.nr = nr;
+ return this;
+ }
+
+ public AnaliseAcidente withAnalise_nr( final String analise_nr )
+ {
+ this.analise_nr = analise_nr;
+ return this;
+ }
+
+ public AnaliseAcidente withData_acidente( final Date data_acidente )
+ {
+ this.data_acidente = data_acidente;
+ return this;
+ }
+
+ public AnaliseAcidente withAcidentado_id( final Integer acidentado_id )
+ {
+ this.acidentado_id = acidentado_id;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_acidentado( final String nome_acidentado )
+ {
+ this.nome_acidentado = nome_acidentado;
+ return this;
+ }
+
+ public AnaliseAcidente withNumero_mecanografico( final String numero_mecanografico )
+ {
+ this.numero_mecanografico = numero_mecanografico;
+ return this;
+ }
+
+ public AnaliseAcidente withEmpresa_id( final Integer empresa_id )
+ {
+ this.empresa_id = empresa_id;
+ return this;
+ }
+
+ public AnaliseAcidente withEstabelecimento_id( final Integer estabelecimento_id )
+ {
+ this.estabelecimento_id = estabelecimento_id;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_estabelecimento( final String nome_estabelecimento )
+ {
+ this.nome_estabelecimento = nome_estabelecimento;
+ return this;
+ }
+
+ public AnaliseAcidente withEstado( final Integer estado )
+ {
+ this.estado = estado;
+ return this;
+ }
+
+ public AnaliseAcidente withEstado_assinatura( final Integer estado_assinatura )
+ {
+ this.estado_assinatura = estado_assinatura;
+ return this;
+ }
+
+ public AnaliseAcidente withFase( final String fase )
+ {
+ this.fase = fase;
+ return this;
+ }
+
+ public AnaliseAcidente withMorada( final String morada )
+ {
+ this.morada = morada;
+ return this;
+ }
+
+ public AnaliseAcidente withTelefone( final String telefone )
+ {
+ this.telefone = telefone;
+ return this;
+ }
+
+ public AnaliseAcidente withHoras_turno( final Integer horas_turno )
+ {
+ this.horas_turno = horas_turno;
+ return this;
+ }
+
+ public AnaliseAcidente withSeccao( final String seccao )
+ {
+ this.seccao = seccao;
+ return this;
+ }
+
+ public AnaliseAcidente withDepartamento_id( final Integer departamento_id )
+ {
+ this.departamento_id = departamento_id;
+ return this;
+ }
+
+ public AnaliseAcidente withSeccao_id( final Integer seccao_id )
+ {
+ this.seccao_id = seccao_id;
+ return this;
+ }
+
+ public AnaliseAcidente withLocal_trabalho( final String local_trabalho )
+ {
+ this.local_trabalho = local_trabalho;
+ return this;
+ }
+
+ public AnaliseAcidente withTarefa( final String tarefa )
+ {
+ this.tarefa = tarefa;
+ return this;
+ }
+
+ public AnaliseAcidente withSubstancias( final String substancias )
+ {
+ this.substancias = substancias;
+ return this;
+ }
+
+ public AnaliseAcidente withCondicoes( final String condicoes )
+ {
+ this.condicoes = condicoes;
+ return this;
+ }
+
+ public AnaliseAcidente withTestemunhas( final String testemunhas )
+ {
+ this.testemunhas = testemunhas;
+ return this;
+ }
+
+ public AnaliseAcidente withCausas( final Integer causas )
+ {
+ this.causas = causas;
+ return this;
+ }
+
+ public AnaliseAcidente withDescricao( final String descricao )
+ {
+ this.descricao = descricao;
+ return this;
+ }
+
+ public AnaliseAcidente withConclusoes( final String conclusoes )
+ {
+ this.conclusoes = conclusoes;
+ return this;
+ }
+
+ public AnaliseAcidente withAccoes( final String accoes )
+ {
+ this.accoes = accoes;
+ return this;
+ }
+
+ public AnaliseAcidente withHora_acidente( final Time hora_acidente )
+ {
+ this.hora_acidente = hora_acidente;
+ return this;
+ }
+
+ public AnaliseAcidente withFormacao_shst( final String formacao_shst )
+ {
+ this.formacao_shst = formacao_shst;
+ return this;
+ }
+
+ public AnaliseAcidente withFormacao_shst_nao_porque( final String formacao_shst_nao_porque )
+ {
+ this.formacao_shst_nao_porque = formacao_shst_nao_porque;
+ return this;
+ }
+
+ public AnaliseAcidente withOutros_acidentes_com_colaborador( final String outros_acidentes_com_colaborador )
+ {
+ this.outros_acidentes_com_colaborador = outros_acidentes_com_colaborador;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_acidentes_com_colaborador( final Integer nr_acidentes_com_colaborador )
+ {
+ this.nr_acidentes_com_colaborador = nr_acidentes_com_colaborador;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_colaborador1( final Integer nr_relatorio_acidente_colaborador1 )
+ {
+ this.nr_relatorio_acidente_colaborador1 = nr_relatorio_acidente_colaborador1;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_colaborador2( final Integer nr_relatorio_acidente_colaborador2 )
+ {
+ this.nr_relatorio_acidente_colaborador2 = nr_relatorio_acidente_colaborador2;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_colaborador3( final Integer nr_relatorio_acidente_colaborador3 )
+ {
+ this.nr_relatorio_acidente_colaborador3 = nr_relatorio_acidente_colaborador3;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_colaborador4( final Integer nr_relatorio_acidente_colaborador4 )
+ {
+ this.nr_relatorio_acidente_colaborador4 = nr_relatorio_acidente_colaborador4;
+ return this;
+ }
+
+ public AnaliseAcidente withAcidentes_outros_colaboradores( final String acidentes_outros_colaboradores )
+ {
+ this.acidentes_outros_colaboradores = acidentes_outros_colaboradores;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_acidentes_outros_colaboradores( final Integer nr_acidentes_outros_colaboradores )
+ {
+ this.nr_acidentes_outros_colaboradores = nr_acidentes_outros_colaboradores;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_outros_colaboradores1( final Integer nr_relatorio_acidente_outros_colaboradores1 )
+ {
+ this.nr_relatorio_acidente_outros_colaboradores1 = nr_relatorio_acidente_outros_colaboradores1;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_outros_colaboradores2( final Integer nr_relatorio_acidente_outros_colaboradores2 )
+ {
+ this.nr_relatorio_acidente_outros_colaboradores2 = nr_relatorio_acidente_outros_colaboradores2;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_outros_colaboradores3( final Integer nr_relatorio_acidente_outros_colaboradores3 )
+ {
+ this.nr_relatorio_acidente_outros_colaboradores3 = nr_relatorio_acidente_outros_colaboradores3;
+ return this;
+ }
+
+ public AnaliseAcidente withNr_relatorio_acidente_outros_colaboradores4( final Integer nr_relatorio_acidente_outros_colaboradores4 )
+ {
+ this.nr_relatorio_acidente_outros_colaboradores4 = nr_relatorio_acidente_outros_colaboradores4;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_cabeca( final String lesao_cabeca )
+ {
+ this.lesao_cabeca = lesao_cabeca;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_pescoco( final String lesao_pescoco )
+ {
+ this.lesao_pescoco = lesao_pescoco;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_tronco( final String lesao_tronco )
+ {
+ this.lesao_tronco = lesao_tronco;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_membro_sup_dir( final String lesao_membro_sup_dir )
+ {
+ this.lesao_membro_sup_dir = lesao_membro_sup_dir;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_membro_sup_esq( final String lesao_membro_sup_esq )
+ {
+ this.lesao_membro_sup_esq = lesao_membro_sup_esq;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_membro_inf_dir( final String lesao_membro_inf_dir )
+ {
+ this.lesao_membro_inf_dir = lesao_membro_inf_dir;
+ return this;
+ }
+
+ public AnaliseAcidente withLesao_membro_inf_esq( final String lesao_membro_inf_esq )
+ {
+ this.lesao_membro_inf_esq = lesao_membro_inf_esq;
+ return this;
+ }
+
+ public AnaliseAcidente withEspecif1( final String especif1 )
+ {
+ this.especif1 = especif1;
+ return this;
+ }
+
+ public AnaliseAcidente withEspecif2( final String especif2 )
+ {
+ this.especif2 = especif2;
+ return this;
+ }
+
+ public AnaliseAcidente withEspecif3( final String especif3 )
+ {
+ this.especif3 = especif3;
+ return this;
+ }
+
+ public AnaliseAcidente withEspecif4( final String especif4 )
+ {
+ this.especif4 = especif4;
+ return this;
+ }
+
+ public AnaliseAcidente withTipo_lesao( final String tipo_lesao )
+ {
+ this.tipo_lesao = tipo_lesao;
+ return this;
+ }
+
+ public AnaliseAcidente withTipo_incapacidade( final String tipo_incapacidade )
+ {
+ this.tipo_incapacidade = tipo_incapacidade;
+ return this;
+ }
+
+ public AnaliseAcidente withCoef_incapacidade( final Integer coef_incapacidade )
+ {
+ this.coef_incapacidade = coef_incapacidade;
+ return this;
+ }
+
+ public AnaliseAcidente withData_aval_incapacidade( final Date data_aval_incapacidade )
+ {
+ this.data_aval_incapacidade = data_aval_incapacidade;
+ return this;
+ }
+
+ public AnaliseAcidente withData_rev_incapacidade( final Date data_rev_incapacidade )
+ {
+ this.data_rev_incapacidade = data_rev_incapacidade;
+ return this;
+ }
+
+ public AnaliseAcidente withPeriodo_incapacidade_de( final Date periodo_incapacidade_de )
+ {
+ this.periodo_incapacidade_de = periodo_incapacidade_de;
+ return this;
+ }
+
+ public AnaliseAcidente withPeriodo_incapacidade_a( final Date periodo_incapacidade_a )
+ {
+ this.periodo_incapacidade_a = periodo_incapacidade_a;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_flexao( final String img_flexao )
+ {
+ this.img_flexao = img_flexao;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ext1( final String img_ext1 )
+ {
+ this.img_ext1 = img_ext1;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ext2( final String img_ext2 )
+ {
+ this.img_ext2 = img_ext2;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_cab2( final String img_cab2 )
+ {
+ this.img_cab2 = img_cab2;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_cab3( final String img_cab3 )
+ {
+ this.img_cab3 = img_cab3;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma2( final String img_ma2 )
+ {
+ this.img_ma2 = img_ma2;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma3( final String img_ma3 )
+ {
+ this.img_ma3 = img_ma3;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma5( final String img_ma5 )
+ {
+ this.img_ma5 = img_ma5;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma6( final String img_ma6 )
+ {
+ this.img_ma6 = img_ma6;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma8( final String img_ma8 )
+ {
+ this.img_ma8 = img_ma8;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma10( final String img_ma10 )
+ {
+ this.img_ma10 = img_ma10;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_rot1( final String img_rot1 )
+ {
+ this.img_rot1 = img_rot1;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_rot2( final String img_rot2 )
+ {
+ this.img_rot2 = img_rot2;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_cab1( final String img_cab1 )
+ {
+ this.img_cab1 = img_cab1;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_cab4( final String img_cab4 )
+ {
+ this.img_cab4 = img_cab4;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma1( final String img_ma1 )
+ {
+ this.img_ma1 = img_ma1;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma4( final String img_ma4 )
+ {
+ this.img_ma4 = img_ma4;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma7( final String img_ma7 )
+ {
+ this.img_ma7 = img_ma7;
+ return this;
+ }
+
+ public AnaliseAcidente withImg_ma9( final String img_ma9 )
+ {
+ this.img_ma9 = img_ma9;
+ return this;
+ }
+
+ public AnaliseAcidente withRestricao_carga( final Integer restricao_carga )
+ {
+ this.restricao_carga = restricao_carga;
+ return this;
+ }
+
+ public AnaliseAcidente withRestricao_motricidade( final String restricao_motricidade )
+ {
+ this.restricao_motricidade = restricao_motricidade;
+ return this;
+ }
+
+ public AnaliseAcidente withRestricao_conducao( final String restricao_conducao )
+ {
+ this.restricao_conducao = restricao_conducao;
+ return this;
+ }
+
+ public AnaliseAcidente withRestricao_vibracoes( final String restricao_vibracoes )
+ {
+ this.restricao_vibracoes = restricao_vibracoes;
+ return this;
+ }
+
+ public AnaliseAcidente withRestricao_outras( final String restricao_outras )
+ {
+ this.restricao_outras = restricao_outras;
+ return this;
+ }
+
+ public AnaliseAcidente withMed_observ( final String med_observ )
+ {
+ this.med_observ = med_observ;
+ return this;
+ }
+
+ public AnaliseAcidente withMedico_id( final Integer medico_id )
+ {
+ this.medico_id = medico_id;
+ return this;
+ }
+
+ public AnaliseAcidente withTecnico_saude_id( final Integer tecnico_saude_id )
+ {
+ this.tecnico_saude_id = tecnico_saude_id;
+ return this;
+ }
+
+ public AnaliseAcidente withAss_consolidacao( final String ass_consolidacao )
+ {
+ this.ass_consolidacao = ass_consolidacao;
+ return this;
+ }
+
+ public AnaliseAcidente withAss_resp_seg( final String ass_resp_seg )
+ {
+ this.ass_resp_seg = ass_resp_seg;
+ return this;
+ }
+
+ public AnaliseAcidente withAss_resp_rh( final String ass_resp_rh )
+ {
+ this.ass_resp_rh = ass_resp_rh;
+ return this;
+ }
+
+ public AnaliseAcidente withData_consolidacao( final Date data_consolidacao )
+ {
+ this.data_consolidacao = data_consolidacao;
+ return this;
+ }
+
+ public AnaliseAcidente withData_assinatura_seg( final Date data_assinatura_seg )
+ {
+ this.data_assinatura_seg = data_assinatura_seg;
+ return this;
+ }
+
+ public AnaliseAcidente withData_assinatura_rh( final Date data_assinatura_rh )
+ {
+ this.data_assinatura_rh = data_assinatura_rh;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_resp_seg( final String nome_resp_seg )
+ {
+ this.nome_resp_seg = nome_resp_seg;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_resp_rh( final String nome_resp_rh )
+ {
+ this.nome_resp_rh = nome_resp_rh;
+ return this;
+ }
+
+ public AnaliseAcidente withCorrecao( final String correcao )
+ {
+ this.correcao = correcao;
+ return this;
+ }
+
+ public AnaliseAcidente withEstado_antes_correcao( final Integer estado_antes_correcao )
+ {
+ this.estado_antes_correcao = estado_antes_correcao;
+ return this;
+ }
+
+ public AnaliseAcidente withObservacoes_correcao( final String observacoes_correcao )
+ {
+ this.observacoes_correcao = observacoes_correcao;
+ return this;
+ }
+
+ public AnaliseAcidente withAss_superior( final String ass_superior )
+ {
+ this.ass_superior = ass_superior;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_superior( final String nome_superior )
+ {
+ this.nome_superior = nome_superior;
+ return this;
+ }
+
+ public AnaliseAcidente withData_assinatura_superior( final Date data_assinatura_superior )
+ {
+ this.data_assinatura_superior = data_assinatura_superior;
+ return this;
+ }
+
+ public AnaliseAcidente withAveriguador( final String averiguador )
+ {
+ this.averiguador = averiguador;
+ return this;
+ }
+
+ public AnaliseAcidente withAveriguacao_posterior( final String averiguacao_posterior )
+ {
+ this.averiguacao_posterior = averiguacao_posterior;
+ return this;
+ }
+
+ public AnaliseAcidente withAveriguacao_obs( final String averiguacao_obs )
+ {
+ this.averiguacao_obs = averiguacao_obs;
+ return this;
+ }
+
+ public AnaliseAcidente withNome_resp_consolidacao( final String nome_resp_consolidacao )
+ {
+ this.nome_resp_consolidacao = nome_resp_consolidacao;
+ return this;
+ }
+
+ public AnaliseAcidente withData_inicio_processo( final Date data_inicio_processo )
+ {
+ this.data_inicio_processo = data_inicio_processo;
+ return this;
+ }
+
+ public AnaliseAcidente withRh_fase4( final Integer rh_fase4 )
+ {
+ this.rh_fase4 = rh_fase4;
+ return this;
+ }
+
+ public AnaliseAcidente withConcluido_por_desactivacao( final Boolean concluido_por_desactivacao )
+ {
+ this.concluido_por_desactivacao = concluido_por_desactivacao;
+ return this;
+ }
+
+ public AnaliseAcidente withData_desactivacao( final java.util.Date data_desactivacao )
+ {
+ this.data_desactivacao = data_desactivacao;
+ return this;
+ }
+
+ public AnaliseAcidente withComentario_desactivacao( final String comentario_desactivacao )
+ {
+ this.comentario_desactivacao = comentario_desactivacao;
+ return this;
+ }
+
+ public AnaliseAcidente withParticipado( final Boolean participado )
+ {
+ this.participado = participado;
+ return this;
+ }
+
+ public AnaliseAcidente withNomeResponsavelParticipacao( final String nomeResponsavelParticipacao )
+ {
+ this.nomeResponsavelParticipacao = nomeResponsavelParticipacao;
+ return this;
+ }
+
+ public AnaliseAcidente withDataParticipacao( final java.util.Date dataParticipacao )
+ {
+ this.dataParticipacao = dataParticipacao;
+ return this;
+ }
+
+ //Tradicional getters and setters
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Causa.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Causa.java
index a41d0634..91c61224 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Causa.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Causa.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.CausasData;
+
import java.io.Serializable;
/**
@@ -24,7 +26,25 @@ public class Causa implements Serializable
public Causa() {
}
- public Integer getId() {
+ public Causa( CausasData causa )
+ {
+ this.withId( causa.getId() )
+ .withCausa( causa.getCausa() );
+ }
+
+ public Causa withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Causa withCausa( final String causa )
+ {
+ this.causa = causa;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Departamento.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Departamento.java
index 38fd48d1..2a5a5a65 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Departamento.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Departamento.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.DepartamentosData;
+
import java.io.Serializable;
/**
@@ -25,7 +27,32 @@ public class Departamento implements Serializable
public Departamento() {
}
- public Integer getId() {
+ public Departamento( DepartamentosData departamentosData )
+ {
+ this.withId( departamentosData.getId() )
+ .withDescricao( departamentosData.getDescricao() )
+ .withActivo( departamentosData.getActivo() );
+ }
+
+ public Departamento withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Departamento withDescricao( final String descricao )
+ {
+ this.descricao = descricao;
+ return this;
+ }
+
+ public Departamento withActivo( final String activo )
+ {
+ this.activo = activo;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Estabelecimento.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Estabelecimento.java
index 5880a0a2..b3ec9805 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Estabelecimento.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Estabelecimento.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp_local.outer.EstabelecimentosData;
+
import java.io.Serializable;
/**
@@ -25,7 +27,32 @@ public class Estabelecimento implements Serializable
public Estabelecimento() {
}
- public Integer getId() {
+ public Estabelecimento( EstabelecimentosData estabelecimentosData )
+ {
+ this.withId( estabelecimentosData.getId() )
+ .withNome( estabelecimentosData.getNome() )
+ .withNome_plain( estabelecimentosData.getNome_plain() );
+ }
+
+ public Estabelecimento withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Estabelecimento withNome_plain( final String nome_plain )
+ {
+ this.nome_plain = nome_plain;
+ return this;
+ }
+
+ public Estabelecimento withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/EstatisticaProcessoBean.java b/trunk/AnaliseAcidentesTrabalho/src/beans/EstatisticaProcessoBean.java
index 7ebd4a6c..dd6faf41 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/EstatisticaProcessoBean.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/EstatisticaProcessoBean.java
@@ -15,7 +15,7 @@ public class EstatisticaProcessoBean implements Serializable
{
private Integer estado = null;
private String fase = null;
- private Long count = new Long( 0 );
+ private Long count = 0l;
public EstatisticaProcessoBean()
{
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Medico.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Medico.java
index e90952bb..66b3f572 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Medico.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Medico.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp_local.outer.MedicosData;
+
import java.io.Serializable;
/**
@@ -25,7 +27,33 @@ public class Medico implements Serializable
public Medico() {
}
- public Integer getId() {
+ public Medico( MedicosData medicosData )
+ {
+ this.withId( medicosData.getId() )
+ .withNome( medicosData.getNome() )
+ .withNumero_cedula( medicosData.getNumero_cedula() );
+ }
+
+ public Medico withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Medico withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Medico withNumero_cedula( final String numero_cedula )
+ {
+ this.numero_cedula = numero_cedula;
+ return this;
+ }
+
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Medida.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Medida.java
index 35d33989..53090e02 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Medida.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Medida.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.MedidasData;
+
import java.io.Serializable;
/**
@@ -25,7 +27,32 @@ public class Medida implements Serializable
public Medida() {
}
- public Integer getId() {
+ public Medida( MedidasData medidasData )
+ {
+ this.withId( medidasData.getId() )
+ .withAnalise_id( medidasData.getAnalise_id() )
+ .withMedida( medidasData.getMedida() );
+ }
+
+ public Medida withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Medida withAnalise_id( final Integer analise_id )
+ {
+ this.analise_id = analise_id;
+ return this;
+ }
+
+ public Medida withMedida( final String medida )
+ {
+ this.medida = medida;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Recomendacao.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Recomendacao.java
index 78a953f3..50b5668c 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Recomendacao.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Recomendacao.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.RecomendacoesData;
+
import java.io.Serializable;
/**
@@ -25,7 +27,32 @@ public class Recomendacao implements Serializable
public Recomendacao() {
}
- public Integer getId() {
+ public Recomendacao( RecomendacoesData recomendacoesData )
+ {
+ this.withId( recomendacoesData.getId() )
+ .withAnalise_id( recomendacoesData.getAnalise_id() )
+ .withRecomendacao( recomendacoesData.getRecomendacao() );
+ }
+
+ public Recomendacao withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Recomendacao withAnalise_id( final Integer analise_id )
+ {
+ this.analise_id = analise_id;
+ return this;
+ }
+
+ public Recomendacao withRecomendacao( final String recomendacao )
+ {
+ this.recomendacao = recomendacao;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Seccao.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Seccao.java
index 80ebe7a2..0317a8a0 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Seccao.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Seccao.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.SeccoesData;
+
import java.io.Serializable;
/**
@@ -26,7 +28,39 @@ public class Seccao implements Serializable
public Seccao() {
}
- public Integer getId() {
+ public Seccao( SeccoesData seccoesData )
+ {
+ this.withId( seccoesData.getId() )
+ .withActivo( seccoesData.getActivo() )
+ .withDepartamento_id( seccoesData.getDepartamento_id() )
+ .withDescricao( seccoesData.getDescricao() );
+ }
+
+ public Seccao withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Seccao withDescricao( final String descricao )
+ {
+ this.descricao = descricao;
+ return this;
+ }
+
+ public Seccao withDepartamento_id( final Integer departamento_id )
+ {
+ this.departamento_id = departamento_id;
+ return this;
+ }
+
+ public Seccao withActivo( final String activo )
+ {
+ this.activo = activo;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/TecnicoSaude.java b/trunk/AnaliseAcidentesTrabalho/src/beans/TecnicoSaude.java
index bb693609..f5b8874d 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/TecnicoSaude.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/TecnicoSaude.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp_local.outer.MarcacoesTecnicosHstData;
+
import java.io.Serializable;
/**
@@ -24,7 +26,24 @@ public class TecnicoSaude implements Serializable
public TecnicoSaude() {
}
- public Integer getId() {
+ public TecnicoSaude( MarcacoesTecnicosHstData marcacoesTecnicosHstData )
+ {
+ this.withId( marcacoesTecnicosHstData.getId() ).withNome( marcacoesTecnicosHstData.getNome() );
+ }
+
+ public TecnicoSaude withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public TecnicoSaude withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/TipoUtilizador.java b/trunk/AnaliseAcidentesTrabalho/src/beans/TipoUtilizador.java
index 1d752629..fc6fa96c 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/TipoUtilizador.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/TipoUtilizador.java
@@ -9,6 +9,8 @@
package beans;
+import db.data.siprp.outer.TiposUtilizadoresData;
+
import java.io.Serializable;
/**
@@ -27,7 +29,75 @@ public class TipoUtilizador implements Serializable
public TipoUtilizador() {
}
- public Integer getId() {
+ public TipoUtilizador( TiposUtilizadoresData tiposUtilizadoresData )
+ {
+ this.withId( tiposUtilizadoresData.getId() )
+ .withOrdem( tiposUtilizadoresData.getOrdem() )
+ .withActivo( tiposUtilizadoresData.getActivo() )
+ .withDescricao( tiposUtilizadoresData.getDescricao() )
+ .withTipo( tiposUtilizadoresData.getTipo() );
+ }
+
+ public TipoUtilizador( TiposUtilizadoresData tiposUtilizadoresData, Integer permissao )
+ {
+ if( permissao.equals( 7 ) )
+ {
+ if( tiposUtilizadoresData.getTipo().equals( 1 ) ||
+ tiposUtilizadoresData.getTipo().equals( 2 ) ||
+ tiposUtilizadoresData.getTipo().equals( 6 ) )
+ {
+ this.withId( tiposUtilizadoresData.getId() )
+ .withDescricao( tiposUtilizadoresData.getDescricao() )
+ .withOrdem( tiposUtilizadoresData.getOrdem() )
+ .withActivo( tiposUtilizadoresData.getActivo() )
+ .withTipo( tiposUtilizadoresData.getTipo() );
+ }
+ else
+ {
+ this.withTipo( tiposUtilizadoresData.getTipo() );
+ }
+ }
+ else
+ {
+ this.withId( tiposUtilizadoresData.getId() )
+ .withOrdem( tiposUtilizadoresData.getOrdem() )
+ .withActivo( tiposUtilizadoresData.getActivo() )
+ .withDescricao( tiposUtilizadoresData.getDescricao() )
+ .withTipo( tiposUtilizadoresData.getTipo() );
+ }
+ }
+
+ public TipoUtilizador withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public TipoUtilizador withTipo( final Integer tipo )
+ {
+ this.tipo = tipo;
+ return this;
+ }
+
+ public TipoUtilizador withDescricao( final String descricao )
+ {
+ this.descricao = descricao;
+ return this;
+ }
+
+ public TipoUtilizador withActivo( final String activo )
+ {
+ this.activo = activo;
+ return this;
+ }
+
+ public TipoUtilizador withOrdem( final Integer ordem )
+ {
+ this.ordem = ordem;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Trabalhador.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Trabalhador.java
index a48d8287..dc436ea3 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Trabalhador.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Trabalhador.java
@@ -9,7 +9,10 @@
package beans;
+import db.data.siprp_local.outer.TrabalhadoresData;
+
import java.io.Serializable;
+import java.sql.Date;
/**
*
@@ -31,7 +34,73 @@ public class Trabalhador implements Serializable
public Trabalhador() {
}
- public Integer getId() {
+ public Trabalhador( TrabalhadoresData trabalhadoresData )
+ {
+ this
+ .withId( trabalhadoresData.getId() )
+ .withNome( trabalhadoresData.getNome() )
+ .withNumero_mecanografico( trabalhadoresData.getNumero_mecanografico() )
+ .withFuncao( trabalhadoresData.getFuncao_proposta() )
+ .withEstabelecimento_id( trabalhadoresData.getEstabelecimento_id() )
+ .withEstabelecimento( trabalhadoresData.toEstabelecimento_id().getNome() )
+ .withData_admissao( new Date( trabalhadoresData.getData_admissao().getTime() ) )
+ .withData_nascimento( new Date( trabalhadoresData.getData_nascimento().getTime() ) );
+ }
+
+ public static Trabalhador createTrabalhador( )
+ {
+ return new Trabalhador();
+ }
+
+ public Trabalhador withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Trabalhador withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Trabalhador withData_nascimento( final java.sql.Date data_nascimento )
+ {
+ this.data_nascimento = data_nascimento;
+ return this;
+ }
+
+ public Trabalhador withFuncao( final String funcao )
+ {
+ this.funcao = funcao;
+ return this;
+ }
+
+ public Trabalhador withData_admissao( final java.sql.Date data_admissao )
+ {
+ this.data_admissao = data_admissao;
+ return this;
+ }
+
+ public Trabalhador withNumero_mecanografico( final String numero_mecanografico )
+ {
+ this.numero_mecanografico = numero_mecanografico;
+ return this;
+ }
+
+ public Trabalhador withEstabelecimento_id( final Integer estabelecimento_id )
+ {
+ this.estabelecimento_id = estabelecimento_id;
+ return this;
+ }
+
+ public Trabalhador withEstabelecimento( final String estabelecimento )
+ {
+ this.estabelecimento = estabelecimento;
+ return this;
+ }
+
+ public Integer getId() {
return id;
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/beans/Utilizador.java b/trunk/AnaliseAcidentesTrabalho/src/beans/Utilizador.java
index 727b9814..e5763466 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/beans/Utilizador.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/beans/Utilizador.java
@@ -9,6 +9,9 @@
package beans;
+import db.data.siprp.outer.UtilizadoresData;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
import java.io.Serializable;
import java.sql.Date;
@@ -58,7 +61,181 @@ public class Utilizador implements Serializable
public Utilizador() {
}
- public Integer getId() {
+ public Utilizador( UtilizadoresData utilizadoresData )
+ {
+ this.withId( utilizadoresData.getId() )
+ .withLogin( utilizadoresData.getLogin() )
+ .withPassword( utilizadoresData.getPassword() )
+ .withData_password( new Date( utilizadoresData.getData_password().getTime() ) )
+ .withEmail( utilizadoresData.getEmail() )
+ .withEmpresa_id( utilizadoresData.getEmpresa_id() )
+ .withEstabelecimento_id( utilizadoresData.getEstabelecimento_id() )
+ .withAdministrador( utilizadoresData.getAdministrador() )
+ .withTipo( utilizadoresData.getTipo() )
+ .withNumero_cedula( utilizadoresData.getNumero_cedula() )
+ .withCap( utilizadoresData.getCap() )
+ .withNome( utilizadoresData.getNome() )
+ .withMedico_id( utilizadoresData.getMedico_id() )
+ .withFuncionario_hst_id( utilizadoresData.getFuncionario_hst_id() )
+ .withActivo( utilizadoresData.getActivo() )
+ .withResponsavel_loja( utilizadoresData.getResponsavel_loja() )
+ .withGestor_geral( utilizadoresData.getGestor_geral() )
+ .withPrimeiro_login( utilizadoresData.getPrimeiro_login() )
+ .withApagado( utilizadoresData.getApagado() );
+ }
+
+ public Utilizador withId( final Integer id )
+ {
+ this.id = id;
+ return this;
+ }
+
+ public Utilizador withLogin( final String login )
+ {
+ this.login = login;
+ return this;
+ }
+
+ public Utilizador withPassword( final String password )
+ {
+ this.password = password;
+ return this;
+ }
+
+ public Utilizador withEmail( final String email )
+ {
+ this.email = email;
+ return this;
+ }
+
+ public Utilizador withEmpresa_id( final Integer empresa_id )
+ {
+ this.empresa_id = empresa_id;
+ return this;
+ }
+
+ public Utilizador withEstabelecimento_id( final Integer estabelecimento_id )
+ {
+ this.estabelecimento_id = estabelecimento_id;
+ return this;
+ }
+
+ public Utilizador withAdministrador( final String administrador )
+ {
+ this.administrador = administrador;
+ return this;
+ }
+
+ public Utilizador withTipo( final Integer tipo )
+ {
+ this.tipo = tipo;
+ return this;
+ }
+
+ public Utilizador withNumero_cedula( final String numero_cedula )
+ {
+ this.numero_cedula = numero_cedula;
+ return this;
+ }
+
+ public Utilizador withCap( final String cap )
+ {
+ this.cap = cap;
+ return this;
+ }
+
+ public Utilizador withCodigo_permissao( final Integer codigo_permissao )
+ {
+ this.codigo_permissao = codigo_permissao;
+ return this;
+ }
+
+ public Utilizador withNome( final String nome )
+ {
+ this.nome = nome;
+ return this;
+ }
+
+ public Utilizador withMedico_id( final Integer medico_id )
+ {
+ this.medico_id = medico_id;
+ return this;
+ }
+
+ public Utilizador withFuncionario_hst_id( final Integer funcionario_hst_id )
+ {
+ this.funcionario_hst_id = funcionario_hst_id;
+ return this;
+ }
+
+ public Utilizador withActivo( final String activo )
+ {
+ this.activo = activo;
+ return this;
+ }
+
+ public Utilizador withAcesso( final Integer acesso )
+ {
+ this.acesso = acesso;
+ return this;
+ }
+
+ public Utilizador withResponsavel_loja( final String responsavel_loja )
+ {
+ this.responsavel_loja = responsavel_loja;
+ return this;
+ }
+
+ public Utilizador withGestor_geral( final String gestor_geral )
+ {
+ this.gestor_geral = gestor_geral;
+ return this;
+ }
+
+ public Utilizador withNumero_mecanografico( final String numero_mecanografico )
+ {
+ this.numero_mecanografico = numero_mecanografico;
+ return this;
+ }
+
+ public Utilizador withCategoria( final String categoria )
+ {
+ this.categoria = categoria;
+ return this;
+ }
+
+ public Utilizador withNome_estabelecimento( final String nome_estabelecimento )
+ {
+ this.nome_estabelecimento = nome_estabelecimento;
+ return this;
+ }
+
+ public Utilizador withPrimeiro_login( final String primeiro_login )
+ {
+ this.primeiro_login = primeiro_login;
+ return this;
+ }
+
+ public Utilizador withApagado( final String apagado )
+ {
+ this.apagado = apagado;
+ return this;
+ }
+
+ public Utilizador withData_password( final Date data_password )
+ {
+ this.data_password = data_password;
+ return this;
+ }
+
+ public Utilizador withEstabelecimento_gestor( final Integer estabelecimento_gestor )
+ {
+ this.estabelecimento_gestor = estabelecimento_gestor;
+ return this;
+ }
+
+
+ public Integer getId() {
return id;
}
@@ -270,5 +447,20 @@ public class Utilizador implements Serializable
public void setEstabelecimento_gestor(Integer estabelecimento_gestor) {
this.estabelecimento_gestor = estabelecimento_gestor;
}
-
+
+ public static Utilizador createUtilizador( )
+ {
+ return new Utilizador( );
+ }
+
+ public static Utilizador createUtilizador( UtilizadoresData utilizadoresData )
+ {
+ return new Utilizador( utilizadoresData );
+ }
+
+ @Override
+ public String toString()
+ {
+ return new ToStringBuilder( this ).append( "id", id ).append( "login", login ).append( "password", password ).append( "email", email ).append( "empresa_id", empresa_id ).append( "estabelecimento_id", estabelecimento_id ).append( "administrador", administrador ).append( "tipo", tipo ).append( "numero_cedula", numero_cedula ).append( "cap", cap ).append( "codigo_permissao", codigo_permissao ).append( "nome", nome ).append( "medico_id", medico_id ).append( "funcionario_hst_id", funcionario_hst_id ).append( "activo", activo ).append( "acesso", acesso ).append( "responsavel_loja", responsavel_loja ).append( "gestor_geral", gestor_geral ).append( "numero_mecanografico", numero_mecanografico ).append( "categoria", categoria ).append( "nome_estabelecimento", nome_estabelecimento ).append( "primeiro_login", primeiro_login ).append( "apagado", apagado ).append( "data_password", data_password ).append( "estabelecimento_gestor", estabelecimento_gestor ).toString();
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/DBConstants.java b/trunk/AnaliseAcidentesTrabalho/src/db/DBConstants.java
index 91408006..8a663271 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/DBConstants.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/DBConstants.java
@@ -18,12 +18,6 @@ public interface DBConstants
public static final String DEFAULT_PROVIDER = Singleton.DEFAULT_OBJECT_PROVIDER;
public static final String LOCAL_PROVIDER = "LOCAL_PROVIDER";
- public static final String DEFAULT_DBMANAGER = "DEFAULT_DBMANAGER";
- public static final String LOCAL_DBMANAGER = "LOCAL_DBMANAGER";
-
- public static final String SESSION_CONNECTION = "SESSION_CONNECTION";
- public static final String SESSION_CONNECTION_LOCAL = "SESSION_CONNECTION_LOCAL";
-
public static final String SERVER_SIPRP = "server.siprp";
public static final String PORT_SIPRP = "port.siprp";
public static final String DATABASE_SIPRP = "database.siprp";
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/EstatisticasConstants.java b/trunk/AnaliseAcidentesTrabalho/src/db/EstatisticasConstants.java
index 71d1622d..21513fd3 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/EstatisticasConstants.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/EstatisticasConstants.java
@@ -5,6 +5,9 @@
package db;
+import db.data.siprp.outer.AcidentadosData;
+import db.data.siprp.outer.AnalisesAcidentesData;
+
/**
*
* @author dneves
@@ -18,25 +21,26 @@ public interface EstatisticasConstants
//TODO: falta os 2 ultimos
};
- public static final String KEY_POR = "acidentados.numero_mecanografico";
- public static final String KEY_NOME = "acidentados.nome";
+ public static final String KEY_POR = AcidentadosData.NUMERO_MECANOGRAFICO_FULL;
+ public static final String KEY_NOME = AcidentadosData.NOME_FULL;
+
+ public static final String KEY_ANO_OCORRENCIA = "date_part( 'year', " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )";
+ public static final String KEY_DATA_OCORRENCIA = AnalisesAcidentesData.DATA_ACIDENTE_FULL;
+ public static final String KEY_HORA_OCORRENCIA = AnalisesAcidentesData.HORA_ACIDENTE_FULL;
+ public static final String KEY_HORAS_TRABALHADAS = AnalisesAcidentesData.HORAS_TURNO_FULL;
- public static final String KEY_ANO_OCORRENCIA = "date_part( 'year', analises_acidentes.data_acidente )";
- public static final String KEY_DATA_OCORRENCIA = "analises_acidentes.data_acidente";
- public static final String KEY_HORA_OCORRENCIA = "analises_acidentes.hora_acidente";
- public static final String KEY_HORAS_TRABALHADAS = "analises_acidentes.horas_turno";
+ public static final String KEY_ESTABELECIMENTO = AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL;
+ public static final String KEY_EMPRESA = AnalisesAcidentesData.EMPRESA_ID_FULL;
-// public static final String KEY_DEPARTAMENTO = "departamentos.descricao";
- public static final String KEY_ESTABELECIMENTO = "analises_acidentes.estabelecimento_id";
- public static final String KEY_SECCAO = "analises_acidentes.seccao_id";
+ public static final String KEY_SECCAO = AnalisesAcidentesData.SECCAO_ID_FULL;
- public static final String KEY_CAUSAS_ACIDENTE = "analises_acidentes.causas";
+ public static final String KEY_CAUSAS_ACIDENTE = AnalisesAcidentesData.CAUSAS_FULL;
- public static final String KEY_TURNO_TRABALHO = "acidentados.turno";
+ public static final String KEY_TURNO_TRABALHO = AcidentadosData.TURNO_FULL;
- public static final String KEY_FORMACAO_SHST = "analises_acidentes.formacao_shst";
+ public static final String KEY_FORMACAO_SHST = AnalisesAcidentesData.FORMACAO_SHST_FULL;
- public static final String KEY_PARTICIPADO_SEGURO = "analises_acidentes.participado";
+ public static final String KEY_PARTICIPADO_SEGURO = AnalisesAcidentesData.PARTICIPADO_FULL;
public static final String KEY_POSTO_ACIDENTADO = "posto_acidentado";
public static final String KEY_OUTROS_ACIDENTADOS = "outros_acidentados";
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/AnalisesAcidentesData.java b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/AnalisesAcidentesData.java
index 5177c7f2..6329b399 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/AnalisesAcidentesData.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/AnalisesAcidentesData.java
@@ -8,6 +8,8 @@
package db.data.siprp.outer;
+import beans.Correcao;
+
public final class AnalisesAcidentesData extends db.data.siprp.inner.AnalisesAcidentes
{
@@ -15,4 +17,12 @@ public final class AnalisesAcidentesData extends db.data.siprp.inner.AnalisesAci
{
super();
}
+
+ public void update( Correcao c )
+ {
+ this.setCorrecao( c.getCorrecao() );
+ this.setEstado( c.getEstado_corr() );
+ this.setEstado_antes_correcao( c.getEstado_actual() );
+ this.setObservacoes_correcao( c.getObservacoes() );
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/PermissoesData.java b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/PermissoesData.java
index 4b7d3356..1273fa28 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/PermissoesData.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/PermissoesData.java
@@ -8,6 +8,11 @@
package db.data.siprp.outer;
+import beans.Permissao;
+import com.evolute.entity.ProviderInterface;
+import com.evolute.entity.evo.EvoDataException;
+import com.evolute.entity.evo.EvoDataObject;
+
public final class PermissoesData extends db.data.siprp.inner.Permissoes
{
@@ -15,4 +20,51 @@ public final class PermissoesData extends db.data.siprp.inner.Permissoes
{
super();
}
+
+ public PermissoesData( Permissao permissao )
+ {
+ this.withCodigo_permissao( permissao.getCodigo_permissao() )
+ .withUser_id( permissao.getUser_id() );
+ }
+
+ public static PermissoesData createPermissao( Permissao permissao )
+ {
+ return new PermissoesData( permissao );
+ }
+
+ public PermissoesData withCodigo_permissao( final Integer codigo_permissao )
+ {
+ this.setCodigo_permissao( codigo_permissao );
+ return this;
+ }
+
+ public PermissoesData withUser_id( final Integer user_id )
+ {
+ this.setUser_id( user_id );
+ return this;
+ }
+
+ public PermissoesData withId( final Integer id )
+ {
+ this.setId( id );
+ return this;
+ }
+
+ public PermissoesData withProvider( ProviderInterface< EvoDataObject< ? >, EvoDataException > provider )
+ {
+ this.setProvider( provider );
+ return this;
+ }
+
+ public PermissoesData refreshMe() throws EvoDataException
+ {
+ this.refresh();
+ return this;
+ }
+
+ public PermissoesData saveMe() throws EvoDataException
+ {
+ this.save();
+ return this;
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/UtilizadoresData.java b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/UtilizadoresData.java
index 3e5a0425..d2f20fc1 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/UtilizadoresData.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/data/siprp/outer/UtilizadoresData.java
@@ -8,6 +8,11 @@
package db.data.siprp.outer;
+import beans.Utilizador;
+import com.evolute.entity.ProviderInterface;
+import com.evolute.entity.evo.EvoDataException;
+import com.evolute.entity.evo.EvoDataObject;
+
public final class UtilizadoresData extends db.data.siprp.inner.Utilizadores
{
@@ -15,4 +20,186 @@ public final class UtilizadoresData extends db.data.siprp.inner.Utilizadores
{
super();
}
+
+ public static UtilizadoresData createUtilizador( )
+ {
+ return new UtilizadoresData( );
+ }
+
+ public static UtilizadoresData createUtilizador( Utilizador utilizador )
+ {
+ return new UtilizadoresData( utilizador );
+ }
+
+ public UtilizadoresData( Utilizador utilizador )
+ {
+ update( utilizador );
+ }
+
+ public UtilizadoresData withBackup_email2( final String backup_email2 )
+ {
+ this.setBackup_email2( backup_email2 );
+ return this;
+ }
+
+ public UtilizadoresData withData_password( final java.util.Date data_password )
+ {
+ this.setData_password( data_password );
+ return this;
+ }
+
+ public UtilizadoresData withApagado( final String apagado )
+ {
+ this.setApagado( apagado );
+ return this;
+ }
+
+ public UtilizadoresData withPrimeiro_login( final String primeiro_login )
+ {
+ this.setPrimeiro_login( primeiro_login );
+ return this;
+ }
+
+ public UtilizadoresData withGestor_geral( final String gestor_geral )
+ {
+ this.setGestor_geral( gestor_geral );
+ return this;
+ }
+
+ public UtilizadoresData withNumero_mecanografico( final String numero_mecanografico )
+ {
+ this.setNumero_mecanografico( numero_mecanografico );
+ return this;
+ }
+
+ public UtilizadoresData withResponsavel_loja( final String responsavel_loja )
+ {
+ this.setResponsavel_loja( responsavel_loja );
+ return this;
+ }
+
+ public UtilizadoresData withActivo( final String activo )
+ {
+ this.setActivo( activo );
+ return this;
+ }
+
+ public UtilizadoresData withFuncionario_hst_id( final Integer funcionario_hst_id )
+ {
+ this.setFuncionario_hst_id( funcionario_hst_id );
+ return this;
+ }
+
+ public UtilizadoresData withNome( final String nome )
+ {
+ this.setNome( nome );
+ return this;
+ }
+
+ public UtilizadoresData withCap( final String cap )
+ {
+ this.setCap( cap );
+ return this;
+ }
+
+ public UtilizadoresData withNumero_cedula( final String numero_cedula )
+ {
+ this.setNumero_cedula( numero_cedula );
+ return this;
+ }
+
+ public UtilizadoresData withTipo( final Integer tipo )
+ {
+ this.setTipo( tipo );
+ return this;
+ }
+
+ public UtilizadoresData withMedico_id( final Integer medico_id )
+ {
+ this.setMedico_id( medico_id );
+ return this;
+ }
+
+ public UtilizadoresData withAdministrador( final String administrador )
+ {
+ this.setAdministrador( administrador );
+ return this;
+ }
+
+ public UtilizadoresData withEstabelecimento_id( final Integer estabelecimento_id )
+ {
+ this.setEstabelecimento_id( estabelecimento_id );
+ return this;
+ }
+
+ public UtilizadoresData withEmpresa_id( final Integer empresa_id )
+ {
+ this.setEmpresa_id( empresa_id );
+ return this;
+ }
+
+ public UtilizadoresData withEmail( final String email )
+ {
+ this.setEmail( email );
+ return this;
+ }
+
+ public UtilizadoresData withPassword( final String password )
+ {
+ this.setPassword( password );
+ return this;
+ }
+
+ public UtilizadoresData withLogin( final String login )
+ {
+ this.setLogin( login );
+ return this;
+ }
+
+ public UtilizadoresData withId( final Integer id )
+ {
+ this.setId( id );
+ return this;
+ }
+
+ public UtilizadoresData withProvider( final ProviderInterface< EvoDataObject< ? >, EvoDataException > provider )
+ {
+ this.setProvider( provider );
+ return this;
+ }
+
+ public UtilizadoresData saveMe( ) throws EvoDataException
+ {
+ this.save();
+ return this;
+ }
+
+ public UtilizadoresData refreshMe( ) throws EvoDataException
+ {
+ this.refresh();
+ return this;
+ }
+
+ public UtilizadoresData update( Utilizador utilizador )
+ {
+ return this.withActivo( utilizador.getActivo() )
+ .withAdministrador( utilizador.getAdministrador() )
+ .withApagado( utilizador.getApagado() )
+ .withCap( utilizador.getCap() )
+ .withData_password( utilizador.getData_password() )
+ .withEmail( utilizador.getEmail() )
+ .withEmpresa_id( utilizador.getEmpresa_id() )
+ .withEstabelecimento_id( utilizador.getEstabelecimento_id() )
+ .withFuncionario_hst_id( utilizador.getFuncionario_hst_id() )
+ .withGestor_geral( utilizador.getGestor_geral() )
+ .withLogin( utilizador.getLogin() )
+ .withMedico_id( utilizador.getMedico_id() )
+ .withNome( utilizador.getNome() )
+ .withNumero_cedula( utilizador.getNumero_cedula() )
+ .withNumero_mecanografico( utilizador.getNumero_mecanografico() )
+ .withPassword( utilizador.getPassword() )
+ .withPrimeiro_login( utilizador.getPrimeiro_login() )
+ .withResponsavel_loja( utilizador.getResponsavel_loja() )
+ .withTipo( utilizador.getTipo() );
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java
index 9d02b79f..f2217fa6 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/AnalisesDataProvider.java
@@ -22,26 +22,36 @@ import beans.Seccao;
import beans.TecnicoSaude;
import beans.TipoUtilizador;
import beans.Trabalhador;
+
+import com.evolute.dbmodel.DBColumn;
+import com.evolute.dbmodel.ModelProvider;
import com.evolute.entity.evo.EvoDataProvider;
+import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.db.Connector;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.strings.StringPlainer;
import com.sun.rave.web.ui.model.Option;
+
+import db.DBConstants;
+import db.DBPropertiesLoader;
import db.data.siprp.outer.AcidentadosData;
import db.data.siprp.outer.AnalisesAcidentesData;
import db.data.siprp.outer.CausasData;
import db.data.siprp.outer.ControleData;
+import db.data.siprp.outer.DepartamentosData;
import db.data.siprp.outer.MedidasData;
import db.data.siprp.outer.RecomendacoesData;
-import db.data.siprp_local.outer.EstabelecimentosData;
-import db.data.siprp_local.outer.TrabalhadoresData;
+import db.data.siprp.outer.SeccoesData;
+import db.data.siprp.outer.TiposUtilizadoresData;
+import db.data.siprp.outer.EstabelecimentosData;
import global.Global;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.Statement;
+
+import java.sql.Connection;
+import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -53,6 +63,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.StringTokenizer;
+
import utils.Strings;
import utils.Utils;
@@ -60,6 +71,7 @@ import utils.Utils;
*
* @author lluis
*/
+@SuppressWarnings( "UnusedParameters" )
public class AnalisesDataProvider extends GenericDataProvider
{
@@ -80,56 +92,19 @@ public class AnalisesDataProvider extends GenericDataProvider
return INSTANCE;
}
- public Controle getControle() throws Exception
- {
- ControleData controle = getProvider().load( ControleData.class, 1 );
-// Statement st = createStatement();
-// String sql = "SELECT * FROM controle WHERE id = 1";
-// ResultSet rs = st.executeQuery( sql );
-// rs.first();
-// Controle c = new Controle();
-// c.setId( new Integer( rs.getInt( "id" ) ) );
-// c.setAnalise_year( new Integer( rs.getInt( "analise_year" ) ) );
-// c.setLast_analise_nr( new Integer( rs.getInt( "last_analise_nr" ) ) );
-// return c;
- return toControleBean( controle );
- }
-
public Controle getControloByAno( Integer ano ) throws Exception
{
List controles = getProvider().listLoad( ControleData.class, new Object[]{ ano },
new String[]{ ControleData.ANALISE_YEAR_FULL }, new String[]{ ControleData.ID_FULL } );
-// Controle c = null;
-// Statement st = createStatement();
-// String sql = "SELECT * FROM controle WHERE analise_year = " + ano;
-// ResultSet rs = st.executeQuery( sql );
-//
-// if ( rs.isBeforeFirst() )
-// {
-// rs.first();
-// c = new Controle();
-// c.setId( new Integer( rs.getInt( "id" ) ) );
-// c.setAnalise_year( new Integer( rs.getInt( "analise_year" ) ) );
-// c.setLast_analise_nr( new Integer( rs.getInt( "last_analise_nr" ) ) );
-// }
-// return c;
return controles.size() > 0 ? toControleBean( controles.get( 0 ) ) : null;
}
public Controle createAnoNumeracao( Integer ano ) throws Exception
{
Controle c = new Controle();
-// Integer newId = getMaxControleId();
-// c.setId( newId );
c.setAnalise_year( ano );
- c.setLast_analise_nr( new Integer( 0 ) );
-// Statement st = createStatement();
-
-// String sql = "INSERT INTO controle (id, analise_year, last_analise_nr) VALUES (";
-// sql += c.getId() + ", ";
-// sql += c.getAnalise_year() + ", ";
-// sql += c.getLast_analise_nr() + ")";
-// st.execute( sql );
+ c.setLast_analise_nr( 0 );
+
ControleData controle = fromControleBean( c, true );
controle.save();
c.setId( controle.getId() );
@@ -138,11 +113,6 @@ public class AnalisesDataProvider extends GenericDataProvider
public void updateControle( Controle c ) throws Exception
{
-// Statement st = createStatement();
-// String sql = "UPDATE controle SET analise_year = " + c.getAnalise_year() + ", ";
-// sql += "last_analise_nr = " + c.getLast_analise_nr() + " ";
-// sql += "WHERE id = " + c.getId();
-// st.execute( sql );
fromControleBean( c, false ).save();
}
@@ -173,665 +143,713 @@ public class AnalisesDataProvider extends GenericDataProvider
return controleBean;
}
- public String getExpression( String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
- {
- String tables = AnalisesAcidentesData.TABLENAME;
- String joinConditions = "";
- String whereExpression = "analises_acidentes.apagada = 'n' ";
-
- if ( nome != null || POR != null )
- {
- tables += ", acidentados";
- joinConditions += "acidentados.id = analises_acidentes.acidentado_id AND ";
- }
-
- if ( nome != null )
- {
- nome = StringPlainer.convertString( nome.trim() );
- nome = nome.replaceAll( " ", "%" );
- whereExpression += "AND plain_utf8( acidentados.nome ) LIKE '%" + nome + "%' ";
- }
- if ( estabelecimentoID != null )
- {
-// estabelecimento = StringPlainer.convertString( estabelecimento.trim() );
-// estabelecimento = estabelecimento.replaceAll( " ", "%" );
-// tables += ", estabelecimentos";
-// joinConditions += "analises_acidentes.estabelecimento_id = estabelecimentos.id AND ";
-// whereExpression += "AND plain_utf8( estabelecimentos.nome ) LIKE '%" + estabelecimento + "%' ";
- whereExpression += " AND analises_acidentes.estabelecimento_id = " + estabelecimentoID + " ";
- }
- if ( visitaDate != null )
- {
- whereExpression += "AND analises_acidentes.data_acidente = '" + visitaDate + "' ";
- }
- if ( POR != null )
- {
- whereExpression += "AND acidentados.numero_mecanografico LIKE '%" + POR.toUpperCase() + "%' ";
- }
-
- if( visitaDate == null )
- {
- whereExpression += " AND EXTRACT( year FROM analises_acidentes.data_acidente ) = " + fromYear + " ";
- }
-
- return "SELECT * FROM " + tables + " WHERE " + joinConditions + whereExpression + " ";
- }
-
/*************************************************************************/
/********************************* ACTUAIS *******************************/
/*************************************************************************/
- public ArrayList searchAnalisesActualSeg( Integer estabelecimento_id,
- String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesActualSeg( Integer estabelecimento_id, String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && visitaDate == null && POR == null )
{
- return getAnalisesActuaisSegList( estabelecimento_id, responsavel_loja, fromYear );
- }
-
- Statement st = createStatement();
- String sql = getExpression( nome, null, visitaDate, POR, fromYear );
-
- if ( responsavel_loja.matches( "y" ) )
- {
- sql += "AND (estado = " + Global.ESTADO_SEG + " OR (averiguacao_posterior = 'y' AND averiguacao_obs = '')" +
- " OR estado = " + Global.ESTADO_ASSINATURA_SEG + ")" + " AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
+ res = getAnalisesActuaisSegList( estabelecimento_id, responsavel_loja, fromYear );
}
else
{
- sql += "AND (estado = " + Global.ESTADO_SEG + " OR (averiguacao_posterior = 'y' AND averiguacao_obs = ''))" +
- " AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
- }
+ CommonExpression commonExpression = new CommonExpression( nome, null, visitaDate, POR, fromYear ).invoke();
+ Expression where = commonExpression.getWhere();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- System.out.println( "SQL: " + sql );
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
+
+ if( responsavel_loja.matches( "y" ) )
+ {
+ where = where
+ .and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG )
+ .or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isEqual( "" ) ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ) ) )
+ .and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
+ }
+ else
+ {
+ where = where
+ .and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG )
+ .or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isEqual( "" ) ) ) )
+ .and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
+ }
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesActuaisSegList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesActuaisSegList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
throws Exception
{
- Expression where = new Field( "analises_acidentes.apagada" ).isEqual( "n" );
- where = where.and( new Field( "analises_acidentes.estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
- Expression states = new Field( "analises_acidentes.estado" ).isEqual( Global.ESTADO_SEG ).or(
- new Field( "analises_acidentes.averiguacao_posterior" ).isEqual( "y" ).and( new Field( "analises_acidentes.averiguacao_obs" ).isEqual( "" ) ) );
+ Expression states = new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG ).or(
+ new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isEqual( "" ) ) );
if ( "y".equals( responsavel_loja ) )
{
- states = states.or( new Field( "analises_acidentes.estado" ).isEqual( Global.ESTADO_ASSINATURA_SEG ) );
+ states = states.or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ) );
}
where = where.and( states );
Select2 query = new Select2(
- new String[]
- {
- "analises_acidentes"
- },
- new Integer[]
- {
- },
- new Expression[]
- {
- },
- new String[]
- {
- "*"
- },
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[]{ "*" },
where,
- new String[]
- {
- "analises_acidentes.analise_nr"
- },
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesActualRH( Integer estabelecimento_id,
- String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesActualRH( Integer estabelecimento_id, String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && visitaDate == null && POR == null )
{
- return getAnalisesActuaisRhList( estabelecimento_id, responsavel_loja, fromYear );
- }
-
- Statement st = createStatement();
- String sql = getExpression( nome, null, visitaDate, POR, fromYear );
-
- if ( responsavel_loja.matches( "y" ) )
- {
- sql += "AND (estado = " + Global.ESTADO_RH1 + " OR estado = " + Global.ESTADO_RH2 +
- " OR estado = " + Global.ESTADO_ASSINATURA_RH + ") AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
+ res = getAnalisesActuaisRhList( estabelecimento_id, responsavel_loja, fromYear );
}
else
{
- sql += "AND (estado = " + Global.ESTADO_RH1 + " OR estado = " + Global.ESTADO_RH2 +
- ") AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
- }
+ CommonExpression commonExpression = new CommonExpression( nome, null, visitaDate, POR, fromYear ).invoke();
+ Expression where = commonExpression.getWhere();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
+
+ if( responsavel_loja.matches( "y" ) )
+ {
+ where = where.and(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH1 )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH2 ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_RH ) )
+ ).and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
+ }
+ else
+ {
+ where = where.and(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH1 )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH2 ) )
+ ).and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
+ }
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesActuaisRhList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesActuaisRhList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
throws Exception
{
- Expression where = new Field( "apagada" ).isEqual( "n" );
- where = where.and( new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
+
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
- Expression or = new Field( "estado" ).isEqual( Global.ESTADO_RH1 ).or( new Field( "estado" ).isEqual( Global.ESTADO_RH2 ) );
+ Expression or = new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH1 )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH2 ) );
if ( "y".equals( responsavel_loja ) )
{
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_ASSINATURA_RH ) );
+ or = or.or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_RH ) );
}
where = where.and( or );
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
new Integer[] { },
new Expression[] { },
new String[] { "*" },
where,
- new String[] { "analise_nr" },
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null );
- System.out.println( "\ngetAnalisesActuaisRhList() : " + query.toString() + "\n" );
+ System.out.println( "SQL: " + query.toString() );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesActuaisHS( Integer estabelecimento_id,
- String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesActuaisHS( Integer estabelecimento_id, String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && estabelecimentoID == null && visitaDate == null && POR == null )
{
- return getAnalisesActuaisHsList( estabelecimento_id, fromYear );
+ res = getAnalisesActuaisHsList( estabelecimento_id, fromYear );
}
+ else
+ {
+ CommonExpression commonExpression = new CommonExpression( nome, estabelecimentoID, visitaDate, POR, fromYear ).invoke();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- Statement st = createStatement();
- String sql = getExpression( nome, estabelecimentoID, visitaDate, POR, fromYear );
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- sql += "AND (estado = " + Global.ESTADO_HS + " OR estado = " + Global.ESTADO_FECHAR +
- " OR estado = " + Global.ESTADO_CONSOLIDACAO + ")" +
- " ORDER BY analise_nr";
+ Expression where = commonExpression.getWhere().and(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_HS )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONSOLIDACAO ) )
+ );
- System.out.println( "\nAnalisesDataProvider . searchAnalisesActuaisHS() :\n\t" + sql );
-
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesActuaisHsList( Integer estabelecimentoID, Integer fromYear ) throws Exception
+ public ArrayList< AnaliseAcidente > getAnalisesActuaisHsList( Integer estabelecimentoID, Integer fromYear ) throws Exception
{
- Expression where = new Field( "apagada" ).isEqual( "n" ).and(
- new Field( "estado" ).isEqual( Global.ESTADO_HS ).or( new Field( "estado" ).isEqual( Global.ESTADO_FECHAR ) ).or( new Field( "estado" ).isEqual( Global.ESTADO_CONSOLIDACAO ) ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ).and(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_HS ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ) ).or( new Field( "estado" ).isEqual( Global.ESTADO_CONSOLIDACAO ) ) );
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
+
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
new Integer[] { },
new Expression[] { },
new String[] { "*" },
where,
- new String[] { "analise_nr" },
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null
);
- System.out.println( "\nAnalisesDataProvider . getAnalisesActuaisHsList() : " + query.toString() );
+ System.out.println( "SQL: " + query.toString() );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
/*************************************************************************/
/******************************* SEGUIMENTO ******************************/
/*************************************************************************/
- public ArrayList searchAnalisesSeguimentoSeg( Integer estabelecimento_id,
- String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoSeg( Integer estabelecimento_id, String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoSegList( estabelecimento_id, responsavel_loja, fromYear );
- }
-
- Statement st = createStatement();
- String sql = getExpression( nome, null, visitaDate, POR, fromYear );
-
- if ( responsavel_loja.matches( "y" ) )
- {
- sql += "AND estabelecimento_id = " + estabelecimento_id + " AND (" +
- "estado > " + Global.ESTADO_SEG + " AND estado < " + Global.ESTADO_ASSINATURA_SEG + " AND (" +
- "averiguacao_posterior = 'n' OR (averiguacao_posterior = 'y' AND averiguacao_obs <> '')" +
- ") " +
- "OR (estado > " + Global.ESTADO_ASSINATURA_SEG + " AND estado < " + Global.ESTADO_CONCLUIDO + ")" +
- ")" + " ORDER BY analise_nr";
+ res = getAnalisesSeguimentoSegList( estabelecimento_id, responsavel_loja, fromYear );
}
else
{
- sql += "AND estabelecimento_id = " + estabelecimento_id + " AND (" +
- "(estado > " + Global.ESTADO_SEG + " AND estado < " + Global.ESTADO_FECHAR + " AND (" +
- "averiguacao_posterior = 'n' OR (averiguacao_posterior = 'y' AND averiguacao_obs <> '')" +
- ")) OR estado = " + Global.ESTADO_FECHAR +
- ")" + " ORDER BY analise_nr";
- }
+ CommonExpression commonExpression = new CommonExpression( nome, null, visitaDate, POR, fromYear ).invoke();
+ Expression where = commonExpression.getWhere();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- System.out.println( "SQL: " + sql );
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
+
+ if( responsavel_loja.matches( "y" ) )
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_ASSINATURA_SEG ) ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "n" ).or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isDifferent( "" ) ) ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_ASSINATURA_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) ) ) );
+ }
+ else
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_FECHAR ) ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "n" ).or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isDifferent( "" ) ) ) ) ) );
+ }
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoSegList( Integer estabelecimento_id, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoSegList( Integer estabelecimento_id, String responsavel_loja, Integer fromYear )
throws Exception
{
- String sql = null;
+ String tables[] = new String[] { AnalisesAcidentesData.TABLENAME };
+ Expression where = new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id )
+ .or( new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ) );
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- // TODO : change to Select2
if ( responsavel_loja.matches( "y" ) )
{
- sql = "SELECT * FROM analises_acidentes WHERE " +
- "estabelecimento_id = " + estabelecimento_id + " AND (" +
- "estado > " + Global.ESTADO_SEG + " AND estado < " + Global.ESTADO_ASSINATURA_SEG + " AND (" +
- "averiguacao_posterior = 'n' OR (averiguacao_posterior = 'y' AND averiguacao_obs <> '')" +
- ") " +
- "OR (estado > " + Global.ESTADO_ASSINATURA_SEG + " AND estado < " + Global.ESTADO_CONCLUIDO + ")" +
- ")" + " AND apagada = 'n' ";
+ where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_ASSINATURA_SEG ) ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "n" ).or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isDifferent( "" ) ) ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_ASSINATURA_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) ) ) );
}
else
{
- sql = "SELECT * FROM analises_acidentes WHERE " +
- "estabelecimento_id = " + estabelecimento_id + " AND (" +
- "(estado > " + Global.ESTADO_SEG + " AND estado < " + Global.ESTADO_FECHAR + " AND (" +
- "averiguacao_posterior = 'n' OR (averiguacao_posterior = 'y' AND averiguacao_obs <> '')" +
- ")) OR estado = " + Global.ESTADO_FECHAR +
- ")" + " AND apagada = 'n' ";
+ where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_FECHAR ) ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "n" ).or( new Field( AnalisesAcidentesData.AVERIGUACAO_POSTERIOR_FULL ).isEqual( "y" ).and( new Field( AnalisesAcidentesData.AVERIGUACAO_OBS_FULL ).isDifferent( "" ) ) ) ) ) );
}
+
if ( fromYear != null )
{
- sql += " AND EXTRACT( year FROM analises_acidentes.data_acidente ) = " + fromYear + " ";
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
- sql += " ORDER BY analise_nr ";
- System.out.println( "\ngetAnalisesSeguimentoSegList() : " + sql + "\n" );
+ Select2 query = new Select2( tables, new Integer[] { }, new Expression[] { }, new String[] { "*" }, where, order, null, null, null );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesSeguimentoHS( Integer estabelecimento_id,
- String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoHS( Integer estabelecimento_id, String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && estabelecimentoID == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoHsList( estabelecimento_id, fromYear );
+ res = getAnalisesSeguimentoHsList( estabelecimento_id, fromYear );
}
+ else
+ {
- Statement st = createStatement();
- String sql = getExpression( nome, estabelecimentoID, visitaDate, POR, fromYear );
+ CommonExpression commonExpression = new CommonExpression( nome, estabelecimentoID, visitaDate, POR, fromYear ).invoke();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- sql += "AND (" +
- "estado < " + Global.ESTADO_HS + " OR (estado > " + Global.ESTADO_HS + " AND estado < " + Global.ESTADO_CONSOLIDACAO + ") " +
- "OR (estado > " + Global.ESTADO_CONSOLIDACAO + " AND estado < " + Global.ESTADO_FECHAR + ")" +
- ")" + " ORDER BY analise_nr";
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ Expression where = commonExpression.getWhere().
+ and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_HS ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_HS ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONSOLIDACAO ) ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_CONSOLIDACAO ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_FECHAR ) ) ) );
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoHsList( Integer estabelecimentoID, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoHsList( Integer estabelecimentoID, Integer fromYear )
throws Exception
{
- Expression where = new Field( "analises_acidentes.apagada" ).isEqual( "n" );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
where = where.and(
- new Field( "estado" ).isLess( Global.ESTADO_HS ).or( new Field( "estado" ).isGreater( Global.ESTADO_HS ).and( new Field( "estado" ).isLess( Global.ESTADO_CONSOLIDACAO ) ) ).or( new Field( "estado" ).isGreater( Global.ESTADO_CONSOLIDACAO ).and( new Field( "estado" ).isLess( Global.ESTADO_FECHAR ) ) ) );
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_HS )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_HS )
+ .and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONSOLIDACAO ) ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_CONSOLIDACAO )
+ .and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_FECHAR ) ) ) );
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
- new Integer[] { },
- new Expression[] { },
- new String[] { "*" },
- where,
- new String[] { "analises_acidentes.analise_nr" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[] { "*" },
+ where,
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null
);
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- System.out.println( "SEGUIMENTO HS SQL : " + query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesSeguimentoRH( Integer estabelecimento_id,
- String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoRH( Integer estabelecimento_id, String nome, String visitaDate, String POR, String responsavel_loja, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoRhList( estabelecimento_id, responsavel_loja, fromYear );
- }
-
- Statement st = createStatement();
- String sql = getExpression( nome, null, visitaDate, POR, fromYear );
-
- if ( responsavel_loja.matches( "y" ) )
- {
- sql += "AND (estado = " + Global.ESTADO_SEG + " OR estado = " + Global.ESTADO_HS +
- " OR estado = " + Global.ESTADO_CONSOLIDACAO + " OR estado = " + Global.ESTADO_ASSINATURA_SEG +
- " OR estado = " + Global.ESTADO_FECHAR + ") AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
+ res = getAnalisesSeguimentoRhList( estabelecimento_id, responsavel_loja, fromYear );
}
else
{
- sql += "AND ( estado = " + Global.ESTADO_SEG + " OR estado = " + Global.ESTADO_HS +
- " OR estado = " + Global.ESTADO_CONSOLIDACAO + " OR estado = " + Global.ESTADO_ASSINATURA_SEG +
- " OR estado = " + Global.ESTADO_ASSINATURA_RH + " OR estado = " + Global.ESTADO_FECHAR +
- ") AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
- }
+ CommonExpression commonExpression = new CommonExpression( nome, null, visitaDate, POR, fromYear ).invoke();
+ Expression where = commonExpression.getWhere();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
+
+ if( responsavel_loja.matches( "y" ) )
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_HS ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONSOLIDACAO ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ) ) );
+ }
+ else
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_HS ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONSOLIDACAO ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_RH ) ).or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ) ) );
+ }
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoRhList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoRhList( Integer estabelecimentoID, String responsavel_loja, Integer fromYear )
throws Exception
{
- Expression where = new Field( "apagada" ).isEqual( "n" );
- where = where.and( new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
- Expression or = new Field( "estado" ).isEqual( Global.ESTADO_SEG );
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_HS ) );
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_CONSOLIDACAO ) );
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_ASSINATURA_SEG ) );
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_FECHAR ) );
+ Expression or = new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_SEG )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_HS ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONSOLIDACAO ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_FECHAR ) );
if ( !"y".equals( responsavel_loja ) )
{
- or = or.or( new Field( "estado" ).isEqual( Global.ESTADO_ASSINATURA_RH ) );
+ or = or.or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_RH ) );
}
where = where.and( or );
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
new Integer[] { },
new Expression[] { },
new String[] { "*" },
where,
- new String[] { "analise_nr" },
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null
);
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesSeguimentoMedico( Integer estabelecimento_id, String nome, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoMedico( Integer estabelecimento_id, String nome, String visitaDate, String POR, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoMedList( estabelecimento_id, fromYear );
+ res = getAnalisesSeguimentoMedList( estabelecimento_id, fromYear );
}
+ else
+ {
- Statement st = createStatement();
- String sql = getExpression( nome, null, visitaDate, POR, fromYear );
+ CommonExpression commonExpression = new CommonExpression( nome, null, visitaDate, POR, fromYear ).invoke();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- sql += "AND estado < 5 OR (estado = 6 AND estado_assinatura <> 2) OR (estado = 6 AND estado_assinatura = 2 AND ass_med = 'y') " +
- "OR (estado > 6 AND estado < 9) " +
- "AND estabelecimento_id = " + estabelecimento_id +
- " ORDER BY analise_nr";
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ Expression where = commonExpression.getWhere()
+ .and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) )
+ .and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONSOLIDACAO ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isDifferent( Global.ESTADO_RH1 ) ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_ASSINATURA_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_RH1 ) ).and( new Field( "ass_med" ).isEqual( "y" ) ) )
+ .or( new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( Global.ESTADO_ASSINATURA_SEG ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) ) );
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoMedList( Integer estabelecimentoID, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoMedList( Integer estabelecimentoID, Integer fromYear )
throws Exception
{
-// String sql = null;
-// sql = "SELECT * FROM analises_acidentes WHERE " +
-// "estado < 5 OR (estado = 6 AND estado_assinatura <> 2) OR (estado = 6 AND estado_assinatura = 2 AND ass_med = 'y') " +
-// "OR (estado > 6 AND estado < 9) " +
-// "AND estabelecimento_id = " + estabelecimentoID + " AND apagada = 'n' ";
-// if ( fromYear != null )
-// {
-// sql += " AND EXTRACT( year FROM analises_acidentes.data_acidente ) = " + fromYear + " ";
-// }
-// sql += " ORDER BY analise_nr ";
-
- Expression where = new Field( "analises_acidentes.apagada" ).isEqual( "n" );
- where = where.and( new Field( "analises_acidentes.estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
+
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
+
where = where.and(
- new Field( "analises_acidentes.estado" ).isLess( 5 ).or(
- new Field( "analises_acidentes.estado" ).isEqual( 6 ).and( new Field( "analises_acidentes.estado_assinatura" ).isDifferent( 2 ) ) ).or(
- new Field( "analises_acidentes.estado" ).isEqual( 6 ).and( new Field( "analises_acidentes.estado_assinatura" ).isEqual( 2 ) ).and( new Field( "analises_acidentes.ass_med" ).isEqual( "y" ) ) ).or(
- new Field( "analises_acidentes.estado" ).isGreater( 6 ).and( new Field( "analises_acidentes.estado" ).isLess( 9 ) ) ) );
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( 5 ).or(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( 6 ).and( new Field( AnalisesAcidentesData.ESTADO_ASSINATURA_FULL ).isDifferent( 2 ) ) ).or(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( 6 ).and( new Field( AnalisesAcidentesData.ESTADO_ASSINATURA_FULL ).isEqual( 2 ) ).and( new Field( "analises_acidentes.ass_med" ).isEqual( "y" ) ) ).or(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isGreater( 6 ).and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( 9 ) ) ) );
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
- new Integer[] { },
- new Expression[] { },
- new String[] { "*" },
- where,
- new String[] { "analises_acidentes.analise_nr" },
- null, null, null
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[] { "*" },
+ where,
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
+ null, null, null
);
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesSeguimentoDirSiprp( String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoDirSiprp( String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && estabelecimentoID == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoDirSiprpList( fromYear );
+ res = getAnalisesSeguimentoDirSiprpList( fromYear );
}
+ else
+ {
- String sql = getExpression( nome, estabelecimentoID, visitaDate, POR, fromYear );
-
- sql += " AND estado < " + Global.ESTADO_CONCLUIDO + " ORDER BY analise_nr";
+ CommonExpression commonExpression = new CommonExpression( nome, estabelecimentoID, visitaDate, POR, fromYear ).invoke();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
+
+ Expression where = commonExpression.getWhere().and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) );
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoDirSiprpList( Integer fromYear ) throws Exception
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoDirSiprpList( Integer fromYear ) throws Exception
{
- Expression where = new Field( "apagada" ).isEqual( "n" );
- where = where.and( new Field( "estado" ).isLess( Global.ESTADO_CONCLUIDO ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) );
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
- new Integer[] { },
- new Expression[] { },
- new String[] { "*" },
- where,
- new String[] { "analise_nr" },
- null, null, null
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[] { "*" },
+ where,
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
+ null, null, null
);
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList searchAnalisesSeguimentoDirGerRh(
- String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoDirGerRh( String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
throws Exception
{
return searchAnalisesSeguimentoDirSiprp( nome, estabelecimentoID, visitaDate, POR, fromYear );
}
- public ArrayList getAnalisesSeguimentoDirGerRhList( Integer fromYear ) throws Exception
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoDirGerRhList( Integer fromYear ) throws Exception
{
return getAnalisesSeguimentoDirSiprpList( fromYear );
}
- public ArrayList searchAnalisesSeguimentoGestor( Integer estabelecimento_id,
- String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesSeguimentoGestor( Integer estabelecimento_id, String nome, Integer estabelecimentoID, String visitaDate, String POR, Integer fromYear )
throws Exception
{
+ ArrayList< AnaliseAcidente > res;
if ( nome == null && estabelecimentoID == null && visitaDate == null && POR == null )
{
- return getAnalisesSeguimentoGestorList( estabelecimento_id, fromYear );
+ res = getAnalisesSeguimentoGestorList( estabelecimento_id, fromYear );
}
+ else
+ {
+ CommonExpression commonExpression = new CommonExpression( nome, estabelecimentoID, visitaDate, POR, fromYear ).invoke();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- Statement st = createStatement();
- String sql = getExpression( nome, estabelecimentoID, visitaDate, POR, fromYear );
- sql += "AND estado < " + Global.ESTADO_CONCLUIDO + " ";
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- if ( estabelecimento_id != null )
- {
- sql += " AND estabelecimento_id = " + estabelecimento_id + " ";
- }
- sql += " ORDER BY analise_nr";
+ Expression where = commonExpression.getWhere().and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) );
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ if( estabelecimento_id != null )
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
+ }
+
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ res = fillAnaliseFields( result );
+ }
+ return res;
}
- public ArrayList getAnalisesSeguimentoGestorList( Integer estabelecimentoID, Integer fromYear )
+ public ArrayList< AnaliseAcidente > getAnalisesSeguimentoGestorList( Integer estabelecimentoID, Integer fromYear )
throws Exception
{
- Expression where = new Field( "apagada" ).isEqual( "n" );
- where = where.and( new Field( "estado" ).isLess( Global.ESTADO_CONCLUIDO ) );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isLess( Global.ESTADO_CONCLUIDO ) );
if ( estabelecimentoID != null )
{
- where = where.and( new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
}
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM analises_acidentes.data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
- new Integer[] { },
- new Expression[] { },
- new String[] { "*" },
- where,
- new String[] { "analise_nr" },
- null, null, null
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[] { "*" },
+ where,
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
+ null, null, null
);
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
/*************************************************************************/
/****************************** CONCLUIDOS *******************************/
/*************************************************************************/
- public ArrayList getAnalisesConcluidasList( Integer estabelecimentoID, Integer fromYear ) throws Exception
+ public ArrayList< AnaliseAcidente > getAnalisesConcluidasList( Integer estabelecimentoID, Integer fromYear ) throws Exception
{
- Statement st = createStatement();
-
- Expression where = new Field( "estado" ).isEqual( Global.ESTADO_CONCLUIDO );
- where = where.and( new Field( "apagada" ).isEqual( "n" ) );
+ Expression where = new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONCLUIDO );
+ where = where.and( new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ) );
if ( estabelecimentoID != null )
{
- where = where.and( new Field( "estabelecimento_id" ).isEqual( estabelecimentoID ) );
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
}
if ( fromYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM data_acidente )" ).isEqual( fromYear ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
new Integer[] { },
new Expression[] { },
new String[] { "*" },
where,
- new String[] { "analise_nr" },
+ new String[] { AnalisesAcidentesData.ANALISE_NR_FULL },
null, null, null
);
System.out.println( "\ngetAnalisesConcluidasList() : " + query.toString() + "\n" );
- ResultSet rs = st.executeQuery( query.toString() );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+ System.out.println( "SQL: " + query.toString() );
+
+
+
+ Virtual2DArray result = getExecuter().executeQuery( query );
+ return fillAnaliseFields( result );
}
- public ArrayList getAnalisesConcluidasHsList( Integer fromYear ) throws Exception
+ public ArrayList< AnaliseAcidente > getAnalisesConcluidasHsList( Integer fromYear ) throws Exception
{
return getAnalisesConcluidasList( null, fromYear );
}
- public ArrayList searchAnalisesConcluidasList( Integer estabelecimento_id,
- Integer ano, Integer mes, Integer dia, String POR, String nome, Integer estabelecimentoID, Integer fromYear )
+ public ArrayList< AnaliseAcidente > searchAnalisesConcluidasList( Integer estabelecimento_id, Integer ano, Integer mes, Integer dia, String POR, String nome, Integer estabelecimentoID, Integer fromYear )
throws Exception
{
- String sql = null;
+ CommonExpression commonExpression = new CommonExpression( nome, estabelecimentoID, null, POR, ano == null ? fromYear : ano ).invoke();
+ Expression where = commonExpression.getWhere();
+ String[] tables = commonExpression.getTables();
+ Integer[] joinTypes = commonExpression.getJoinTypes();
+ Expression[] joinConditions = commonExpression.getJoinConditions();
- sql = getExpression( nome, estabelecimentoID, null, POR, ano == null ? fromYear : ano );
+ String[] order = new String[]{ AnalisesAcidentesData.ANALISE_NR_FULL };
- if ( estabelecimento_id != null && estabelecimento_id.intValue() > 0 )
+ if ( estabelecimento_id != null && estabelecimento_id > 0 )
{
- sql += "AND analises_acidentes.estabelecimento_id = " + estabelecimento_id + " ";
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimento_id ) );
}
if ( ano != null )
@@ -840,23 +858,23 @@ public class AnalisesDataProvider extends GenericDataProvider
Calendar calendar_from = Calendar.getInstance();
Calendar calendar_to = Calendar.getInstance();
- calendar_from.set( Calendar.YEAR, ano.intValue() );
+ calendar_from.set( Calendar.YEAR, ano );
calendar_from.set( Calendar.MONTH, 0 );
calendar_from.set( Calendar.DATE, 1 );
- calendar_to.set( Calendar.YEAR, ano.intValue() );
+ calendar_to.set( Calendar.YEAR, ano );
calendar_to.set( Calendar.MONTH, 11 );
calendar_to.set( Calendar.DATE, 31 );
if ( mes != null )
{
- calendar_from.set( Calendar.MONTH, mes.intValue() - 1 );
- calendar_to.set( Calendar.MONTH, mes.intValue() - 1 );
+ calendar_from.set( Calendar.MONTH, mes - 1 );
+ calendar_to.set( Calendar.MONTH, mes - 1 );
if ( dia != null )
{
- calendar_from.set( Calendar.DATE, dia.intValue() );
- calendar_to.set( Calendar.DATE, dia.intValue() );
+ calendar_from.set( Calendar.DATE, dia );
+ calendar_to.set( Calendar.DATE, dia );
}
else
{
@@ -875,860 +893,386 @@ public class AnalisesDataProvider extends GenericDataProvider
if ( dateStart.compareTo( dateEnd ) == 0 )
{
- sql += "AND analises_acidentes.data_acidente = '" + D_F.format( dateStart ) + "' ";
+ where = where.and( new Field( AnalisesAcidentesData.DATA_ACIDENTE_FULL ).isEqual( D_F.format( dateStart ) ) );
}
else
{
- sql += "AND ( analises_acidentes.data_acidente >= '" + D_F.format( dateStart ) + "' AND analises_acidentes.data_acidente <= '" + D_F.format( dateEnd ) + "' ) ";
+ where = where.and( new Field( AnalisesAcidentesData.DATA_ACIDENTE_FULL ).isGreaterOrEqual( D_F.format( dateStart ) ) )
+ .and( new Field( AnalisesAcidentesData.DATA_ACIDENTE_FULL ).isLessOrEqual( D_F.format( dateEnd ) ) );
}
}
- sql += " AND estado = " + Global.ESTADO_CONCLUIDO + " ";
+ where = where.and( new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONCLUIDO ) );
- // if search parameters are null, account with fromYear
if ( ano == null && mes == null && dia == null && POR == null && nome == null && estabelecimentoID == null && fromYear != null )
{
- sql += " AND EXTRACT( year FROM analises_acidentes.data_acidente ) = " + fromYear + " ";
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).isEqual( fromYear ) );
}
- sql += " ORDER BY analises_acidentes.analise_nr ASC ";
+ Select select = new Select2( tables, joinTypes, joinConditions, new String[]{ "*" }, where, order, null, null, null );
- System.out.println( "CONCLUIDAS SQL: " + sql );
+ System.out.println( "SQL: " + select.toString() );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( sql );
- ArrayList list = fillAnaliseFields( rs );
- return list;
+
+
+ Virtual2DArray result = getExecuter().executeQuery( select );
+ return fillAnaliseFields( result );
}
- //by lino
-// public ArrayList searchAanalisesConcluidasList( Integer estabelecimento_id,
-// Integer ano, Integer mes, Integer dia, String por, String nome, String estabelecimento )
-// throws Exception
-// {
-// Calendar cal = Calendar.getInstance();
-// Statement st = createStatement();
-// String sql = "";
-// if(por != null)
-// {
-// por = por.toUpperCase();
-// }
-// if(nome != null)
-// {
-// nome = nome.toUpperCase();
-// }
-//
-// if( ano != null)
-// {
-// if( mes != null)
-// {
-// if( dia != null)
-// {
-// cal.set( cal.YEAR, ano.intValue() );
-// cal.set( cal.MONTH, mes.intValue() -1 );
-// cal.set( cal.DATE, dia.intValue() );
-// java.sql.Date data_acidente = new java.sql.Date( cal.getTime().getTime() );
-// if(por != null && nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else if(por != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND numero_mecanografico LIKE '%" + por + "%' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND numero_mecanografico LIKE '%" + por + "%' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND estabelecimento_id = " + estabelecimento_id + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// else if( nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND nome LIKE '%" + nome + "%' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente = '" + data_acidente +
-// "' AND nome LIKE '%" + nome + "%' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND estabelecimento_id = " + estabelecimento_id + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente = '" + data_acidente + "' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente = '" + data_acidente + "' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND estabelecimento_id = " + estabelecimento_id + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// }
-// else
-// {
-// cal.set( cal.YEAR, ano.intValue() );
-// cal.set( cal.MONTH, mes.intValue() -1 );
-// cal.set( cal.DATE, 1 );
-// java.sql.Date data_acidente_from = new java.sql.Date( cal.getTime().getTime() );
-// cal.set( cal.DATE, 31 );
-// java.sql.Date data_acidente_to = new java.sql.Date( cal.getTime().getTime() );
-// if(por != null && nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else if(por != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND numero_mecanografico LIKE '%" + por + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND numero_mecanografico LIKE '%" + por + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// else if( nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados" +
-// " WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente >= '" + data_acidente_from + "' AND data_acidente <= '" + data_acidente_to +
-// "' AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente >= '" + data_acidente_from + "' AND data_acidente <= '" + data_acidente_to +
-// "' AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// } // dia
-// } // mes
-// else
-// {
-// cal.set( cal.YEAR, ano.intValue() );
-// cal.set( cal.MONTH, 0 );
-// cal.set( cal.DATE, 1 );
-// java.sql.Date data_acidente_from = new java.sql.Date( cal.getTime().getTime() );
-// cal.set( cal.MONTH, 11 );
-// cal.set( cal.DATE, 31 );
-// java.sql.Date data_acidente_to = new java.sql.Date( cal.getTime().getTime() );
-// if(por != null && nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to +
-// "' AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else if(por != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to +
-// "' AND numero_mecanografico LIKE '%" + por + "%' AND estado = " + Global.ESTADO_CONCLUIDO +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND numero_mecanografico LIKE '%" + por + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// else if( nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND data_acidente >= '" + data_acidente_from +
-// "' AND data_acidente <= '" + data_acidente_to + "' AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente >= '" + data_acidente_from + "' AND data_acidente <= '" + data_acidente_to +
-// "' AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE data_acidente >= '" + data_acidente_from + "' AND data_acidente <= '" + data_acidente_to +
-// "' AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// }
-// } // ano
-// else
-// {
-// if(por != null && nome != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND (numero_mecanografico LIKE '%" + por + "%' OR nome LIKE '%" + nome + "%') " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// }
-// else if(por != null)
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND numero_mecanografico LIKE '%" + por + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND numero_mecanografico LIKE '%" + por + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// else if( nome != null )
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes, acidentados " +
-// "WHERE acidentado_id = acidentados.id AND nome LIKE '%" + nome + "%' " +
-// "AND estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// else
-// {
-// if(estabelecimento_id == null)
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE estado = " + Global.ESTADO_CONCLUIDO + " AND apagada = 'n' ORDER BY analise_nr";
-// }
-// else
-// {
-// sql = "SELECT * FROM analises_acidentes " +
-// "WHERE estado = " + Global.ESTADO_CONCLUIDO + " AND estabelecimento_id = " + estabelecimento_id +
-// " AND apagada = 'n' ORDER BY analise_nr";
-// }
-//
-// }
-// }
-// ResultSet rs = st.executeQuery(sql);
-// ArrayList list = fillAnaliseFields(rs);
-//
-// return list;
-// }
- private ArrayList fillAnaliseFields( ResultSet rs ) throws Exception
- {
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
-// Statement stlocal1 = dblocal.createStatement();
-
- ArrayList list = new ArrayList();
- if ( !rs.isBeforeFirst() ) //rs empty
- {
- return list;
- }
-
- Statement stlocal = createLocalStatement();
- Statement stlocal1 = createLocalStatement();
-
- rs.first();
- int nr = 0;
- do
- {
- AnaliseAcidente a = new AnaliseAcidente();
- a.setId( new Integer( rs.getInt( "id" ) ) );
-
- nr++;
- a.setNr( new Integer( nr ) );
- a.setData_acidente( rs.getDate( "data_acidente" ) );
- a.setEmpresa_id( new Integer( rs.getInt( "empresa_id" ) ) );
- a.setEstabelecimento_id( new Integer( rs.getInt( "estabelecimento_id" ) ) );
- String sqllocal1 = "SELECT nome FROM estabelecimentos WHERE id = " + a.getEstabelecimento_id();
- ResultSet rslocal1 = stlocal1.executeQuery( sqllocal1 );
- rslocal1.first();
- a.setNome_estabelecimento( utils.Utils.unicodeToHTML( rslocal1.getString( "nome" ) ) );
-
- a.setEstado( new Integer( rs.getInt( "estado" ) ) );
- a.setEstado_assinatura( new Integer( rs.getInt( "estado_assinatura" ) ) );
- a.setFase( getFase( a.getEstado().intValue() ) );
- a.setAcidentado_id( new Integer( rs.getInt( "acidentado_id" ) ) );
- Acidentado ac = getAcidentado( a.getAcidentado_id() );
- String sqllocal = "SELECT nome, numero_mecanografico FROM trabalhadores WHERE id = " + ac.getTrabalhador_id();
- ResultSet rslocal = stlocal.executeQuery( sqllocal );
- String nome_acidentado = "";
- String numero_mecanografico = "";
- if ( rslocal.first() )
- {
- nome_acidentado = rslocal.getString( "nome" );
- numero_mecanografico = rslocal.getString( "numero_mecanografico" );
- }
- a.setNome_acidentado( utils.Utils.unicodeToHTML( nome_acidentado ) );
- a.setNumero_mecanografico( numero_mecanografico );
- Object horas_turno = rs.getObject( "horas_turno" );
- if ( horas_turno == null )
- {
- a.setHoras_turno( null );
- }
- else
- {
- a.setHoras_turno( new Integer( rs.getInt( "horas_turno" ) ) );
- }
+ private ArrayList< AnaliseAcidente > fillAnaliseFields( Virtual2DArray rs ) throws Exception
+ {
+ ArrayList< AnaliseAcidente > list = new ArrayList< AnaliseAcidente >();
+ if( rs.rowCount() > 0 ) //rs not empty
+ {
+ Expression exp;
+ Select select;
+ Virtual2DArray subresult;
+ String nome_estabelecimento;
+ Acidentado ac;
+ Integer acidentado_id;
+ Integer estabelecimento_id;
+ String nome_acidentado;
+ String numero_mecanografico;
+ Integer estado;
- a.setAveriguador( rs.getString( "averiguador" ) );
- //a.setSeccao(rs.getString("seccao"));
- a.setDepartamento_id( new Integer( rs.getInt( "departamento_id" ) ) );
- a.setSeccao_id( new Integer( rs.getInt( "seccao_id" ) ) );
- a.setLocal_trabalho( rs.getString( "local_trabalho" ) );
- a.setTarefa( rs.getString( "tarefa" ) );
- a.setSubstancias( rs.getString( "substancias" ) );
-// a.setSuperior_hierarquico(rs.getString("superior_hierarquico"));
- a.setCondicoes( rs.getString( "condicoes" ) );
- a.setTestemunhas( rs.getString( "testemunhas" ) );
- a.setCausas( new Integer( rs.getInt( "causas" ) ) );
- a.setDescricao( rs.getString( "descricao" ) );
- a.setConclusoes( rs.getString( "conclusoes" ) );
- a.setAccoes( rs.getString( "accoes" ) );
- a.setAveriguacao_posterior( rs.getString( "averiguacao_posterior" ) );
- a.setAveriguacao_obs( rs.getString( "averiguacao_obs" ) );
-
- a.setHora_acidente( rs.getTime( "hora_acidente" ) );
- a.setFormacao_shst( rs.getString( "formacao_shst" ) );
- Object o = rs.getString( "formacao_shst_nao_porque" );
- if ( o == null )
- {
- a.setFormacao_shst_nao_porque( "" );
- }
- else
+ for( int i = 0; i < rs.rowCount(); i++ )
{
- a.setFormacao_shst_nao_porque( rs.getString( "formacao_shst_nao_porque" ) );
+
+
+ estabelecimento_id = rs.get( i, "estabelecimento_id" );
+ acidentado_id = rs.get( i, "acidentado_id" );
+ ac = getAcidentado( acidentado_id );
+
+ exp = new Field( db.data.siprp_local.outer.EstabelecimentosData.ID_FULL ).isEqual( estabelecimento_id );
+ select = new Select2( db.data.siprp_local.outer.EstabelecimentosData.TABLENAME, exp, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL );
+ subresult = getLocalExecuter().executeQuery( select );
+ nome_estabelecimento = ( subresult.rowCount() > 0 ) ? ( String ) subresult.get( 0, "nome" ) : "";
+
+ exp = new Field( db.data.siprp_local.outer.TrabalhadoresData.ID_FULL ).isEqual( ac.getTrabalhador_id() );
+ select = new Select2( db.data.siprp_local.outer.TrabalhadoresData.TABLENAME, exp, db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL, db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL );
+ subresult = getLocalExecuter().executeQuery( select );
+ nome_acidentado = ( subresult.rowCount() > 0 ) ? ( String ) subresult.get( 0, "nome" ) : "";
+ numero_mecanografico = ( subresult.rowCount() > 0 ) ? ( String ) subresult.get( 0, "numero_mecanografico" ) : "";
+
+ estado = rs.get( i, "estado" );
+
+ AnaliseAcidente acidente = AnaliseAcidente
+ .build()
+ .withId( ( Integer ) rs.get( i, "id" ) )
+ .withNr( i )
+ .withData_acidente( ( java.sql.Date ) rs.get( i, "data_acidente" ) )
+ .withEmpresa_id( ( Integer ) rs.get( i, "empresa_id" ) )
+ .withEstabelecimento_id( estabelecimento_id )
+ .withNome_estabelecimento( Utils.unicodeToHTML( nome_estabelecimento ) )
+ .withEstado( estado )
+ .withEstado_assinatura( ( Integer ) rs.get( i, "estado_assinatura" ) )
+ .withFase( getFase( estado ) )
+ .withAcidentado_id( acidentado_id )
+ .withNome_acidentado( Utils.unicodeToHTML( nome_acidentado ) )
+ .withNumero_mecanografico( numero_mecanografico )
+ .withHoras_turno( ( Integer ) rs.get( i, "horas_turno" ) )
+ .withAveriguador( ( String ) rs.get( i, "averiguador" ) )
+ .withDepartamento_id( ( Integer ) rs.get( i, "departamento_id" ) )
+ .withSeccao_id( ( Integer ) rs.get( i, "seccao_id" ) )
+ .withLocal_trabalho( ( String ) rs.get( i, "local_trabalho" ) );
+
+
+ acidente = acidente
+ .withTarefa( ( String ) rs.get( i, "tarefa" ) )
+ .withSubstancias( ( String ) rs.get( i, "substancias" ) )
+ .withCondicoes( ( String ) rs.get( i, "condicoes" ) )
+ .withTestemunhas( ( String ) rs.get( i, "testemunhas" ) )
+ .withCausas( ( Integer ) rs.get( i, "causas" ) )
+ .withDescricao( ( String ) rs.get( i, "descricao" ) )
+ .withConclusoes( ( String ) rs.get( i, "conclusoes" ) )
+ .withAccoes( ( String ) rs.get( i, "accoes" ) )
+ .withAveriguacao_posterior( ( String ) rs.get( i, "averiguacao_posterior" ) )
+ .withAveriguacao_obs( ( String ) rs.get( i, "averiguacao_obs" ) )
+ .withHora_acidente( ( java.sql.Time ) rs.get( i, "hora_acidente" ) )
+ .withFormacao_shst( ( String ) rs.get( i, "formacao_shst" ) )
+ .withFormacao_shst_nao_porque( Strings.nullToEmpty( ( String ) rs.get( i, "formacao_shst_nao_porque" ) ) );
+
+
+ acidente = acidente
+ .withOutros_acidentes_com_colaborador( ( String ) rs.get( i, "outros_acidentes_com_colaborador" ) )
+ .withNr_acidentes_com_colaborador( ( Integer ) rs.get( i, "nr_acidentes_com_colaborador" ) )
+ .withNr_relatorio_acidente_colaborador1( ( Integer ) rs.get( i, "nr_relatorio_acidente_colaborador1" ) )
+ .withNr_relatorio_acidente_colaborador2( ( Integer ) rs.get( i, "nr_relatorio_acidente_colaborador2" ) )
+ .withNr_relatorio_acidente_colaborador3( ( Integer ) rs.get( i, "nr_relatorio_acidente_colaborador3" ) )
+ .withNr_relatorio_acidente_colaborador4( ( Integer ) rs.get( i, "nr_relatorio_acidente_colaborador4" ) )
+ .withAcidentes_outros_colaboradores( ( String ) rs.get( i, "acidentes_outros_colaboradores" ) )
+ .withNr_acidentes_outros_colaboradores( ( Integer ) rs.get( i, "nr_acidentes_outros_colaboradores" ) )
+ .withNr_relatorio_acidente_outros_colaboradores1( ( Integer ) rs.get( i, "nr_relatorio_acidente_outros_colaboradores1" ) )
+ .withNr_relatorio_acidente_outros_colaboradores2( ( Integer ) rs.get( i, "nr_relatorio_acidente_outros_colaboradores2" ) )
+ .withNr_relatorio_acidente_outros_colaboradores3( ( Integer ) rs.get( i, "nr_relatorio_acidente_outros_colaboradores3" ) )
+ .withNr_relatorio_acidente_outros_colaboradores4( ( Integer ) rs.get( i, "nr_relatorio_acidente_outros_colaboradores4" ) )
+ .withLesao_cabeca( ( String ) rs.get( i, "lesao_cabeca" ) )
+ .withLesao_pescoco( ( String ) rs.get( i, "lesao_pescoco" ) )
+ .withLesao_tronco( ( String ) rs.get( i, "lesao_tronco" ) );
+
+ acidente = acidente
+ .withLesao_membro_sup_dir( ( String ) rs.get( i, "lesao_membro_sup_dir" ) )
+ .withLesao_membro_sup_esq( ( String ) rs.get( i, "lesao_membro_sup_esq" ) )
+ .withLesao_membro_inf_dir( ( String ) rs.get( i, "lesao_membro_inf_dir" ) )
+ .withLesao_membro_inf_esq( ( String ) rs.get( i, "lesao_membro_inf_esq" ) )
+ .withEspecif1( Strings.nullToEmpty( ( String ) rs.get( i, "especif1" ) ) )
+ .withEspecif2( Strings.nullToEmpty( ( String ) rs.get( i, "especif2" ) ) )
+ .withEspecif3( Strings.nullToEmpty( ( String ) rs.get( i, "especif3" ) ) )
+ .withEspecif4( Strings.nullToEmpty( ( String ) rs.get( i, "especif4" ) ) )
+ .withTipo_lesao( Strings.nullToEmpty( ( String ) rs.get( i, "tipo_lesao" ) ) )
+ .withTipo_incapacidade( ( String ) rs.get( i, "tipo_incapacidade" ) )
+ .withCoef_incapacidade( ( Integer ) rs.get( i, "coef_incapacidade" ) )
+ .withData_aval_incapacidade( ( java.sql.Date ) rs.get( i, "data_aval_incapacidade" ) )
+ .withData_rev_incapacidade( ( java.sql.Date ) rs.get( i, "data_rev_incapacidade" ) )
+ .withPeriodo_incapacidade_de( ( java.sql.Date ) rs.get( i, "periodo_incapacidade_de" ) )
+ .withPeriodo_incapacidade_a( ( java.sql.Date ) rs.get( i, "periodo_incapacidade_a" ) );
+
+ acidente = acidente
+ .withImg_flexao( ( String ) rs.get( i, "img_flexao" ) )
+ .withImg_ext1( ( String ) rs.get( i, "img_ext1" ) )
+ .withImg_ext2( ( String ) rs.get( i, "img_ext2" ) )
+ .withImg_cab2( ( String ) rs.get( i, "img_cab2" ) )
+ .withImg_cab3( ( String ) rs.get( i, "img_cab3" ) )
+ .withImg_ma2( ( String ) rs.get( i, "img_ma2" ) )
+ .withImg_ma3( ( String ) rs.get( i, "img_ma3" ) )
+ .withImg_ma5( ( String ) rs.get( i, "img_ma5" ) )
+ .withImg_ma6( ( String ) rs.get( i, "img_ma6" ) )
+ .withImg_ma8( ( String ) rs.get( i, "img_ma8" ) )
+ .withImg_ma10( ( String ) rs.get( i, "img_ma10" ) )
+ .withImg_rot1( ( String ) rs.get( i, "img_rot1" ) )
+ .withImg_rot2( ( String ) rs.get( i, "img_rot2" ) )
+ .withImg_cab1( ( String ) rs.get( i, "img_cab1" ) )
+ .withImg_cab4( ( String ) rs.get( i, "img_cab4" ) )
+ .withImg_ma1( ( String ) rs.get( i, "img_ma1" ) )
+ .withImg_ma4( ( String ) rs.get( i, "img_ma4" ) )
+ .withImg_ma7( ( String ) rs.get( i, "img_ma7" ) )
+ .withImg_ma9( ( String ) rs.get( i, "img_ma9" ) );
+
+ acidente = acidente
+ .withRestricao_carga( ( Integer ) rs.get( i, "restricao_carga" ) )
+ .withRestricao_motricidade( ( String ) rs.get( i, "restricao_motricidade" ) )
+ .withRestricao_conducao( ( String ) rs.get( i, "restricao_conducao" ) )
+ .withRestricao_vibracoes( ( String ) rs.get( i, "restricao_vibracoes" ) )
+ .withRestricao_outras( Strings.nullToEmpty( ( String ) rs.get( i, "restricao_outras" ) ) )
+ .withMed_observ( Strings.nullToEmpty( ( String ) rs.get( i, "med_observ" ) ) )
+ .withAnalise_nr( ( String ) rs.get( i, "analise_nr" ) )
+ .withMedico_id( ( Integer ) rs.get( i, "medico_id" ) )
+ .withTecnico_saude_id( ( Integer ) rs.get( i, "tecnico_saude_id" ) )
+ .withAss_resp_seg( ( String ) rs.get( i, "ass_resp_seg" ) )
+ .withAss_resp_rh( ( String ) rs.get( i, "ass_resp_rh" ) )
+ .withAss_consolidacao( ( String ) rs.get( i, "ass_consolidacao" ) );
+
+ acidente = acidente
+ .withData_consolidacao( ( java.sql.Date ) rs.get( i, "data_consolidacao" ) )
+ .withData_assinatura_seg( ( java.sql.Date ) rs.get( i, "data_assinatura_seg" ) )
+ .withData_assinatura_rh( ( java.sql.Date ) rs.get( i, "data_assinatura_rh" ) )
+ .withNome_resp_seg( ( String ) rs.get( i, "nome_resp_seg" ) )
+ .withNome_resp_rh( ( String ) rs.get( i, "nome_resp_rh" ) )
+ .withCorrecao( ( String ) rs.get( i, "correcao" ) )
+ .withObservacoes_correcao( ( String ) rs.get( i, "observacoes_correcao" ) )
+ .withEstado_antes_correcao( ( Integer ) rs.get( i, "estado_antes_correcao" ) )
+ .withAss_superior( ( String ) rs.get( i, "ass_superior" ) )
+ .withNome_superior( ( String ) rs.get( i, "nome_superior" ) )
+ .withData_assinatura_superior( ( java.sql.Date ) rs.get( i, "data_assinatura_superior" ) )
+ .withData_inicio_processo( ( java.sql.Date ) rs.get( i, "data_inicio_processo" ) )
+ .withNome_resp_consolidacao( ( String ) rs.get( i, "nome_resp_consolidacao" ) );
+
+ acidente = acidente
+ .withRh_fase4( ( Integer ) rs.get( i, "rh_fase4" ) )
+ .withConcluido_por_desactivacao( ( Boolean ) rs.get( i, "concluido_por_desactivacao" ) )
+ .withData_desactivacao( ( Date ) rs.get( i, "data_desactivacao" ) )
+ .withComentario_desactivacao( ( String ) rs.get( i, "comentario_desactivacao" ) )
+ .withParticipado( "y".equals( rs.get( i, "participado" ) ) )
+ .withNomeResponsavelParticipacao( ( String ) rs.get( i, "nome_responsavel_participacao" ) )
+ .withDataParticipacao( ( Date ) rs.get( i, "data_participacao" ) )
+ .end();
+
+ list.add( acidente );
}
- a.setOutros_acidentes_com_colaborador( rs.getString( "outros_acidentes_com_colaborador" ) );
- a.setNr_acidentes_com_colaborador( new Integer( rs.getInt( "nr_acidentes_com_colaborador" ) ) );
- a.setNr_relatorio_acidente_colaborador1( new Integer( rs.getInt( "nr_relatorio_acidente_colaborador1" ) ) );
- a.setNr_relatorio_acidente_colaborador2( new Integer( rs.getInt( "nr_relatorio_acidente_colaborador2" ) ) );
- a.setNr_relatorio_acidente_colaborador3( new Integer( rs.getInt( "nr_relatorio_acidente_colaborador3" ) ) );
- a.setNr_relatorio_acidente_colaborador4( new Integer( rs.getInt( "nr_relatorio_acidente_colaborador4" ) ) );
- a.setAcidentes_outros_colaboradores( rs.getString( "acidentes_outros_colaboradores" ) );
- a.setNr_acidentes_outros_colaboradores( new Integer( rs.getInt( "nr_acidentes_outros_colaboradores" ) ) );
- a.setNr_relatorio_acidente_outros_colaboradores1( new Integer( rs.getInt( "nr_relatorio_acidente_outros_colaboradores1" ) ) );
- a.setNr_relatorio_acidente_outros_colaboradores2( new Integer( rs.getInt( "nr_relatorio_acidente_outros_colaboradores2" ) ) );
- a.setNr_relatorio_acidente_outros_colaboradores3( new Integer( rs.getInt( "nr_relatorio_acidente_outros_colaboradores3" ) ) );
- a.setNr_relatorio_acidente_outros_colaboradores4( new Integer( rs.getInt( "nr_relatorio_acidente_outros_colaboradores4" ) ) );
-
- a.setLesao_cabeca( rs.getString( "lesao_cabeca" ) );
- a.setLesao_pescoco( rs.getString( "lesao_pescoco" ) );
- a.setLesao_tronco( rs.getString( "lesao_tronco" ) );
- a.setLesao_membro_sup_dir( rs.getString( "lesao_membro_sup_dir" ) );
- a.setLesao_membro_sup_esq( rs.getString( "lesao_membro_sup_esq" ) );
- a.setLesao_membro_inf_dir( rs.getString( "lesao_membro_inf_dir" ) );
- a.setLesao_membro_inf_esq( rs.getString( "lesao_membro_inf_esq" ) );
- Object ob = rs.getString( "especif1" );
- if ( ob == null )
- {
- a.setEspecif1( "" );
- }
- else
- {
- a.setEspecif1( rs.getString( "especif1" ) );
- }
- ob = rs.getString( "especif2" );
- if ( ob == null )
- {
- a.setEspecif2( "" );
- }
- else
- {
- a.setEspecif2( rs.getString( "especif2" ) );
- }
- ob = rs.getString( "especif3" );
- if ( ob == null )
- {
- a.setEspecif3( "" );
- }
- else
- {
- a.setEspecif3( rs.getString( "especif3" ) );
- }
- ob = rs.getString( "especif4" );
- if ( ob == null )
- {
- a.setEspecif4( "" );
- }
- else
- {
- a.setEspecif4( rs.getString( "especif4" ) );
- }
- ob = rs.getString( "tipo_lesao" );
- if ( ob == null )
- {
- a.setTipo_lesao( "" );
- }
- else
- {
- a.setTipo_lesao( rs.getString( "tipo_lesao" ) );
- }
-
- a.setTipo_incapacidade( rs.getString( "tipo_incapacidade" ) );
- //a.setCoef_incapacidade(new Integer(( rs.getInt("coef_incapacidade") )));
- a.setCoef_incapacidade( ( Integer ) rs.getObject( "coef_incapacidade" ) );
- a.setData_aval_incapacidade( rs.getDate( "data_aval_incapacidade" ) );
- a.setData_rev_incapacidade( rs.getDate( "data_rev_incapacidade" ) );
- a.setPeriodo_incapacidade_de( rs.getDate( "periodo_incapacidade_de" ) );
- a.setPeriodo_incapacidade_a( rs.getDate( "periodo_incapacidade_a" ) );
- a.setImg_flexao( rs.getString( "img_flexao" ) );
- a.setImg_ext1( rs.getString( "img_ext1" ) );
- a.setImg_ext2( rs.getString( "img_ext2" ) );
- a.setImg_cab2( rs.getString( "img_cab2" ) );
- a.setImg_cab3( rs.getString( "img_cab3" ) );
- a.setImg_ma2( rs.getString( "img_ma2" ) );
- a.setImg_ma3( rs.getString( "img_ma3" ) );
- a.setImg_ma5( rs.getString( "img_ma5" ) );
- a.setImg_ma6( rs.getString( "img_ma6" ) );
- a.setImg_ma8( rs.getString( "img_ma8" ) );
- a.setImg_ma10( rs.getString( "img_ma10" ) );
- a.setImg_rot1( rs.getString( "img_rot1" ) );
- a.setImg_rot2( rs.getString( "img_rot2" ) );
- a.setImg_cab1( rs.getString( "img_cab1" ) );
- a.setImg_cab4( rs.getString( "img_cab4" ) );
- a.setImg_ma1( rs.getString( "img_ma1" ) );
- a.setImg_ma4( rs.getString( "img_ma4" ) );
- a.setImg_ma7( rs.getString( "img_ma7" ) );
- a.setImg_ma9( rs.getString( "img_ma9" ) );
- a.setRestricao_carga( new Integer( rs.getInt( "restricao_carga" ) ) );
- a.setRestricao_motricidade( rs.getString( "restricao_motricidade" ) );
- a.setRestricao_conducao( rs.getString( "restricao_conducao" ) );
- a.setRestricao_vibracoes( rs.getString( "restricao_vibracoes" ) );
- ob = rs.getString( "restricao_outras" );
- if ( ob == null )
- {
- a.setRestricao_outras( "" );
- }
- else
- {
- a.setRestricao_outras( rs.getString( "restricao_outras" ) );
- }
- ob = rs.getString( "med_observ" );
- if ( ob == null )
- {
- a.setMed_observ( "" );
- }
- else
- {
- a.setMed_observ( rs.getString( "med_observ" ) );
- }
- a.setAnalise_nr( rs.getString( "analise_nr" ) );
- a.setMedico_id( new Integer( rs.getInt( "medico_id" ) ) );
- a.setTecnico_saude_id( new Integer( rs.getInt( "tecnico_saude_id" ) ) );
-
- //a.setAss_hs(rs.getString("ass_hs"));
- //a.setAss_seg(rs.getString("ass_seg"));
- a.setAss_resp_seg( rs.getString( "ass_resp_seg" ) );
- //a.setAss_med(rs.getString("ass_med"));
- a.setAss_resp_rh( rs.getString( "ass_resp_rh" ) );
- a.setAss_consolidacao( rs.getString( "ass_consolidacao" ) );
- a.setData_consolidacao( rs.getDate( "data_consolidacao" ) );
- a.setData_assinatura_seg( rs.getDate( "data_assinatura_seg" ) );
- a.setData_assinatura_rh( rs.getDate( "data_assinatura_rh" ) );
- a.setNome_resp_seg( rs.getString( "nome_resp_seg" ) );
- a.setNome_resp_rh( rs.getString( "nome_resp_rh" ) );
- a.setCorrecao( rs.getString( "correcao" ) );
- a.setObservacoes_correcao( rs.getString( "observacoes_correcao" ) );
- a.setEstado_antes_correcao( new Integer( rs.getInt( "estado_antes_correcao" ) ) );
- a.setAss_superior( rs.getString( "ass_superior" ) );
- a.setNome_superior( rs.getString( "nome_superior" ) );
- a.setData_assinatura_superior( rs.getDate( "data_assinatura_superior" ) );
- a.setData_inicio_processo( rs.getDate( "data_inicio_processo" ) );
- a.setNome_resp_consolidacao( rs.getString( "nome_resp_consolidacao" ) );
- //System.out.println("ANALISE NR : " + a.getAnalise_nr());
- a.setRh_fase4( new Integer( rs.getInt( "rh_fase4" ) ) );
-
- a.setConcluido_por_desactivacao( rs.getBoolean( "concluido_por_desactivacao" ) );
- a.setData_desactivacao( rs.getDate( "data_desactivacao" ) );
- a.setComentario_desactivacao( rs.getString( "comentario_desactivacao" ) );
- a.setParticipado( "y".equals( rs.getString( "participado" ) ) );
- a.setNomeResponsavelParticipacao( rs.getString( "nome_responsavel_participacao" ) );
- a.setDataParticipacao( rs.getDate( "data_participacao" ) );
- list.add( a );
- }
- while ( rs.next() );
-
+ }
return list;
}
- public ArrayList searchTrabalhador( Integer empresa_id, Integer estabelecimento_id, String nrMecanografico, String nome )
+ public ArrayList< Trabalhador > searchTrabalhador( Integer empresa_id, Integer estabelecimento_id, String nrMecanografico, String nome )
throws Exception
{
- ArrayList list = new ArrayList();
+ ArrayList< Trabalhador > list = new ArrayList< Trabalhador >();
+
+// All
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ String[] fields = { db.data.siprp_local.outer.TrabalhadoresData.ID_FULL, db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL, db.data.siprp_local.outer.TrabalhadoresData.DATA_NASCIMENTO_FULL,
+ db.data.siprp_local.outer.TrabalhadoresData.FUNCAO_PROPOSTA_FULL, db.data.siprp_local.outer.TrabalhadoresData.DATA_ADMISSAO_FULL,
+ db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL, db.data.siprp_local.outer.EstabelecimentosData.ID_FULL, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL };
+
+ String[] tables = { db.data.siprp_local.outer.TrabalhadoresData.TABLENAME, db.data.siprp_local.outer.EstabelecimentosData.TABLENAME };
+
+ Expression[] joinExp = { new Field( db.data.siprp_local.outer.TrabalhadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( new Field( db.data.siprp_local.outer.EstabelecimentosData.ID_FULL ) ) };
+
+ Integer[] joinTypes = { Select2.JOIN_INNER };
+
+ Expression whereExp = new Field( db.data.siprp_local.outer.EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( empresa_id )
+ .and( new Field( db.data.siprp_local.outer.TrabalhadoresData.INACTIVO_FULL ).isEqual( "n" ) );
+
+ String[] order = { db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL };
+
+// trabalhadores do estabelecimento
+
+ Expression firstWhereExp = whereExp.and( new Field( db.data.siprp_local.outer.EstabelecimentosData.ID_FULL ).isEqual( estabelecimento_id ) );
- String sql = "";
- // trabalhadores do estabelecimento
if ( nrMecanografico != null )
{
if ( nome != null )
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id = " + estabelecimento_id + " AND (trabalhadores.nome LIKE '%" + nome + "%' OR LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%') AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
+ firstWhereExp = firstWhereExp.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL ).isLike( "%" + nome + "%" ).or( new Field( "lower(" + db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL + ")" ).isLike( "%" + nrMecanografico.toLowerCase() + "%" ) ) );
}
else
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id = " + estabelecimento_id + " AND LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
+ firstWhereExp = firstWhereExp.and( new Field( "lower(" + db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL + ")" ).isLike( "%" + nrMecanografico.toLowerCase() + "%" ) );
}
}
else
{
if ( nome != null )
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id = " + estabelecimento_id + " AND trabalhadores.nome LIKE '%" + nome + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
+ firstWhereExp = firstWhereExp.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL ).isLike( "%" + nome + "%" ) );
}
}
- System.out.println( "TRABALHADORES SQL B : " + sql );
- ResultSet rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+ Select select = new Select2( tables, joinTypes, joinExp, fields, firstWhereExp, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+ Virtual2DArray result = getLocalExecuter().executeQuery( select );
+
+ for( int i = 0; i < result.rowCount(); i++ )
{
- rslocal.first();
- do
- {
- Trabalhador t = new Trabalhador();
- t.setId( new Integer( rslocal.getInt( 1 ) ) ); //id
- String nome_trab = rslocal.getString( 2 );
- t.setNome( utils.Utils.unicodeToHTML( nome_trab ) );
- t.setData_nascimento( rslocal.getDate( "data_nascimento" ) );
- t.setFuncao( rslocal.getString( "funcao_proposta" ) );
- t.setData_admissao( rslocal.getDate( "data_admissao" ) );
- t.setNumero_mecanografico( rslocal.getString( "numero_mecanografico" ) );
- t.setEstabelecimento_id( new Integer( rslocal.getInt( 7 ) ) );
- //if(nome != null)
- //{
- t.setEstabelecimento( utils.Utils.unicodeToHTML( rslocal.getString( 8 ) ) );
- //}
-
- list.add( t );
- }
- while ( rslocal.next() );
+ Integer rId = result.get( i, 0 );
+ String rNome = result.get( i, 1 );
+ Date rDataNascimento = result.get( i, 2 );
+ String rFuncao = result.get( i, 3 );
+ Date rDataAdmissao = result.get( i, 4 );
+ String rNumeroMecanografico = result.get( i, 5 );
+ Integer rEstabelecimentoId = result.get( i, 6 );
+ String rEstabelecimentoNome = result.get( i, 7 );
+
+ Trabalhador trabalhador = Trabalhador
+ .createTrabalhador()
+ .withId( rId )
+ .withNome( rNome )
+ .withData_nascimento( new java.sql.Date( rDataNascimento.getTime() ) )
+ .withFuncao( rFuncao )
+ .withData_admissao( new java.sql.Date( rDataAdmissao.getTime() ) )
+ .withNumero_mecanografico( rNumeroMecanografico )
+ .withEstabelecimento_id( rEstabelecimentoId )
+ .withEstabelecimento( rEstabelecimentoNome );
+
+ list.add( trabalhador );
}
+//restantes trabalhadores
+
+ Expression secondWhereExp = whereExp.and( new Field( db.data.siprp_local.outer.EstabelecimentosData.ID_FULL ).isDifferent( estabelecimento_id ) );
- //restantes trabalhadores
if ( nrMecanografico != null )
{
if ( nome != null )
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id <> " + estabelecimento_id + " AND (trabalhadores.nome LIKE '%" + nome + "%' OR LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%') AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n';";
+ secondWhereExp = secondWhereExp.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL ).isLike( "%" + nome + "%" ).or( new Field( "lower(" + db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL + ")" ).isLike( "%" + nrMecanografico.toLowerCase() + "%" ) ) );
}
else
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id <> " + estabelecimento_id + " AND LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n';";
+ secondWhereExp = secondWhereExp.and( new Field( "lower(" + db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL + ")" ).isLike( "%" + nrMecanografico.toLowerCase() + "%" ) );
}
}
else
{
if ( nome != null )
{
- sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND estabelecimento_id <> " + estabelecimento_id + " AND trabalhadores.nome LIKE '%" + nome + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
+ secondWhereExp = secondWhereExp.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL ).isLike( "%" + nome + "%" ) );
}
}
-// if(nrMecanografico != null)
-// {
-// sql = "SELECT * FROM trabalhadores WHERE LOWER(numero_mecanografico) = '" + nrMecanografico.toLowerCase() + "'";
-// }
-// else if(nome != null)
-// {
-// sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND trabalhadores.nome LIKE '%" + nome + "%'";
-// }
- System.out.println( "TRABALHADORES SQL : " + sql );
- rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+ select = new Select2( tables, joinTypes, joinExp, fields, secondWhereExp, order, null, null, null );
+
+ System.out.println( "SQL: " + select.toString() );
+
+ result = getLocalExecuter().executeQuery( select );
+
+ for( int i = 0; i < result.rowCount(); i++ )
{
- rslocal.first();
- do
- {
- Trabalhador t = new Trabalhador();
- t.setId( new Integer( rslocal.getInt( 1 ) ) ); //id
- String nome_trab = rslocal.getString( 2 );
- t.setNome( utils.Utils.unicodeToHTML( nome_trab ) );
- t.setData_nascimento( rslocal.getDate( "data_nascimento" ) );
- t.setFuncao( rslocal.getString( "funcao_proposta" ) );
- t.setData_admissao( rslocal.getDate( "data_admissao" ) );
- t.setNumero_mecanografico( rslocal.getString( "numero_mecanografico" ) );
- t.setEstabelecimento_id( new Integer( rslocal.getInt( 7 ) ) );
- //if(nome != null)
- //{
- t.setEstabelecimento( utils.Utils.unicodeToHTML( rslocal.getString( 8 ) ) );
- //}
-
- list.add( t );
- }
- while ( rslocal.next() );
+ Integer rId = result.get( i, 0 );
+ String rNome = result.get( i, 1 );
+ Date rDataNascimento = result.get( i, 2 );
+ String rFuncao = result.get( i, 3 );
+ Date rDataAdmissao = result.get( i, 4 );
+ String rNumeroMecanografico = result.get( i, 5 );
+ Integer rEstabelecimentoId = result.get( i, 6 );
+ String rEstabelecimentoNome = result.get( i, 7 );
+
+ Trabalhador trabalhador = Trabalhador
+ .createTrabalhador()
+ .withId( rId )
+ .withNome( rNome )
+ .withData_nascimento( new java.sql.Date( rDataNascimento.getTime() ) )
+ .withFuncao( rFuncao )
+ .withData_admissao( new java.sql.Date( rDataAdmissao.getTime() ) )
+ .withNumero_mecanografico( rNumeroMecanografico )
+ .withEstabelecimento_id( rEstabelecimentoId )
+ .withEstabelecimento( rEstabelecimentoNome );
+
+ list.add( trabalhador );
}
+
return list;
}
- public ArrayList searchTrabalhador( Integer empresa_id, String nrMecanografico, String nome ) throws Exception
+ public ArrayList< Trabalhador > searchTrabalhador( Integer empresa_id, String nrMecanografico, String nome ) throws Exception
{
- ArrayList list = new ArrayList();
-
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
-// String sql = "";
+ ArrayList< Trabalhador > list = new ArrayList< Trabalhador >();
- StringTokenizer st = null;
+ StringTokenizer st;
- Expression expr = new Field( EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( empresa_id ).and(
- new Field( TrabalhadoresData.INACTIVO_FULL ).isEqual( "n" ) ).and(
- new Field( EstabelecimentosData.INACTIVO_FULL ).isEqual( "n" ) );
-
-
+ Expression expr = new Field( db.data.siprp_local.outer.EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( empresa_id ).and(
+ new Field( db.data.siprp_local.outer.TrabalhadoresData.INACTIVO_FULL ).isEqual( "n" ) ).and( new Field( db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL ).isEqual( "n" ) );
if( nome != null )
{
st = new StringTokenizer( nome );
while ( st.hasMoreTokens() )
{
- expr = expr.and( new Field( TrabalhadoresData.NOME_FULL ).isILike( "%" + st.nextToken() + "%" ) );
+ expr = expr.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL ).isILike( "%" + st.nextToken() + "%" ) );
}
}
if ( nrMecanografico != null )
{
- expr = expr.and( new Field( TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL ).isILike( nrMecanografico.toLowerCase() ) );
+ expr = expr.and( new Field( db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL ).isILike( nrMecanografico.toLowerCase() ) );
}
Select select =
- new Select2( new String[]{ TrabalhadoresData.TABLENAME, EstabelecimentosData.TABLENAME },
+ new Select2( new String[]{ db.data.siprp_local.outer.TrabalhadoresData.TABLENAME, db.data.siprp_local.outer.EstabelecimentosData.TABLENAME },
new Integer[]{ Select2.JOIN_INNER },
- new Expression[]{ new Field( TrabalhadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( new Field( EstabelecimentosData.ID_FULL ) ) },
- new String[]{ TrabalhadoresData.ID_FULL, TrabalhadoresData.NOME_FULL, TrabalhadoresData.DATA_NASCIMENTO_FULL,
- TrabalhadoresData.FUNCAO_PROPOSTA_FULL, TrabalhadoresData.DATA_ADMISSAO_FULL, TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL,
- EstabelecimentosData.ID_FULL, EstabelecimentosData.NOME_FULL },
+ new Expression[]{ new Field( db.data.siprp_local.outer.TrabalhadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( new Field( EstabelecimentosData.ID_FULL ) ) },
+ new String[]{ db.data.siprp_local.outer.TrabalhadoresData.ID_FULL, db.data.siprp_local.outer.TrabalhadoresData.NOME_FULL, db.data.siprp_local.outer.TrabalhadoresData.DATA_NASCIMENTO_FULL,
+ db.data.siprp_local.outer.TrabalhadoresData.FUNCAO_PROPOSTA_FULL, db.data.siprp_local.outer.TrabalhadoresData.DATA_ADMISSAO_FULL, db.data.siprp_local.outer.TrabalhadoresData.NUMERO_MECANOGRAFICO_FULL,
+ db.data.siprp_local.outer.EstabelecimentosData.ID_FULL, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL },
expr,
null,
null,
null,
null );
-// if ( nrMecanografico != null )
-// {
-// if ( nome != null )
-// {
-//
-//
-//// String sql1 = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND (";
-//// String sql2 = "";
-//// String sql3 = ") AND LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
-//// st = new StringTokenizer( nome );
-//// int n = 0;
-//// while ( st.hasMoreTokens() )
-//// {
-//// if ( n > 0 )
-//// {
-//// sql2 += "AND ";
-//// }
-//// sql2 += "trabalhadores.nome LIKE '%" + st.nextToken() + "%' ";
-//// n++;
-//// }
-//// sql = sql1 + sql2 + sql3;
-// //sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND (trabalhadores.nome LIKE '%" + nome + "%' AND LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%') AND estabelecimentos.empresa_id = " + empresa_id;
-// }
-// else
-// {
-//// sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND LOWER(numero_mecanografico) LIKE '%" + nrMecanografico.toLowerCase() + "%' AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
-// }
-// }
-// else
-// {
-// if ( nome != null )
-// {
-//// //sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND trabalhadores.nome LIKE '%" + nome + "%' AND estabelecimentos.empresa_id = " + empresa_id;
-//// String sql1 = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.id, estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND (";
-//// String sql2 = "";
-//// String sql3 = ") AND estabelecimentos.empresa_id = " + empresa_id + " AND trabalhadores.inactivo = 'n'";
-//// st = new StringTokenizer( nome );
-//// int n = 0;
-//// while ( st.hasMoreTokens() )
-//// {
-//// if ( n > 0 )
-//// {
-//// sql2 += "AND ";
-//// }
-//// sql2 += "trabalhadores.nome LIKE '%" + st.nextToken() + "%' ";
-//// n++;
-//// }
-//// sql = sql1 + sql2 + sql3;
-//
-// }
-// }
System.out.println( "TRABALHADORES SQL (NOVO) : " + select );
-// if(nrMecanografico != null)
-// {
-// sql = "SELECT * FROM trabalhadores WHERE LOWER(numero_mecanografico) = '" + nrMecanografico.toLowerCase() + "'";
-// }
-// else if(nome != null)
-// {
-// sql = "SELECT trabalhadores.id, trabalhadores.nome, data_nascimento, funcao_proposta, data_admissao, numero_mecanografico , estabelecimentos.nome FROM trabalhadores, estabelecimentos WHERE estabelecimento_id = estabelecimentos.id AND trabalhadores.nome LIKE '%" + nome + "%'";
-// }
-// ResultSet rslocal = stlocal.executeQuery( sql );
-// rslocal.first();
+
Virtual2DArray array = getLocalExecuter().executeQuery( select );
-// do
-// {
-// Trabalhador t = new Trabalhador();
-// t.setId( new Integer( rslocal.getInt( 1 ) ) ); //id
-// String nome_trab = rslocal.getString( 2 );
-// t.setNome( utils.Utils.unicodeToHTML( nome_trab ) );
-// t.setData_nascimento( rslocal.getDate( "data_nascimento" ) );
-// t.setFuncao( rslocal.getString( "funcao_proposta" ) );
-// t.setData_admissao( rslocal.getDate( "data_admissao" ) );
-// t.setNumero_mecanografico( rslocal.getString( "numero_mecanografico" ) );
-// t.setEstabelecimento_id( new Integer( rslocal.getInt( 7 ) ) );
-// //if(nome != null)
-// //{
-// t.setEstabelecimento( utils.Utils.unicodeToHTML( rslocal.getString( 8 ) ) );
-// //}
-//
-// list.add( t );
-// }
-// while ( rslocal.next() );
- System.out.println( "Encontrei : " + array.columnLength() );
- for( int n = 0; n < array.columnLength(); n++ )
+ System.out.println( "Encontrei : " + array.rowCount() );
+ for( int n = 0; n < array.rowCount(); n++ )
{
try
{
Trabalhador t = new Trabalhador();
t.setId( ( Integer ) array.get( n, 0 ) );
- String nome_trab = ( String ) array.get( n, 1 );
+ String nome_trab = array.get( n, 1 );
t.setNome( utils.Utils.unicodeToHTML( nome_trab ) );
t.setData_nascimento( ( java.sql.Date ) array.get( n, 2 ) );
t.setFuncao( ( String ) array.get( n, 3 ) );
@@ -1744,359 +1288,109 @@ public class AnalisesDataProvider extends GenericDataProvider
ex.printStackTrace();
}
}
- System.out.println( "na lista vao : " + list.size() );
- return list;
- }
-
- public ArrayList getTrabalhadoresListByEstabelecimento( Integer estabelecimento_id ) throws Exception
- {
- Utils utils = new Utils();
- ArrayList list = new ArrayList();
-
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
- String sql = "SELECT * FROM trabalhadores WHERE estabelecimento_id = " + estabelecimento_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- int nr = 0;
- do
- {
- Trabalhador t = new Trabalhador();
- t.setId( new Integer( rslocal.getInt( "id" ) ) );
- String nome = rslocal.getString( "nome" );
- t.setNome( utils.unicodeToHTML( nome ) );
- t.setData_nascimento( rslocal.getDate( "data_nascimento" ) );
- t.setFuncao( rslocal.getString( "funcao_proposta" ) );
- t.setData_admissao( rslocal.getDate( "data_admissao" ) );
- list.add( t );
- }
- while ( rslocal.next() );
-
+ System.out.println( "na lista vao : " + list.size() );
return list;
}
+ @SuppressWarnings( "UnusedDeclaration" )
public Trabalhador getTrabalhador( Integer id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
- String sql = "SELECT * FROM trabalhadores WHERE id = " + id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- Trabalhador t = new Trabalhador();
- t.setId( new Integer( rslocal.getInt( "id" ) ) );
- t.setNome( rslocal.getString( "nome" ) );
- t.setData_nascimento( rslocal.getDate( "data_nascimento" ) );
- t.setFuncao( rslocal.getString( "funcao_proposta" ) );
- t.setData_admissao( rslocal.getDate( "data_admissao" ) );
- return t;
+ return new Trabalhador( EvoBaseProvider.getInstance().
+ getLocalProvider().load(
+ db.data.siprp_local.outer.TrabalhadoresData.class,
+ new Object[] { id },
+ new String[] { db.data.siprp_local.outer.TrabalhadoresData.ID_FULL }, null ) );
}
public Acidentado getAcidentado( Integer acidentado_id ) throws Exception
{
- Strings strings = new Strings();
- Acidentado a = new Acidentado();
- Statement st = createStatement();
- String sql = "SELECT * FROM acidentados WHERE id = " + acidentado_id;
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- a.setId( new Integer( rs.getInt( "id" ) ) );
- a.setNome( rs.getString( "nome" ) );
- a.setData_nascimento( rs.getDate( "data_nascimento" ) );
- a.setBilhete_identidade( rs.getString( "bilhete_identidade" ) );
- a.setMorada( rs.getString( "morada" ) );
- a.setCod_postal( rs.getString( "cod_postal" ) );
- a.setLocalidade( rs.getString( "localidade" ) );
- a.setContacto_telefonico( rs.getString( "contacto_telefonico" ) );
- a.setData_admissao( rs.getDate( "data_admissao" ) );
- a.setTurno( rs.getString( "turno" ) );
- String funcao = rs.getString( "funcao" );
- a.setFuncao( utils.Utils.unicodeToHTML( funcao ) );
- a.setTrabalhador_id( new Integer( rs.getInt( "trabalhador_id" ) ) );
- a.setNumero_mecanografico( rs.getString( "numero_mecanografico" ) );
- a.setNome_superior_hierarquico( rs.getString( "nome_superior_hierarquico" ) );
- a.setEmail_superior_hierarquico( rs.getString( "email_superior_hierarquico" ) );
- a.setEstabelecimento_origem( rs.getString( "estabelecimento_origem" ) );
- a.setData_email_superior_hierarquico( rs.getDate( "data_email_superior_hierarquico" ) );
- //a.setAnalise_acidente_id(new Integer("analise_acidente_id"));
- return a;
+ return new Acidentado( EvoBaseProvider.getInstance().
+ getProvider().load(
+ AcidentadosData.class,
+ new Object[] { acidentado_id },
+ new String[] { AcidentadosData.ID_FULL }, null )
+ );
}
public String getEmpresaNome( Integer empresa_id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ Expression dataFilter = new Field( db.data.siprp_local.outer.EmpresasData.ID_FULL ).isEqual( empresa_id );
+ Select select = new Select2( db.data.siprp_local.outer.EmpresasData.TABLENAME, dataFilter, db.data.siprp_local.outer.EmpresasData.DESIGNACAO_SOCIAL_FULL );
+
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
- String sql = "SELECT designacao_social FROM empresas WHERE id = " + empresa_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- String nome = rslocal.getString( "designacao_social" );
- return nome;
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
public String getEstabelecimentoNome( Integer estabelecimento_id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ Expression dataFilter = new Field( db.data.siprp_local.outer.EstabelecimentosData.ID_FULL ).isEqual( estabelecimento_id );
+ Select select = new Select2( db.data.siprp_local.outer.EstabelecimentosData.TABLENAME, dataFilter, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL );
- String sql = "SELECT nome FROM estabelecimentos WHERE id = " + estabelecimento_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
- String nome = "";
- if ( rslocal.first() )
- {
- nome = rslocal.getString( "nome" );
- }
- return Utils.unicodeToHTML( nome );
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
+ @SuppressWarnings( "UnusedDeclaration" )
public String getMedicoNome( Integer medico_id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ Expression dataFilter = new Field( db.data.siprp_local.outer.MedicosData.ID_FULL ).isEqual( medico_id );
+ Select select = new Select2( db.data.siprp_local.outer.MedicosData.TABLENAME, dataFilter, db.data.siprp_local.outer.MedicosData.NOME_FULL );
+
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
- String sql = "SELECT nome FROM medicos WHERE id = " + medico_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- String nome = rslocal.getString( "nome" );
- return Utils.unicodeToHTML( nome );
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
public Medico getMedico( Integer id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
- String sql = "SELECT * FROM medicos WHERE id = " + id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- Medico m = new Medico();
- m.setId( new Integer( rslocal.getInt( "id" ) ) );
- m.setNome( rslocal.getString( "nome" ) );
- m.setNumero_cedula( rslocal.getString( "numero_cedula" ) );
- return m;
+ return new Medico( EvoBaseProvider.getInstance().
+ getLocalProvider().load(
+ db.data.siprp_local.outer.MedicosData.class,
+ new Object[] { id },
+ new String[] { db.data.siprp_local.outer.MedicosData.ID_FULL }, null )
+ );
}
public String getTecnicoSaudeNome( Integer tecnico_id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ Expression dataFilter = new Field( db.data.siprp_local.outer.MarcacoesTecnicosHstData.ID_FULL ).isEqual( tecnico_id );
+ Select select = new Select2( db.data.siprp_local.outer.MarcacoesTecnicosHstData.TABLENAME, dataFilter, db.data.siprp_local.outer.MarcacoesTecnicosHstData.NOME_FULL );
- String sql = "SELECT nome FROM marcacoes_tecnicos_hst WHERE id = " + tecnico_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- String nome = rslocal.getString( "nome" );
- return nome;
- }
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
- public Integer getMaxAcidentadoId()
- {
- Statement st = createStatement();
- String sql = "SELECT max(acidentados.id)+1 AS MAXACIDENTADOID FROM acidentados";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Integer newId = new Integer( rs.getInt( "MAXACIDENTADOID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- return newId;
- }
- catch ( Exception ex )
- {
- return new Integer( 1 );
- }
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
public Integer createAcidentado( Acidentado a ) throws Exception
{
-// Statement st = createStatement();
-// Integer newId = getMaxAcidentadoId();
-// String sql = "INSERT INTO acidentados (id, nome, data_nascimento, bilhete_identidade, morada, cod_postal, localidade, contacto_telefonico, data_admissao, turno, funcao, trabalhador_id, numero_mecanografico, nome_superior_hierarquico, email_superior_hierarquico, estabelecimento_origem, data_email_superior_hierarquico) VALUES (";
-// sql += newId + ", '";
-// sql += a.getNome() + "', ";
-// if ( a.getData_nascimento() == null )
-// {
-// sql += null + ", '";
-// }
-// else
-// {
-// sql += "'" + a.getData_nascimento() + "', '";
-// }
-// //sql += a.getData_nascimento() + "', '";
-// sql += a.getBilhete_identidade() + "', '";
-// sql += a.getMorada() + "', '";
-// sql += a.getCod_postal() + "', '";
-// sql += a.getLocalidade() + "', '";
-// sql += a.getContacto_telefonico() + "', ";
-// if ( a.getData_admissao() == null )
-// {
-// sql += null + ", '";
-// }
-// else
-// {
-// sql += "'" + a.getData_admissao() + "', '";
-// }
-//// sql += a.getData_admissao() + "', '";
-// sql += a.getTurno() + "', '";
-// sql += a.getFuncao() + "', ";
-// sql += a.getTrabalhador_id() + ", '";
-// sql += a.getNumero_mecanografico() + "', '";
-// sql += a.getNome_superior_hierarquico() + "', '";
-// sql += a.getEmail_superior_hierarquico() + "', '";
-// sql += a.getEstabelecimento_origem() + "', ";
-// if ( a.getData_email_superior_hierarquico() == null )
-// {
-// sql += null + ")";
-// }
-// else
-// {
-// sql += "'" + a.getData_email_superior_hierarquico() + "')";
-// }
-// //sql += a.getAnalise_acidente_id() + ")";
-// System.out.println( "SQL ACIDENTADO : " + sql );
-// st.execute( sql );
-
AcidentadosData acidentado = fromAcidentadoBean( a, true );
acidentado.save();
-
return acidentado.getId();
}
public void updateAcidentado( Acidentado a ) throws Exception
{
-// Statement st = createStatement();
-// String sql = "UPDATE acidentados SET nome = '" + a.getNome() + "', ";
-// if ( a.getData_nascimento() == null )
-// {
-// sql += "data_nascimento = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_nascimento = '" + a.getData_nascimento() + "', ";
-// }
-//// sql += "data_nascimento = '" + a.getData_nascimento() + "', ";
-// sql += "bilhete_identidade = '" + a.getBilhete_identidade() + "', ";
-// sql += "morada = '" + a.getMorada() + "', ";
-// sql += "cod_postal = '" + a.getCod_postal() + "', ";
-// sql += "localidade = '" + a.getLocalidade() + "', ";
-// sql += "contacto_telefonico = '" + a.getContacto_telefonico() + "', ";
-// if ( a.getData_admissao() == null )
-// {
-// sql += "data_admissao = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_admissao = '" + a.getData_admissao() + "', ";
-// }
-//// sql += "data_admissao = '" + a.getData_admissao() + "', ";
-// sql += "turno = '" + a.getTurno() + "', ";
-// sql += "funcao = '" + a.getFuncao() + "', ";
-// sql += "trabalhador_id = " + a.getTrabalhador_id() + ", ";
-// sql += "numero_mecanografico = '" + a.getNumero_mecanografico() + "', ";
-// sql += "nome_superior_hierarquico = '" + a.getNome_superior_hierarquico() + "', ";
-// sql += "email_superior_hierarquico = '" + a.getEmail_superior_hierarquico() + "', ";
-// sql += "estabelecimento_origem = '" + a.getEstabelecimento_origem() + "', ";
-// if ( a.getData_email_superior_hierarquico() == null )
-// {
-// sql += "data_email_superior_hierarquico = " + null + " ";
-// }
-// else
-// {
-// sql += "data_email_superior_hierarquico = '" + a.getData_email_superior_hierarquico() + "' ";
-// }
-// //sql += "analise_acidente_id = '" + a.getAnalise_acidente_id() + " ";
-// sql += "WHERE id = " + a.getId();
-// System.out.println( "SQL UPDATE ACIDENTADO : " + sql );
-// st.execute( sql );
AcidentadosData acidentado = fromAcidentadoBean( a, false );
acidentado.save();
}
- public Integer getMaxControleId()
- {
- Statement st = createStatement();
- String sql = "SELECT max(controle.id)+1 AS MAXCONTROLEID FROM controle";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Integer newId = new Integer( rs.getInt( "MAXCONTROLEID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- return newId;
- }
- catch ( Exception ex )
- {
- return new Integer( 1 );
- }
- }
-
- public Integer getMaxAnaliseId()
- {
- Statement st = createStatement();
- String sql = "SELECT max(analises_acidentes.id)+1 AS MAXANALISEID FROM analises_acidentes";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Integer newId = new Integer( rs.getInt( "MAXANALISEID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- return newId;
- }
- catch ( Exception ex )
- {
- return new Integer( 1 );
- }
- }
-
public AnaliseAcidente createAnalise( AnaliseAcidente a ) throws Exception
{
-// Integer newId = getMaxAnaliseId();
-
- //calc analise_nr
java.util.Date data_acidente = new java.util.Date( a.getData_acidente().getTime() );
Calendar cal = new GregorianCalendar();
cal.setTime( data_acidente );
int ano = cal.get( Calendar.YEAR );
- Controle c = getControloByAno( new Integer( ano ) );
+ Controle c = getControloByAno( ano );
if ( c == null )
{
- c = createAnoNumeracao( new Integer( ano ) );
- }
-// if(c.getAnalise_year().intValue() != ano)
-// {
-// c.setAnalise_year(new Integer(ano));
-// c.setLast_analise_nr(new Integer(0));
-// }
- //String seq_str = new Integer(10000 + newId.intValue()).toString();
- int i_analise_nr = c.getLast_analise_nr().intValue() + 1;
- c.setLast_analise_nr( new Integer( i_analise_nr ) );
- //updateControle(c);
- String seq_str = new Integer( 10000 + i_analise_nr ).toString();
- String ano_str = new Integer( ano ).toString();
+ c = createAnoNumeracao( ano );
+ }
+ int i_analise_nr = c.getLast_analise_nr() + 1;
+ c.setLast_analise_nr( i_analise_nr );
+ String seq_str = Integer.toString( 10000 + i_analise_nr );
+ String ano_str = Integer.toString( ano );
String analise_nr = ano_str.substring( 2 ) + "/" + seq_str.substring( 1 );
a.setAnalise_nr( analise_nr );
@@ -2105,45 +1399,6 @@ public class AnalisesDataProvider extends GenericDataProvider
a.setId( analise.getId() );
-// Insert insert = new Insert( "analises_acidentes", new Assignment[] {
-//// new Assignment( new Field( "id" ), newId ),
-// new Assignment( new Field( "averiguador" ), a.getAveriguador() ),
-// new Assignment( new Field( "data_acidente" ), a.getData_acidente() ),
-// new Assignment( new Field( "acidentado_id" ), a.getAcidentado_id() ),
-// new Assignment( new Field( "estado" ), a.getEstado() ),
-// new Assignment( new Field( "empresa_id" ), a.getEmpresa_id() ),
-// new Assignment( new Field( "estabelecimento_id" ), a.getEstabelecimento_id() ),
-// new Assignment( new Field( "horas_turno" ), a.getHoras_turno() ),
-// new Assignment( new Field( "departamento_id" ), a.getDepartamento_id() ),
-// new Assignment( new Field( "seccao_id" ), a.getSeccao_id() ),
-// new Assignment( new Field( "local_trabalho" ), a.getLocal_trabalho() ),
-// new Assignment( new Field( "tarefa" ), a.getTarefa() ),
-// new Assignment( new Field( "substancias" ), a.getSubstancias() ),
-// new Assignment( new Field( "condicoes" ), a.getCondicoes() ),
-// new Assignment( new Field( "testemunhas" ), a.getTestemunhas() ),
-// new Assignment( new Field( "causas" ), a.getCausas() ),
-// new Assignment( new Field( "descricao" ), a.getDescricao() ),
-// new Assignment( new Field( "conclusoes" ), a.getConclusoes() ),
-// new Assignment( new Field( "accoes" ), a.getAccoes() ),
-// new Assignment( new Field( "hora_acidente" ), a.getHora_acidente() ),
-// new Assignment( new Field( "medico_id" ), a.getMedico_id() ),
-// new Assignment( new Field( "tecnico_saude_id" ), a.getTecnico_saude_id() ),
-// new Assignment( new Field( "averiguacao_posterior" ), a.getAveriguacao_posterior() ),
-// new Assignment( new Field( "averiguacao_obs" ), a.getAveriguacao_obs() ),
-// new Assignment( new Field( "data_inicio_processo" ), a.getData_inicio_processo() ),
-// new Assignment( new Field( "analise_nr" ), analise_nr ),
-// new Assignment( new Field( "coef_incapacidade" ), null ),
-// new Assignment( new Field( "concluido_por_desactivacao" ), Boolean.FALSE ),
-// new Assignment( new Field( "data_desactivacao" ), null ),
-// new Assignment( new Field( "comentario_desactivacao" ), null ),
-// } );
-// Virtual2DArray array = getExecuter().executeQuery( insert );
-// Integer insertedID = getInsertedID( array );
-// System.out.println( "SQL : " + insert.toString() );
-// System.out.println( "\nINSERTED ANALISE ID : " + insertedID );
-// a.setId( insertedID );
-
-
updateControle( c );
return a;
}
@@ -2197,176 +1452,6 @@ public class AnalisesDataProvider extends GenericDataProvider
a.setComentario_desactivacao( null );
}
-
-// Statement st = createStatement();
-// String sql = "UPDATE analises_acidentes SET data_acidente = '" + a.getData_acidente() + "', ";
-// sql += "acidentado_id = " + a.getAcidentado_id() + ", ";
-// sql += "estado = " + a.getEstado() + ", ";
-// sql += "empresa_id = " + a.getEmpresa_id() + ", ";
-// sql += "estabelecimento_id = " + a.getEstabelecimento_id() + ", ";
-// sql += "horas_turno = " + a.getHoras_turno() + ", ";
-// sql += "departamento_id = " + a.getDepartamento_id() + ", ";
-// sql += "seccao_id = " + a.getSeccao_id() + ", ";
-// sql += "local_trabalho = '" + a.getLocal_trabalho() + "', ";
-// sql += "tarefa = '" + a.getTarefa() + "', ";
-// sql += "substancias = '" + a.getSubstancias() + "', ";
-//// sql += "superior_hierarquico = '" + a.getSuperior_hierarquico() + "', ";
-// sql += "condicoes = '" + a.getCondicoes() + "', ";
-// sql += "testemunhas = '" + a.getTestemunhas() + "', ";
-// sql += "causas = " + a.getCausas() + ", ";
-// sql += "descricao = '" + a.getDescricao() + "', ";
-// sql += "conclusoes = '" + a.getConclusoes() + "', ";
-// sql += "accoes = '" + a.getAccoes() + "', ";
-// sql += "averiguador = '" + a.getAveriguador() + "', ";
-// if ( a.getHora_acidente() == null )
-// {
-// sql += "hora_acidente = " + null + ", ";
-// }
-// else
-// {
-// sql += "hora_acidente = '" + a.getHora_acidente() + "', ";
-// }
-//
-// sql += "formacao_shst = '" + a.getFormacao_shst() + "', ";
-// sql += "formacao_shst_nao_porque = '" + a.getFormacao_shst_nao_porque() + "', ";
-// sql += "outros_acidentes_com_colaborador = '" + a.getOutros_acidentes_com_colaborador() + "', ";
-// sql += "nr_acidentes_com_colaborador = " + a.getNr_acidentes_com_colaborador() + ", ";
-// sql += "nr_relatorio_acidente_colaborador1 = " + a.getNr_relatorio_acidente_colaborador1() + ", ";
-// sql += "nr_relatorio_acidente_colaborador2 = " + a.getNr_relatorio_acidente_colaborador2() + ", ";
-// sql += "nr_relatorio_acidente_colaborador3 = " + a.getNr_relatorio_acidente_colaborador3() + ", ";
-// sql += "nr_relatorio_acidente_colaborador4 = " + a.getNr_relatorio_acidente_colaborador4() + ", ";
-// sql += "acidentes_outros_colaboradores = '" + a.getAcidentes_outros_colaboradores() + "', ";
-// sql += "nr_acidentes_outros_colaboradores = " + a.getNr_acidentes_outros_colaboradores() + ", ";
-// sql += "nr_relatorio_acidente_outros_colaboradores1 = " + a.getNr_relatorio_acidente_outros_colaboradores1() + ", ";
-// sql += "nr_relatorio_acidente_outros_colaboradores2 = " + a.getNr_relatorio_acidente_outros_colaboradores2() + ", ";
-// sql += "nr_relatorio_acidente_outros_colaboradores3 = " + a.getNr_relatorio_acidente_outros_colaboradores3() + ", ";
-// sql += "nr_relatorio_acidente_outros_colaboradores4 = " + a.getNr_relatorio_acidente_outros_colaboradores4() + ", ";
-// sql += "lesao_cabeca = '" + a.getLesao_cabeca() + "', ";
-// sql += "lesao_pescoco = '" + a.getLesao_pescoco() + "', ";
-// sql += "lesao_tronco = '" + a.getLesao_tronco() + "', ";
-// sql += "lesao_membro_sup_dir = '" + a.getLesao_membro_sup_dir() + "', ";
-// sql += "lesao_membro_sup_esq = '" + a.getLesao_membro_sup_esq() + "', ";
-// sql += "lesao_membro_inf_dir = '" + a.getLesao_membro_inf_dir() + "', ";
-// sql += "lesao_membro_inf_esq = '" + a.getLesao_membro_inf_esq() + "', ";
-// sql += "especif1 = '" + a.getEspecif1() + "', ";
-// sql += "especif2 = '" + a.getEspecif2() + "', ";
-// sql += "especif3 = '" + a.getEspecif3() + "', ";
-// sql += "especif4 = '" + a.getEspecif4() + "', ";
-// sql += "tipo_lesao = '" + a.getTipo_lesao() + "', ";
-// sql += "tipo_incapacidade = '" + a.getTipo_incapacidade() + "', ";
-// sql += "coef_incapacidade = " + a.getCoef_incapacidade() + ", ";
-// if ( a.getData_aval_incapacidade() == null )
-// {
-// sql += "data_aval_incapacidade = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_aval_incapacidade = '" + a.getData_aval_incapacidade() + "', ";
-// }
-// if ( a.getData_rev_incapacidade() == null )
-// {
-// sql += "data_rev_incapacidade = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_rev_incapacidade = '" + a.getData_rev_incapacidade() + "', ";
-// }
-// if ( a.getPeriodo_incapacidade_de() == null )
-// {
-// sql += "periodo_incapacidade_de = " + null + ", ";
-// }
-// else
-// {
-// sql += "periodo_incapacidade_de = '" + a.getPeriodo_incapacidade_de() + "', ";
-// }
-// if ( a.getPeriodo_incapacidade_a() == null )
-// {
-// sql += "periodo_incapacidade_a = " + null + ", ";
-// }
-// else
-// {
-// sql += "periodo_incapacidade_a = '" + a.getPeriodo_incapacidade_a() + "', ";
-// }
-// sql += "img_flexao = '" + a.getImg_flexao() + "', ";
-// sql += "img_ext1 = '" + a.getImg_ext1() + "', ";
-// sql += "img_ext2 = '" + a.getImg_ext2() + "', ";
-// sql += "img_cab2 = '" + a.getImg_cab2() + "', ";
-// sql += "img_cab3 = '" + a.getImg_cab3() + "', ";
-// sql += "img_ma2 = '" + a.getImg_ma2() + "', ";
-// sql += "img_ma3 = '" + a.getImg_ma3() + "', ";
-// sql += "img_ma5 = '" + a.getImg_ma5() + "', ";
-// sql += "img_ma6 = '" + a.getImg_ma6() + "', ";
-// sql += "img_ma8 = '" + a.getImg_ma8() + "', ";
-// sql += "img_ma10 = '" + a.getImg_ma10() + "', ";
-// sql += "img_rot1 = '" + a.getImg_rot1() + "', ";
-// sql += "img_rot2 = '" + a.getImg_rot2() + "', ";
-// sql += "img_cab1 = '" + a.getImg_cab1() + "', ";
-// sql += "img_cab4 = '" + a.getImg_cab4() + "', ";
-// sql += "img_ma1 = '" + a.getImg_ma1() + "', ";
-// sql += "img_ma4 = '" + a.getImg_ma4() + "', ";
-// sql += "img_ma7 = '" + a.getImg_ma7() + "', ";
-// sql += "img_ma9 = '" + a.getImg_ma9() + "', ";
-// sql += "restricao_carga = " + a.getRestricao_carga() + ", ";
-// sql += "restricao_motricidade = '" + a.getRestricao_motricidade() + "', ";
-// sql += "restricao_conducao = '" + a.getRestricao_conducao() + "', ";
-// sql += "restricao_vibracoes = '" + a.getRestricao_vibracoes() + "', ";
-// sql += "restricao_outras = '" + a.getRestricao_outras() + "', ";
-// sql += "med_observ = '" + a.getMed_observ() + "', ";
-// sql += "estado_assinatura = " + a.getEstado_assinatura() + ", ";
-// sql += "tecnico_saude_id = " + a.getTecnico_saude_id() + ", ";
-// sql += "medico_id = " + a.getMedico_id() + ", ";
-// sql += "ass_consolidacao = '" + a.getAss_consolidacao() + "', ";
-// sql += "ass_resp_seg = '" + a.getAss_resp_seg() + "', ";
-// sql += "ass_resp_rh = '" + a.getAss_resp_rh() + "', ";
-// if ( a.getData_consolidacao() == null )
-// {
-// sql += "data_consolidacao = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_consolidacao = '" + a.getData_consolidacao() + "', ";
-// }
-// if ( a.getData_assinatura_seg() == null )
-// {
-// sql += "data_assinatura_seg = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_assinatura_seg = '" + a.getData_assinatura_seg() + "', ";
-// }
-// if ( a.getData_assinatura_rh() == null )
-// {
-// sql += "data_assinatura_rh = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_assinatura_rh = '" + a.getData_assinatura_rh() + "', ";
-// }
-// sql += "nome_resp_seg = '" + a.getNome_resp_seg() + "', ";
-// sql += "nome_resp_rh = '" + a.getNome_resp_rh() + "', ";
-// sql += "correcao = '" + a.getCorrecao() + "', ";
-// sql += "observacoes_correcao = '" + a.getObservacoes_correcao() + "', ";
-// sql += "estado_antes_correcao = " + a.getEstado_antes_correcao() + ", ";
-// sql += "ass_superior = '" + a.getAss_superior() + "', ";
-// sql += "nome_superior = '" + a.getNome_superior() + "', ";
-// sql += "averiguacao_posterior = '" + a.getAveriguacao_posterior() + "', ";
-// sql += "averiguacao_obs = '" + a.getAveriguacao_obs() + "', ";
-// sql += "nome_resp_consolidacao = '" + a.getNome_resp_consolidacao() + "', ";
-// if ( a.getData_assinatura_superior() == null )
-// {
-// sql += "data_assinatura_superior = " + null + ", ";
-// }
-// else
-// {
-// sql += "data_assinatura_superior = '" + a.getData_assinatura_superior() + "', ";
-// }
-// sql += "rh_fase4 = " + a.getRh_fase4() + ", ";
-// sql += "concluido_por_desactivacao = " + a.getConcluido_por_desactivacao() + ", ";
-// sql += "comentario_desactivacao = " + ( a.getComentario_desactivacao() == null ? "null" : "'" + a.getComentario_desactivacao() + "'" ) + ", ";
-// sql += "data_desactivacao = " + ( a.getData_desactivacao() == null ? "null" : "'" + new java.sql.Date( a.getData_desactivacao().getTime() ) + "'" );
-// sql += " WHERE id = " + a.getId();
-// System.out.println( "SQL UPDATE : " + sql );
-// st.execute( sql );
AnalisesAcidentesData analise = fromAnaliseAcidenteBean( a, false );
analise.save();
@@ -2374,57 +1459,26 @@ public class AnalisesDataProvider extends GenericDataProvider
public void changeEstado( Correcao c ) throws Exception
{
- Statement st = createStatement();
- String sql = "UPDATE analises_acidentes SET correcao = '" + c.getCorrecao() + "', estado = " + c.getEstado_corr() + ", estado_antes_correcao = " + c.getEstado_actual() + ", observacoes_correcao = '" + c.getObservacoes() + "' WHERE id = " + c.getAnalise_id();
- st.execute( sql );
- }
+
+ AnalisesAcidentesData analisesAcidentesData = EvoBaseProvider
+ .getInstance().getLocalProvider().load( AnalisesAcidentesData.class, new Object[]{ c.getAnalise_id() }, new String[]{ AnalisesAcidentesData.ID_FULL }, null );
- public Integer getMaxRecomendacaoId()
- {
- Statement st = createStatement();
- String sql = "SELECT max(recomendacoes.id)+1 AS MAXRECOMENDACAOID FROM recomendacoes";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Integer newId = new Integer( rs.getInt( "MAXRECOMENDACAOID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- return newId;
- }
- catch ( Exception ex )
- {
- return new Integer( 1 );
- }
+ analisesAcidentesData.update( c );
+ analisesAcidentesData.save();
+ analisesAcidentesData.refresh();
}
public Integer createRecomendacao( Recomendacao r ) throws Exception
{
-// Statement st = createStatement();
-// Integer newId = getMaxRecomendacaoId();
-// String sql = "INSERT INTO recomendacoes (id, analise_id, recomendacao) VALUES (";
-// sql += newId + ", ";
-// sql += r.getAnalise_id() + ", '";
-// sql += r.getRecomendacao() + "')";
-// st.execute( sql );
-//
-// return newId;
RecomendacoesData recomendacao = fromRecomendacaoBean( r, true );
recomendacao.save();
return recomendacao.getId();
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void updateRecomendacao( Recomendacao r )
throws Exception
{
-// Statement st = createStatement();
-// String sql = "UPDATE recomendacoes SET analise_id = " + r.getAnalise_id() + ", ";
-// sql += "recomendacao = '" + r.getRecomendacao() + "' ";
-// sql += "WHERE id = " + r.getId();
-// //System.out.println("SQL : " + sql);
-// st.execute( sql );
fromRecomendacaoBean( r, false ).save();
}
@@ -2448,97 +1502,69 @@ public class AnalisesDataProvider extends GenericDataProvider
public void deleteRecomendacoesByAnalise( Integer analise_id ) throws Exception
{
- System.out.println( "DELETE RECOMENDACOES" );
- Statement st = createStatement();
- String sql = "DELETE FROM recomendacoes WHERE analise_id = " + analise_id;
- st.execute( sql );
+
+ for( RecomendacoesData recomendacoesData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ RecomendacoesData.class, new Object[]{ analise_id },
+ new String[]{ RecomendacoesData.ANALISE_ID_FULL }, new String[]{ RecomendacoesData.ANALISE_ID_FULL } ) )
+ {
+ recomendacoesData.delete();
+ }
}
public void deleteAnaliseAcidente( Integer analise_id ) throws Exception
{
- Statement st = createStatement();
- //String sql = "DELETE FROM analises_acidentes WHERE id = " + analise_id;
- String sql = "UPDATE analises_acidentes SET apagada = 'y' WHERE id = " + analise_id;
- st.execute( sql );
+
+ for( AnalisesAcidentesData analisesAcidentesData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ AnalisesAcidentesData.class, new Object[]{ analise_id },
+ new String[]{ AnalisesAcidentesData.ID_FULL }, new String[]{ AnalisesAcidentesData.ID_FULL } ) )
+ {
+ analisesAcidentesData.setApagada( "y" );
+ analisesAcidentesData.save();
+ }
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void deleteAcidentado( Integer acidentado_id ) throws Exception
{
- Statement st = createStatement();
- String sql = "DELETE FROM acidentados WHERE id = " + acidentado_id;
- st.execute( sql );
- }
-
- public ArrayList getRecomendacoesByAnalise( Integer analiseId ) throws Exception
- {
- ArrayList list = new ArrayList();
- Statement st = createStatement();
- String sql = "SELECT * FROM recomendacoes WHERE analise_id = " + analiseId;
- //System.out.println("SQL : " + sql);
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+
+ for( AcidentadosData acidentadosData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ AcidentadosData.class, new Object[]{ acidentado_id },
+ new String[]{ AcidentadosData.ID_FULL }, new String[]{ AcidentadosData.ID_FULL } ) )
{
- rs.first();
- do
- {
- Recomendacao r = new Recomendacao();
- r.setId( new Integer( rs.getInt( "id" ) ) );
- r.setAnalise_id( new Integer( rs.getInt( "analise_id" ) ) );
- r.setRecomendacao( rs.getString( "recomendacao" ) );
- list.add( r );
- }
- while ( rs.next() );
+ acidentadosData.delete();
}
-
- return list;
}
- public Integer getMaxMedidaId()
+ public ArrayList< Recomendacao > getRecomendacoesByAnalise( Integer analiseId ) throws Exception
{
- Statement st = createStatement();
- String sql = "SELECT max(medidas.id)+1 AS MAXMEDIDAID FROM medidas";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Integer newId = new Integer( rs.getInt( "MAXMEDIDAID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- return newId;
- }
- catch ( Exception ex )
+
+ ArrayList< Recomendacao > list = new ArrayList< Recomendacao >();
+
+ for( RecomendacoesData recomendacoesData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ RecomendacoesData.class, new Object[]{ analiseId },
+ new String[]{ RecomendacoesData.ANALISE_ID_FULL }, new String[]{ RecomendacoesData.ID_FULL } ) )
{
- return new Integer( 1 );
+ list.add( new Recomendacao( recomendacoesData ) );
}
+
+ return list;
}
public Integer createMedida( Medida m ) throws Exception
{
-// Statement st = createStatement();
-// Integer newId = getMaxMedidaId();
-// String sql = "INSERT INTO medidas (id, analise_id, medida) VALUES (";
-// sql += newId + ", ";
-// sql += m.getAnalise_id() + ", '";
-// sql += m.getMedidaForSql() + "')";
-// st.execute( sql );
-//
-// return newId;
MedidasData medida = fromMedidaBean( m, true );
medida.save();
return medida.getId();
}
+ @SuppressWarnings( "UnusedDeclaration" )
public void updateMedida( Medida m ) throws Exception
{
-// Statement st = createStatement();
-// String sql = "UPDATE medidas SET analise_id = " + m.getAnalise_id() + ", ";
-// sql += "medida = '" + m.getMedidaForSql() + "' ";
-// sql += "WHERE id = " + m.getId();
-// //System.out.println("SQL : " + sql);
-// st.execute( sql );
fromMedidaBean( m, false ).save();
}
@@ -2562,30 +1588,27 @@ public class AnalisesDataProvider extends GenericDataProvider
public void deleteMedidasByAnalise( Integer analise_id ) throws Exception
{
- Statement st = createStatement();
- String sql = "DELETE FROM medidas WHERE analise_id = " + analise_id;
- st.execute( sql );
+
+ for( MedidasData medidasData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ MedidasData.class, new Object[]{ analise_id },
+ new String[]{ MedidasData.ANALISE_ID_FULL }, new String[]{ MedidasData.ANALISE_ID_FULL } ) )
+ {
+ medidasData.delete();
+ }
}
- public ArrayList getMedidasByAnalise( Integer analiseId ) throws Exception
+ public ArrayList< Medida > getMedidasByAnalise( Integer analiseId ) throws Exception
{
- ArrayList list = new ArrayList();
- Statement st = createStatement();
- String sql = "SELECT * FROM medidas WHERE analise_id = " + analiseId;
- //System.out.println("SQL : " + sql);
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+
+ ArrayList< Medida > list = new ArrayList< Medida >();
+
+ for( MedidasData medidasData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ MedidasData.class, new Object[]{ analiseId },
+ new String[]{ MedidasData.ANALISE_ID_FULL }, new String[]{ MedidasData.ID_FULL } ) )
{
- rs.first();
- do
- {
- Medida m = new Medida();
- m.setId( new Integer( rs.getInt( "id" ) ) );
- m.setAnalise_id( new Integer( rs.getInt( "analise_id" ) ) );
- m.setMedida( rs.getString( "medida" ) );
- list.add( m );
- }
- while ( rs.next() );
+ list.add( new Medida( medidasData ) );
}
return list;
@@ -2593,61 +1616,53 @@ public class AnalisesDataProvider extends GenericDataProvider
public String getNumeroCedula( Integer medico_id ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ Expression dataFilter = new Field( db.data.siprp_local.outer.MedicosData.ID_FULL ).isEqual( medico_id );
+ Select select = new Select2( db.data.siprp_local.outer.MedicosData.TABLENAME, dataFilter, db.data.siprp_local.outer.MedicosData.NUMERO_CEDULA_FULL );
- String sql = "SELECT numero_cedula FROM medicos WHERE id = " + medico_id;
- ResultSet rslocal = stlocal.executeQuery( sql );
- rslocal.first();
- String numero_cedula = rslocal.getString( "numero_cedula" );
- return numero_cedula;
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
+
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
public String getTipoDescricao( Integer tipo ) throws Exception
{
- Statement st = createStatement();
- String sql = "SELECT descricao FROM tipos_utilizadores WHERE tipo = " + tipo;
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- String descricao = rs.getString( "descricao" );
- return descricao;
+ Expression dataFilter = new Field( TiposUtilizadoresData.TIPO_FULL ).isEqual( tipo );
+ Select select = new Select2( TiposUtilizadoresData.TABLENAME, dataFilter, TiposUtilizadoresData.DESCRICAO_FULL );
+
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
+
+ return array.rowCount() > 0 ? Utils.unicodeToHTML( (String) array.get( 0, 0 ) ) : "";
}
- public com.sun.rave.web.ui.model.Option[] getTiposList() throws Exception
+ public Option[] getTiposList() throws Exception
{
- ArrayList list = new ArrayList();
+ ArrayList< TipoUtilizador > list = new ArrayList< TipoUtilizador >();
TipoUtilizador t = new TipoUtilizador();
- t.setId( new Integer( 0 ) );
- t.setTipo( new Integer( 0 ) );
+ t.setId( 0 );
+ t.setTipo( 0 );
t.setDescricao( "" );
list.add( t );
- Statement st = createStatement();
- String sql = "SELECT * FROM tipos_utilizadores WHERE activo = 'y' ORDER BY ordem";
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+
+ for( TiposUtilizadoresData tiposUtilizadoresData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ TiposUtilizadoresData.class, new Object[]{ "y" },
+ new String[]{ TiposUtilizadoresData.ACTIVO_FULL }, new String[]{ TiposUtilizadoresData.ORDEM_FULL } ) )
{
- rs.first();
- do
- {
- t = new TipoUtilizador();
- t.setId( new Integer( rs.getInt( "id" ) ) );
- t.setTipo( new Integer( rs.getInt( "tipo" ) ) );
- t.setDescricao( rs.getString( "descricao" ) );
- //t.setActivo(rs.getString("activo"));
- //t.setOrdem(new Integer(rs.getInt("ordem")));
- list.add( t );
- }
- while ( rs.next() );
+ list.add( new TipoUtilizador( tiposUtilizadoresData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptions( list );
+ }
+
+ private Option[] getOptions( ArrayList< TipoUtilizador > list )
+ {
+ TipoUtilizador t;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< TipoUtilizador > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- t = ( TipoUtilizador ) iter.next();
+ t = iter.next();
listOptions[i] = new Option( t.getTipo(), t.getDescricao() );
i++;
@@ -2655,110 +1670,67 @@ public class AnalisesDataProvider extends GenericDataProvider
return listOptions;
}
- public com.sun.rave.web.ui.model.Option[] getTiposList( Integer permissao ) throws Exception
+ public Option[] getTiposList( Integer permissao ) throws Exception
{
- ArrayList list = new ArrayList();
+ ArrayList< TipoUtilizador > list = new ArrayList< TipoUtilizador >();
TipoUtilizador t = new TipoUtilizador();
- t.setId( new Integer( 0 ) );
- t.setTipo( new Integer( 0 ) );
+ t.setId( 0 );
+ t.setTipo( 0 );
t.setDescricao( "" );
list.add( t );
- Statement st = createStatement();
- String sql = "SELECT * FROM tipos_utilizadores WHERE activo = 'y' ORDER BY ordem";
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
- {
- rs.first();
- do
- {
- t = new TipoUtilizador();
- if ( permissao.intValue() == 7 ) //director rh
- {
- t.setTipo( new Integer( rs.getInt( "tipo" ) ) );
- if ( t.getTipo().intValue() == 1 || t.getTipo().intValue() == 2 || t.getTipo().intValue() == 6 ) // seguranca || rh || gestor
- {
- t.setId( new Integer( rs.getInt( "id" ) ) );
- t.setDescricao( rs.getString( "descricao" ) );
- //t.setActivo(rs.getString("activo"));
- //t.setOrdem(new Integer(rs.getInt("ordem")));
- list.add( t );
- }
- }
- else
- {
- t.setId( new Integer( rs.getInt( "id" ) ) );
- t.setTipo( new Integer( rs.getInt( "tipo" ) ) );
- t.setDescricao( rs.getString( "descricao" ) );
- //t.setActivo(rs.getString("activo"));
- //t.setOrdem(new Integer(rs.getInt("ordem")));
- list.add( t );
- }
-
- }
- while ( rs.next() );
- }
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
- int i = 0;
- while ( iter.hasNext() )
+ for( TiposUtilizadoresData tiposUtilizadoresData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ TiposUtilizadoresData.class, new Object[]{ "y" },
+ new String[]{ TiposUtilizadoresData.ACTIVO_FULL }, new String[]{ TiposUtilizadoresData.ORDEM_FULL } ) )
{
- t = ( TipoUtilizador ) iter.next();
- listOptions[i] = new Option( t.getTipo(), t.getDescricao() );
- i++;
+ list.add( new TipoUtilizador( tiposUtilizadoresData, permissao ) );
}
- return listOptions;
+
+ return getOptions( list );
}
- public com.sun.rave.web.ui.model.Option[] getEstabelecimentosList( Integer empresa_id, Boolean booGestor ) throws Exception
+ public Option[] getEstabelecimentosList( Integer empresa_id, Boolean booGestor ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ ArrayList< Estabelecimento > list = new ArrayList< Estabelecimento >();
- ArrayList list = new ArrayList();
Estabelecimento e = new Estabelecimento();
- e.setId( new Integer( -1 ) );
-
+ e.setId( -1 );
e.setNome( "-Seleccionar-" );
-
list.add( e );
- if ( booGestor.equals( new Boolean( true ) ) )
+
+ if ( booGestor.equals( Boolean.TRUE ) )
{
e = new Estabelecimento();
- e.setId( new Integer( 0 ) );
+ e.setId( 0 );
e.setNome( "-Todos os estabelecimentos-" );
list.add( e );
}
- String sql = "SELECT * FROM estabelecimentos WHERE empresa_id = " + empresa_id + " AND inactivo = 'n' ORDER BY nome_plain";
- ResultSet rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+ for( db.data.siprp_local.outer.EstabelecimentosData estabelecimentosData :
+ EvoBaseProvider.getInstance().getLocalProvider().listLoad(
+ db.data.siprp_local.outer.EstabelecimentosData.class, new Object[]{ "n", empresa_id },
+ new String[]{ db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL, db.data.siprp_local.outer.EstabelecimentosData.EMPRESA_ID_FULL },
+ new String[]{ db.data.siprp_local.outer.EstabelecimentosData.NOME_PLAIN_FULL } ) )
{
- rslocal.first();
- do
- {
- e = new Estabelecimento();
- e.setId( new Integer( rslocal.getInt( "id" ) ) );
- //e.setNome_plain(rslocal.getString("nome_plain"));
- e.setNome( rslocal.getString( "nome" ) );
- System.out.println( "ESTABELECIMENTOAA : " + e.getId().toString() + " - " + e.getNome() );
- //t.setActivo(rs.getString("activo"));
- //t.setOrdem(new Integer(rs.getInt("ordem")));
- list.add( e );
- }
- while ( rslocal.next() );
+
+ list.add( new Estabelecimento( estabelecimentosData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptionsEstabelecimento( list );
+ }
+
+ private Option[] getOptionsEstabelecimento( ArrayList< Estabelecimento > list )
+ {
+ Estabelecimento e;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< Estabelecimento > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- e = ( Estabelecimento ) iter.next();
+ e = iter.next();
System.out.println( "ESTABELECIMENTOL : " + e.getId().toString() + " - " + e.getNome() );
listOptions[i] = new Option( e.getId(), Utils.unicodeToHTML( e.getNome() ) );
i++;
@@ -2766,95 +1738,62 @@ public class AnalisesDataProvider extends GenericDataProvider
return listOptions;
}
- public com.sun.rave.web.ui.model.Option[] getEstabelecimentosGestorList( Integer empresa_id, Boolean booGestor ) throws Exception
+ public Option[] getEstabelecimentosGestorList( Integer empresa_id, Boolean booGestor ) throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
+ ArrayList< Estabelecimento > list = new ArrayList< Estabelecimento >();
- ArrayList list = new ArrayList();
- Estabelecimento e = null;
- //Estabelecimento e = new Estabelecimento();
- //e.setId(new Integer(-1));
-
- //e.setNome("-Seleccionar-");
-
- //list.add(e);
- if ( booGestor.equals( new Boolean( true ) ) )
+ if ( booGestor.equals( Boolean.TRUE ) )
{
- e = new Estabelecimento();
- e.setId( new Integer( 0 ) );
+ Estabelecimento e = new Estabelecimento();
+ e.setId( 0 );
e.setNome( "-Todos os estabelecimentos-" );
list.add( e );
}
- String sql = "SELECT * FROM estabelecimentos WHERE empresa_id = " + empresa_id + " AND inactivo = 'n' ORDER BY nome_plain";
- ResultSet rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+ for( db.data.siprp_local.outer.EstabelecimentosData estabelecimentosData :
+ EvoBaseProvider.getInstance().getLocalProvider().listLoad(
+ db.data.siprp_local.outer.EstabelecimentosData.class, new Object[]{ "n", empresa_id },
+ new String[]{ db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL, db.data.siprp_local.outer.EstabelecimentosData.EMPRESA_ID_FULL },
+ new String[]{ db.data.siprp_local.outer.EstabelecimentosData.NOME_PLAIN_FULL } ) )
{
- rslocal.first();
- do
- {
- e = new Estabelecimento();
- e.setId( new Integer( rslocal.getInt( "id" ) ) );
- //e.setNome_plain(rslocal.getString("nome_plain"));
- e.setNome( rslocal.getString( "nome" ) );
- System.out.println( "ESTABELECIMENTOAA : " + e.getId().toString() + " - " + e.getNome() );
- //t.setActivo(rs.getString("activo"));
- //t.setOrdem(new Integer(rs.getInt("ordem")));
- list.add( e );
- }
- while ( rslocal.next() );
- }
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
- int i = 0;
- while ( iter.hasNext() )
- {
- e = ( Estabelecimento ) iter.next();
- System.out.println( "ESTABELECIMENTOL : " + e.getId().toString() + " - " + e.getNome() );
- listOptions[i] = new Option( e.getId(), Utils.unicodeToHTML( e.getNome() ) );
- i++;
+ list.add( new Estabelecimento( estabelecimentosData ) );
}
- return listOptions;
+
+ return getOptionsEstabelecimento( list );
}
- public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception
+ public Option[] getMedicosList() throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
- ArrayList list = new ArrayList();
+ ArrayList< Medico > list = new ArrayList< Medico >();
Medico m = new Medico();
- m.setId( new Integer( 0 ) );
+ m.setId( 0 );
m.setNome( "-Seleccionar-" );
list.add( m );
- String sql = "SELECT * FROM medicos WHERE inactivo = 'n'";
- ResultSet rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+
+ for( db.data.siprp_local.outer.MedicosData medicosData :
+ EvoBaseProvider.getInstance().getLocalProvider().listLoad(
+ db.data.siprp_local.outer.MedicosData.class, new Object[]{ "n" },
+ new String[]{ db.data.siprp_local.outer.MedicosData.INACTIVO_FULL },
+ new String[]{ db.data.siprp_local.outer.MedicosData.NOME_FULL} ) )
{
- rslocal.first();
- do
- {
- m = new Medico();
- m.setId( new Integer( rslocal.getInt( "id" ) ) );
- m.setNome( rslocal.getString( "nome" ) );
- list.add( m );
- }
- while ( rslocal.next() );
+
+ list.add( new Medico( medicosData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptionsMedicos( list );
+ }
+
+ private Option[] getOptionsMedicos( ArrayList< Medico > list )
+ {
+ Medico m;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< Medico > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- m = ( Medico ) iter.next();
+ m = iter.next();
listOptions[i] = new Option( m.getId(), Utils.unicodeToHTML( m.getNome() ) );
i++;
@@ -2862,39 +1801,36 @@ public class AnalisesDataProvider extends GenericDataProvider
return listOptions;
}
- public com.sun.rave.web.ui.model.Option[] getTecnicosSaudeList() throws Exception
+ public Option[] getTecnicosSaudeList() throws Exception
{
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement stlocal = createLocalStatement();
-
- ArrayList list = new ArrayList();
+ ArrayList< TecnicoSaude > list = new ArrayList< TecnicoSaude >();
TecnicoSaude t = new TecnicoSaude();
- t.setId( new Integer( 0 ) );
+ t.setId( 0 );
t.setNome( "-Seleccionar-" );
list.add( t );
- String sql = "SELECT * FROM marcacoes_tecnicos_hst WHERE inactivo = 'n'";
- ResultSet rslocal = stlocal.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
+
+ for( db.data.siprp_local.outer.MarcacoesTecnicosHstData marcacoesTecnicosHstData :
+ EvoBaseProvider.getInstance().getLocalProvider().listLoad(
+ db.data.siprp_local.outer.MarcacoesTecnicosHstData.class, new Object[]{ "n" },
+ new String[]{ db.data.siprp_local.outer.MarcacoesTecnicosHstData.INACTIVO_FULL },
+ new String[]{ db.data.siprp_local.outer.MarcacoesTecnicosHstData.NOME_FULL} ) )
{
- rslocal.first();
- do
- {
- t = new TecnicoSaude();
- t.setId( new Integer( rslocal.getInt( "id" ) ) );
- t.setNome( rslocal.getString( "nome" ) );
- list.add( t );
- }
- while ( rslocal.next() );
+
+ list.add( new TecnicoSaude( marcacoesTecnicosHstData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptionsTecnicosSaude( list );
+ }
+
+ private Option[] getOptionsTecnicosSaude( ArrayList< TecnicoSaude > list )
+ {
+ TecnicoSaude t;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< TecnicoSaude > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- t = ( TecnicoSaude ) iter.next();
+ t = iter.next();
listOptions[i] = new Option( t.getId(), Utils.unicodeToHTML( t.getNome() ) );
i++;
@@ -2903,9 +1839,9 @@ public class AnalisesDataProvider extends GenericDataProvider
}
- public com.sun.rave.web.ui.model.Option[] getCausasAcidente( boolean toStatistics ) throws Exception
+ public Option[] getCausasAcidente( boolean toStatistics ) throws Exception
{
- com.sun.rave.web.ui.model.Option[] options = null;
+ Option[] options = null;
Select2 query = new Select2(
new String[] { CausasData.TABLENAME },
@@ -2919,9 +1855,9 @@ public class AnalisesDataProvider extends GenericDataProvider
Virtual2DArray array = getExecuter().executeQuery( query );
if ( array != null )
{
- options = new com.sun.rave.web.ui.model.Option[ array.columnLength() + 1 ];
- options[ 0 ] = toStatistics ? new Option( "", "" ) : new Option( new Integer( 0 ), "-Seleccionar" );
- for ( int i = 0; i < array.columnLength(); i++ )
+ options = new Option[ array.rowCount() + 1 ];
+ options[ 0 ] = toStatistics ? new Option( "", "" ) : new Option( 0, "-Seleccionar" );
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer causaID = array.get( i, 0 );
String causa = array.get( i, 1 );
@@ -2931,72 +1867,36 @@ public class AnalisesDataProvider extends GenericDataProvider
return options;
}
-// public com.sun.rave.web.ui.model.Option[] getCausasList() throws Exception
-// {
-// ArrayList list = new ArrayList();
-// Causa c = new Causa();
-// c.setId( new Integer( 0 ) );
-// c.setCausa( "-Seleccionar-" );
-// list.add( c );
-// Statement st = createStatement();
-// String sql = "SELECT * FROM causas WHERE activa = 'y'";
-// ResultSet rs = st.executeQuery( sql );
-// if ( rs.isBeforeFirst() )
-// {
-// rs.first();
-// do
-// {
-// c = new Causa();
-// c.setId( new Integer( rs.getInt( "id" ) ) );
-// c.setCausa( rs.getString( "causa" ) );
-// list.add( c );
-// }
-// while ( rs.next() );
-// }
-//
-// com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
-// ListIterator iter = list.listIterator();
-// int i = 0;
-// while ( iter.hasNext() )
-// {
-// c = ( Causa ) iter.next();
-//
-// listOptions[i] = new Option( c.getId(), c.getCausa() );
-// i++;
-// }
-// return listOptions;
-// }
-
- public com.sun.rave.web.ui.model.Option[] getDepartamentosList() throws Exception
- {
- ArrayList list = new ArrayList();
+ public Option[] getDepartamentosList() throws Exception
+ {
+ ArrayList< Departamento > list = new ArrayList< Departamento >();
Departamento d = new Departamento();
- d.setId( new Integer( 0 ) );
+ d.setId( 0 );
d.setDescricao( "-Todos-" );
list.add( d );
- Statement st = createStatement();
- String sql = "SELECT * FROM departamentos WHERE activo = 'y'";
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+
+ for( DepartamentosData departamentosData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ DepartamentosData.class, new Object[]{ "y" },
+ new String[]{ DepartamentosData.ACTIVO_FULL },
+ new String[]{ DepartamentosData.ID_FULL } ) )
{
- rs.first();
- do
- {
- d = new Departamento();
- d.setId( new Integer( rs.getInt( "id" ) ) );
- d.setDescricao( rs.getString( "descricao" ) );
- list.add( d );
- }
- while ( rs.next() );
+ list.add( new Departamento( departamentosData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptionsDepartamentos( list );
+ }
+
+ private Option[] getOptionsDepartamentos( ArrayList< Departamento > list )
+ {
+ Departamento d;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< Departamento > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- d = ( Departamento ) iter.next();
+ d = iter.next();
listOptions[i] = new Option( d.getId(), d.getDescricao() );
i++;
@@ -3004,46 +1904,49 @@ public class AnalisesDataProvider extends GenericDataProvider
return listOptions;
}
- public com.sun.rave.web.ui.model.Option[] getSeccoesList( Integer departamento_id ) throws Exception
+ public Option[] getSeccoesList( Integer departamento_id ) throws Exception
{
- ArrayList list = new ArrayList();
+ ArrayList< Seccao > list = new ArrayList< Seccao >();
Seccao s = new Seccao();
- s.setId( new Integer( 0 ) );
+ s.setId( 0 );
s.setDescricao( "-Seleccionar-" );
list.add( s );
- Statement st = createStatement();
- String sql = "";
- if ( departamento_id == null ) // todos
+
+ Object[] values;
+ String[] names;
+
+ if( departamento_id == null )
{
- sql = "SELECT * FROM seccoes WHERE activo = 'y'";
+ values = new Object[] { "y" };
+ names = new String[] { SeccoesData.ACTIVO_FULL };
}
else
{
- sql = "SELECT * FROM seccoes WHERE activo = 'y' AND departamento_id = " + departamento_id;
+ values = new Object[] { "y", departamento_id };
+ names = new String[] { SeccoesData.ACTIVO_FULL, SeccoesData.DEPARTAMENTO_ID_FULL };
}
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+ for( SeccoesData seccoesData :
+ EvoBaseProvider.getInstance().getProvider().listLoad(
+ SeccoesData.class, values, names,
+ new String[]{ SeccoesData.ID_FULL } ) )
{
- rs.first();
- do
- {
- s = new Seccao();
- s.setId( new Integer( rs.getInt( "id" ) ) );
- s.setDescricao( rs.getString( "descricao" ) );
- s.setDepartamento_id( new Integer( rs.getInt( "departamento_id" ) ) );
- list.add( s );
- }
- while ( rs.next() );
+ list.add( new Seccao( seccoesData ) );
}
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[ list.size() ];
- ListIterator iter = list.listIterator();
+ return getOptionsSeccoes( list );
+ }
+
+ private Option[] getOptionsSeccoes( ArrayList< Seccao > list )
+ {
+ Seccao s;
+ Option[] listOptions = new Option[ list.size() ];
+ ListIterator< Seccao > iter = list.listIterator();
int i = 0;
while ( iter.hasNext() )
{
- s = ( Seccao ) iter.next();
+ s = iter.next();
listOptions[i] = new Option( s.getId(), s.getDescricao() );
i++;
@@ -3053,57 +1956,44 @@ public class AnalisesDataProvider extends GenericDataProvider
public Causa getCausa( Integer id ) throws Exception
{
- Statement st = createStatement();
- String sql = null;
-
- sql = "SELECT * FROM causas WHERE id = " + id;
-
- ResultSet rs = st.executeQuery( sql );
- Causa c = null;
- if ( rs.first() )
- {
- c = new Causa();
- c.setId( new Integer( rs.getInt( "id" ) ) );
- c.setCausa( rs.getString( "causa" ) );
- }
- return c;
+ return new Causa( EvoBaseProvider.getInstance().
+ getProvider().load(
+ CausasData.class,
+ new Object[] { id },
+ new String[] { CausasData.ID_FULL }, null )
+ );
}
public Seccao getSeccao( Integer id ) throws Exception
{
- Statement st = createStatement();
- String sql = null;
-
- sql = "SELECT * FROM seccoes WHERE id = " + id;
-
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- Seccao s = new Seccao();
- s.setId( new Integer( rs.getInt( "id" ) ) );
- s.setDescricao( rs.getString( "descricao" ) );
- return s;
+ return new Seccao( EvoBaseProvider.getInstance().
+ getProvider().load(
+ SeccoesData.class,
+ new Object[] { id },
+ new String[] { SeccoesData.ID_FULL }, null )
+ );
}
public List getDistinctYears( Integer excludeYear ) throws Exception
{
List result = new LinkedList();
- Expression where = new Field( "apagada" ).isEqual( "n" );
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
if ( excludeYear != null )
{
- where = where.and( new Field( "EXTRACT( year FROM data_acidente )" ).notIn( new Integer[] { excludeYear } ) );
+ where = where.and( new Field( "EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " )" ).notIn( new Integer[] { excludeYear } ) );
}
Select2 query = new Select2(
- new String[] { "analises_acidentes" },
+ new String[] { AnalisesAcidentesData.TABLENAME },
new Integer[] { },
new Expression[] { },
- new String[] { "DISTINCT( cast( EXTRACT( year FROM data_acidente ) as integer ) ) AS ano" },
+ new String[] { "DISTINCT( cast( EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " ) as integer ) ) AS ano" },
where,
new String[] { "ano DESC" },
null, null, null );
query.disableOrderFieldsVerification();
Virtual2DArray array = getExecuter().executeQuery( query );
- for ( int i = 0; i < array.columnLength(); i++ )
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer ano = array.get( i, 0 );
result.add( ano );
@@ -3111,28 +2001,28 @@ public class AnalisesDataProvider extends GenericDataProvider
return result;
}
- public ArrayList getAnosListFromAnalises() throws Exception
+ public ArrayList< Integer > getAnosListFromAnalises() throws Exception
{
- ArrayList list = new ArrayList();
+ ArrayList< Integer > list = new ArrayList< Integer >();
- String sql = "SELECT DISTINCT EXTRACT( year FROM data_acidente ) AS ano " +
- "FROM analises_acidentes " +
- "WHERE " +
- "apagada = 'n' AND estado = " + Global.ESTADO_CONCLUIDO +
- " ORDER BY ano";
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ).and(
+ new Field( AnalisesAcidentesData.ESTADO_FULL ).isEqual( Global.ESTADO_CONCLUIDO )
+ );
- Statement st = createStatement();
- ResultSet rs = st.executeQuery( sql );
- if ( rs.isBeforeFirst() )
+ Select2 query = new Select2(
+ new String[] { AnalisesAcidentesData.TABLENAME },
+ new Integer[] { },
+ new Expression[] { },
+ new String[] { "DISTINCT( cast( EXTRACT( year FROM " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + " ) as integer ) ) AS ano" },
+ where,
+ new String[] { "ano DESC" },
+ null, null, null );
+ query.disableOrderFieldsVerification();
+ Virtual2DArray array = getExecuter().executeQuery( query );
+ for ( int i = 0; i < array.rowCount(); i++ )
{
- rs.first();
- do
- {
- Double dAno = new Double( rs.getDouble( "ano" ) );
- Integer iAno = new Integer( dAno.intValue() );
- list.add( iAno );
- }
- while ( rs.next() );
+ Integer ano = array.get( i, 0 );
+ list.add( ano );
}
return list;
}
@@ -3155,22 +2045,10 @@ public class AnalisesDataProvider extends GenericDataProvider
{
return "FASE 4 - RH - MEDIDAS + LES\u00c3O";
}
-// else if(estado == Global.ESTADO_MEDICINA)
-// {
-// return "Medicina";
-// }
else if ( estado == Global.ESTADO_CONSOLIDACAO )
{
return "FASE 5 - SIPRP - CONSOLIDA\u00c7\u00c3O";
}
-// else if(estado == Global.ESTADO_ASSINATURAS)
-// {
-// return "Verificação";
-// }
-// else if(estado == Global.ESTADO_IMPRESSAO)
-// {
-// return "Impressão";
-// }
else if ( estado == Global.ESTADO_ASSINATURA_SEG )
{
return "FASE 6 - SEG - VERIFICA\u00c7\u00c3O SEG.";
@@ -3190,55 +2068,66 @@ public class AnalisesDataProvider extends GenericDataProvider
return null;
}
- public HashMap getMetaData( String table ) throws Exception
- {
- Statement st = createStatement();
- String sql = "select * from " + table;
+ private static final ModelProvider MODEL_PROVIDER;
+
+ static {
+
+ ModelProvider tmp = null;
+ try
+ {
+ Connection connection = ( Connection ) Singleton.getInstance( "CONNECTION_OBJECT" );
+ if ( connection == null )
+ {
+ String connectionURL = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL );
+ String username = DBPropertiesLoader.getInstance().findProperty( DBConstants.USERNAME_SIPRP );
+ String password = DBPropertiesLoader.getInstance().findProperty( DBConstants.PASSWORD_SIPRP );
+
+ try
+ {
+ connection = Connector.getConnection( connectionURL, username, password );
+ }
+ catch( SQLException ignored )
+ {
+ }
+ }
+ tmp = new ModelProvider( connection );
+ }
+ catch( Exception ignored )
+ {
- ResultSet rs = st.executeQuery( sql );
- ResultSetMetaData rsmd = rs.getMetaData();
+ }
+ MODEL_PROVIDER = tmp;
+ }
- HashMap hash = new HashMap();
- int cols = rsmd.getColumnCount();
+ public HashMap< String, Integer > getMetaData( String table ) throws Exception
+ {
+ HashMap< String, Integer > hash = new HashMap< String, Integer >();
- for ( int i = 0; i < cols; i++ )
+ for( DBColumn column : MODEL_PROVIDER.getTableByName( table ).getColumns() )
{
- String field = rsmd.getColumnName( i + 1 );
- int len = rsmd.getPrecision( i + 1 );
- hash.put( field, new Integer( len ) );
+ hash.put( (String) column.get( DBColumn.NAME ), Integer.parseInt( (String) column.get( DBColumn.LENGTH ) ) );
}
return hash;
}
public byte[] getLogoByEmpresa( Integer empresaID ) throws Exception
{
- byte[] result = null;
- String sql = "SELECT empresa_logo_id FROM empresas WHERE id = " + empresaID;
- Statement st = createLocalStatement();
- ResultSet rslocal = st.executeQuery( sql );
- if ( rslocal.isBeforeFirst() )
- {
- rslocal.first();
- Integer logoId = new Integer( rslocal.getInt( "empresa_logo_id" ) );
- result = getLogo( logoId );
- }
- return result;
+ Expression dataFilter = new Field( db.data.siprp_local.outer.EmpresasData.ID_FULL ).isEqual( empresaID );
+ Select select = new Select2( db.data.siprp_local.outer.EmpresasData.TABLENAME, dataFilter, db.data.siprp_local.outer.EmpresasData.EMPRESA_LOGO_ID_FULL );
+
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
+
+ return array.rowCount() > 0 ? getLogo( ( Integer ) array.get( 0, 0 ) ) : null;
}
private byte[] getLogo( Integer logoID ) throws Exception
{
- System.out.println( "AnalisesDataProvider . getLogo( " + logoID + " ) : " );
+ Expression dataFilter = new Field( db.data.siprp_local.outer.ImageData.ID_FULL ).isEqual( logoID );
+ Select select = new Select2( db.data.siprp_local.outer.ImageData.TABLENAME, dataFilter, db.data.siprp_local.outer.ImageData.IMAGE_DATA_FULL );
- byte[] result = null;
- String sql = "SELECT image_data FROM image WHERE id = " + logoID;
- Statement st = createLocalStatement();
- ResultSet rslocal = st.executeQuery( sql );
- if ( rslocal.first() )
- {
- result = rslocal.getBytes( "image_data" );
- }
- System.out.println( "\tLOGO SIZE : " + ( result == null ? "null" : result.length ) );
- return result;
+ Virtual2DArray array = getLocalExecuter().executeQuery( select );
+
+ return array.rowCount() > 0 ? ( byte[] ) array.get( 0, 0 ) : null;
}
protected AnalisesAcidentesData fromAnaliseAcidenteBean( AnaliseAcidente analiseBean, boolean criar )
@@ -3402,4 +2291,89 @@ public class AnalisesDataProvider extends GenericDataProvider
return acidentado;
}
+ private static class CommonExpression
+ {
+ private String nome;
+ private String visitaDate;
+ private String por;
+ private Integer fromYear;
+ private Expression where;
+ private String[] tables;
+ private Expression[] joinConditions;
+ private Integer[] joinTypes;
+ private Integer estabelecimentoID;
+
+ public CommonExpression( String nome, Integer estabelecimentoID, String visitaDate, String por, Integer fromYear )
+ {
+ this.nome = nome;
+ this.estabelecimentoID = estabelecimentoID;
+ this.visitaDate = visitaDate;
+ this.por = por;
+ this.fromYear = fromYear;
+ }
+
+ public Expression getWhere()
+ {
+ return where;
+ }
+
+ public String[] getTables()
+ {
+ return tables;
+ }
+
+ public Expression[] getJoinConditions()
+ {
+ return joinConditions;
+ }
+
+ public Integer[] getJoinTypes()
+ {
+ return joinTypes;
+ }
+
+ public CommonExpression invoke()
+ {
+ where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ tables = null;
+ joinConditions = null;
+ joinTypes = null;
+
+ if ( nome != null || por != null )
+ {
+ tables = new String[] { AnalisesAcidentesData.TABLENAME, AcidentadosData.TABLENAME };
+ joinTypes = new Integer[] { Select2.JOIN_INNER };
+ joinConditions = new Expression[] { new Field( AcidentadosData.ID_FULL ).isEqual( AnalisesAcidentesData.ACIDENTADO_ID_FULL ) };
+ }
+ else
+ {
+ tables = new String[] { AnalisesAcidentesData.TABLENAME };
+ }
+
+ if ( nome != null )
+ {
+ nome = StringPlainer.convertString( nome.trim() );
+ nome = nome.replaceAll( " ", "%" );
+ where = where.and( new Field( "plain_utf8( " + AcidentadosData.NOME_FULL + " )" ).isLike( "%" + nome + "%" ) );
+ }
+ if ( visitaDate != null )
+ {
+ where = where.and( new Field( AnalisesAcidentesData.DATA_ACIDENTE_FULL ).isEqual( visitaDate ) );
+ }
+ if ( estabelecimentoID != null )
+ {
+ where = where.and( new Field( AnalisesAcidentesData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
+ }
+ if ( por != null )
+ {
+ where = where.and( new Field( AcidentadosData.NUMERO_MECANOGRAFICO_FULL ).isLike( "%" + por.toUpperCase() + "%" ) );
+ }
+
+ if( visitaDate == null )
+ {
+ where = where.and( new Field( "EXTRACT( year from " + AnalisesAcidentesData.DATA_ACIDENTE_FULL + ")" ).isEqual(fromYear) );
+ }
+ return this;
+ }
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/EstatisticasDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/EstatisticasDataProvider.java
index 2f2f9587..b313a2ff 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/EstatisticasDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/EstatisticasDataProvider.java
@@ -14,10 +14,11 @@ import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.sun.rave.web.ui.model.Option;
+import db.data.siprp.outer.AcidentadosData;
+import db.data.siprp.outer.AnalisesAcidentesData;
import db.data.siprp.outer.CausasData;
import db.data.siprp.outer.SeccoesData;
-import db.data.siprp_local.outer.EstabelecimentosData;
-import global.Global;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -51,15 +52,6 @@ public class EstatisticasDataProvider extends GenericDataProvider
return INSTANCE;
}
-// private Statement createStatement()
-// {
-// if ( db == null )
-// {
-// db = new Db();
-// }
-// return db.createStatement();
-// }
-
public List< EstatisticaProcessoBean > getEstatisticas( Map< String, Object > searchProperties )
{
String por = ( String ) searchProperties.get( EstatisticasConstants.KEY_POR );
@@ -68,52 +60,52 @@ public class EstatisticasDataProvider extends GenericDataProvider
Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA );
String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA );
String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS );
-// String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO );
Integer estabelecimentoID = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_ESTABELECIMENTO );
Integer seccaoID = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_SECCAO );
Integer causas = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE );
String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO );
Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST );
Boolean participado_seguro = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_PARTICIPADO_SEGURO );
- Boolean postoAcidentado = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_POSTO_ACIDENTADO );
- Boolean outrosAcidentados = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_OUTROS_ACIDENTADOS );
- String tableNames = "analises_acidentes";
- String joinConditions = "";
- String whereConditions = " analises_acidentes.apagada = 'n' ";
+ String[] tables;
+ Expression[] joins;
+ Expression where = new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" );
+ Integer[] joinTypes;
if ( por != null || nome != null || turno != null )
{
- tableNames += ", acidentados";
- joinConditions += " analises_acidentes.acidentado_id = acidentados.id ";
+ tables = new String[] { AnalisesAcidentesData.TABLENAME, AcidentadosData.TABLENAME };
+ joins = new Expression[] { new Field( AnalisesAcidentesData.ACIDENTADO_ID_FULL ).isEqual( AcidentadosData.ID_FULL ) };
+ joinTypes = new Integer[] { Select2.JOIN_INNER };
+ }
+ else
+ {
+ joins = new Expression[] { };
+ tables = new String[] { AnalisesAcidentesData.TABLENAME };
+ joinTypes = new Integer[] { };
}
-// if ( departamento != null )
-// {
-// tableNames += ", departamentos";
-// joinConditions += ( "".equals( joinConditions ) ? "" : " AND " ) + " analises_acidentes.departamento_id = departamentos.id ";
-// }
if ( por != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_POR + " = '" + por + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_POR ).isEqual( por ) );
}
if ( nome != null )
{
nome = nome.replaceAll( " ", "%" );
- whereConditions += " AND " + EstatisticasConstants.KEY_NOME + " ILIKE '%" + nome + "%' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_NOME ).isILike( "'%" + nome + "%'" ) );
}
if ( turno != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_TURNO_TRABALHO + " = '" + turno + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_TURNO_TRABALHO ).isEqual( turno ) );
}
if ( anoOcorrencia != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_ANO_OCORRENCIA + " = '" + anoOcorrencia + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_ANO_OCORRENCIA ).isEqual( anoOcorrencia ) );
}
if ( dataOcorrencia != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_DATA_OCORRENCIA + " = '" + D_F.format( dataOcorrencia ) + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_DATA_OCORRENCIA ).isEqual( D_F.format( dataOcorrencia ) ) );
}
if ( horaOcorrencia != null )
{
@@ -129,7 +121,7 @@ public class EstatisticasDataProvider extends GenericDataProvider
}
if ( hora != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_HORA_OCORRENCIA + " = '" + hora + "' " ;
+ where = where.and( new Field( EstatisticasConstants.KEY_HORA_OCORRENCIA ).isEqual( hora ) );
}
}
if ( horasTrabalhadas != null )
@@ -145,52 +137,39 @@ public class EstatisticasDataProvider extends GenericDataProvider
}
if ( nrHoras != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_HORAS_TRABALHADAS + " = " + nrHoras + " ";
+ where = where.and( new Field( EstatisticasConstants.KEY_HORAS_TRABALHADAS ).isEqual( nrHoras ) );
}
}
if ( causas != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_CAUSAS_ACIDENTE + " = " + causas + " ";
+ where = where.and( new Field( EstatisticasConstants.KEY_CAUSAS_ACIDENTE ).isEqual( causas ) );
}
-// if ( departamento != null )
-// {
-// departamento = departamento.replaceAll( " ", "%" );
-// whereConditions += " AND " + EstatisticasConstants.KEY_DEPARTAMENTO + " ILIKE '%" + departamento + "%' ";
-// }
if ( estabelecimentoID != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_ESTABELECIMENTO + " = " + estabelecimentoID + " ";
+ where = where.and( new Field( EstatisticasConstants.KEY_ESTABELECIMENTO ).isEqual( estabelecimentoID ) );
}
if ( seccaoID != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_SECCAO + " = " + seccaoID + " ";
+ where = where.and( new Field( EstatisticasConstants.KEY_SECCAO ).isEqual( seccaoID ) );
}
if ( formacao_shst != null )
{
- /**
- * opcoes possiveis : 'y', 'n', 't' ( AnaliseAcidentesTrabalho.java )
- * 'y' -> if ( yes selected )
- * 'n' -> if ( ! yes selected ) && ( no selected )
- * 't' -> else
- */
- whereConditions += " AND " + EstatisticasConstants.KEY_FORMACAO_SHST + " = '" + ( formacao_shst ? "y" : "n" ) + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_FORMACAO_SHST ).isEqual( formacao_shst ? "y" : "n" ) );
}
if( participado_seguro != null )
{
- whereConditions += " AND " + EstatisticasConstants.KEY_PARTICIPADO_SEGURO + " = '" + ( participado_seguro ? "y" : "n" ) + "' ";
+ where = where.and( new Field( EstatisticasConstants.KEY_PARTICIPADO_SEGURO ).isEqual( participado_seguro ? "y" : "n" ) );
}
- String sql = "SELECT analises_acidentes.estado, COUNT( analises_acidentes.* ) AS count " +
- "FROM " + tableNames + " " +
- "WHERE " + ( "".equals( joinConditions ) ? "" : joinConditions + " AND " ) + whereConditions + " " +
- "GROUP BY analises_acidentes.estado " +
- "ORDER BY analises_acidentes.estado";
+ Select select = new Select2( tables, joinTypes, joins,
+ new String[]{ AnalisesAcidentesData.ESTADO_FULL, "COUNT( analises_acidentes.* ) AS count" },
+ where, new String[]{ AnalisesAcidentesData.ESTADO_FULL }, new String[]{ AnalisesAcidentesData.ESTADO_FULL }, null, null );
List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >();
try
{
- stats = getEstatisticasForSQL( sql );
+ stats = getEstatisticasForSQL( select );
}
catch ( Exception ex )
{
@@ -200,17 +179,17 @@ public class EstatisticasDataProvider extends GenericDataProvider
}
- private List< EstatisticaProcessoBean > getEstatisticasForSQL( String sql ) throws Exception
+ private List< EstatisticaProcessoBean > getEstatisticasForSQL( Select select ) throws Exception
{
- System.out.println( "\nEstatisticasQuery : " + sql + "\n" );
+ System.out.println( "\nEstatisticasQuery : " + select.toString() + "\n" );
List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >();
AnalisesDataProvider adp = AnalisesDataProvider.getInstance();
- Virtual2DArray array = getExecuter().executeQuery( new Select( sql ) );
+ Virtual2DArray array = getExecuter().executeQuery( select );
if ( array != null )
{
- for ( int i = 0; i < array.columnLength(); i++ )
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer estado = array.get( i, 0 );
Long count = array.get( i, 1 );
@@ -229,9 +208,9 @@ public class EstatisticasDataProvider extends GenericDataProvider
return stats;
}
- public com.sun.rave.web.ui.model.Option[] getSeccoesList( ) throws Exception
+ public Option[] getSeccoesList( ) throws Exception
{
- com.sun.rave.web.ui.model.Option[] options = null;
+ Option[] options = null;
Select2 query = new Select2(
new String[] { SeccoesData.TABLENAME },
new Integer[] { },
@@ -245,9 +224,9 @@ public class EstatisticasDataProvider extends GenericDataProvider
Virtual2DArray array = getExecuter().executeQuery( query );
if ( array != null )
{
- options = new com.sun.rave.web.ui.model.Option[ array.columnLength() + 1 ];
+ options = new Option[ array.rowCount() + 1 ];
options[ 0 ] = new Option( "", "" );
- for ( int i = 0; i < array.columnLength(); i++ )
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer seccaoID = array.get( i, 0 );
String seccao = array.get( i, 1 );
@@ -260,14 +239,14 @@ public class EstatisticasDataProvider extends GenericDataProvider
public SeccoesData loadSeccaoByID( Integer seccaoID ) throws Exception
{
- return getProvider().load( SeccoesData.class, seccaoID, SeccoesData.ID );
+ return getProvider().load( SeccoesData.class, seccaoID, SeccoesData.ID, null );
}
public String getCausaByID( Integer causaID ) throws Exception
{
String causa = "";
- CausasData causaData = getProvider().load( CausasData.class, causaID, CausasData.ID );
+ CausasData causaData = getProvider().load( CausasData.class, causaID, CausasData.ID, null );
if ( causaData != null )
{
causa = causaData.getCausa();
@@ -275,27 +254,28 @@ public class EstatisticasDataProvider extends GenericDataProvider
return causa;
}
- public com.sun.rave.web.ui.model.Option[] getEstabelecimentos() throws Exception
+ public Option[] getEstabelecimentos( ) throws Exception
{
- com.sun.rave.web.ui.model.Option[] options = null;
+ Option[] options = null;
+
+ Expression where = new Field( db.data.siprp_local.outer.EstabelecimentosData.INACTIVO_FULL ).isDifferent( "y" );
Select2 query = new Select2(
- new String[] { EstabelecimentosData.TABLENAME },
+ new String[] { db.data.siprp_local.outer.EstabelecimentosData.TABLENAME },
new Integer[] { },
new Expression[] {},
- new String[] {
- EstabelecimentosData.ID_FULL, EstabelecimentosData.NOME_FULL
+ new String[] {
+ db.data.siprp_local.outer.EstabelecimentosData.ID_FULL, db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL
},
- new Field( EstabelecimentosData.INACTIVO_FULL ).isDifferent( "y" )
- .and( new Field( EstabelecimentosData.EMPRESA_ID_FULL ).isEqual( Global.AUCHAN ) ),
- new String[] { EstabelecimentosData.NOME_FULL },
+ where,
+ new String[] { db.data.siprp_local.outer.EstabelecimentosData.NOME_FULL },
null, null, null );
Virtual2DArray array = getLocalExecuter().executeQuery( query );
if ( array != null )
{
- options = new com.sun.rave.web.ui.model.Option[ array.columnLength() + 1 ];
+ options = new Option[ array.rowCount() + 1 ];
options[ 0 ] = new Option( "", "" );
- for ( int i = 0; i < array.columnLength(); i++ )
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer estabelecimentoID = array.get( i, 0 );
String estabelecimentoNome = array.get( i, 1 );
@@ -308,7 +288,7 @@ public class EstatisticasDataProvider extends GenericDataProvider
public String getEstabelecimentoByID( Integer estabelecimentoID ) throws Exception
{
String estabelecimento = "";
- EstabelecimentosData estabelecimentoData = getLocalProvider().load( EstabelecimentosData.class, estabelecimentoID, EstabelecimentosData.ID );
+ db.data.siprp_local.outer.EstabelecimentosData estabelecimentoData = getLocalProvider().load( db.data.siprp_local.outer.EstabelecimentosData.class, estabelecimentoID, db.data.siprp_local.outer.EstabelecimentosData.ID, null );
if ( estabelecimentoData != null )
{
estabelecimento = estabelecimentoData.getNome();
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/EvoBaseProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/EvoBaseProvider.java
index f67a64a0..0e3be9d6 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/EvoBaseProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/EvoBaseProvider.java
@@ -17,7 +17,6 @@ import com.evolute.utils.db.DBException;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.db.JDBCManager;
-import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.jdbc.DBStatementExecuter;
import com.evolute.utils.jdbc.StatementExecuterFactory;
import com.evolute.utils.sql.SQLQuery;
@@ -25,13 +24,6 @@ import com.evolute.utils.sql.backend.BackendProvider;
import com.evolute.utils.strings.UnicodeChecker;
import db.DBConstants;
import db.DBPropertiesLoader;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpSession;
/**
*
@@ -71,16 +63,12 @@ public class EvoBaseProvider
String username = DBPropertiesLoader.getInstance().findProperty( DBConstants.USERNAME_SIPRP );
String password = DBPropertiesLoader.getInstance().findProperty( DBConstants.PASSWORD_SIPRP );
-// System.out.println( "\t" + server + " : " + port + " : " + dbname + " : " + username + " : " + password );
-
String server_local = DBPropertiesLoader.getInstance().findProperty( DBConstants.SERVER_SIPRP_LOCAL );
int port_local = DBPropertiesLoader.getInstance().findProperty( DBConstants.PORT_SIPRP_LOCAL, -1 );
String dbname_local = DBPropertiesLoader.getInstance().findProperty( DBConstants.DATABASE_SIPRP_LOCAL );
String username_local = DBPropertiesLoader.getInstance().findProperty( DBConstants.USERNAME_SIPRP_LOCAL );
String password_local = DBPropertiesLoader.getInstance().findProperty( DBConstants.PASSWORD_SIPRP_LOCAL );
-// System.out.println( "\t" + server_local + " : " + port_local + " : " + dbname_local + " : " + username_local + " : " + password_local );
-
init( DBConstants.DB.SIPRP, server, port, dbname, username, password );
init( DBConstants.DB.SIPRP_LOCAL, server_local, port_local, dbname_local, username_local, password_local );
}
@@ -112,12 +100,10 @@ public class EvoBaseProvider
dbManager.close();
}
String dbUrl = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL );
- DBManager manager = new JDBCManager( dbUrl, username, password , 14, 7, 7, new SQLQuery[] { } );
+ DBManager manager = new JDBCManager( dbUrl, username, password , 14, 7, new SQLQuery[] { } );
StatementExecuterFactory.initialize( new DBStatementExecuter( manager.getSharedExecuter( EvoBaseProvider.class ) ) );
UnicodeChecker.setUseDoubleSlash( true );
-// Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
dbManager = manager;
-// System.out.println( "\nDBManager : " + dbManager );
}
else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) )
{
@@ -126,13 +112,11 @@ public class EvoBaseProvider
localDBManager.close();
}
String dbUrl = ( String ) Singleton.getInstance( DBConstants.LOCAL_CONNECTION_URL );
- DBManager manager = new JDBCManager( dbUrl, username, password , 14, 7, 7, new SQLQuery[] { } );
+ DBManager manager = new JDBCManager( dbUrl, username, password , 14, 7, new SQLQuery[] { } );
StatementExecuterFactory.initialize( new DBStatementExecuter( manager.getSharedExecuter( EvoBaseProvider.class ) ) );
UnicodeChecker.setUseDoubleSlash( true );
-// Insert.setDefaultKeyRetriever( PostgresqlAutoKeyRetriever.RETRIEVER );
localDBManager = manager;
Singleton.setInstance( Singleton.DEFAULT_DBMANAGER, localDBManager );
-// System.out.println( "\nLocalDBManager : " + localDBManager );
}
}
@@ -151,6 +135,7 @@ public class EvoBaseProvider
}
}
+ @SuppressWarnings( "unchecked" )
private static ProviderInterface< EvoDataObject< ? >, EvoDataException > createInstance( DBConstants.DB db, String url, String user, String password )
{
ProviderRegistry.registerDefaultProviderFactory( new EvoDataProviderFactory() );
@@ -178,6 +163,11 @@ public class EvoBaseProvider
return getProvider( DBConstants.DB.SIPRP );
}
+ public ProviderInterface< EvoDataObject< ? >, EvoDataException > getLocalProvider()
+ {
+ return getProvider( DBConstants.DB.SIPRP_LOCAL );
+ }
+
public ProviderInterface< EvoDataObject< ? >, EvoDataException > getProvider( DBConstants.DB db )
{
ProviderInterface< EvoDataObject< ? >, EvoDataException > provider = null;
@@ -214,20 +204,12 @@ public class EvoBaseProvider
}
public Executer getExecuter() throws DBException
- {
- return getExecuter( this );
- }
-
- private Executer getExecuter( Object clazz ) throws DBException
{
if ( getDbManager() == null )
{
init();
}
-// DBManager dbm = ( DBManager ) Singleton.getInstance( DBConstants.DEFAULT_DBMANAGER );
-// return dbm.getSharedExecuter( this );
-
DBManager dbm = getDbManager( DBConstants.DB.SIPRP );
if ( dbm != null )
{
@@ -237,18 +219,11 @@ public class EvoBaseProvider
}
public Executer getLocalExecuter() throws DBException
- {
- return getLocalExecuter( this );
- }
-
- private Executer getLocalExecuter( Object clazz ) throws DBException
{
if ( getDbManager( DBConstants.DB.SIPRP_LOCAL ) == null )
{
init();
}
-// DBManager dbm = ( DBManager ) Singleton.getInstance( DBConstants.LOCAL_DBMANAGER );
-// return dbm.getSharedExecuter( this );
DBManager dbm = getDbManager( DBConstants.DB.SIPRP_LOCAL );
if ( dbm != null )
@@ -258,113 +233,4 @@ public class EvoBaseProvider
return null;
}
- @Deprecated
- public Statement createStatement()
- {
- String connectionURL = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL );
- String username = DBPropertiesLoader.getInstance().findProperty( DBConstants.USERNAME_SIPRP );
- String password = DBPropertiesLoader.getInstance().findProperty( DBConstants.PASSWORD_SIPRP );
-
- return getStatement( DBConstants.DB.SIPRP, connectionURL, username, password );
- }
-
- @Deprecated
- public Statement createLocalStatement()
- {
- String connectionURL = ( String ) Singleton.getInstance( DBConstants.LOCAL_CONNECTION_URL );
- String username = DBPropertiesLoader.getInstance().findProperty( DBConstants.USERNAME_SIPRP_LOCAL );
- String password = DBPropertiesLoader.getInstance().findProperty( DBConstants.PASSWORD_SIPRP_LOCAL );
-
- return getStatement( DBConstants.DB.SIPRP_LOCAL, connectionURL, username, password );
- }
-
- private Statement getStatement( DBConstants.DB db, String connectionURL, String username, String password )
- {
- Statement stm = null;
- try
- {
- Connection connection = getConnection( db, connectionURL, username, password );
- if ( connection != null )
- {
- stm = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
- }
- }
- catch ( Exception e )
- {
- ErrorLogger.logException( e );
- }
- return stm;
- }
-
- private Connection getConnection( DBConstants.DB db, String connectionURL, String username, String password ) throws Exception
- {
- Connection connection = null;
-// System.out.println( "\nEvoBaseProvider . getConnection( " + connectionURL + ", " + username + " ) : " );
-
- FacesContext fc = FacesContext.getCurrentInstance();
-// System.out.println( "\tFacesContext : " + fc );
- if ( fc != null )
- {
-
- ExternalContext ec = fc.getExternalContext();
- // System.out.println( "\tExternalContext : " + ec );
- if ( ec != null )
- {
- HttpSession session = ( HttpSession ) ec.getSession( false );
- // System.out.println( "\tSession : " + session );
-
- if ( session != null )
- {
- if ( DBConstants.DB.SIPRP.equals( db ) )
- {
- connection = ( Connection ) session.getAttribute( DBConstants.SESSION_CONNECTION );
- if ( connection == null )
- {
- // System.out.println( "\n-> Creating new SIPRP connection ..." );
- Class.forName( "org.postgresql.Driver" ).newInstance();
- connection = DriverManager.getConnection( connectionURL, username, password );
- session.setAttribute( DBConstants.SESSION_CONNECTION, connection );
- }
- }
- else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) )
- {
- connection = ( Connection ) session.getAttribute( DBConstants.SESSION_CONNECTION_LOCAL );
- if ( connection == null )
- {
- // System.out.println( "\n-> Creating new SIPRP_LOCAL connection ..." );
- Class.forName( "org.postgresql.Driver" ).newInstance();
- connection = DriverManager.getConnection( connectionURL, username, password );
- session.setAttribute( DBConstants.SESSION_CONNECTION_LOCAL, connection );
- }
- }
- }
- }
- }
-
- if ( connection == null )
- {
- connection = ( Connection ) Singleton.getInstance( "CONNECTION_OBJECT" );
- if ( connection == null )
- {
- // System.out.println( "\nEvoBaseProvider . getConnection() : session is null !" );
-
- if ( DBConstants.DB.SIPRP.equals( db ) )
- {
- // System.out.println( "\t-> Creating new SIPRP connection ..." );
- Class.forName( "org.postgresql.Driver" ).newInstance();
- connection = DriverManager.getConnection( connectionURL, username, password );
- }
- else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) )
- {
- // System.out.println( "\t-> Creating new SIPRP_LOCAL connection ..." );
- Class.forName( "org.postgresql.Driver" ).newInstance();
- connection = DriverManager.getConnection( connectionURL, username, password );
- }
- Singleton.setInstance( "CONNECTION_OBJECT", connection );
- }
- }
-
-// System.out.println( "<-- getConnection() : " + connection );
- return connection;
- }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/GenericDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/GenericDataProvider.java
index fa61ac52..c2bddb65 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/GenericDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/GenericDataProvider.java
@@ -8,13 +8,8 @@ package db.providers;
import com.evolute.entity.ProviderInterface;
import com.evolute.entity.evo.EvoDataException;
import com.evolute.entity.evo.EvoDataObject;
-import com.evolute.utils.arrays.Virtual2DArray;
-import com.evolute.utils.db.DBException;
import com.evolute.utils.db.Executer;
-import com.evolute.utils.error.ErrorLogger;
import db.DBConstants;
-import java.sql.ResultSet;
-import java.sql.Statement;
public abstract class GenericDataProvider
@@ -53,81 +48,4 @@ public abstract class GenericDataProvider
{
return localProvider;
}
-
-
-// public void checkConnection()
-// {
-// Db db = Db.getInstance();
-// if ( db.getConnection() == null )
-// {
-// try
-// {
-// db.connect();
-// }
-// catch ( Exception ex )
-// {
-// ErrorLogger.logException( ex );
-// }
-// }
-// }
-
- protected Integer getInsertedID( Virtual2DArray array )
- {
- Integer id = null;
- if ( array != null && array.columnLength() > 0 )
- {
- id = array.get( 0, 0 );
- }
- return id;
- }
- protected Integer getMaxTableId(String table)
- {
- Statement st = createStatement();
- String id = table + ".id";
- String sql = "SELECT max(" + id + ")+1 AS MAXID FROM " + table;
- try
- {
- ResultSet rs = st.executeQuery(sql);
- rs.first();
- Integer newId = new Integer(rs.getInt("MAXID"));
- if(newId.intValue() == 0)
- {
- newId = new Integer(1);
- }
- return newId;
- }
- catch(Exception ex)
- {
- return new Integer(1);
- }
- }
-
- protected Statement createStatement()
- {
- try
- {
-// Db db = Db.getInstance();
-// return db.createStatement();
- return EvoBaseProvider.getInstance().createStatement();
- }
- catch ( DBException ex )
- {
- ErrorLogger.logException( ex );
- }
- return null;
- }
-
- protected Statement createLocalStatement()
- {
- try
- {
- return EvoBaseProvider.getInstance().createLocalStatement();
- }
- catch ( DBException ex )
- {
- ErrorLogger.logException( ex );
- }
- return null;
- }
-
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/db/providers/UtilizadoresDataProvider.java b/trunk/AnaliseAcidentesTrabalho/src/db/providers/UtilizadoresDataProvider.java
index b01ad691..9d3b59d1 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/db/providers/UtilizadoresDataProvider.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/db/providers/UtilizadoresDataProvider.java
@@ -11,9 +11,9 @@ package db.providers;
import beans.Medico;
import beans.Permissao;
-import beans.TecnicoSaude;
import beans.Utilizador;
import com.evolute.utils.arrays.Virtual2DArray;
+import com.evolute.utils.db.DBException;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
@@ -21,17 +21,15 @@ import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.expression.Par;
import com.evolute.utils.strings.StringPlainer;
-import com.sun.rave.web.ui.model.Option;
+import db.data.siprp.outer.EmpresasData;
+import db.data.siprp.outer.PermissoesData;
import db.data.siprp.outer.TiposUtilizadoresData;
import db.data.siprp.outer.UtilizadoresData;
import global.Global;
-import java.sql.ResultSet;
-import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import utils.Utils;
/**
@@ -56,238 +54,94 @@ public class UtilizadoresDataProvider extends GenericDataProvider
return INSTANCE;
}
-
- public Integer getMaxUserId()
- {
- Integer newId = new Integer( 1 );
-
- Statement st = createStatement();
- String sql = "SELECT max( utilizadores.id ) + 1 AS MAXUSERID FROM utilizadores";
- try
- {
- ResultSet rs = st.executeQuery( sql );
- rs.first();
- newId = new Integer( rs.getInt( "MAXUSERID" ) );
- if ( newId.intValue() == 0 )
- {
- newId = new Integer( 1 );
- }
- }
- catch ( Exception ex )
- {
- ErrorLogger.logException( ex );
- }
- return newId;
- }
-
public Integer createNewUtilizador( Utilizador u ) throws Exception
{
- Statement st = createStatement();
- Integer newUserId = getMaxUserId();
-
- String sql = "INSERT INTO utilizadores (id, login, password, data_password, email, empresa_id, estabelecimento_id, administrador, tipo, numero_cedula, cap, nome, medico_id, funcionario_hst_id, activo, responsavel_loja, gestor_geral, numero_mecanografico) VALUES (";
- sql += newUserId + ", '";
- sql += u.getLogin() + "', '";
- sql += u.getPassword() + "', ";
- if(u.getData_password() == null)
- {
- sql += null + ", '";
- }
- else
- {
- sql += "'" + u.getData_password() + "', '";
- }
- sql += u.getEmail() + "', ";
- sql += u.getEmpresa_id() + ", ";
- sql += u.getEstabelecimento_id() + ", '";
- sql += u.getAdministrador() + "', ";
- sql += u.getTipo() + ", '";
- sql += u.getNumero_cedula() + "', '";
- sql += u.getCap() + "', '";
- sql += u.getNome() + "', ";
- sql += u.getMedico_id() + ", ";
- sql += u.getFuncionario_hst_id() + ", '";
- sql += u.getActivo() + "', '";
- sql += u.getResponsavel_loja() + "', '";
- sql += u.getGestor_geral() + "', '";
- sql += u.getNumero_mecanografico() + "')";
- System.out.println("USER SQL : " + sql);
- st.execute(sql);
- return newUserId;
+ return UtilizadoresData.createUtilizador( u )
+ .withProvider( EvoBaseProvider.getInstance().getProvider() )
+ .saveMe().refreshMe().getID();
}
public void updateUtilizador(Utilizador u) throws Exception
{
- Statement st = createStatement();
- String sql = "";
- if(u.getData_password() == null)
- {
- sql = "UPDATE utilizadores SET login = '" + u.getLogin() + "', password = '" + u.getPassword() + "', data_password = " + null + ", email = '" + u.getEmail() + "', empresa_id = " + u.getEmpresa_id() + ", estabelecimento_id = " + u.getEstabelecimento_id() + ", administrador = '" + u.getAdministrador() + "', tipo = " + u.getTipo() + ", numero_cedula = '" + u.getNumero_cedula() + "', cap = '" + u.getCap() + "', nome = '" + u.getNome() + "', medico_id = " + u.getMedico_id() + ", funcionario_hst_id = " + u.getFuncionario_hst_id() + ", activo = '" + u.getActivo() + "', responsavel_loja = '" + u.getResponsavel_loja() + "', gestor_geral = '" + u.getGestor_geral() + "', primeiro_login = '" + u.getPrimeiro_login() + "' WHERE id = " + u.getId();
- }
- else
- {
- sql = "UPDATE utilizadores SET login = '" + u.getLogin() + "', password = '" + u.getPassword() + "', data_password = '" + u.getData_password() + "', email = '" + u.getEmail() + "', empresa_id = " + u.getEmpresa_id() + ", estabelecimento_id = " + u.getEstabelecimento_id() + ", administrador = '" + u.getAdministrador() + "', tipo = " + u.getTipo() + ", numero_cedula = '" + u.getNumero_cedula() + "', cap = '" + u.getCap() + "', nome = '" + u.getNome() + "', medico_id = " + u.getMedico_id() + ", funcionario_hst_id = " + u.getFuncionario_hst_id() + ", activo = '" + u.getActivo() + "', responsavel_loja = '" + u.getResponsavel_loja() + "', gestor_geral = '" + u.getGestor_geral() + "', primeiro_login = '" + u.getPrimeiro_login() + "' WHERE id = " + u.getId();
- }
-
- System.out.println("SQL UPDATE USER : " + sql);
- st.execute(sql);
+ EvoBaseProvider.getInstance().getProvider().load(
+ UtilizadoresData.class,
+ new Object[]{ u.getId() }, new String[]{ UtilizadoresData.ID_FULL }, null ).update( u ).save();
}
public void deleteUser( Integer userID ) throws Exception
{
- Statement st = createStatement();
- String sql = "UPDATE utilizadores SET apagado = 'y', activo = 'n' WHERE id = " + userID;
- st.execute(sql);
+ EvoBaseProvider.getInstance().getProvider().load(
+ UtilizadoresData.class,
+ new Object[]{ userID }, new String[]{ UtilizadoresData.ID_FULL }, null ).withActivo( "n" ).withApagado( "y" ).save();
}
public Utilizador getUtilizador(String login) throws Exception
{
- Utilizador u = new Utilizador();
- Statement st = createStatement();
- String sql = "SELECT * FROM utilizadores WHERE LOWER(login) = '" + login.toLowerCase() + "' AND apagado = 'n'";
- ResultSet rs = st.executeQuery(sql);
- if ( rs.first() )
- {
- u.setId(new Integer(rs.getInt("id")));
- u.setLogin(rs.getString("login"));
- u.setPassword(rs.getString("password"));
- u.setData_password(rs.getDate("data_password"));
- u.setEmail(rs.getString("email"));
- u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
- u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
- u.setAdministrador(rs.getString("administrador"));
- u.setTipo(new Integer(rs.getInt("tipo")));
- u.setNumero_cedula(rs.getString("numero_cedula"));
- u.setCap(rs.getString("cap"));
- u.setNome(rs.getString("nome"));
- u.setMedico_id(new Integer(rs.getInt("medico_id")));
- u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
- u.setActivo(rs.getString("activo"));
- u.setResponsavel_loja(rs.getString("responsavel_loja"));
- u.setGestor_geral(rs.getString("gestor_geral"));
- u.setPrimeiro_login(rs.getString("primeiro_login"));
- u.setApagado(rs.getString("apagado"));
- }
- return u;
+ return Utilizador.createUtilizador( EvoBaseProvider.getInstance().getProvider().load( UtilizadoresData.class, new Object[]{ login, "n" }, new String[]{ UtilizadoresData.LOGIN_FULL, UtilizadoresData.APAGADO_FULL }, null ) );
}
public Utilizador getUtilizador(Integer id) throws Exception
{
- Utilizador u = new Utilizador();
- Statement st = createStatement();
- String sql = "SELECT * FROM utilizadores WHERE id = " + id;
- ResultSet rs = st.executeQuery(sql);
-
- if ( rs.first() )
- {
- u.setId(new Integer(rs.getInt("id")));
- u.setLogin(rs.getString("login"));
- u.setPassword(rs.getString("password"));
- u.setData_password(rs.getDate("data_password"));
- u.setEmail(rs.getString("email"));
- u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
- u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
- u.setAdministrador(rs.getString("administrador"));
- u.setTipo(new Integer(rs.getInt("tipo")));
- u.setNumero_cedula(rs.getString("numero_cedula"));
- u.setCap(rs.getString("cap"));
- u.setNome(rs.getString("nome"));
- u.setMedico_id(new Integer(rs.getInt("medico_id")));
- u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
- u.setActivo(rs.getString("activo"));
- u.setResponsavel_loja(rs.getString("responsavel_loja"));
- u.setGestor_geral(rs.getString("gestor_geral"));
- u.setApagado(rs.getString("apagado"));
- }
- return u;
+ return Utilizador.createUtilizador( EvoBaseProvider.getInstance().getProvider().load(
+ UtilizadoresData.class,
+ new Object[]{ id }, new String[]{ UtilizadoresData.ID_FULL }, null ) );
}
- public ArrayList getUtilizadoresListByTipo( Integer tipo, String responsavel_loja, Integer estabelecimento_id )
+ public ArrayList< Utilizador > getUtilizadoresListByTipo( Integer tipo, String responsavel_loja, Integer estabelecimento_id )
throws Exception
{
- ArrayList list = new ArrayList();
- Statement st = createStatement();
- String sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo;
- String estabelecimento_constraint = "";
- if( tipo != null && ( tipo.intValue() == Global.TIPO_UTILIZADOR_RH || tipo.intValue() == Global.TIPO_UTILIZADOR_SEGURANCA ) )
- {
- estabelecimento_constraint = " AND estabelecimento_id = " + estabelecimento_id;
- }
- sql += estabelecimento_constraint;
+ ArrayList list = new ArrayList();
- if ( "y".equals( responsavel_loja ) )
- {
- sql += " AND responsavel_loja = 'y'";
-// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND responsavel_loja = 'y' AND tipo = " + tipo + estabelecimento_constraint;
- }
-// else
-// {
-// sql = "SELECT * FROM utilizadores WHERE activo = 'y' AND apagado = 'n' AND tipo = " + tipo + estabelecimento_constraint;
-// }
-
- ResultSet rs = st.executeQuery( sql );
-// rs.first();
-// do
-// {
- while ( rs != null && rs.next() )
- {
- Utilizador u = new Utilizador();
- u.setId(new Integer(rs.getInt("id")));
- u.setLogin(rs.getString("login"));
- u.setPassword(rs.getString("password"));
- u.setData_password(rs.getDate("data_password"));
- u.setEmail(rs.getString("email"));
- u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
- u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
- u.setAdministrador(rs.getString("administrador"));
- u.setTipo(new Integer(rs.getInt("tipo")));
- u.setNumero_cedula(rs.getString("numero_cedula"));
- u.setCap(rs.getString("cap"));
- u.setNome(rs.getString("nome"));
- u.setMedico_id(new Integer(rs.getInt("medico_id")));
- u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
- u.setActivo(rs.getString("activo"));
- u.setResponsavel_loja(rs.getString("responsavel_loja"));
- list.add( u );
- }
-// }while(rs.next());
+ List utilizadoresData;
+
+ if( tipo != null && ( tipo == Global.TIPO_UTILIZADOR_RH || tipo == Global.TIPO_UTILIZADOR_SEGURANCA ) )
+ {
+ utilizadoresData = getProvider().listLoad( UtilizadoresData.class, new Object[]{ "y", "n", tipo, estabelecimento_id, responsavel_loja }, new String[]{ UtilizadoresData.ACTIVO_FULL, UtilizadoresData.APAGADO_FULL, UtilizadoresData.TIPO_FULL, UtilizadoresData.ESTABELECIMENTO_ID_FULL, UtilizadoresData.RESPONSAVEL_LOJA_FULL }, new String[]{ UtilizadoresData.NOME_FULL }, null );
+ }
+ else
+ {
+ utilizadoresData = getProvider().listLoad( UtilizadoresData.class, new Object[]{ "y", "n", tipo, responsavel_loja }, new String[]{ UtilizadoresData.ACTIVO_FULL, UtilizadoresData.APAGADO_FULL, UtilizadoresData.TIPO_FULL, UtilizadoresData.RESPONSAVEL_LOJA_FULL }, new String[]{ UtilizadoresData.NOME_FULL }, null );
+ }
+
+ for( UtilizadoresData utilizadorData : utilizadoresData )
+ {
+ list.add( Utilizador.createUtilizador( utilizadorData ) );
+ }
return list;
}
+ @SuppressWarnings( { "ConstantConditions", "UnusedParameters" } )
public List< Utilizador > getUtilizadoresList( String por, String nome, String login, Integer estabelecimentoID, String activo, String dirRH )
throws Exception
{
List< Utilizador > listUtilizadores = new LinkedList< Utilizador >();
-// por = por == null ? "" : por;
nome = nome == null ? null : StringPlainer.convertString( nome.replaceAll( " ", "%" ) );
login = login == null ? null : StringPlainer.convertString( login.replaceAll( " ", "%" ) );
activo = activo == null ? "y" : activo;
- dirRH = dirRH == null ? "n" : dirRH;
- boolean isDirRH = "y".equals( dirRH );
Expression whereExpression = new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" );
whereExpression = whereExpression.and( new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( activo ) );
whereExpression = whereExpression.and( new Field( UtilizadoresData.TIPO_FULL ).isDifferent( Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP ) );
- if ( por != null )
+ if( por != null )
{
whereExpression = whereExpression.and( new Field( "plain( " + UtilizadoresData.NUMERO_MECANOGRAFICO_FULL + " )" ).isILike( "%" + por + "%" ) );
}
- if ( nome != null )
+ if( nome != null )
{
Expression nomeExpression = new Field( "plain( " + UtilizadoresData.NOME_FULL + " )" ).isILike( "%" + nome + "%" ).or(
new Field( "plain_utf8( " + UtilizadoresData.NOME_FULL + " )" ).isILike( "%" + nome + "%" ) );
whereExpression = whereExpression.and( new Par( nomeExpression ) );
}
- if ( login != null )
+ if( login != null )
{
Expression loginExpression = new Field( "plain( " + UtilizadoresData.LOGIN_FULL + " )" ).isILike( "%" + login + "%" ).or(
new Field( "plain_utf8( " + UtilizadoresData.LOGIN_FULL + " )" ).isILike( "%" + login + "%" ) );
whereExpression = whereExpression.and( new Par( loginExpression ) );
}
- if ( estabelecimentoID != null )
+ if( estabelecimentoID != null )
{
whereExpression = whereExpression.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
}
@@ -319,7 +173,7 @@ public class UtilizadoresDataProvider extends GenericDataProvider
Virtual2DArray array = getExecuter().executeQuery( query );
if ( array != null )
{
- for ( int i = 0; i < array.columnLength(); i++ )
+ for ( int i = 0; i < array.rowCount(); i++ )
{
Integer userID = array.get( i, 0 );
String loginUtilizador = array.get( i, 1 );
@@ -338,7 +192,6 @@ public class UtilizadoresDataProvider extends GenericDataProvider
String responsavelLoja = array.get( i, 14 );
String numeroMecanografico = array.get( i, 15 );
String gestorGeral = array.get( i, 16 );
- String primeiroLogin = array.get( i, 17 );
String apagado = array.get( i, 18 );
Date dataPassword = array.get( i, 19 );
java.sql.Date sqlDataPassword = dataPassword == null ? null : new java.sql.Date( dataPassword.getTime() );
@@ -354,224 +207,63 @@ public class UtilizadoresDataProvider extends GenericDataProvider
ErrorLogger.logException( e );
}
- Utilizador u = new Utilizador();
- u.setId( userID );
- u.setLogin( loginUtilizador );
- u.setPassword( password );
- u.setData_password( sqlDataPassword );
- u.setEmail( email );
- u.setEmpresa_id( empresaID );
- u.setEstabelecimento_id( estabelecimento_ID );
- u.setAdministrador( administrador );
- u.setTipo( tipoTIPO );
- u.setNumero_cedula( numeroCedula );
- u.setCap( cap );
- u.setNome( Utils.htmlToText( Utils.unicodeToHTML( nomeUtilizador ) ) );
- u.setMedico_id( medicoID );
- u.setFuncionario_hst_id( funcionarioHSTID );
- u.setActivo( activoUtilizador );
- u.setResponsavel_loja( responsavelLoja );
- u.setGestor_geral( gestorGeral );
- u.setNumero_mecanografico( numeroMecanografico );
- u.setCategoria( categoria );
- u.setApagado( apagado );
- u.setNome_estabelecimento( Utils.htmlToText( Utils.unicodeToHTML( nomeEstabelecimento ) ) );
-
- listUtilizadores.add( u );
+ listUtilizadores.add(
+ Utilizador.createUtilizador( )
+ .withId( userID )
+ .withLogin( loginUtilizador )
+ .withPassword( password )
+ .withData_password( sqlDataPassword )
+ .withEmail( email )
+ .withEmpresa_id( empresaID )
+ .withEstabelecimento_id( estabelecimento_ID )
+ .withAdministrador( administrador )
+ .withTipo( tipoTIPO )
+ .withNumero_cedula( numeroCedula )
+ .withCap( cap )
+ .withNome( Utils.htmlToText( Utils.unicodeToHTML( nomeUtilizador ) ) )
+ .withMedico_id( medicoID )
+ .withFuncionario_hst_id( funcionarioHSTID )
+ .withActivo( activoUtilizador )
+ .withResponsavel_loja( responsavelLoja )
+ .withGestor_geral( gestorGeral )
+ .withNumero_mecanografico( numeroMecanografico )
+ .withCategoria( categoria )
+ .withApagado( apagado )
+ .withNome_estabelecimento( Utils.htmlToText( Utils.unicodeToHTML( nomeEstabelecimento ) ) ) );
}
}
return listUtilizadores;
}
-// public List< Utilizador > getUtilizadoresList(String por, String nome, Integer estabelecimento_id, String activo, String booDirRh) throws Exception
-// {
-// StringTokenizer stk = null;
-// AnalisesDataProvider adp = AnalisesDataProvider.getInstance();
-// List< Utilizador > list = new LinkedList< Utilizador >();
-// Statement st = createStatement();
-//
-// String sql = "";
-// String sql1 = "";
-// String sql2 = "";
-// String sql3 = "";
-// if(por != null && nome != null && estabelecimento_id != null)
-// {
-// sql1 = "SELECT * FROM utilizadores, tipos_utilizadores " +
-// "WHERE utilizadores.tipo = tipos_utilizadores.tipo AND LOWER(numero_mecanografico) LIKE '%" + por + "%' AND (";
-// sql3 = ") AND estabelecimento_id = " + estabelecimento_id + " AND utilizadores.activo ='" + activo + "' AND apagado = 'n' AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP + " ORDER BY numero_mecanografico";
-// stk = new StringTokenizer (nome);
-// int n = 0;
-// while (stk.hasMoreTokens ()) {
-// if(n > 0)
-// {
-// sql2 += "AND ";
-// }
-// sql2 += "LOWER(nome) LIKE '%" + stk.nextToken () + "%' ";
-// n++;
-// }
-// sql = sql1 + sql2 + sql3;
-// }
-// else if(por != null && nome != null)
-// {
-// sql1 = "SELECT * FROM utilizadores, tipos_utilizadores " +
-// "WHERE utilizadores.tipo = tipos_utilizadores.tipo AND LOWER(numero_mecanografico) LIKE '%" + por + "%' AND (";
-// sql3 = ") AND utilizadores.activo ='" + activo + "' AND apagado = 'n' AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// stk = new StringTokenizer (nome);
-// int n = 0;
-// while (stk.hasMoreTokens ()) {
-// if(n > 0)
-// {
-// sql2 += "AND ";
-// }
-// sql2 += "LOWER(nome) LIKE '%" + stk.nextToken () + "%' ";
-// n++;
-// }
-// sql = sql1 + sql2 + sql3;
-// }
-// else if(por != null && estabelecimento_id != null)
-// {
-// sql = "SELECT * FROM utilizadores, tipos_utilizadores " +
-// "WHERE utilizadores.tipo = tipos_utilizadores.tipo " +
-// "AND LOWER(numero_mecanografico) LIKE '%" + por + "%' AND estabelecimento_id = " + estabelecimento_id +
-// " AND utilizadores.activo ='" + activo + "' AND apagado = 'n' AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// }
-// else if(nome != null && estabelecimento_id != null)
-// {
-// sql1 = "SELECT * FROM utilizadores, tipos_utilizadores WHERE utilizadores.tipo = tipos_utilizadores.tipo AND (";
-// sql3 = ") AND estabelecimento_id = " + estabelecimento_id + " AND utilizadores.activo ='" + activo + "' AND apagado = 'n' " +
-// "AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// stk = new StringTokenizer (nome);
-// int n = 0;
-// while (stk.hasMoreTokens ()) {
-// if(n > 0)
-// {
-// sql2 += "AND ";
-// }
-// sql2 += "LOWER(nome) LIKE '%" + stk.nextToken () + "%' ";
-// n++;
-// }
-// sql = sql1 + sql2 + sql3;
-// }
-// else if(por != null)
-// {
-// sql = "SELECT * FROM utilizadores, tipos_utilizadores WHERE utilizadores.tipo = tipos_utilizadores.tipo " +
-// "AND LOWER(numero_mecanografico) LIKE '%" + por + "%' AND utilizadores.activo ='" + activo + "' AND apagado = 'n' " +
-// "AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// }
-// else if(nome != null)
-// {
-// sql1 = "SELECT * FROM utilizadores, tipos_utilizadores WHERE utilizadores.tipo = tipos_utilizadores.tipo AND (";
-// sql3 = ") AND utilizadores.activo ='" + activo + "' AND apagado = 'n' AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// stk = new StringTokenizer (nome);
-// int n = 0;
-// while (stk.hasMoreTokens ()) {
-// if(n > 0)
-// {
-// sql2 += "AND ";
-// }
-// sql2 += "LOWER(nome) LIKE '%" + stk.nextToken () + "%' ";
-// n++;
-// }
-// sql = sql1 + sql2 + sql3;
-// }
-// else if(estabelecimento_id != null)
-// {
-// sql = "SELECT * FROM utilizadores, tipos_utilizadores WHERE utilizadores.tipo = tipos_utilizadores.tipo " +
-// "AND estabelecimento_id = " + estabelecimento_id + " AND utilizadores.activo ='" + activo + "' AND apagado = 'n' " +
-// "AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// }
-// else
-// {
-// sql = "SELECT * FROM utilizadores, tipos_utilizadores WHERE utilizadores.tipo = tipos_utilizadores.tipo " +
-// "AND utilizadores.activo ='" + activo + "' AND apagado = 'n' AND utilizadores.tipo <> " + Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP +
-// " ORDER BY numero_mecanografico";
-// }
-// System.out.println("UTILIZADORES SQL : " + sql);
-// ResultSet rs = st.executeQuery(sql);
-// rs.first();
-// do
-// {
-// Utilizador u = new Utilizador();
-// u.setId(new Integer(rs.getInt(1)));
-// u.setLogin(rs.getString("login"));
-// u.setPassword(rs.getString("password"));
-// u.setData_password(rs.getDate("data_password"));
-// u.setEmail(rs.getString("email"));
-// u.setEmpresa_id(new Integer(rs.getInt("empresa_id")));
-// u.setEstabelecimento_id(new Integer(rs.getInt("estabelecimento_id")));
-// u.setAdministrador(rs.getString("administrador"));
-// u.setTipo(new Integer(rs.getInt("tipo")));
-// u.setNumero_cedula(rs.getString("numero_cedula"));
-// u.setCap(rs.getString("cap"));
-// u.setNome(Utils.unicodeToHTML(rs.getString("nome")) );
-// u.setMedico_id(new Integer(rs.getInt("medico_id")));
-// u.setFuncionario_hst_id(new Integer(rs.getInt("funcionario_hst_id")));
-// u.setActivo(rs.getString(14));
-// u.setResponsavel_loja(rs.getString("responsavel_loja"));
-// u.setGestor_geral(rs.getString("gestor_geral"));
-// u.setNumero_mecanografico(rs.getString("numero_mecanografico"));
-// u.setCategoria(rs.getString("descricao"));
-// u.setApagado(rs.getString("apagado"));
-// try
-// {
-// u.setNome_estabelecimento( adp.getEstabelecimentoNome(u.getEstabelecimento_id()) );
-// }
-// catch(Exception e)
-// {
-// ErrorLogger.logException( e );
-// }
-//
-// if ( booDirRh.matches( "y" ) )
-// {
-// int uType = u.getTipo().intValue();
-// if ( uType == Global.TIPO_UTILIZADOR_SEGURANCA || uType == Global.TIPO_UTILIZADOR_RH ||
-// uType == Global.TIPO_UTILIZADOR_GESTOR || uType == Global.TIPO_UTILIZADOR_DIRECTOR_LOJA)
-// {
-// list.add( u );
-// }
-// }
-// else
-// {
-// list.add( u );
-// }
-//
-// }while(rs.next());
-// return list;
-// }
-
- public ArrayList getResponsavelRhList(Integer estabelecimento_id)
+ public ArrayList< Utilizador > getResponsavelRhList(Integer estabelecimento_id)
{
- ArrayList list = new ArrayList();
- Utilizador u = null;
- Statement st = createStatement();
- String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_RH + " AND apagado = 'n' AND responsavel_loja = 'y' AND estabelecimento_id = " + estabelecimento_id;
+ ArrayList list = null;
try
{
- ResultSet rs = st.executeQuery(sql);
- rs.first();
- do
- {
- u = new Utilizador();
- u.setId(new Integer(rs.getInt("id")));
- u.setNome(rs.getString("nome"));
- u.setLogin(rs.getString("login"));
- u.setEmail(rs.getString("email"));
- list.add(u);
- }while(rs.next());
- return list;
+
+ List utilizadoresDatas;
+
+ utilizadoresDatas = getProvider().listLoad( UtilizadoresData.class,
+ new Object[]{ "y", Global.TIPO_UTILIZADOR_RH, "n", "y", estabelecimento_id },
+ new String[]{ UtilizadoresData.ACTIVO_FULL, UtilizadoresData.TIPO_FULL, UtilizadoresData.APAGADO_FULL,
+ UtilizadoresData.RESPONSAVEL_LOJA_FULL, UtilizadoresData.ESTABELECIMENTO_ID_FULL },
+ new String[]{ UtilizadoresData.NOME_FULL }, null );
+
+ list = new ArrayList();
+
+ for( UtilizadoresData utilizadoresData : utilizadoresDatas )
+ {
+ list.add( Utilizador.createUtilizador().withId( utilizadoresData.getId() )
+ .withNome( utilizadoresData.getNome() ).withLogin( utilizadoresData.getLogin() )
+ .withEmail( utilizadoresData.getEmail() ) );
+ }
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
- return null;
- }
+ }
+ return list;
}
public Medico getMedico( Integer estabelecimentoID )
@@ -579,19 +271,20 @@ public class UtilizadoresDataProvider extends GenericDataProvider
Medico result = null;
try
{
+ Expression whereExpression = new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" )
+ .and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) )
+ .and( new Field( UtilizadoresData.TIPO_FULL ).isEqual( Global.TIPO_UTILIZADOR_MEDICO ) )
+ .and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) );
+
Select2 query = new Select2(
new String[] { UtilizadoresData.TABLENAME },
new Integer[] {},
new Expression[] {},
new String[] { UtilizadoresData.ID_FULL, UtilizadoresData.NOME_FULL, UtilizadoresData.NUMERO_CEDULA_FULL },
- new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" )
- .and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) )
- .and( new Field( UtilizadoresData.TIPO_FULL ).isEqual( Global.TIPO_UTILIZADOR_MEDICO ) )
- .and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ),
- null, null, null, null
+ whereExpression, null, null, null, null
);
Virtual2DArray array = getExecuter().executeQuery( query );
- if ( array.columnLength() > 0 )
+ if ( array.rowCount() > 0 )
{
Integer medicoID = array.get( 0, 0 );
String nome = array.get( 0, 1 );
@@ -610,142 +303,37 @@ public class UtilizadoresDataProvider extends GenericDataProvider
return result;
}
-// public Medico getMedico(Integer estabelecimento_id)
-// {
-// Medico m = null;
-// Statement st = createStatement();
-// String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_MEDICO + " AND apagado = 'n' AND estabelecimento_id = " + estabelecimento_id;
-// try
-// {
-// ResultSet rs = st.executeQuery(sql);
-// rs.first();
-// m = new Medico();
-// m.setId(new Integer(rs.getInt("id")));
-// m.setNome(rs.getString("nome"));
-// m.setNumero_cedula(rs.getString("numero_cedula"));
-// return m;
-// }
-// catch(Exception ex)
-// {
-// ErrorLogger.logException( ex );
-// return null;
-// }
-// }
-
-
- public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception
- {
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement st = createStatement();
- ArrayList list = new ArrayList();
-// Medico m = new Medico();
-// m.setId(new Integer(0));
-// m.setNome("-Seleccionar-");
-// list.add(m);
- String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = 5 AND apagado = 'n' ";
- ResultSet rs = st.executeQuery(sql);
- rs.first();
- do
- {
- Medico m = new Medico();
- m.setId(new Integer(rs.getInt("id")));
- m.setNome(Utils.unicodeToHTML(rs.getString("nome")));
- list.add(m);
- }while(rs.next());
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[list.size()];
- ListIterator iter = list.listIterator();
- int i = 0;
- while(iter.hasNext())
- {
- Medico m = (Medico) iter.next();
-
- listOptions[i] = new Option(m.getId(), Utils.unicodeToHTML(m.getNome()));
- i++;
- }
-// dblocal.close();
- return listOptions;
- }
-
- public com.sun.rave.web.ui.model.Option[] getTecnicosSaudeList() throws Exception
- {
-// Dblocal dblocal = new Dblocal();
-// dblocal.connect();
-// Statement stlocal = dblocal.createStatement();
- Statement st = createStatement();
- ArrayList list = new ArrayList();
- TecnicoSaude t = new TecnicoSaude();
- t.setId(new Integer(0));
- t.setNome("");
- list.add(t);
- String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_HS;
- ResultSet rs = st.executeQuery(sql);
- rs.first();
- do
- {
- t = new TecnicoSaude();
- t.setId(new Integer(rs.getInt("id")));
- t.setNome(Utils.unicodeToHTML(rs.getString("nome")));
- list.add(t);
- }while(rs.next());
- com.sun.rave.web.ui.model.Option[] listOptions = new com.sun.rave.web.ui.model.Option[list.size()];
- ListIterator iter = list.listIterator();
- int i = 0;
- while(iter.hasNext())
- {
- t = (TecnicoSaude) iter.next();
-
- listOptions[i] = new Option(t.getId(), Utils.unicodeToHTML(t.getNome()));
- i++;
- }
-// dblocal.close();
- return listOptions;
- }
-
- public Integer getMaxPermissaoId()
- {
- Statement st = createStatement();
- String sql = "SELECT max(permissoes.id)+1 AS MAXPERMISSAOID FROM permissoes";
- try
- {
- ResultSet rs = st.executeQuery(sql);
- rs.first();
- Integer newId = new Integer(rs.getInt("MAXPERMISSAOID"));
- if(newId.intValue() == 0)
- {
- newId = new Integer(1);
- }
- return newId;
- }
- catch(Exception ex)
- {
- ErrorLogger.logException( ex );
- return new Integer(1);
- }
- }
-
public Integer createPermissao(Permissao p) throws Exception
{
- Statement st = createStatement();
- Integer newId = getMaxPermissaoId();
-
- String sql = "INSERT INTO permissoes (id, user_id, codigo_permissao) VALUES (" + newId + ", " + p.getUser_id() + ", " + p.getCodigo_permissao() + ")";
- st.execute(sql);
- return newId;
+ return PermissoesData.createPermissao( p )
+ .withProvider( EvoBaseProvider.getInstance().getProvider() )
+ .saveMe().refreshMe().getID();
}
public Integer getPermissionCode( Integer userId ) throws Exception
{
- Integer permission = null;
- Statement st = createStatement();
- String sql = "SELECT * FROM permissoes WHERE user_id = " + userId;
- ResultSet rs = st.executeQuery( sql );
- if ( rs.first() )
- {
- permission = new Integer( rs.getInt( "codigo_permissao" ) );
- }
- return permission;
+ Expression dataFilter = new Field( PermissoesData.USER_ID_FULL ).isEqual( userId );
+ Select select = new Select2( PermissoesData.TABLENAME, dataFilter, PermissoesData.CODIGO_PERMISSAO_FULL );
+
+ Virtual2DArray array = getExecuter().executeQuery( select );
+
+ Integer rPermission = 0;
+ if( array.rowCount() > 0 )
+ {
+ rPermission = array.get( 0, 0 );
+ }
+ return rPermission;
}
-
+
+ public Boolean isSiprp( Utilizador utilizador ) throws DBException
+ {
+ Select select = new Select2( EmpresasData.TABLENAME, new Field( EmpresasData.DESIGNACAO_SOCIAL_FULL ).isILike( "siprp%" )
+ .and( new Field( EmpresasData.ID_FULL ).isEqual( utilizador.getEmpresa_id() ) ), "1" );
+
+ Select outer = new Select( "select exists( " + select.toString() + " )" );
+
+ Virtual2DArray array = getExecuter().executeQuery( outer );
+
+ return array.rowCount() > 0 ? ( Boolean ) array.get( 0, 1 ) : Boolean.FALSE;
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/src/utils/Strings.java b/trunk/AnaliseAcidentesTrabalho/src/utils/Strings.java
index 1fbfc2d0..fb911f61 100644
--- a/trunk/AnaliseAcidentesTrabalho/src/utils/Strings.java
+++ b/trunk/AnaliseAcidentesTrabalho/src/utils/Strings.java
@@ -147,5 +147,10 @@ public class Strings {
output = output.replaceAll( "\\\\u00", "\\\\'" );
return output;
}
+
+ public static String nullToEmpty( String string )
+ {
+ return string == null ? "" : string;
+ }
}
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-awt-util-1.6-1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-awt-util-1.6-1.jar
new file mode 100644
index 00000000..b62ac158
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-awt-util-1.6-1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-ext-1.6-1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-ext-1.6-1.jar
new file mode 100644
index 00000000..e85a2701
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-ext-1.6-1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-gui-util-1.6-1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-gui-util-1.6-1.jar
new file mode 100644
index 00000000..2b290802
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-gui-util-1.6-1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-util-1.6-1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-util-1.6-1.jar
new file mode 100644
index 00000000..7550b480
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/batik-util-1.6-1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections-3.2.1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections-3.2.1.jar
new file mode 100644
index 00000000..c35fa1fe
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections-3.2.1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections4-4.0.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections4-4.0.jar
new file mode 100644
index 00000000..4fb2b114
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-collections4-4.0.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-fileupload-1.3.1.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-fileupload-1.3.1.jar
new file mode 100644
index 00000000..af0cda22
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/commons-fileupload-1.3.1.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/evolute.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/evolute.jar
index d68c41b6..ec566036 100644
Binary files a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/evolute.jar and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/evolute.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/geronimo-atinject_1.0_spec-1.0.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/geronimo-atinject_1.0_spec-1.0.jar
new file mode 100644
index 00000000..453dc977
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/geronimo-atinject_1.0_spec-1.0.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/oro-2.0.8.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/oro-2.0.8.jar
new file mode 100644
index 00000000..23488d26
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/oro-2.0.8.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar
new file mode 100644
index 00000000..f00ee16a
Binary files /dev/null and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/postgresql-9.3-1100-jdbc4.jar differ
diff --git a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/shst.jar b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/shst.jar
index 5905b22f..21931d58 100644
Binary files a/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/shst.jar and b/trunk/AnaliseAcidentesTrabalho/web/WEB-INF/lib/shst.jar differ