From eae43733b0f497eb07b8d55ad87a2bd6a66ed57a Mon Sep 17 00:00:00 2001 From: "thomas.millot" Date: Tue, 14 Dec 2021 08:44:24 +0100 Subject: [PATCH] Merge origin/master Conflicts: src/java/bdd/PompierMysql.java web/WEB-INF/ProfilJSP.jsp --- build.xml | 71 ++ nbproject/ant-deploy.xml | 57 + nbproject/build-impl.xml | 1434 +++++++++++++++++++++++ nbproject/genfiles.properties | 8 + nbproject/project.properties | 89 ++ nbproject/project.xml | 31 + src/conf/MANIFEST.MF | 2 + src/java/bdd/CaserneMySQL.java | 41 + src/java/bdd/Connexion.java | 61 + src/java/bdd/ParamMySQL.java | 80 ++ src/java/bdd/PompierMySQL.java | 338 ++++++ src/java/bdd/VentilMysql.java | 194 +++ src/java/bean/Caserne.java | 101 ++ src/java/bean/Parametre.java | 71 ++ src/java/bean/Pompier.java | 227 ++++ src/java/bean/Ventil.java | 116 ++ src/java/doc/readMe | 15 + src/java/filter/authentifFilter.java | 229 ++++ src/java/form/AuthentifForm.java | 75 ++ src/java/form/PompierForm.java | 169 +++ src/java/form/VentilForm.java | 58 + src/java/servlet/AuthentifServlet.java | 115 ++ src/java/servlet/LesDispoServlet.java | 180 +++ src/java/servlet/MesDispoServlet.java | 173 +++ src/java/servlet/PompierServlet.java | 194 +++ src/java/util/CtrlSaisie.java | 64 + src/java/util/MD5.java | 36 + src/java/util/TrmtDate.java | 129 ++ web/META-INF/context.xml | 2 + web/WEB-INF/authentifJSP.jsp | 41 + web/WEB-INF/jspf/debutJSP.jspf | 16 + web/WEB-INF/jspf/footer.jspf | 5 + web/WEB-INF/jspf/formChoixPompier.jspf | 30 + web/WEB-INF/jspf/formulairePompier.jspf | 144 +++ web/WEB-INF/jspf/header.jspf | 126 ++ web/WEB-INF/lesDispoJSP.jsp | 86 ++ web/WEB-INF/mesDispoJSP.jsp | 86 ++ web/WEB-INF/pompierJSP.jsp | 50 + web/WEB-INF/web.xml | 56 + web/css/mycss.css | 119 ++ web/images/favicon.ico | Bin 0 -> 3390 bytes web/images/logo-sdis.png | Bin 0 -> 12885 bytes web/images/pompier.png | Bin 0 -> 3107 bytes web/index.html | 15 + web/js/ctrlCodePostal.js | 28 + 45 files changed, 5162 insertions(+) create mode 100644 build.xml create mode 100644 nbproject/ant-deploy.xml create mode 100644 nbproject/build-impl.xml create mode 100644 nbproject/genfiles.properties create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 src/conf/MANIFEST.MF create mode 100644 src/java/bdd/CaserneMySQL.java create mode 100644 src/java/bdd/Connexion.java create mode 100644 src/java/bdd/ParamMySQL.java create mode 100644 src/java/bdd/PompierMySQL.java create mode 100644 src/java/bdd/VentilMysql.java create mode 100644 src/java/bean/Caserne.java create mode 100644 src/java/bean/Parametre.java create mode 100644 src/java/bean/Pompier.java create mode 100644 src/java/bean/Ventil.java create mode 100644 src/java/doc/readMe create mode 100644 src/java/filter/authentifFilter.java create mode 100644 src/java/form/AuthentifForm.java create mode 100644 src/java/form/PompierForm.java create mode 100644 src/java/form/VentilForm.java create mode 100644 src/java/servlet/AuthentifServlet.java create mode 100644 src/java/servlet/LesDispoServlet.java create mode 100644 src/java/servlet/MesDispoServlet.java create mode 100644 src/java/servlet/PompierServlet.java create mode 100644 src/java/util/CtrlSaisie.java create mode 100644 src/java/util/MD5.java create mode 100644 src/java/util/TrmtDate.java create mode 100644 web/META-INF/context.xml create mode 100644 web/WEB-INF/authentifJSP.jsp create mode 100644 web/WEB-INF/jspf/debutJSP.jspf create mode 100644 web/WEB-INF/jspf/footer.jspf create mode 100644 web/WEB-INF/jspf/formChoixPompier.jspf create mode 100644 web/WEB-INF/jspf/formulairePompier.jspf create mode 100644 web/WEB-INF/jspf/header.jspf create mode 100644 web/WEB-INF/lesDispoJSP.jsp create mode 100644 web/WEB-INF/mesDispoJSP.jsp create mode 100644 web/WEB-INF/pompierJSP.jsp create mode 100644 web/WEB-INF/web.xml create mode 100644 web/css/mycss.css create mode 100644 web/images/favicon.ico create mode 100644 web/images/logo-sdis.png create mode 100644 web/images/pompier.png create mode 100644 web/index.html create mode 100644 web/js/ctrlCodePostal.js diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..90fd2bb --- /dev/null +++ b/build.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + Builds, tests, and runs the project sdis29M1. + + + diff --git a/nbproject/ant-deploy.xml b/nbproject/ant-deploy.xml new file mode 100644 index 0000000..c2349eb --- /dev/null +++ b/nbproject/ant-deploy.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..1af4776 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1434 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set build.web.dir + Must set build.generated.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.war + + + + + + + + + +The Java EE server classpath is not correctly set up - server home directory is missing. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Dj2ee.server.home=<app_server_installation_directory> + + +The Java EE server classpath is not correctly set up. Your active server type is ${j2ee.server.type}. +Either open the project in the IDE and assign the server or setup the server classpath manually. +For example like this: + ant -Duser.properties.file=<path_to_property_file> (where you put the property "j2ee.platform.classpath" in a .properties file) +or ant -Dj2ee.platform.classpath=<server_classpath> (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The libs.CopyLibs.classpath property is not set up. +This property must point to +org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part +of NetBeans IDE installation and is usually located at +<netbeans_installation>/java<version>/ant/extra folder. +Either open the project in the IDE and make sure CopyLibs library +exists or setup the property manually. For example like this: + ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + Must select a file in the IDE or set jsp.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Browser not found, cannot launch the deployed application. Try to set the BROWSER environment variable. + + + Launching ${browse.url} + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..b4c6904 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=b54f128f +build.xml.script.CRC32=111e10f7 +build.xml.stylesheet.CRC32=1707db4f@1.86.0.1 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=b54f128f +nbproject/build-impl.xml.script.CRC32=bc2b5756 +nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.86.0.1 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..83e3e7b --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,89 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=true +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.web.dir}/WEB-INF/classes +build.classes.excludes=**/*.java,**/*.form +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +build.web.dir=${build.dir}/web +build.web.excludes=${build.classes.excludes} +client.urlPart=authentification +compile.jsps=false +conf.dir=${source.root}/conf +debug.classpath=${build.classes.dir}:${javac.classpath} +debug.test.classpath=\ + ${run.test.classpath} +display.browser=true +# Files to be excluded from distribution war +dist.archive.excludes= +dist.dir=dist +dist.ear.war=${dist.dir}/${war.ear.name} +dist.javadoc.dir=${dist.dir}/javadoc +dist.war=${dist.dir}/${war.name} +endorsed.classpath=\ + ${libs.javaee-endorsed-api-7.0.classpath} +excludes= +file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=C:\\Users\\domin\\Downloads\\lib\\jakarta.servlet.jsp.jstl-2.0.0.jar +file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=C:\\Users\\domin\\Downloads\\lib\\jakarta.servlet.jsp.jstl-api-2.0.0.jar +file.reference.mysql-connector-java-8.0.26.jar=C:\\Users\\domin\\Downloads\\lib\\mysql-connector-java-8.0.26.jar +includes=** +j2ee.compile.on.save=true +j2ee.copy.static.files.on.save=true +j2ee.deploy.on.save=true +j2ee.platform=1.7-web +j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.20.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.0-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar +j2ee.server.type=Tomcat +jar.compress=false +javac.classpath=\ + ${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\ + ${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}:\ + ${file.reference.mysql-connector-java-8.0.26.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.debug=true +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.preview=true +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +lib.dir=${web.docbase.dir}/WEB-INF/lib +persistence.xml.dir=${conf.dir} +platform.active=default_platform +resource.dir=setup +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +# Space-separated list of JVM arguments used when running a class with a main method or a unit test +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): +runmain.jvmargs= +source.encoding=UTF-8 +source.root=src +src.dir=${source.root}/java +test.src.dir=test +war.content.additional= +war.ear.name=${war.name} +war.name=sdis29M1.war +web.docbase.dir=web +webinf.dir=web/WEB-INF diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..579a4b5 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,31 @@ + + + org.netbeans.modules.web.project + + + sdis29M1 + 1.6.5 + + + ${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar} + WEB-INF/lib + + + ${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar} + WEB-INF/lib + + + ${file.reference.mysql-connector-java-8.0.26.jar} + WEB-INF/lib + + + + + + + + + + + + diff --git a/src/conf/MANIFEST.MF b/src/conf/MANIFEST.MF new file mode 100644 index 0000000..58630c0 --- /dev/null +++ b/src/conf/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/java/bdd/CaserneMySQL.java b/src/java/bdd/CaserneMySQL.java new file mode 100644 index 0000000..4857a74 --- /dev/null +++ b/src/java/bdd/CaserneMySQL.java @@ -0,0 +1,41 @@ +/* + * bddd/CaserneMySQL.java + */ +package bdd; + +import bean.Caserne; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * + * @author Dominique_2 + */ +public class CaserneMySQL { + private final Connection laConnection = Connexion.getConnect("Localhost", + "sdis29", + "adminBDsdis", + "mdpBDsdis"); + public Caserne read(int id) { + Caserne laCaserne = null; + try { + PreparedStatement prepStmt = null; + String sql = "SELECT * FROM caserne WHERE id=?"; + prepStmt = laConnection.prepareStatement(sql); + prepStmt.setInt(1, id); + ResultSet result = prepStmt.executeQuery(); + if (result.next()) { + laCaserne = new Caserne(result.getInt(1), result.getString(2), + result.getString(3), result.getString(4)); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return laCaserne; + } +} diff --git a/src/java/bdd/Connexion.java b/src/java/bdd/Connexion.java new file mode 100644 index 0000000..d594f36 --- /dev/null +++ b/src/java/bdd/Connexion.java @@ -0,0 +1,61 @@ +package bdd; +/* +Connexion.java +Classe permettant d'établir une connexion avec une base de données mySQL +*/ +import java.sql.Connection; +import java.sql.DriverManager; + +public class Connexion { + private static Connection connect; // Variable de connexion + + /** + * Constructeur + * @param serveur nom du serveur, localhost si local + * @param bdd nom de la base de données + * @param nomUtil nom utilisateur + * @param mdp mot de passe lié à l'utilisateur + */ + private Connexion(String serveur, String bdd, String nomUtil, String mdp) { + try { + // 1. Chargement du driver + //Class.forName("com.mysql.jdbc.Driver"); + Class.forName("com.mysql.cj.jdbc.Driver"); + System.out.println("Driver accessible"); + + // 2. Initialisation des paramètres de connexion + String host = serveur; // Serveur de bd + String dbname = bdd; // Nom bd + String url = "jdbc:mysql://" + host + "/" + dbname; // url de connexion + url += "?autoReconnect=true"; // Ajout 26/09/2021 + System.out.println("url : "+url); + String user = nomUtil; // nom du user + System.out.println("nomUtil : "+nomUtil); + String passwd = mdp; // mot de passe + System.out.println("mdp : "+mdp); + + // 3. Connexion + connect = (Connection) DriverManager.getConnection(url, user, passwd); + System.out.println("Connexion réussie !"); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Retourne la connection établie (Création d'une connection si elle n'existe pas) + * @param serveur nom du serveur, localhost si local + * @param bdd nom de la base de données + * @param nomUtil nom utilisateur + * @param mdp mot de passe lié à l'utilisateur + * @return connection établie + */ + public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) { + //System.out.println("getConnect"); + if (connect == null) { + new Connexion(serveur, bdd, nomUtil, mdp); + } + return connect; + } +} diff --git a/src/java/bdd/ParamMySQL.java b/src/java/bdd/ParamMySQL.java new file mode 100644 index 0000000..4498d7e --- /dev/null +++ b/src/java/bdd/ParamMySQL.java @@ -0,0 +1,80 @@ +/* + * bdd/ParamMySQL.java + */ +package bdd; + + + +import bean.Parametre; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +/** + * + * @author Dominique_2 + */ +public class ParamMySQL { + + private final Connection laConnection = Connexion.getConnect("Localhost", + "sdis29", + "adminBDsdis", + "mdpBDsdis"); + /** + * Recherche du paramètre correspondant au type et à l'indice passé en paramètres + * @param typeParam + * @param ind + * @return Parametre concerné ou null si non trouvé + */ + public Parametre read(String typeParam, int ind) { + Parametre leParam = null; + try { + PreparedStatement prepStmt = null; + String sql = "SELECT * FROM parametre WHERE idType=? AND indice=?"; + prepStmt = laConnection.prepareStatement(sql); + prepStmt.setString(1, typeParam); + prepStmt.setInt(2, ind); + ResultSet result = prepStmt.executeQuery(); + if (result.next()) { + leParam = new Parametre(result.getString(1), result.getInt(2), + result.getString(3)); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return leParam; + } + + /** + * Recherche de tous les paramètres du type passé en paramètre + * @param unType + * @return collection de Parametre correspondant au type + */ + public ArrayList readType(String unType) { + ArrayList lesParam = new ArrayList(); + try { + PreparedStatement prepStmt = null; + String sql = "SELECT * FROM parametre WHERE idType=? "; + prepStmt = laConnection.prepareStatement(sql); + prepStmt.setString(1, unType); + ResultSet result = prepStmt.executeQuery(); + Parametre leParam; + while (result.next()) { + leParam = new Parametre(result.getString(1), result.getInt(2), + result.getString(3)); + lesParam.add(leParam); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return lesParam; + } +} diff --git a/src/java/bdd/PompierMySQL.java b/src/java/bdd/PompierMySQL.java new file mode 100644 index 0000000..1e291f7 --- /dev/null +++ b/src/java/bdd/PompierMySQL.java @@ -0,0 +1,338 @@ +/* + * bdd/PompierMysql.java + */ +package bdd; + +import bean.Caserne; +import bean.Parametre; +import bean.Pompier; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Dominique_2 + */ +public class PompierMySQL { + + private final Connection theConnection = Connexion.getConnect("localhost", + "sdis29", + "adminBDsdis", + "mdpBDsdis"); + // Tableau des attributs mis à jour + // 1ère dimension : noms des attributs en bdd + // 2ème dimension : noms des champs transmis + // 3ème dimension : type de données, i pour Integet, s pour String + private String[][] lesAttributs = { + {"id", "idCaserne", "nom", "prenom", "statut", "typePers", "mail", "login", "mdp", "adresse", "cp", "ville", "bip", "grade", "commentaire"}, + {"idP", "idC", "ztNom", "ztPrenom", "ldrStatut", "ldrType", "ztMail", "ztLogin", "ztMdp", "ztAdresse", "ztCP", "zlVille", "ztBip", "ldrGrade", "ztObs"}, + {"i", "i", "s", "s", "i", "i", "s", "s", "s", "s", "s", "s", "s", "i", "s"} + }; + + /** + * Recherche du pompier ayant le login et le mdp passé en paramètres + * + * @param login + * @param mdp + * @return Pompier correspondant ou null si non trouvé + */ + public Pompier readAuthentif(String login, String mdp) { + Pompier lePompier = null; + try { + PreparedStatement prepStmt; + String sql = "SELECT * FROM pompier WHERE login=? AND mdp=? "; + + prepStmt = theConnection.prepareStatement(sql); + prepStmt.setString(1, login); + prepStmt.setString(2, mdp); + ResultSet result = prepStmt.executeQuery(); + if (result.next()) { + CaserneMySQL laCaserneMySQL = new CaserneMySQL(); + Caserne laCaserne = laCaserneMySQL.read(result.getInt(2)); + lePompier = constituerLePompier(result, laCaserne); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return lePompier; + } + + /** + * Recherche des pompiers volontaires de la caserne + * + * @param idCaserne + * @return collection des pompiers concernés + */ + public ArrayList readLesPompiersCaserne(int idCaserne) { + ArrayList lesPompiers = new ArrayList(); + try { + PreparedStatement prepStmt; + String sql = "SELECT * FROM pompier WHERE idCaserne=? AND Statut=1 AND typePers=2 ORDER BY nom, prenom"; + + prepStmt = theConnection.prepareStatement(sql); + prepStmt.setInt(1, idCaserne); + ResultSet result = prepStmt.executeQuery(); + CaserneMySQL laCaserneMySQL = new CaserneMySQL(); + Caserne laCaserne = laCaserneMySQL.read(idCaserne); + while (result.next()) { + Pompier unPompier = constituerLePompier(result, laCaserne); + lesPompiers.add(unPompier); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return lesPompiers; + } + + public Pompier constituerLePompier(ResultSet result, Caserne laCaserne) { + Pompier lePompier = null; + ParamMySQL leParamMySQL = new ParamMySQL(); + try { + Parametre leStatut = leParamMySQL.read("statAgt", result.getInt(5)); + Parametre leType = leParamMySQL.read("typePer", result.getInt(6)); + Parametre leGrade = leParamMySQL.read("grade", result.getInt(15)); + lePompier = new Pompier(laCaserne, result.getInt(1), + result.getString(3), result.getString(4), + leStatut, leType, + result.getString(7), result.getString(8), + result.getString(9), result.getString(10), + result.getString(11), result.getString(12), + result.getString(13), leGrade, result.getString(16)); + //System.out.println("lePompier " + lePompier); + } catch (SQLException ex) { + Logger.getLogger(PompierMySQL.class.getName()).log(Level.SEVERE, null, ex); + } + return lePompier; + } + + /** + * Recherche du dernier no de pompier utilisé pour une caserne + * + * @param idC : caserne concernée + * @return dernier no de pompier utilisé dansla caserne + */ + public int getIdMax(int idC) { + int max = 0; + try { + PreparedStatement prepStmt; + String sql = "SELECT max(pId) FROM pompier WHERE pCis = ?"; + prepStmt = theConnection.prepareStatement(sql); + prepStmt.setInt(1, idC); + ResultSet result = prepStmt.executeQuery(); + if (result.first()) { + max = result.getInt(1); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return max; + } + + public Pompier update(HashMap lesParametres, int idP) { +// Date dateJ = new Date(); +// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); +// String dateDuJour = dateFormat.format(dateJ); + Pompier lePompierMaj = null; + // Constitution de la requête en fonction des données transmises + String valeurs [] = new String[lesAttributs[1].length]; + String sql = "UPDATE pompier SET "; + int nbAttributsMaj = 0; + String virgule = ""; + for (HashMap.Entry unParam : lesParametres.entrySet()) { + // Recherche attribut correspondant au champ trnasmis + int i = 0; + while (i < lesAttributs[1].length && !(lesAttributs[1][i].equals(unParam.getKey()))) { + i++; + } + if (i < lesAttributs[0].length) { + sql += virgule + lesAttributs[0][i] + "= ?"; + valeurs[nbAttributsMaj] = "("+lesAttributs[2][i]+")" + unParam.getValue(); + nbAttributsMaj++; + virgule = ", "; + } + } + sql += ", dateModif = ? WHERE id = ?;"; + // Alimentation des valeurs de la requête + PreparedStatement prepStmt; + try { + prepStmt = theConnection.prepareStatement(sql); + for (int i=0; i 0) { + System.out.println("nbLigne " + nbLigne); + lePompierMaj = read(idP); + System.out.println("lePompierMaj : "+ lePompierMaj); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + + + + + return lePompierMaj; +// String sql = "UPDATE pompier " +// + "SET pNom = ?, pPrenom = ?, pMail = ?, " +// + "pLogin = ?, pMdp = ?, pAdresse = ?, pCp = ?, pVille = ?, " +// + "pBip = ?, pGrade = ?, pCommentaire = ?, pDateModif = ? " +// + "WHERE pCis=? AND pId=?; "; +// return requeteMaj(sql, lesParametres); + } + + public Pompier create(HashMap lesParametres) { + Pompier lePompierCree = null; + // Constitution de la requête en fonction des données transmises + String valeurs [] = new String[lesAttributs[1].length]; + String sql = "INSERT INTO pompier ("; + int nbAttributsMaj = 0; + String virgule = ""; + for (HashMap.Entry unParam : lesParametres.entrySet()) { + // Recherche attribut correspondant au champ trnasmis + int i = 0; + while (i < lesAttributs[1].length && !(lesAttributs[1][i].equals(unParam.getKey()))) { + i++; + } + if (i < lesAttributs[0].length) { + sql += virgule + lesAttributs[0][i]; + valeurs[nbAttributsMaj] = "("+lesAttributs[2][i]+")" + unParam.getValue(); + nbAttributsMaj++; + virgule = ", "; + } + } + sql += ", dateEnreg) values (?"; + for (int i=0; i 0) { + ResultSet result = prepStmt.getGeneratedKeys(); + if (result.first()) { + int id = result.getInt(1); + lePompierCree = read(id); + System.out.println("lePompierCree : "+ lePompierCree); + } + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + + return lePompierCree; + } + + private Pompier requeteMaj(String sql, HashMap lesParametres) { + int nbLigne = 0; + try { + PreparedStatement prepStmt; + prepStmt = theConnection.prepareStatement(sql); + prepStmt.setString(1, (String) lesParametres.get("ztNom")); + prepStmt.setString(2, (String) lesParametres.get("ztPrenom")); + prepStmt.setString(3, (String) lesParametres.get("ztMail")); + prepStmt.setString(4, (String) lesParametres.get("ztLogin")); + prepStmt.setString(5, (String) lesParametres.get("ztMdp")); + prepStmt.setString(6, (String) lesParametres.get("ztAdresse")); + prepStmt.setString(7, (String) lesParametres.get("ztCP")); + prepStmt.setString(8, (String) lesParametres.get("ztVille")); + prepStmt.setString(9, (String) lesParametres.get("ztBip")); + prepStmt.setInt(10, (Integer) lesParametres.get("ldrGrade")); + prepStmt.setString(11, (String) lesParametres.get("taObs")); + //prepStmt.setDate(12, java.sql.Date.valueOf(java.time.LocalDate.now())); + prepStmt.setTimestamp(12, new Timestamp(Calendar.getInstance().getTimeInMillis())); + prepStmt.setInt(13, (Integer) lesParametres.get("idC")); + prepStmt.setInt(14, (Integer) lesParametres.get("zhIdP")); + if (sql.substring(0, 6).equals("INSERT")) { + prepStmt.setInt(15, (Integer) lesParametres.get("idStatut")); + prepStmt.setInt(16, (Integer) lesParametres.get("idType")); + } + + System.out.println(prepStmt); + nbLigne = prepStmt.executeUpdate(); + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + Pompier lePompierMaj = null; + if (nbLigne > 0) { + //lePompierMaj = read((Integer) lesParametres.get("idC"), (Integer) lesParametres.get("zhIdP")); + } + return lePompierMaj; + } + + public Pompier read(int idP) { + Pompier unPompier = null; + try { + PreparedStatement prepStmt; + String sql = "SELECT * FROM pompier WHERE id=? "; + + prepStmt = theConnection.prepareStatement(sql); + prepStmt.setInt(1, idP); + ResultSet result = prepStmt.executeQuery(); + if (result.next()) { + CaserneMySQL laCaserneMySQL = new CaserneMySQL(); + Caserne laCaserne = laCaserneMySQL.read(result.getInt(2)); + unPompier = constituerLePompier(result, laCaserne); + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return unPompier; + } +} diff --git a/src/java/bdd/VentilMysql.java b/src/java/bdd/VentilMysql.java new file mode 100644 index 0000000..430330c --- /dev/null +++ b/src/java/bdd/VentilMysql.java @@ -0,0 +1,194 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package bdd; + +import bean.Parametre; +import bean.Pompier; +import bean.Ventil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.logging.Level; +import java.util.logging.Logger; +import util.TrmtDate; + +/** + * + * @author sio + */ +public class VentilMysql { + + private final Connection theConnection = Connexion.getConnect("localhost", + "sdis29", + "adminBDsdis", + "mdpBDsdis"); + + public ArrayList getLesVentil(Calendar[] lesDates, String[] lesPeriodes, HttpServletRequest request) { + ArrayList lesVentil = new ArrayList<>(); + Ventil uneVentil; + + /* a. Initialisation de la collection lesVentil pour la période, + création d'une ventil par pompier, par date et période + */ + int indiceDateFin = lesDates.length - 1; + Pompier lePompier; + PompierMySQL pm = new PompierMySQL(); + HttpSession maSession = request.getSession(); + ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); + for (Pompier unPompier : lesPompiers) { + for (Calendar uneDate : lesDates) { + for (String unePeriode : lesPeriodes) { + uneVentil = new Ventil(uneDate, unePeriode, unPompier); + lesVentil.add(uneVentil); + } + } + } + + /* b) Maj de la collection lesVentil + */ + readAll(lesVentil, lesDates[0], lesDates[indiceDateFin]); + //System.out.println("lesVentil : " + lesVentil); + return lesVentil; + } + + public void readAll(ArrayList lesVentil, Calendar d1, Calendar d2) { + Pompier lePompier; + Ventil uneVentil; + Ventil laVentilTrouvee; + ParamMySQL leParamMySQL = new ParamMySQL(); + String sql = "SELECT * FROM ventilation " + + "INNER JOIN pompier on idPompier = id " + + "WHERE jourVentil BETWEEN ? and ?;"; + try { + PreparedStatement prepStmt = theConnection.prepareStatement(sql); + prepStmt.setDate(1, TrmtDate.getSQLDate(d1)); + prepStmt.setDate(2, TrmtDate.getSQLDate(d2)); + ResultSet resultat = prepStmt.executeQuery(); + while (resultat.next()) { + Parametre leStatut = leParamMySQL.read("statAgt", resultat.getInt(5)); + lePompier = new Pompier(resultat.getInt("id"), + resultat.getString("nom"), + resultat.getString("prenom"), + leStatut); + uneVentil = new Ventil(TrmtDate.getCalDate(resultat.getDate("jourVentil")), + resultat.getString("periode"), + lePompier); + // Recherche si uneVentil existe dans les Ventil + int indice = lesVentil.indexOf(uneVentil); + if (indice > -1) { + laVentilTrouvee = lesVentil.get(indice); + laVentilTrouvee.setActivite(resultat.getInt("ventil")); + laVentilTrouvee.setIsInBD(true); + } + } + prepStmt.close(); + resultat.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + } + + /** + * Suppression de la ventilation passée en paramètre + * + * @param v : ventilation à supprimer + * @return : nb lignes supprimées ou -1 si erreur + */ + public int delete(Ventil v) { + int nbMAJ = -1; + String sql = "DELETE FROM ventilation " + + "WHERE idPompier = ? " + + "AND periode = ? " + + "AND jourVentil = ?;"; + try { + PreparedStatement prepStmt = theConnection.prepareStatement(sql); + prepStmt.setInt(1, v.getPompier().getId()); + prepStmt.setString(2, v.getPeriode()); + prepStmt.setDate(3, TrmtDate.getSQLDate(v.getJourVentil())); + nbMAJ = prepStmt.executeUpdate(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return nbMAJ; + } + + /** + * Création de la ventilation passée en paramètre + * + * @param v : ventilation à créer + * @return : identifiant de la ventilation créé, ou -1 si erreur + */ + public int create(Ventil v) { + int idCree = -1; + String sql = "INSERT into ventilation " + + "(jourVentil, periode, idPompier, ventil) " + + "VALUES (?, ?, ?, ?)"; + + try { + PreparedStatement prepStmt = null; + prepStmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + prepStmt.setDate(1, TrmtDate.getSQLDate(v.getJourVentil())); + prepStmt.setString(2, v.getPeriode()); + prepStmt.setInt(3, v.getPompier().getId()); + prepStmt.setInt(4, v.getActivite()); + + System.out.println("create : "+ prepStmt); + int nbLigne = prepStmt.executeUpdate(); + + // Recherche du no de la ventilation créée + if (nbLigne > 0) { + ResultSet result = prepStmt.getGeneratedKeys(); + if (result.next()) { + idCree = result.getInt(1); + } + } + prepStmt.close(); + } catch (SQLException ex) { + System.out.println("SQLExeption : " + ex.getMessage()); + System.out.println("SQLState : " + ex.getSQLState()); + System.out.println("Code erreur : " + ex.getErrorCode()); + } + return idCree; + } + + /** + * Mise à jour de la ventilation passée en paramètre + * @param v : ventilation à mettre à jour + * @return : nb lignes mises à jour, -1 si erreur + */ + public int update(Ventil v) { + + int nbMAJ = -1; + String sql = "UPDATE ventilation " + + "SET ventil = ? " + + "WHERE idPompier = ? " + + "AND jourVentil = ? " + + "AND periode = ?"; + try { + PreparedStatement prepStmt = theConnection.prepareStatement(sql); + prepStmt.setInt(1, v.getActivite()); + prepStmt.setInt(2, v.getPompier().getId()); + prepStmt.setDate(3, TrmtDate.getSQLDate(v.getJourVentil())); + prepStmt.setString(4, v.getPeriode()); + System.out.println("update : " + prepStmt); + nbMAJ = prepStmt.executeUpdate(); + } catch (SQLException ex) { + Logger.getLogger(VentilMysql.class.getName()).log(Level.SEVERE, null, ex); + } + return nbMAJ; + } + +} diff --git a/src/java/bean/Caserne.java b/src/java/bean/Caserne.java new file mode 100644 index 0000000..8a3cad1 --- /dev/null +++ b/src/java/bean/Caserne.java @@ -0,0 +1,101 @@ +/* + * bean/Caserne.java + */ +package bean; + +import java.util.Objects; + +/** + * + * @author Dominique_2 + */ +public class Caserne { + private int id; + private String nom; + private String adresse; + private String tel; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNom() { + return nom; + } + + public void setNom(String nom) { + this.nom = nom; + } + + public String getAdresse() { + return adresse; + } + + public void setAdresse(String adresse) { + this.adresse = adresse; + } + + public String getTel() { + return tel; + } + + public void setTel(String tel) { + this.tel = tel; + } + + + + public Caserne(int cId, String cNom, String cAdresse, String cTel) { + this.id = cId; + this.nom = cNom; + this.adresse = cAdresse; + this.tel = cTel; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 17 * hash + this.id; + hash = 17 * hash + Objects.hashCode(this.nom); + hash = 17 * hash + Objects.hashCode(this.adresse); + hash = 17 * hash + Objects.hashCode(this.tel); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Caserne other = (Caserne) obj; + if (this.id != other.id) { + return false; + } + if (!Objects.equals(this.nom, other.nom)) { + return false; + } + if (!Objects.equals(this.adresse, other.adresse)) { + return false; + } + if (!Objects.equals(this.tel, other.tel)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Caserne{" + "id=" + id + ", nom=" + nom + ", adresse=" + adresse + ", tel=" + tel + '}'; + } + +} diff --git a/src/java/bean/Parametre.java b/src/java/bean/Parametre.java new file mode 100644 index 0000000..448ad98 --- /dev/null +++ b/src/java/bean/Parametre.java @@ -0,0 +1,71 @@ +/* + * bean/Parametre.java + */ +package bean; + +/** + * + * @author Dominique_2 + */ +public class Parametre { + private String typParam; + private int code; + private String valeur; + + + /** + * @return the code + */ + public int getCode() { + return code; + } + + /** + * @param code the code to set + */ + public void setCode(int code) { + this.code = code; + } + + /** + * @return the valeur + */ + public String getValeur() { + return valeur; + } + + /** + * @param valeur the valeur to set + */ + public void setValeur(String valeur) { + this.valeur = valeur; + } + + public Parametre(String typParam, int code, String valeur) { + this.typParam = typParam; + this.code = code; + this.valeur = valeur; + } + + /** + * @return the typParam + */ + public String getTypParam() { + return typParam; + } + + /** + * @param typParam the typParam to set + */ + public void setTypParam(String typParam) { + this.typParam = typParam; + } + + @Override + public String toString() { + return "Parametre{" + "typParam=" + typParam + ", code=" + code + ", valeur=" + valeur + '}'; + } + + + +} diff --git a/src/java/bean/Pompier.java b/src/java/bean/Pompier.java new file mode 100644 index 0000000..359510a --- /dev/null +++ b/src/java/bean/Pompier.java @@ -0,0 +1,227 @@ +/* + * bean/Pompier.java + */ +package bean; + +import java.util.Objects; + +/** + * + * @author Dominique_2 + */ +public class Pompier { + private Caserne laCaserne; + private int id; + private String nom; + private String prenom; + private Parametre leStatut; + private Parametre leType; + private String mail; + private String login; + private String mdp; + private String adresse; + private String cp; + private String ville; + private String bip; + private Parametre leGrade; + private String commentaire; + + public Caserne getLaCaserne() { + return laCaserne; + } + + public void setLaCaserne(Caserne laCaserne) { + this.laCaserne = laCaserne; + } + + public Pompier(Caserne laCaserne, int id, String nom, String prenom, Parametre leStatut, Parametre leType, String mail, String login, String mdp, String adresse, String cp, String ville, String bip, Parametre leGrade, String commentaire) { +// this.laCaserne = laCaserne; +// this.pId = pId; +// this.pNom = pNom; +// this.pPrenom = pPrenom; + this(laCaserne, id, nom, prenom); + this.leStatut = leStatut; + this.leType = leType; + this.mail = mail; + this.login = login; + this.mdp = mdp; + this.adresse = adresse; + this.cp = cp; + this.ville = ville; + this.bip = bip; + this.leGrade = leGrade; + this.commentaire = commentaire; + } + + public Pompier(int id, String nom, String prenom, Parametre leStatut) { + this.id = id; + this.nom = nom; + this.prenom = prenom; + this.leStatut = leStatut; + } + + public Pompier(Caserne laCaserne, int id, String nom, String prenom) { + this.laCaserne = laCaserne; + this.id = id; + this.nom = nom; + this.prenom = prenom; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getNom() { + return nom; + } + + public void setNom(String nom) { + this.nom = nom; + } + + public String getPrenom() { + return prenom; + } + + public void setPrenom(String prenom) { + this.prenom = prenom; + } + + public Parametre getLeStatut() { + return leStatut; + } + + public void setLeStatut(Parametre leStatut) { + this.leStatut = leStatut; + } + + public Parametre getLeType() { + return leType; + } + + public void setLeType(Parametre leType) { + this.leType = leType; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getMdp() { + return mdp; + } + + public void setMdp(String mdp) { + this.mdp = mdp; + } + + public String getAdresse() { + return adresse; + } + + public void setAdresse(String adresse) { + this.adresse = adresse; + } + + public String getCp() { + return cp; + } + + public void setCp(String cp) { + this.cp = cp; + } + + public String getVille() { + return ville; + } + + public void setVille(String ville) { + this.ville = ville; + } + + public String getBip() { + return bip; + } + + public void setBip(String bip) { + this.bip = bip; + } + + public Parametre getLeGrade() { + return leGrade; + } + + public void setLeGrade(Parametre leGrade) { + this.leGrade = leGrade; + } + + public String getCommentaire() { + return commentaire; + } + + public void setCommentaire(String commentaire) { + this.commentaire = commentaire; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 67 * hash + Objects.hashCode(this.laCaserne); + hash = 67 * hash + this.id; + hash = 67 * hash + Objects.hashCode(this.nom); + hash = 67 * hash + Objects.hashCode(this.prenom); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Pompier other = (Pompier) obj; + if (this.id != other.id) { + return false; + } + + return true; + } + + @Override + public String toString() { + return "Pompier{" + "laCaserne=" + laCaserne + ", id=" + id + ", nom=" + nom + ", prenom=" + prenom + ", leStatut=" + leStatut + ", leType=" + leType + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adresse=" + adresse + ", cp=" + cp + ", ville=" + ville + ", bip=" + bip + ", grade=" + leGrade + ", commentaire=" + commentaire + '}'; + } + + + + + + + + + + + + +} diff --git a/src/java/bean/Ventil.java b/src/java/bean/Ventil.java new file mode 100644 index 0000000..ca9387b --- /dev/null +++ b/src/java/bean/Ventil.java @@ -0,0 +1,116 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package bean; + +import java.util.Calendar; +import java.util.Objects; + +/** + * + * @author sio + */ +public class Ventil { + Calendar JourVentil; + String periode; + Pompier pompier; + int activite; + boolean isInBD; + + public Calendar getJourVentil() { + return JourVentil; + } + + public void setJourVentil(Calendar JourVentil) { + this.JourVentil = JourVentil; + } + + public String getPeriode() { + return periode; + } + + public void setPeriode(String periode) { + this.periode = periode; + } + + public Pompier getPompier() { + return pompier; + } + + public void setPompier(Pompier pompier) { + this.pompier = pompier; + } + + public int getActivite() { + return activite; + } + + public void setActivite(int activite) { + this.activite = activite; + } + + public boolean isIsInBD() { + return isInBD; + } + + public void setIsInBD(boolean isInBD) { + this.isInBD = isInBD; + } + + public Ventil(Calendar JourVentil, String periode, Pompier pompier, int activite, boolean isInBD) { + this.JourVentil = JourVentil; + this.periode = periode; + this.pompier = pompier; + this.activite = activite; + this.isInBD = isInBD; + } + + public Ventil(Calendar JourVentil, String periode, Pompier pompier) { + this.JourVentil = JourVentil; + this.periode = periode; + this.pompier = pompier; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 71 * hash + Objects.hashCode(this.JourVentil); + hash = 71 * hash + Objects.hashCode(this.periode); + hash = 71 * hash + Objects.hashCode(this.pompier); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Ventil other = (Ventil) obj; + if (!Objects.equals(this.periode, other.periode)) { + return false; + } + if (!Objects.equals(this.JourVentil, other.JourVentil)) { + return false; + } + if (!Objects.equals(this.pompier, other.pompier)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Ventil{" + "JourVentil=" + JourVentil.getTime() + ", periode=" + periode + ", pompier=" + pompier + ", activite=" + activite + ", isInBD=" + isInBD + '}'; + } + + + +} diff --git a/src/java/doc/readMe b/src/java/doc/readMe new file mode 100644 index 0000000..3393280 --- /dev/null +++ b/src/java/doc/readMe @@ -0,0 +1,15 @@ +Variables de session : + Variables mises en session après authentification (AuthentifForm.java) + lePompierConnecte : pompier authentifié + lePompier : pompier à afficher dans pompierJSP + lesGrades : collection des grades possibles ( + lesPeriodes : collections des périodes d'affectation possibles (nuit, matin, ...) + lesStatuts : collection des statuts (pompier, chef de centre, resp. alertes) + lesTypes : collection des types (pompier volontaires, perso médical, perso adm.) + lesPompiers : collection des pompiers de la caserne, reseignée uniquement si le pompier connecté est un chef de centre + Variables mises en session dans PompierServlet.java) + lePompier : pompier à afficher dans pompierJSP + +Attributs utilisés entre la servet PompierServlet.java et pompierJSP : + page : 2 --> affichage des données du pompier connecté + 3 --> affichage des données d'un pompier de la caserne pour le chef de centre diff --git a/src/java/filter/authentifFilter.java b/src/java/filter/authentifFilter.java new file mode 100644 index 0000000..312e43e --- /dev/null +++ b/src/java/filter/authentifFilter.java @@ -0,0 +1,229 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Filter.java to edit this template + */ +package filter; + +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; + +/** + * + * @author domin + */ +public class authentifFilter implements Filter { + + private static final boolean debug = true; + + // The filter configuration object we are associated with. If + // this value is null, this filter instance is not currently + // configured. + private FilterConfig filterConfig = null; + + public authentifFilter() { + } + + private void doBeforeProcessing(ServletRequest request, ServletResponse response) + throws IOException, ServletException { + if (debug) { + log("authentifFilter:DoBeforeProcessing"); + } + + // Write code here to process the request and/or response before + // the rest of the filter chain is invoked. + // For example, a logging filter might log items on the request object, + // such as the parameters. + /* + for (Enumeration en = request.getParameterNames(); en.hasMoreElements(); ) { + String name = (String)en.nextElement(); + String values[] = request.getParameterValues(name); + int n = values.length; + StringBuffer buf = new StringBuffer(); + buf.append(name); + buf.append("="); + for(int i=0; i < n; i++) { + buf.append(values[i]); + if (i < n-1) + buf.append(","); + } + log(buf.toString()); + } + */ + } + + private void doAfterProcessing(ServletRequest request, ServletResponse response) + throws IOException, ServletException { + if (debug) { + log("authentifFilter:DoAfterProcessing"); + } + + // Write code here to process the request and/or response after + // the rest of the filter chain is invoked. + // For example, a logging filter might log the attributes on the + // request object after the request has been processed. + /* + for (Enumeration en = request.getAttributeNames(); en.hasMoreElements(); ) { + String name = (String)en.nextElement(); + Object value = request.getAttribute(name); + log("attribute: " + name + "=" + value.toString()); + + } + */ + // For example, a filter might append something to the response. + /* + PrintWriter respOut = new PrintWriter(response.getWriter()); + respOut.println("

This has been appended by an intrusive filter."); + */ + } + + /** + * + * @param request The servlet request we are processing + * @param response The servlet response we are creating + * @param chain The filter chain we are processing + * + * @exception IOException if an input/output error occurs + * @exception ServletException if a servlet error occurs + */ + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) + throws IOException, ServletException { + + if (debug) { + log("authentifFilter:doFilter()"); + } + + // Cast de l'objet request + HttpServletRequest requete = (HttpServletRequest) request; + // Pas de filtrage des css, des images, des js + String chemin = requete.getRequestURI().substring(requete.getContextPath().length()); + //System.out.println("Chemin : " + chemin); + if (chemin.startsWith("/css") || chemin.startsWith("/images") || chemin.startsWith("/js")) { + //System.out.println(" - passage ok"); + chain.doFilter(request, response); + return; + } +// Récupération de la session + HttpSession maSession = requete.getSession(); +// Récupération du booléen d'authentification + boolean authentificationOK = false; + if (maSession.getAttribute("lePompierConnecte") != null) { + authentificationOK = true; + } + //System.out.println("authentificationOK : "+ authentificationOK); + if (authentificationOK) { + // Poursuite sans problème + chain.doFilter(request, response); + } else { + // retour vers la page d'authentification + request.getRequestDispatcher("authentification").forward(request, response); + } + } + + /** + * Return the filter configuration object for this filter. + */ + public FilterConfig getFilterConfig() { + return (this.filterConfig); + } + + /** + * Set the filter configuration object for this filter. + * + * @param filterConfig The filter configuration object + */ + public void setFilterConfig(FilterConfig filterConfig) { + this.filterConfig = filterConfig; + } + + /** + * Destroy method for this filter + */ + public void destroy() { + } + + /** + * Init method for this filter + */ + public void init(FilterConfig filterConfig) { + this.filterConfig = filterConfig; + if (filterConfig != null) { + if (debug) { + log("authentifFilter:Initializing filter"); + } + } + } + + /** + * Return a String representation of this object. + */ + @Override + public String toString() { + if (filterConfig == null) { + return ("authentifFilter()"); + } + StringBuffer sb = new StringBuffer("authentifFilter("); + sb.append(filterConfig); + sb.append(")"); + return (sb.toString()); + } + + private void sendProcessingError(Throwable t, ServletResponse response) { + String stackTrace = getStackTrace(t); + + if (stackTrace != null && !stackTrace.equals("")) { + try { + response.setContentType("text/html"); + PrintStream ps = new PrintStream(response.getOutputStream()); + PrintWriter pw = new PrintWriter(ps); + pw.print("\n\nError\n\n\n"); //NOI18N + + // PENDING! Localize this for next official release + pw.print("

The resource did not process correctly

\n
\n");                
+                pw.print(stackTrace);                
+                pw.print("
\n"); //NOI18N + pw.close(); + ps.close(); + response.getOutputStream().close(); + } catch (Exception ex) { + } + } else { + try { + PrintStream ps = new PrintStream(response.getOutputStream()); + t.printStackTrace(ps); + ps.close(); + response.getOutputStream().close(); + } catch (Exception ex) { + } + } + } + + public static String getStackTrace(Throwable t) { + String stackTrace = null; + try { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + pw.close(); + sw.close(); + stackTrace = sw.getBuffer().toString(); + } catch (Exception ex) { + } + return stackTrace; + } + + public void log(String msg) { + filterConfig.getServletContext().log(msg); + } + +} diff --git a/src/java/form/AuthentifForm.java b/src/java/form/AuthentifForm.java new file mode 100644 index 0000000..23b670a --- /dev/null +++ b/src/java/form/AuthentifForm.java @@ -0,0 +1,75 @@ +/* + * form/authentifForm.java + * Controle des données saisie dans le formulaire d'authentification + */ +package form; + +import bdd.ParamMySQL; +import bdd.PompierMySQL; +import bean.Parametre; +import bean.Pompier; +import com.sun.net.httpserver.HttpServer; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import util.CtrlSaisie; +import util.MD5; + +/** + * + * @author domin + */ +public class AuthentifForm { + String message; + HttpServletRequest request; + + public AuthentifForm(HttpServletRequest request) { + this.request = request; + } + + public boolean ctrlAuthentif() { + request.removeAttribute("message"); + // Vérification de la présence des zones obligatoires + String[] champsObligatoires = {"ztLogin", "ztMDP"}; + if (!CtrlSaisie.CtrlChampsObligatoires(request, champsObligatoires)) { + return false; + } + + // Vérification absence de chevron + if (!CtrlSaisie.CtrlChevron(request)) { + return false; + } + return true; + } + + public boolean ctrlBDD() { + boolean trouve = false; + String login = request.getParameter("ztLogin"); + String mdp = MD5.encode(request.getParameter("ztMDP")); + PompierMySQL pompierMySQL = new PompierMySQL(); + Pompier lePompier = pompierMySQL.readAuthentif(login, mdp); + if (lePompier!= null) { + trouve = true; + HttpSession maSession = request.getSession(); + maSession.setAttribute("lePompierConnecte", lePompier); + ParamMySQL paramMySQL = new ParamMySQL(); + ArrayList lesGrades = paramMySQL.readType("grade"); + maSession.setAttribute("lesGrades", lesGrades); + ArrayList lesPeriodes = paramMySQL.readType("tranche"); + maSession.setAttribute("lesPeriodes", lesPeriodes); + ArrayList lesStatuts = paramMySQL.readType("statAgt"); + maSession.setAttribute("lesStatuts", lesStatuts); + ArrayList lesTypes = paramMySQL.readType("typePer"); + maSession.setAttribute("lesTypes", lesTypes); + if (lePompier.getLeStatut().getCode()==2) { + // Recherche des pompiers de la caserne + ArrayList lesPompiers = pompierMySQL.readLesPompiersCaserne(lePompier.getLaCaserne().getId()); + maSession.setAttribute("lesPompiers", lesPompiers); + } + } else { + request.setAttribute("message", "Login ou mot de passe erroné"); + } + + return trouve; + } +} diff --git a/src/java/form/PompierForm.java b/src/java/form/PompierForm.java new file mode 100644 index 0000000..f00b740 --- /dev/null +++ b/src/java/form/PompierForm.java @@ -0,0 +1,169 @@ +/* + * form/PompierForm.java + * Contrôle des données saisies dans le formulaire pompier et maj bdd + */ +package form; + +import bdd.ParamMySQL; +import bdd.PompierMySQL; +import bean.Parametre; +import bean.Pompier; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Enumeration; +import java.util.HashMap; +import util.CtrlSaisie; +import util.MD5; + +/** + * + * @author domin + */ +public class PompierForm { + + String message; + HttpServletRequest request; + + public PompierForm(HttpServletRequest request) { + this.request = request; + } + + public boolean ctrlPompier() { + request.removeAttribute("message"); + // Vérification de la présence des zones obligatoires + String[] champsObligatoires = {"ztNom", "ztPrenom", "ztAdresse", "ztCP", + "zlVille", "ztMail", "ztLogin", "ztMdp", "ztBip", "ldrGrade", "ldrStatut", "ldrType"}; + if (!CtrlSaisie.CtrlChampsObligatoires(request, champsObligatoires)) { + return false; + } + + // Contrôle caractères indésirables + if (!CtrlSaisie.CtrlChevron(request)) { + return false; + } + + // Contrôle des zones grade, statut et typerPers + HttpSession maSession = request.getSession(); + Pompier lePompierConnecte = (Pompier) maSession.getAttribute("lePompierConnecte"); + boolean chef = lePompierConnecte.getLeStatut().getCode() == 2; + ParamMySQL pm = new ParamMySQL(); + if (chef) { // contrôle uniquement pour les chefs de centre + int statut, type, grade = -1; + + try { + statut = Integer.parseInt(request.getParameter("ldrStatut")); + type = Integer.parseInt(request.getParameter("ldrType")); + grade = Integer.parseInt(request.getParameter("ldrGrade")); + } catch (Exception e) { + System.out.println("Statut, type ou grade transmis non numérique - " + e.getMessage()); + request.setAttribute("message", "Erreur au niveau de la saisie du statut, du grade ou du type"); + return false; + } + Parametre leStatut = pm.read("statAgt", statut); + Parametre leType = pm.read("typePer", type); + Parametre leGrade = pm.read("grade", grade); + if (leStatut == null || leType == null || leGrade == null) { + System.out.println("Statut, type ou grade transmis inexistant dans la table paramètre - " + + "Statut:" + statut + " - Type:" + type + " - Grade:" + grade); + request.setAttribute("message", "Erreur au niveau de la saisie du statut, du grade ou du type"); + return false; + } + } + return true; + } + + // Mise à jour de la fiche du pompier + public Pompier majBDD() { + HttpSession maSession = request.getSession(); + Pompier lePompierConnecte = (Pompier) maSession.getAttribute("lePompierConnecte"); + boolean chef = lePompierConnecte.getLeStatut().getCode() == 2; + Pompier lepompierAffiche = (Pompier) maSession.getAttribute("lePompier"); + + // Recherche du type de mise à jour à effectuer + int typMaj = -1; + if (chef && maSession.getAttribute("lePompier") == null) { + System.out.println("Creation d'un nouveau pompier"); + typMaj = 1; + } else { + if (chef && lepompierAffiche.getId() != lePompierConnecte.getId()) { + System.out.println("Maj d'un pompier par le chef de centre"); + typMaj = 2; + } else { + System.out.println("Maj du pompier connecté par lui-même"); + typMaj = 3; + } + } + + ArrayList nonModifParPompier = new ArrayList<>(); + nonModifParPompier.add("ldrGrade"); + nonModifParPompier.add("ldrStatut"); + nonModifParPompier.add("ldrType"); + nonModifParPompier.add("ztBip"); + + // Zones saisies + HashMap lesParametres = new HashMap(); + Enumeration names = request.getParameterNames(); + while (names.hasMoreElements()) { + String name = names.nextElement(); + // Exclusion des zones non modifiables pour les pompiers + if (typMaj == 1 || typMaj == 2 || !nonModifParPompier.contains(name)) { + Object value = request.getParameter(name); + lesParametres.put(name, value); + } + } + + // Zones implicites + if (typMaj == 1) { + int idC = lePompierConnecte.getLaCaserne().getId(); + lesParametres.put("idC", idC); // Caserne + } +// if (typMaj == 2 || typMaj == 3) { +// int idP = lepompierAffiche.getId(); +// lesParametres.put("idP", idP); // id du pompier +// } + + // Cas particulier du mot de passe, actuellement non modifiable + String ztMdp = MD5.encode((String) lesParametres.get("ztLogin")); + lesParametres.put("ztMdp", ztMdp); // Mot de passe défini à partir du login + + /* Pb pour les zones numériques : + elles doivent être mémorisées dans le dictionnaire en entier, pour + une lecture par la suite */ + + Pompier lePompierMaj = null; + PompierMySQL pompierMySQL = new PompierMySQL(); + if (typMaj == 1) { + lePompierMaj = pompierMySQL.create(lesParametres); + } else { + lePompierMaj = pompierMySQL.update(lesParametres, lepompierAffiche.getId()); + } + if (lePompierMaj != null) { + request.setAttribute("message", "Le pompier no " + lePompierMaj.getId() + " a été mis à jour"); + } else { + request.setAttribute("message", "Erreur lors de la mise à jour du pompier"); + } + + // Mise à jour de la collection les Pompiers, si le pompier mis à jour est volontaire + if (chef && lePompierMaj != null) { +// ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); +// if (lesPompiers.contains(lePompierMaj)) { +// lesPompiers.remove(lePompierMaj); +// } +// if (lePompierConnecte.getId() != lePompierMaj.getId()) { +// lesPompiers.add(lePompierMaj); +// } + ArrayList lesPompiers = pompierMySQL.readLesPompiersCaserne(lePompierConnecte.getLaCaserne().getId()); + + maSession.setAttribute("lesPompiers", lesPompiers); + maSession.setAttribute("lePompier", lesPompiers.get(0)); + + } + if (typMaj==3) { + maSession.setAttribute("lePompierConnecte", lePompierMaj); + maSession.setAttribute("lePompier", lePompierMaj); + } + return lePompierMaj; + } +} diff --git a/src/java/form/VentilForm.java b/src/java/form/VentilForm.java new file mode 100644 index 0000000..825e64d --- /dev/null +++ b/src/java/form/VentilForm.java @@ -0,0 +1,58 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package form; + +import bdd.VentilMysql; +import bean.Ventil; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Map; + +/** + * + * @author thomas.millot + */ +public class VentilForm { + + public void verifVentil(HttpServletRequest request) { + + //a.récupération de la collection des ventilation + HttpSession maSession = request.getSession(); + ArrayList lesVentil + = (ArrayList) maSession.getAttribute("lesVentilInit"); + + //b.Créer un objet de type VentilMysql + VentilMysql vm = new VentilMysql(); + + //c.Récupérer les données du formulaire + Map map = request.getParameterMap(); + String[] lesNvVentil = map.get("lesActivites"); + + //d. Initialiser du compteur de boucle + int i = 0; + + //e.Mise a jour des activité des salariés + for (Ventil uneVentil : lesVentil) { + int oldAct = uneVentil.getActivite(); + int newAct = Integer.parseInt(lesNvVentil[i]); + if (oldAct != newAct) { + if (uneVentil.isIsInBD()) { + if(newAct == 0){ + vm.delete(uneVentil); + } else { + uneVentil.setActivite(newAct); + vm.update(uneVentil); + } + } else { + uneVentil.setActivite(newAct); + vm.create(uneVentil); + } + } + i++; + } + } +} diff --git a/src/java/servlet/AuthentifServlet.java b/src/java/servlet/AuthentifServlet.java new file mode 100644 index 0000000..73f6be7 --- /dev/null +++ b/src/java/servlet/AuthentifServlet.java @@ -0,0 +1,115 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template + */ +package servlet; + +import bean.Pompier; +import form.AuthentifForm; +import java.io.IOException; +import java.io.PrintWriter; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; + +/** + * + * @author domin + */ +public class AuthentifServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + /* TODO output your page here. You may use following sample code. */ + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet AuthentifServlet"); + out.println(""); + out.println(""); + out.println("

Servlet AuthentifServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + // Suppression des variables de session + System.out.println("doGet AuthentifServlet"); + HttpSession maSession = request.getSession(); + maSession.removeAttribute("lePompierConnecte"); + maSession.removeAttribute("lesPompiers"); + maSession.removeAttribute("lePompier"); + getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response); + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + Pompier lePompier = null; + int page = 2; + AuthentifForm af = new AuthentifForm(request); + if (af.ctrlAuthentif() && af.ctrlBDD()) { // Contrôle des zones saisies et contrôle en base de données + HttpSession maSession = request.getSession(); + lePompier = (Pompier) maSession.getAttribute("lePompierConnecte"); + if (lePompier.getLeStatut().getCode()==2) { // Chef de centre + ArrayList lesPompiers = (ArrayList ) maSession.getAttribute("lesPompiers"); + if (lesPompiers.size() > 0) { + lePompier = lesPompiers.get(0); + page = 3; + } + } + request.setAttribute("page", page); + //request.setAttribute("lePompier", lePompier); + maSession.setAttribute("lePompier", lePompier); + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); + } else { // Une erreur a été détectée + getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response); + } + } + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/java/servlet/LesDispoServlet.java b/src/java/servlet/LesDispoServlet.java new file mode 100644 index 0000000..cd571ca --- /dev/null +++ b/src/java/servlet/LesDispoServlet.java @@ -0,0 +1,180 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package servlet; + +import bdd.VentilMysql; +import bean.Pompier; +import bean.Ventil; +import com.mysql.cj.util.StringUtils; +import form.VentilForm; +import java.io.IOException; +import java.io.PrintWriter; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Calendar; +import util.TrmtDate; +/** + * + * @author thomas.millot + */ +public class LesDispoServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try ( PrintWriter out = response.getWriter()) { + /* TODO output your page here. You may use following sample code. */ + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet LesDispoServlet"); + out.println(""); + out.println(""); + out.println("

Servlet LesDispoServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + // processRequest(request, response); + //Méthode accédée uniquement depuis la barre du menu + int pageDemandee = 0; + int page = 5; + String jsp = "lesDispoJSP.jsp"; + + boolean erreur = false; + if (request.getParameter("pageDemandee") != null) { + String pageEnString = request.getParameter("pageDemandee"); + boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString); + if (isNumeric) { + pageDemandee = Integer.parseInt(pageEnString); + if (pageDemandee != 5) { // erreur + erreur = true; + } + } else { + erreur = true; + } + } else { + erreur = true; + } + + HttpSession maSession = request.getSession(); + Pompier lePompier = null; + + if (maSession.getAttribute("lesVentilInit") == null) { + + /* Initialisations des dates de la semaine */ + Calendar[] lesDates = new Calendar[7]; + String[] lesDatesEnString = new String[7]; + lesDates[0] = TrmtDate.getDateDebutSemaine(); + lesDatesEnString[0] = TrmtDate.getDateAAfficher(lesDates[0]); + for (int i = 1; i < lesDates.length; i++) { + lesDates[i] = TrmtDate.addDays(lesDates[0], i); + lesDatesEnString[i] = TrmtDate.getDateAAfficher(lesDates[i]); + } + + maSession.setAttribute("lesDates", lesDates); + maSession.setAttribute("lesDatesEnString", lesDatesEnString); + //System.out.println("lesDates "+ lesDates[4].getTime()); + + /* Initialisation des périodes */ + String[] lesPeriodes = {"1", "2", "3", "4"}; + maSession.setAttribute("lesPeriodes", lesPeriodes); + + /* Recherche des ventilations */ + VentilMysql vm = new VentilMysql(); + ArrayList lesVentilInit = vm.getLesVentil(lesDates, lesPeriodes, request); + //System.out.println("lesVentilInit : " + lesVentilInit); + maSession.setAttribute("lesVentilInit", lesVentilInit); + + /* Initialisation des couleurs */ + String[] lesCouleurs = {"vert", "orange", "rouge"}; + maSession.setAttribute("lesCouleurs", lesCouleurs); + } + + if (erreur == false) { + lePompier = (Pompier) maSession.getAttribute("lePompierConnecte"); + if (pageDemandee == 5 && lePompier.getLeStatut().getCode() != 2) { // erreur + erreur = true; + } + } + + if (erreur == false && pageDemandee == 5) { // Chef de centre + ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); + //System.out.println("lesPompiers de la caserne " + lesPompiers); + if (lesPompiers.size() > 0) { + lePompier = lesPompiers.get(0); + page = 5; + } + } + if (erreur) { + request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet + } else { + request.setAttribute("page", page); + maSession.setAttribute("lePompier", lePompier); + getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response); + } + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + //a.créer un objet de type ventilForm + VentilForm vf = new VentilForm(); + + //b.Appeler verifVentil + vf.verifVentil(request); + + //c.Afficher le menu + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); + + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/java/servlet/MesDispoServlet.java b/src/java/servlet/MesDispoServlet.java new file mode 100644 index 0000000..75bea6e --- /dev/null +++ b/src/java/servlet/MesDispoServlet.java @@ -0,0 +1,173 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package servlet; + +import bdd.VentilMysql; +import bean.Pompier; +import bean.Ventil; +import com.mysql.cj.util.StringUtils; +import form.VentilForm; +import java.io.IOException; +import java.io.PrintWriter; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; +import java.util.Calendar; +import util.TrmtDate; + +/** + * + * @author thomas.millot + */ +public class MesDispoServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try ( PrintWriter out = response.getWriter()) { + /* TODO output your page here. You may use following sample code. */ + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet MesDispoServlet"); + out.println(""); + out.println(""); + out.println("

Servlet MesDispoServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + //Méthode accédée uniquement depuis la barre du menu + System.out.println("doGet mesDispo"); + int pageDemandee = 0; + int page = 6; + String jsp = "mesDispoJSP.jsp"; + + boolean erreur = false; + if (request.getParameter("pageDemandee") != null) { + String pageEnString = request.getParameter("pageDemandee"); + boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString); + if (isNumeric) { + pageDemandee = Integer.parseInt(pageEnString); + if (pageDemandee != 6) { // erreur + erreur = true; + } + } else { + erreur = true; + } + } else { + erreur = true; + } + + HttpSession maSession = request.getSession(); + Pompier lePompier = null; + + if (maSession.getAttribute("lesVentilInit") == null) { + + /* Initialisations des dates de la semaine */ + Calendar[] lesDates = new Calendar[7]; + String[] lesDatesEnString = new String[7]; + lesDates[0] = TrmtDate.getDateDebutSemaine(); + lesDatesEnString[0] = TrmtDate.getDateAAfficher(lesDates[0]); + for (int i = 1; i < lesDates.length; i++) { + lesDates[i] = TrmtDate.addDays(lesDates[0], i); + lesDatesEnString[i] = TrmtDate.getDateAAfficher(lesDates[i]); + } + + maSession.setAttribute("lesDates", lesDates); + maSession.setAttribute("lesDatesEnString", lesDatesEnString); + //System.out.println("lesDates "+ lesDates[4].getTime()); + + /* Initialisation des périodes */ + String[] lesPeriodes = {"1", "2", "3", "4"}; + maSession.setAttribute("lesPeriodes", lesPeriodes); + + /* Recherche des ventilations */ + VentilMysql vm = new VentilMysql(); + ArrayList lesVentilInit = vm.getLesVentil(lesDates, lesPeriodes, request); + //System.out.println("lesVentilInit : " + lesVentilInit); + maSession.setAttribute("lesVentilInit", lesVentilInit); + + /* Initialisation des couleurs */ + String[] lesCouleurs = {"vert", "orange", "rouge"}; + maSession.setAttribute("lesCouleurs", lesCouleurs); + } + + if (erreur == false) { + lePompier = (Pompier) maSession.getAttribute("lePompierConnecte"); + if (pageDemandee == 6 && lePompier.getLeStatut().getCode() != 1) { // erreur + erreur = true; + } + } + System.out.println("erreur : "+ erreur); + if (erreur) { + request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet + } else { + request.setAttribute("page", page); + maSession.setAttribute("lePompier", lePompier); + getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response); + } + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + //a.créer un objet de type ventilForm + VentilForm vf = new VentilForm(); + + //b.Appeler verifVentil + vf.verifVentil(request); + + //c.Afficher le menu + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/java/servlet/PompierServlet.java b/src/java/servlet/PompierServlet.java new file mode 100644 index 0000000..9cb09f3 --- /dev/null +++ b/src/java/servlet/PompierServlet.java @@ -0,0 +1,194 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template + */ +package servlet; + +import bean.Pompier; +import com.mysql.cj.util.StringUtils; +import form.PompierForm; +import java.io.IOException; +import java.io.PrintWriter; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import java.util.ArrayList; + +/** + * + * @author domin + */ +public class PompierServlet extends HttpServlet { + + /** + * Processes requests for both HTTP GET and POST + * methods. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + protected void processRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + response.setContentType("text/html;charset=UTF-8"); + try (PrintWriter out = response.getWriter()) { + /* TODO output your page here. You may use following sample code. */ + out.println(""); + out.println(""); + out.println(""); + out.println("Servlet PompierServlet"); + out.println(""); + out.println(""); + out.println("

Servlet PompierServlet at " + request.getContextPath() + "

"); + out.println(""); + out.println(""); + } + } + + // + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + //Méthode accédée uniquement depuis la barre du menu + int pageDemandee = 0; + int page = 2; + String jsp = "pompierJSP.jsp"; + + boolean erreur = false; + if (request.getParameter("pageDemandee") != null) { + String pageEnString = request.getParameter("pageDemandee"); + boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString); + if (isNumeric) { + pageDemandee = Integer.parseInt(pageEnString); + if (pageDemandee != 2 && pageDemandee != 3) { // erreur + erreur = true; + } + } else { + erreur = true; + } + } else { + erreur = true; + } + + HttpSession maSession = request.getSession(); + Pompier lePompier = null; + if (erreur == false) { + lePompier = (Pompier) maSession.getAttribute("lePompierConnecte"); + if (pageDemandee == 3 && lePompier.getLeStatut().getCode() != 2) { // erreur + erreur = true; + } + } + + if (erreur == false && pageDemandee == 3) { // Chef de centre + ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); + //System.out.println("lesPompiers de la caserne " + lesPompiers); + if (lesPompiers.size() > 0) { + lePompier = lesPompiers.get(0); + page = 3; + } + } + if (erreur) { + request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet + } else { + request.setAttribute("page", page); + maSession.setAttribute("lePompier", lePompier); + getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response); + } + } + + /** + * Handles the HTTP POST method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + //processRequest(request, response); + /* Méthode accédée + depuis la validation du formulaire de choix du pompier à afficher (btAfficherPompier = "Afficher") + depuis le bouton Ajouter du formulaire du choix du pompier (btAfficherPompier = "Ajouter") + depuis le bouton de validation de mise à jour d'un pompier (btAfficherPompier = "ValiderMaj") + */ + int erreur = 0; + String btValue = null; + ArrayList valeursBt = new ArrayList() ; + valeursBt.add("Afficher") ; + valeursBt.add("Ajouter") ; + valeursBt.add("ValiderMaj") ; + + // Test du bouton btAfficherPompier + if (request.getParameter("btAfficherPompier")==null) { + erreur = 1; + } else { + btValue = request.getParameter("btAfficherPompier"); + if (!valeursBt.contains(btValue)) { + erreur = 2; + } + } + if (erreur > 0) { + request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet + //response.sendRedirect("/sdis29M1/authentification"); + return; + } + + HttpSession maSession = request.getSession(); + ArrayList lesPompiers = (ArrayList) maSession.getAttribute("lesPompiers"); + if (request.getParameter("btAfficherPompier").equals("Afficher") + && Integer.parseInt(request.getParameter("ldrPompier")) < lesPompiers.size()) { + int noPompier = Integer.parseInt(request.getParameter("ldrPompier")); + //request.setAttribute("lePompier", lesPompiers.get(noPompier)); + maSession.setAttribute("lePompier", lesPompiers.get(noPompier)); + request.setAttribute("page", 3); + } + + if (request.getParameter("btAfficherPompier").equals("Ajouter")) { + maSession.removeAttribute("lePompier"); + } + + if (request.getParameter("btAfficherPompier").equals("ValiderMaj")) { + PompierForm pf = new PompierForm(request); + boolean valid = pf.ctrlPompier(); +// if (maSession.getAttribute("lePompier")==null) { +// System.out.println("Creation d'un nouveau pompier"); +// } else { +// Pompier lePompier = (Pompier) maSession.getAttribute("lePompier"); +// Pompier lePompierConnecte = (Pompier) maSession.getAttribute("lePompierConnecte"); +// if (lePompier.getId() != lePompierConnecte.getId()) { +// System.out.println("Maj d'un pompier par le chef de centre"); +// } else { +// System.out.println("Maj du pompier connecté par lui-même"); +// } +// } + pf.majBDD(); + } + + getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response); + } + + /** + * Returns a short description of the servlet. + * + * @return a String containing servlet description + */ + @Override + public String getServletInfo() { + return "Short description"; + }// + +} diff --git a/src/java/util/CtrlSaisie.java b/src/java/util/CtrlSaisie.java new file mode 100644 index 0000000..a40fba5 --- /dev/null +++ b/src/java/util/CtrlSaisie.java @@ -0,0 +1,64 @@ +/* + * util/CtrlSaisie.java + */ +package util; + +import jakarta.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.Enumeration; + +/** + * + * @author domin + */ +public abstract class CtrlSaisie { + /** + * Vérifie la présence des champs obligatoires dans les paramètres transmis + * @param request + * @param champsObligatoires : tableau de chaine de caractères, avec le nom des champs obligatoires + * @return booléen + */ + public static boolean CtrlChampsObligatoires(HttpServletRequest request, String[] champsObligatoires) { + ArrayList champsPresents = new ArrayList<>(request.getParameterMap().keySet()); + int i = 0; + int nbChampsO = champsObligatoires.length; + boolean erreur = false; + while (erreur == false && i < nbChampsO && champsPresents.contains(champsObligatoires[i])){ + String value=request.getParameter(champsObligatoires[i]); + if (value.trim().length() > 0) { + i++; + } else { + erreur = true; + } + } + if (i < nbChampsO) { + request.setAttribute("message", "Veuillez renseigner toutes les zones obligatoires ("+i+')'); + } + return (i>=nbChampsO); + } + + /** + * Contrôle si un champ de saisie contient un chevron + * @param request + * @return 0 sinon, -1 si oui + */ + public static boolean CtrlChevron(HttpServletRequest request) { + // Contrôle car "<" dans les zones de texte + Enumeration lesNoms = request.getParameterNames(); + int erreur = 0; + //ArrayList parameterNames = new ArrayList(request.getParameterMap().keySet()); + while (erreur == 0 && lesNoms.hasMoreElements()) { + Object paramObjet=lesNoms.nextElement(); + String param=(String) paramObjet; + String value=request.getParameter(param); + if (value.contains("<") || value.contains("<")) { + String message = "Veuillez recommencer votre saisie, une anomalie sur une zone de saisie a été détectée "; + request.setAttribute("message", message); + erreur=1; + } + } + return (erreur > 0) ? false : true; + + } + +} diff --git a/src/java/util/MD5.java b/src/java/util/MD5.java new file mode 100644 index 0000000..cccd368 --- /dev/null +++ b/src/java/util/MD5.java @@ -0,0 +1,36 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package util; + +/** + * + * @author sio + */ + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.logging.Level; +import java.util.logging.Logger; + +public abstract class MD5 { + + public static String encode(String uneChaine){ + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException ex) { + throw new IllegalArgumentException(ex); + } + md.update(uneChaine.getBytes()); + byte[] digest = md.digest(); + //myHash = DatatypeConverter.printHexBinary(digest).toLowerCase(); + StringBuilder sb = new StringBuilder(); + for (byte b : digest) { + sb.append(String.format("%02x", b)); + } + return sb.toString(); + } +} diff --git a/src/java/util/TrmtDate.java b/src/java/util/TrmtDate.java new file mode 100644 index 0000000..cd96aa1 --- /dev/null +++ b/src/java/util/TrmtDate.java @@ -0,0 +1,129 @@ +package util; +/* + * Classe abstraite facilitant le traitement des dates + * Toutes les méthodes sont statiques, appel : TrmtDate.nomMéthode + */ + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +/** + * + * @author Dominique_2 + */ +public abstract class TrmtDate { + static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); + + /** + * Recherche de la date du début de la semaine courante + * @return date du lundi de la semaine, format Calendar + */ + public static Calendar getDateDebutSemaine() { + return getDateDebutSemaine(getDateDuJour()); + } + + /** + * Recherche de la date du début de semaine à partir de la date passée en paramètre + * @param c Calendar, date de recherche + * @return Calendar, début semaine à partir de c + */ + public static Calendar getDateDebutSemaine(Calendar c) { + Calendar leCal = getClone(c); + leCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); + //System.out.println("Date du lundi correspondant : " + nvCal.getTime()); + return leCal; + } + /** + * Retourne la date passée en paramètre sous la forme : lun.05/10 par exemple + * @param d date à transformer + * @return chaine de car., forme lun.05/10 par exemple + */ + public static String getDateAAfficher(Calendar d) { + Locale locale = Locale.getDefault(); + String dateAAfficher = d.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM"); + String jrMois = sdf.format(d.getTime()); + dateAAfficher += jrMois; + return dateAAfficher; + } + + /** + * Retourne une date égale à la date passée en paramètre plus le nb jours indiqués + * @param dateInit date initiale, format Calendar + * @param days nb jours à ajouter + * @return dateInit + days, format Calendar + */ + public static Calendar addDays(Calendar dateInit, int days) { + Calendar leCal = getClone(dateInit); + leCal.setTime(dateInit.getTime()); + leCal.add(Calendar.DAY_OF_MONTH, days); + return leCal; + } + + /** + * Retourne une instance de Calendar correspondant à la date au format SQl + * passée en paramètre + * @param sqlDate : date au format java.sql.Date + * @return instance de Calendar + */ + public static Calendar getCalDate(java.sql.Date sqlDate) { + cal.setTime(new java.util.Date(sqlDate.getTime())); + return cal; + } + + /** + * Retourne une date sql à partir d'une instance de Calendar + * @param unCal + * @return date sql + */ + public static java.sql.Date getSQLDate(Calendar unCal) { + return new java.sql.Date(unCal.getTimeInMillis()); + } + + /** + * Retourne une instance de Calendar correspondant à la date + * passée en paramètre + * @param utilDate : date au format java.util.Date + * @return instance de Calendar + */ + public static Calendar getCalDate(java.util.Date utilDate) { + cal.setTime(utilDate); + return cal; + } + + /** + * Retourne la date du jour au format SQL + * @return Date au format sql + */ + public static java.sql.Date getSQLDateDuJour() { + return java.sql.Date.valueOf(java.time.LocalDate.now()); + } + + /** + * Retourne la date du jour au format Calendar + * @return Calendar + */ + public static Calendar getDateDuJour() { + Calendar nvCal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris")); + nvCal.set(Calendar.HOUR_OF_DAY, 0); + nvCal.set(Calendar.MINUTE, 0); + nvCal.set(Calendar.SECOND, 0); + nvCal.set(Calendar.MILLISECOND, 0); + //System.out.println("Date du jour : " + nvCal.getTime()); + return nvCal; + } + + /** + * Permet d'obtenir une autre instance de Calendar identique à celle passée en paramètre + * @param c Calendar à cloner + * @return nouvelle instance de Calendar + */ + public static Calendar getClone(Calendar c) { + Calendar leCal = Calendar.getInstance(); + leCal.setTime(c.getTime()); + return leCal; + } +} \ No newline at end of file diff --git a/web/META-INF/context.xml b/web/META-INF/context.xml new file mode 100644 index 0000000..dbffef5 --- /dev/null +++ b/web/META-INF/context.xml @@ -0,0 +1,2 @@ + + diff --git a/web/WEB-INF/authentifJSP.jsp b/web/WEB-INF/authentifJSP.jsp new file mode 100644 index 0000000..e2e951e --- /dev/null +++ b/web/WEB-INF/authentifJSP.jsp @@ -0,0 +1,41 @@ +<%-- + Document : authentifJSP + Created on : 23 oct. 2021, 10:02:18 + Author : domin +--%> +<%@include file= "jspf/debutJSP.jspf" %> + + + <%@include file= "jspf/header.jspf" %> +
+ +
+
+ + Authentification + +
+
+ + +
+
+ + +
+
+ +
+
+ ${message} +
+
+ <%@include file= "jspf/footer.jspf" %> +
+ + + + + diff --git a/web/WEB-INF/jspf/debutJSP.jspf b/web/WEB-INF/jspf/debutJSP.jspf new file mode 100644 index 0000000..1331b5f --- /dev/null +++ b/web/WEB-INF/jspf/debutJSP.jspf @@ -0,0 +1,16 @@ +<%-- jspf/debutJSP.jsp --%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + + + + + + + + + + SDIS29 + diff --git a/web/WEB-INF/jspf/footer.jspf b/web/WEB-INF/jspf/footer.jspf new file mode 100644 index 0000000..4362381 --- /dev/null +++ b/web/WEB-INF/jspf/footer.jspf @@ -0,0 +1,5 @@ +<%-- jspf/footer.jspf --%> +<%@ page pageEncoding="UTF-8" %> +
+

SDIS 29 - 58, avenue de Keradennec - 29337 QUIMPER CEDEX - 02 98 10 31 50

+
diff --git a/web/WEB-INF/jspf/formChoixPompier.jspf b/web/WEB-INF/jspf/formChoixPompier.jspf new file mode 100644 index 0000000..47b08ba --- /dev/null +++ b/web/WEB-INF/jspf/formChoixPompier.jspf @@ -0,0 +1,30 @@ +<%-- any content can be specified here e.g.: --%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ page pageEncoding="UTF-8" %> + +
+
+
+ + +
+
+ + + +
+
+
+ + + + diff --git a/web/WEB-INF/jspf/formulairePompier.jspf b/web/WEB-INF/jspf/formulairePompier.jspf new file mode 100644 index 0000000..9c61a35 --- /dev/null +++ b/web/WEB-INF/jspf/formulairePompier.jspf @@ -0,0 +1,144 @@ +<%@ page pageEncoding="UTF-8" %> +
+
+ + +
+
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + + + +
+
+ +
+
+ + +
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ + +
+
+ +
${message}
+ +
+ +
+ +

* zone obligatoire

+ +
+
+
+ + diff --git a/web/WEB-INF/jspf/header.jspf b/web/WEB-INF/jspf/header.jspf new file mode 100644 index 0000000..690df10 --- /dev/null +++ b/web/WEB-INF/jspf/header.jspf @@ -0,0 +1,126 @@ +<%-- jspf/header.jspf --%> +<%@ page pageEncoding="UTF-8" %> + +
+
+ + +
+
+ + +

Bienvenue

+
+ +

Bienvenue ${sessionScope.lePompierConnecte.getPrenom()} + ${sessionScope.lePompierConnecte.getNom()} ( + ${sessionScope.lePompierConnecte.getLeStatut().getValeur()}) +

+ + +
+
+
+

Service Départemental d'Incendie et de Secours du Finistère

+ +
+ ${sessionScope.lePompierConnecte.getLaCaserne().getNom()} + ${sessionScope.lePompierConnecte.getLaCaserne().getAdresse()}
+ ${sessionScope.lePompierConnecte.getLaCaserne().getTel()}
+
+ +
+
+
\ No newline at end of file diff --git a/web/WEB-INF/lesDispoJSP.jsp b/web/WEB-INF/lesDispoJSP.jsp new file mode 100644 index 0000000..f346f9a --- /dev/null +++ b/web/WEB-INF/lesDispoJSP.jsp @@ -0,0 +1,86 @@ +<%-- + Document : LesDispoJSP + Created on : 6 déc. 2021, 15:15:56 + Author : thomas.millot +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@include file= "jspf/debutJSP.jspf" %> + + + <%@include file= "jspf/header.jspf" %> +
+
+ + + Les disponibilités + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id Nom prénom${uneDate}
${unePeriode}
${uneVentil.getPompier().getId()}${uneVentil.getPompier().getNom()} + ${uneVentil.getPompier().getPrenom()} + +
+
+ +
+
+
+ Disponible + Au travail + Indisponible +
+
+
+ + + diff --git a/web/WEB-INF/mesDispoJSP.jsp b/web/WEB-INF/mesDispoJSP.jsp new file mode 100644 index 0000000..0b98cd7 --- /dev/null +++ b/web/WEB-INF/mesDispoJSP.jsp @@ -0,0 +1,86 @@ +<%-- + Document : LesDispoJSP + Created on : 6 déc. 2021, 15:15:56 + Author : thomas.millot +--%> + +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@include file= "jspf/debutJSP.jspf" %> + + + <%@include file= "jspf/header.jspf" %> +
+
+ + + Les disponibilités + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id Nom prénom${uneDate}
${unePeriode}
${uneVentil.getPompier().getId()}${uneVentil.getPompier().getNom()} + ${uneVentil.getPompier().getPrenom()} + +
+
+ +
+
+
+ Disponible + Au travail + Indisponible +
+
+
+ + + diff --git a/web/WEB-INF/pompierJSP.jsp b/web/WEB-INF/pompierJSP.jsp new file mode 100644 index 0000000..1b9721a --- /dev/null +++ b/web/WEB-INF/pompierJSP.jsp @@ -0,0 +1,50 @@ +<%-- + pompierJSP.jsp +--%> +<%@page contentType="text/html" pageEncoding="UTF-8"%> +<%@include file= "jspf/debutJSP.jspf" %> + + + <%@include file= "jspf/header.jspf" %> +
+
+ + + + + Données du pompier ${lePompier.getNom()} ${lePompier.getPrenom()} + + + + Données du pompier à créer + + +
+ <%@include file= "jspf/formChoixPompier.jspf" %> +
+
+
+ +
+ + ${legend} + + + <%@include file= "jspf/formulairePompier.jspf" %> +
+
+ + <%@include file= "jspf/footer.jspf" %> +
+ + + + + + + + + + + + diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml new file mode 100644 index 0000000..776276a --- /dev/null +++ b/web/WEB-INF/web.xml @@ -0,0 +1,56 @@ + + + + AuthentifServlet + servlet.AuthentifServlet + + + ModifServlet + servlet.ModifServlet + + + ProfilServlet + servlet.ProfilServlet + + + LesDispoServlet + servlet.LesDispoServlet + + + MesDispoServlet + servlet.MesDispoServlet + + + VentilServlet + servlet.VentilServlet + + + PompierServlet + servlet.PompierServlet + + + AuthentifServlet + /authentification + + + ModifServlet + /Modif + + + LesDispoServlet + /affectation + + + MesDispoServlet + /MesDisponibilites + + + PompierServlet + /pompier + + + + 30 + + + diff --git a/web/css/mycss.css b/web/css/mycss.css new file mode 100644 index 0000000..23f5898 --- /dev/null +++ b/web/css/mycss.css @@ -0,0 +1,119 @@ +/* + css/mycss.css +*/ + +body { + background-color: #ECECEC; +} +#contenuAffiche { + display: flex; + justify-content:center; + padding-top: 10px; + padding-bottom: 10px; + background-color: #ffffff; + border-radius: 5px; +} +#authentif { + width : 50%; +} +fieldset { + border-radius: 5px; + padding: 5px; + border: 1px solid #DB0005; + width: 100%; +} +legend { + margin-bottom:0px; + padding-bottom: 0px; +} +footer { + margin-top: 10px; + background-color: #EDEDED; + text-align: center; + font-size: smaller; + padding: 10px; + /*border-bottom: 3px solid #DB0005; */ +} +header { + background-color: #333333; + color: #EDEDED; + padding: 10px; + +} +#entete { + display: flex; + /* align-items: center; */ + align-items: flex-end ; +} + +li { + text-align: center; +} +li:not(:first-child) { + border-left: 2px solid #EDEDED; +} +#identite { + width : 100%; +} +.navbar { + padding: 0 0 0 0; + border-radius: 5px; + margin-left: -8%; +} +#logo { + z-index:1; /* arriere plan */ +} +#login { + background-color: #EDEDED; + color: #333333; + display: flex; + justify-content:space-around; + align-items: center; + margin-left: -8%; +} + +button a { + text-decoration:none; + color: #333333; +} +aside, #btAfficherPompier { + justify-content: center; + display: flex; + align-items: center; +} +select[readonly] { + pointer-events: none; +} + +#legendCouleurs span{ + color: black; +} + +.vert { + background-color: green; + color: green; + border-color : green; +} + +.rouge { + background-color: red; + color: red; + border-color: red; +} + +.orange { + background-color: orange; + color: orange; + border-color: orange; +} + +.ztVentil { + width : 20px; + height: 20px; + border: 3px solid; +} + +.ztVentil:hover { + border-color: grey; +} + diff --git a/web/images/favicon.ico b/web/images/favicon.ico new file mode 100644 index 0000000000000000000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mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0007MNklejNAt{$pj!@Infyzk3F*t$2lB! zkH^!L??2g>QcVB=>chx#gu{?9u76QotNF1mIPBu9KrAd_ZHC+qhAJt(IQ%mf?&xgp zy*1i?K=I#tqh$%> z)9Wf>DqOQdi*w`s$!Guo%vSF}Uz5*=R(7^sktPz}tR|1BZr}?gNTH;=`;6=84S}UU zJvkSAOLZUXI8^r>u$=9UQ9327CN!8sF}5l=|1rKe+;^$@Wq|71&u^y|N?UJh@<_T> zNUV(S3Ia>pNNYuD=6izh2j+94DVf#GQn)N;^YO_-nN%o~L{o?IO)UWMX}S=fY_Ao= zzwBRPRSQfbQJet)iqZFA`5MVALssG$K22kU69oX=;%xB^;re{LeYK)AliRj_WAuCh zDK|+~!kA-0RYh%F~aFSalhJqc85_303dF$(b>V+(kP-eIy^nDuIoAj@jviq0KJMf UgV^1nJOBUy07*qoM6N<$g260F-2eap literal 0 HcmV?d00001 diff --git a/web/images/logo-sdis.png b/web/images/logo-sdis.png new file mode 100644 index 0000000000000000000000000000000000000000..c15050e4cb8e7d07f7d8f1bfd3b4c3fba89c6e18 GIT binary patch literal 12885 zcmaKTbyOTpv-jf85`w!2ciBZ3cXxMp7Iz5}5+t|<7I%k0@Bj(HJ-E9C2<{)xd*Aoo z`^R_goHNrh^{c9`sy^Lky5@tLiYyj72|54(z>=4f(s(URUhgDS{wao!QO*p<(xR zc6&tw0K#IvZswMb)}B-r*0%O8A~dJ%-85A8Rw6XIe9D~4Zj#n^_HzCn)|&n*T9*Ef zmS8IyF;OaEU%^)f&eophRKCtmE>J;V5t@JT6@0D#)6GFc^)C`nM-iI;Qc6!*jY`th z!(0b}M@;L4E;lPEHUXpMJ^_3&h1M0OI2UN%C?^fWf>H|G~<;Kt0V}EUo{8wf`S1@BfJvl=QGR_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?6D8=4%-NOqWoFq4@UMiBhsDQ3>{`tNUMCO;WOhsJBzEe zSJ*A>78!qEFwU4kyU^-t?G;Yq3pbaJlP9P#O@{<8Ycq_;(8|jl$GmQaRheaOaFcuT zN#s9^bp2?O^FC4uQ~wOV>}I)|43gyhPL7jgFj?`d9xb>>%PB1|OVh)8G#afBX=%Ee zxw1G6CCL*QG^BQ@f!ZbXl}bLMXC%7YJy5|(=8l4+_ChlSab&u(4b{Vn8Txl3ME*2@ z@?-Bc&|cHeIrv>y{th1L)Tu9HTCdPPX>04FY2*Pv*J+W$nd2jG3Gt4VqyeXen(@p$IGt3)Nea9 + + + + TODO supply a title + + + + +
TODO write content
+ + diff --git a/web/js/ctrlCodePostal.js b/web/js/ctrlCodePostal.js new file mode 100644 index 0000000..8bf094b --- /dev/null +++ b/web/js/ctrlCodePostal.js @@ -0,0 +1,28 @@ + // Recherche de la ou des villes correspondantes au code postal saisi (exemple 54490 --> 7 villes) + ztCP.onchange = function () { + //alert("ztCP a changé"); + msgCP.textContent = ""; + zlVille.length = 0; + const XHTTP = new XMLHttpRequest(); + XHTTP.onload = function () { + if (this.status != 200) { + msgCP.textContent = "Code postal erroné"; + } else { + var lesVilles = JSON.parse(this.responseText); + var info = ""; + if (lesVilles.length > 1) { + info += ""; + } + for (var i = 0; i < lesVilles.length; i++) { + var uneVille = lesVilles[i]; + info += "'; + } + zlVille.innerHTML = info; + } + } + var cp = ztCP.value; + XHTTP.open("GET", "https://apicarto.ign.fr/api/codes-postaux/communes/" + cp); + XHTTP.send(); + } +