Compare commits
21 Commits
68bf428f4f
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
5287b5ff74 | ||
|
623728d3e3 | ||
|
ad612c663c | ||
|
3162d0eeb3 | ||
|
332960f92d | ||
|
cac0c6423f | ||
|
f74104e7ff | ||
|
f293ce8b0f | ||
|
c1b8fa7a27 | ||
|
0783dfd5ab | ||
|
40db789d06 | ||
|
80aa3ed6ea | ||
|
b4da29af06 | ||
|
07aaf3248d | ||
|
e23f0e37e2 | ||
|
fb1699b16f | ||
|
93022f82e3 | ||
|
03780acc84 | ||
|
8c53a38e4b | ||
|
785442caf6 | ||
|
5729a4a7eb |
142
build.xml
142
build.xml
@@ -1,71 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="sdis29M1" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project sdis29M1.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-dist: called before archive building
|
||||
-post-dist: called after archive building
|
||||
-post-clean: called after cleaning build products
|
||||
-pre-run-deploy: called before deploying
|
||||
-post-run-deploy: called after deploying
|
||||
|
||||
Example of pluging an obfuscator after the compilation could look like
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Other way how to customize the build is by overriding existing main targets.
|
||||
The target of interest are:
|
||||
|
||||
init-macrodef-javac: defines macro for javac compilation
|
||||
init-macrodef-junit: defines macro for junit execution
|
||||
init-macrodef-debug: defines macro for class debugging
|
||||
do-dist: archive building
|
||||
run: execution of project
|
||||
javadoc-build: javadoc generation
|
||||
|
||||
Example of overriding the target for project execution could look like
|
||||
|
||||
<target name="run" depends="<PROJNAME>-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that overridden target depends on jar target and not only on
|
||||
compile target as regular run target does. Again, for list of available
|
||||
properties which you can use check the target you are overriding in
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="sdis29M1" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project sdis29M1.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-dist: called before archive building
|
||||
-post-dist: called after archive building
|
||||
-post-clean: called after cleaning build products
|
||||
-pre-run-deploy: called before deploying
|
||||
-post-run-deploy: called after deploying
|
||||
|
||||
Example of pluging an obfuscator after the compilation could look like
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Other way how to customize the build is by overriding existing main targets.
|
||||
The target of interest are:
|
||||
|
||||
init-macrodef-javac: defines macro for javac compilation
|
||||
init-macrodef-junit: defines macro for junit execution
|
||||
init-macrodef-debug: defines macro for class debugging
|
||||
do-dist: archive building
|
||||
run: execution of project
|
||||
javadoc-build: javadoc generation
|
||||
|
||||
Example of overriding the target for project execution could look like
|
||||
|
||||
<target name="run" depends="<PROJNAME>-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that overridden target depends on jar target and not only on
|
||||
compile target as regular run target does. Again, for list of available
|
||||
properties which you can use check the target you are overriding in
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=b54f128f
|
||||
build.xml.script.CRC32=111e10f7
|
||||
build.xml.stylesheet.CRC32=1707db4f@1.87.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.87.0.1
|
||||
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
|
||||
|
@@ -36,7 +36,7 @@ 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.domain}/lib/annotations-api.jar:${j2ee.server.domain}/lib/catalina-ant.jar:${j2ee.server.domain}/lib/catalina-ha.jar:${j2ee.server.domain}/lib/catalina-ssi.jar:${j2ee.server.domain}/lib/catalina-storeconfig.jar:${j2ee.server.domain}/lib/catalina-tribes.jar:${j2ee.server.domain}/lib/catalina.jar:${j2ee.server.domain}/lib/ecj-4.20.jar:${j2ee.server.domain}/lib/el-api.jar:${j2ee.server.domain}/lib/jakartaee-migration-1.0.0-shaded.jar:${j2ee.server.domain}/lib/jasper-el.jar:${j2ee.server.domain}/lib/jasper.jar:${j2ee.server.domain}/lib/jaspic-api.jar:${j2ee.server.domain}/lib/jsp-api.jar:${j2ee.server.domain}/lib/servlet-api.jar:${j2ee.server.domain}/lib/tomcat-api.jar:${j2ee.server.domain}/lib/tomcat-coyote.jar:${j2ee.server.domain}/lib/tomcat-dbcp.jar:${j2ee.server.domain}/lib/tomcat-i18n-cs.jar:${j2ee.server.domain}/lib/tomcat-i18n-de.jar:${j2ee.server.domain}/lib/tomcat-i18n-es.jar:${j2ee.server.domain}/lib/tomcat-i18n-fr.jar:${j2ee.server.domain}/lib/tomcat-i18n-ja.jar:${j2ee.server.domain}/lib/tomcat-i18n-ko.jar:${j2ee.server.domain}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.domain}/lib/tomcat-i18n-ru.jar:${j2ee.server.domain}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.domain}/lib/tomcat-jdbc.jar:${j2ee.server.domain}/lib/tomcat-jni.jar:${j2ee.server.domain}/lib/tomcat-util-scan.jar:${j2ee.server.domain}/lib/tomcat-util.jar:${j2ee.server.domain}/lib/tomcat-websocket.jar:${j2ee.server.domain}/lib/websocket-api.jar
|
||||
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=\
|
||||
|
@@ -1,31 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.web.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/web-project/3">
|
||||
<name>sdis29M1</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<web-module-libraries>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.mysql-connector-java-8.0.26.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
</web-module-libraries>
|
||||
<web-module-additional-libraries/>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.web.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/web-project/3">
|
||||
<name>sdis29M1</name>
|
||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||
<web-module-libraries>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
<library dirs="200">
|
||||
<file>${file.reference.mysql-connector-java-8.0.26.jar}</file>
|
||||
<path-in-war>WEB-INF/lib</path-in-war>
|
||||
</library>
|
||||
</web-module-libraries>
|
||||
<web-module-additional-libraries/>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
||||
|
214
src/java/bdd/GardeMySQL.java
Normal file
214
src/java/bdd/GardeMySQL.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* 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.Caserne;
|
||||
import bean.Gardes;
|
||||
import bean.Pompier;
|
||||
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 funcha.ahamadi
|
||||
*/
|
||||
public class GardeMySQL {
|
||||
private final Connection theConnection = Connexion.getConnect("localhost",
|
||||
"sdis29",
|
||||
"adminBDsdis",
|
||||
"mdpBDsdis");
|
||||
public ArrayList<Gardes> getLesDisponibilite(Calendar[] lesDates, int[] lesPeriodes,HttpServletRequest request) {
|
||||
|
||||
ArrayList<Gardes> lesDispo = new ArrayList<>();
|
||||
Gardes uneDispo;
|
||||
|
||||
/* a. Initialisation de la collection lesVentil pour la période,
|
||||
création d'une ventil par salarié, par date et période
|
||||
*/
|
||||
int indiceDateFin = lesDates.length - 1;
|
||||
Pompier lePompier;
|
||||
PompierMySQL pm = new PompierMySQL();
|
||||
HttpSession maSession = request.getSession();
|
||||
ArrayList<Pompier> lesPompiers = (ArrayList<Pompier>) maSession.getAttribute("lesPompiers");
|
||||
Pompier lePompierConnecte =(Pompier) maSession.getAttribute("lePompierConnecte");
|
||||
if(lesPompiers==null){
|
||||
lesPompiers = new ArrayList<>();
|
||||
lesPompiers.add(lePompierConnecte);
|
||||
}
|
||||
for (Pompier unPompier : lesPompiers) {
|
||||
for (Calendar uneDate : lesDates) {
|
||||
for (int unePeriode : lesPeriodes) {
|
||||
uneDispo = new Gardes(uneDate, unePeriode, unPompier);
|
||||
lesDispo.add(uneDispo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* b) Maj de la collection lesVentil
|
||||
*/
|
||||
readAll(lesDispo, lesDates[0], lesDates[indiceDateFin]);
|
||||
System.out.println("lesDispo : " + lesDispo);
|
||||
|
||||
return lesDispo;
|
||||
|
||||
}
|
||||
public void readAll(ArrayList<Gardes> lesDispo, Calendar d1, Calendar d2) {
|
||||
Pompier lePompier;
|
||||
Gardes uneDispo;
|
||||
Gardes laDispoTrouvee;
|
||||
String sql = "SELECT * FROM gardes "
|
||||
+ "INNER JOIN pompier on idPompier = id "
|
||||
+ "WHERE jourGarde 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()) {
|
||||
CaserneMySQL laCaserneMySQL = new CaserneMySQL();
|
||||
int idCaserne = resultat.getInt("idCaserne");
|
||||
Caserne laCaserne = laCaserneMySQL.read(idCaserne);
|
||||
lePompier = new Pompier(laCaserne,
|
||||
resultat.getInt("id"),
|
||||
resultat.getString("nom"),
|
||||
resultat.getString("prenom"));
|
||||
uneDispo = new Gardes(TrmtDate.getCalDate(resultat.getDate("jourGarde")),
|
||||
resultat.getInt("periode")
|
||||
,lePompier);
|
||||
// Recherche si uneDispo existe dans les Dispos
|
||||
int indice = lesDispo.indexOf(uneDispo);
|
||||
if (indice > -1) {
|
||||
laDispoTrouvee = lesDispo.get(indice);
|
||||
laDispoTrouvee.setDisponibilite(resultat.getInt("disponibilite"));
|
||||
laDispoTrouvee.setIsInBDD(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 garde passé en paramètre
|
||||
*
|
||||
* @param g ventilation à supprimer
|
||||
* @return nb ligne a supprimer
|
||||
*/
|
||||
public int delete(Gardes g) {
|
||||
int nbMaj = -1;
|
||||
String sql = "DELETE FROM gardes "
|
||||
+ "WHERE idPompier=?"
|
||||
+ " AND periode=?"
|
||||
+ " AND jourGarde= ?;";
|
||||
try {
|
||||
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, g.getPompier().getId());
|
||||
prepStmt.setInt(2, g.getPeriode());
|
||||
prepStmt.setDate(3, TrmtDate.getSQLDate(g.getJourGarde()));
|
||||
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* Creation de la ventilation passé en paramètre ventilation à créer
|
||||
*
|
||||
* @return : identifiant de la ventilation créé, ou -1 si erreur
|
||||
*/
|
||||
public int create(Gardes g) {
|
||||
int idCree = -1;
|
||||
String sql = "INSERT into gardes "
|
||||
+ "(jourGarde, periode, idPompier, disponibilite, deGarde) "
|
||||
+ "VALUES (?, ?, ?,?,?);";
|
||||
|
||||
try {
|
||||
// PreparedStatement prepStmt = null;
|
||||
// prepStmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
|
||||
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setDate(1, TrmtDate.getSQLDate(g.getJourGarde()));
|
||||
prepStmt.setInt(2, g.getPeriode());
|
||||
prepStmt.setInt(3, g.getPompier().getId());
|
||||
prepStmt.setInt(4, g.getDisponibilite());
|
||||
prepStmt.setBoolean(5, g.isDeGarde());
|
||||
|
||||
System.out.println(prepStmt);
|
||||
int nbLigne = prepStmt.executeUpdate();
|
||||
|
||||
// Recherche du no du pompier créé
|
||||
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(Gardes g) {
|
||||
|
||||
int nbMAJ = -1;
|
||||
String sql = "UPDATE gardes "
|
||||
+ "SET disponibilite = ?, deGarde = ? "
|
||||
+ "WHERE idPompier = ? "
|
||||
+ "AND jourGarde = ? "
|
||||
+ "AND periode = ?;";
|
||||
try {
|
||||
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||
prepStmt.setInt(1, g.getDisponibilite());
|
||||
prepStmt.setBoolean(2, g.isDeGarde());
|
||||
prepStmt.setInt(3, g.getPompier().getId());
|
||||
prepStmt.setDate(4, TrmtDate.getSQLDate(g.getJourGarde()));
|
||||
prepStmt.setInt(5, g.getPeriode());
|
||||
|
||||
System.out.println("update : " + prepStmt);
|
||||
nbMAJ = prepStmt.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(GardeMySQL.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return nbMAJ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* 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.Gardes;
|
||||
import bean.Pompier;
|
||||
import com.sdis29a.util.TrmtDate;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author funcha.ahamadi
|
||||
*/
|
||||
public class gardeMySQL {
|
||||
private final Connection theConnection = Connexion.getConnect("localhost",
|
||||
"sdis29",
|
||||
"adminBDsdis",
|
||||
"mdpBDsdis");
|
||||
public ArrayList<Gardes> getLesDisponibilite(Calendar[] lesDates, int[] lesPeriodes) {
|
||||
ArrayList<Gardes> lesDispo = new ArrayList<>();
|
||||
Gardes uneDispo;
|
||||
|
||||
/* a. Initialisation de la collection lesVentil pour la période,
|
||||
création d'une ventil par salarié, par date et période
|
||||
*/
|
||||
int indiceDateFin = lesDates.length - 1;
|
||||
Pompier lePompier;
|
||||
PompierMySQL pm = new PompierMySQL();
|
||||
ArrayList<Pompier> lesPompiers = pm.readLesPompiersCaserne(idCaserne);
|
||||
for (Pompier unPompier : lesPompiers) {
|
||||
for (Calendar uneDate : lesDates) {
|
||||
for (int unePeriode : lesPeriodes) {
|
||||
uneDispo = new Gardes(uneDate, unePeriode, unPompier);
|
||||
lesDispo.add(uneDispo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* b) Maj de la collection lesVentil
|
||||
*/
|
||||
readAll(lesDispo, lesDates[0], lesDates[indiceDateFin]);
|
||||
//System.out.println("lesDispo : " + lesDispo);
|
||||
return lesDispo;
|
||||
}
|
||||
public void readAll(ArrayList<Gardes> lesDispo, Calendar d1, Calendar d2) {
|
||||
Pompier lePompier;
|
||||
Gardes uneDispo;
|
||||
Gardes laDispoTrouvee;
|
||||
String sql = "SELECT * FROM gardes "
|
||||
+ "INNER JOIN pompier on idPompier = id "
|
||||
+ "WHERE jourGarde 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())
|
||||
// public Pompier(Caserne laCaserne, int id, String nom, String prenom) {
|
||||
lePompier = new Pompier(resultat.getCaserne("laCaserne"),
|
||||
resultat.getString("nom"),
|
||||
resultat.getString("prenom");
|
||||
uneDispo = new Gardes(TrmtDate.getCalDate(resultat.getDate("jourGarde")),
|
||||
resultat.getInt("periode")
|
||||
,lePompier);
|
||||
// Recherche si uneDispo existe dans les Dispos
|
||||
int indice = lesDispo.indexOf(uneDispo);
|
||||
if (indice > -1) {
|
||||
laDispoTrouvee = lesDispo.get(indice);
|
||||
laDispoTrouvee.setActivite(resultat.getInt("disponibilite"));
|
||||
laDispoTrouvee.setIsInDB(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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@@ -13,26 +13,38 @@ import java.util.Objects;
|
||||
* @author funcha.ahamadi
|
||||
*/
|
||||
public class Gardes {
|
||||
private Calendar jourGarde;
|
||||
private int periode;
|
||||
private Pompier pompier;
|
||||
private int disponibilite;
|
||||
private boolean isInBDD;
|
||||
Calendar jourGarde;
|
||||
int periode;
|
||||
Pompier pompier;
|
||||
int disponibilite;
|
||||
boolean isInBDD;
|
||||
boolean deGarde;
|
||||
|
||||
public Gardes(Calendar jourGarde, int periode, Pompier pompier, int disponibilite, boolean isInBDD) {
|
||||
public Gardes(Calendar jourGarde, int periode, Pompier pompier, int disponibilite, boolean isInBDD, boolean deGarde) {
|
||||
this.jourGarde = jourGarde;
|
||||
this.periode = periode;
|
||||
this.pompier = pompier;
|
||||
this.disponibilite = disponibilite;
|
||||
this.isInBDD = isInBDD;
|
||||
this.deGarde = deGarde;
|
||||
}
|
||||
|
||||
public Gardes(Calendar jourGarde, int periode, Pompier pompier, boolean deGarde) {
|
||||
this.jourGarde = jourGarde;
|
||||
this.periode = periode;
|
||||
this.pompier = pompier;
|
||||
this.deGarde = deGarde;
|
||||
}
|
||||
|
||||
|
||||
public Gardes(Calendar jourGarde, int periode, Pompier pompier) {
|
||||
this.jourGarde = jourGarde;
|
||||
this.periode = periode;
|
||||
this.pompier = pompier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Calendar getJourGarde() {
|
||||
return jourGarde;
|
||||
}
|
||||
@@ -73,14 +85,23 @@ public class Gardes {
|
||||
this.isInBDD = isInBDD;
|
||||
}
|
||||
|
||||
public boolean isDeGarde() {
|
||||
return deGarde;
|
||||
}
|
||||
|
||||
public void setDeGarde(boolean deGarde) {
|
||||
this.deGarde = deGarde;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = 43 * hash + Objects.hashCode(this.jourGarde);
|
||||
hash = 43 * hash + this.periode;
|
||||
hash = 43 * hash + Objects.hashCode(this.pompier);
|
||||
hash = 43 * hash + this.disponibilite;
|
||||
hash = 43 * hash + (this.isInBDD ? 1 : 0);
|
||||
int hash = 5;
|
||||
hash = 37 * hash + Objects.hashCode(this.jourGarde);
|
||||
hash = 37 * hash + this.periode;
|
||||
hash = 37 * hash + Objects.hashCode(this.pompier);
|
||||
hash = 37 * hash + this.disponibilite;
|
||||
hash = 37 * hash + (this.isInBDD ? 1 : 0);
|
||||
hash = 37 * hash + (this.deGarde ? 1 : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@@ -105,6 +126,9 @@ public class Gardes {
|
||||
if (this.isInBDD != other.isInBDD) {
|
||||
return false;
|
||||
}
|
||||
if (this.deGarde != other.deGarde) {
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(this.jourGarde, other.jourGarde)) {
|
||||
return false;
|
||||
}
|
||||
@@ -116,8 +140,9 @@ public class Gardes {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Gardes{" + "jourGarde=" + jourGarde + ", periode=" + periode + ", pompier=" + pompier + ", disponibilite=" + disponibilite + ", isInBDD=" + isInBDD + '}';
|
||||
return "\nGardes{" + "jourGarde=" + jourGarde.getTime() + ", periode=" + periode + ", pompier=" + pompier + ", disponibilite=" + disponibilite + ", isInBDD=" + isInBDD + ", deGarde=" + deGarde + '}';
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -59,7 +59,6 @@ public class Pompier {
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
@@ -10,6 +10,6 @@ Variables de session :
|
||||
Variables mises en session dans PompierServlet.java)
|
||||
lePompier : pompier à afficher dans pompierJSP
|
||||
|
||||
Attributs utilisés entre la servet PompierServlet.java et pompierJSP :
|
||||
Attributs utilisés entre la serlvet 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
|
||||
|
122
src/java/form/DispoForm.java
Normal file
122
src/java/form/DispoForm.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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.GardeMySQL;
|
||||
|
||||
import bean.Gardes;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import javax.swing.JCheckBox;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author clementine.desrucques
|
||||
*/
|
||||
public class DispoForm {
|
||||
|
||||
HttpServletRequest request;
|
||||
|
||||
public void verifDispo(HttpServletRequest request) {
|
||||
HttpSession maS = request.getSession();
|
||||
ArrayList<Gardes> lesG = (ArrayList<Gardes>) maS.getAttribute("lesVentilInit");
|
||||
|
||||
GardeMySQL vm = new GardeMySQL();
|
||||
Map<String, String[]> map = request.getParameterMap();
|
||||
String[] lesNvVentil = map.get("lesActivites");
|
||||
String[] lesNvGardes = map.get("cbGarde");
|
||||
ArrayList<Integer> lesNvGardesN = new ArrayList<>();
|
||||
if(lesNvGardes != null){
|
||||
for(String uneGarde : lesNvGardes){
|
||||
lesNvGardesN.add(Integer.parseInt(uneGarde));
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (Gardes uneGarde : lesG) {
|
||||
int oldAct = uneGarde.getDisponibilite();
|
||||
int newAct = Integer.parseInt(lesNvVentil[i]);
|
||||
if (oldAct != newAct) {
|
||||
if (uneGarde.isIsInBDD()) {
|
||||
|
||||
if (newAct == 0) {
|
||||
vm.delete(uneGarde);
|
||||
uneGarde.setIsInBDD(false);
|
||||
uneGarde.setDisponibilite(newAct);
|
||||
} else {
|
||||
uneGarde.setDisponibilite(newAct);
|
||||
vm.update(uneGarde);
|
||||
}
|
||||
} else {
|
||||
uneGarde.setDisponibilite(newAct);
|
||||
vm.create(uneGarde);
|
||||
uneGarde.setIsInBDD(true);
|
||||
}
|
||||
|
||||
}
|
||||
boolean oldGarde = uneGarde.isDeGarde();
|
||||
boolean newGarde = lesNvGardesN.contains(i)?true:false;
|
||||
System.out.println("1: "+oldGarde +" "+ newGarde);
|
||||
if(oldGarde!= newGarde){
|
||||
uneGarde.setDeGarde(newGarde);
|
||||
System.out.println("2: "+oldGarde +" "+ newGarde);
|
||||
if (uneGarde.isIsInBDD()) {
|
||||
vm.update(uneGarde);
|
||||
}else{
|
||||
vm.create(uneGarde);
|
||||
uneGarde.setIsInBDD(true);
|
||||
System.out.println("3: "+oldGarde +" "+ newGarde);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public void verifGarde(HttpServletRequest request) {
|
||||
HttpSession maS = request.getSession();
|
||||
ArrayList<Gardes> lesG = (ArrayList<Gardes>) maS.getAttribute("lesVentilInit");
|
||||
|
||||
GardeMySQL vm = new GardeMySQL();
|
||||
Map<String, String[]> map = request.getParameterMap();
|
||||
String[] lesNvVentil = map.get("cbGarde");
|
||||
// JCheckBox garde = new JCheckBox();
|
||||
int i = 0;
|
||||
for (Gardes uneGarde : lesG) {
|
||||
boolean oldAct = uneGarde.isDeGarde();
|
||||
int newAct = Integer.parseInt(lesNvVentil[i]);
|
||||
boolean newActO = (newAct==Integer.parseInt(lesNvVentil[i]));
|
||||
|
||||
if (oldAct != newActO) {
|
||||
if (uneGarde.isIsInBDD()) {
|
||||
|
||||
if (newActO == false) {
|
||||
vm.delete(uneGarde);
|
||||
uneGarde.setIsInBDD(false);
|
||||
uneGarde.isDeGarde();
|
||||
} else {
|
||||
uneGarde.isDeGarde();
|
||||
vm.update(uneGarde);
|
||||
}
|
||||
} else {
|
||||
uneGarde.isDeGarde();
|
||||
vm.create(uneGarde);
|
||||
uneGarde.setIsInBDD(true);
|
||||
}
|
||||
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
@@ -66,6 +66,7 @@ public class AuthentifServlet extends HttpServlet {
|
||||
maSession.removeAttribute("lePompierConnecte");
|
||||
maSession.removeAttribute("lesPompiers");
|
||||
maSession.removeAttribute("lePompier");
|
||||
maSession.removeAttribute("lesVentilInit");
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/authentifJSP.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,12 @@
|
||||
*/
|
||||
package servlet;
|
||||
|
||||
import bdd.GardeMySQL;
|
||||
|
||||
import bean.Gardes;
|
||||
import bean.Pompier;
|
||||
import com.sdis29a.util.TrmtDate;
|
||||
import form.DispoForm;
|
||||
import util.TrmtDate;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
@@ -63,25 +67,44 @@ public class GardesServlet extends HttpServlet {
|
||||
throws ServletException, IOException {
|
||||
//processRequest(request, response);
|
||||
HttpSession maSession = request.getSession();
|
||||
|
||||
if(maSession.getAttribute("lesVentilInit") == null){
|
||||
ArrayList<Pompier> lesPompiers = (ArrayList<Pompier>) maSession.getAttribute("lesPompiers");
|
||||
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(lesDatesEnString.toString());
|
||||
/*Initialisation des periodes */
|
||||
int[] lesPeriodes = {1,2,3,4};
|
||||
maSession.setAttribute("lesPeriodes", lesPeriodes);
|
||||
|
||||
|
||||
// maSession.setAttribute("lesPeriodes", lesPeriodes);
|
||||
System.out.println(lesPeriodes.toString());
|
||||
/* Recherche des ventilations */
|
||||
|
||||
GardeMySQL vm = new GardeMySQL();
|
||||
ArrayList<Gardes> lesVentilInit = vm.getLesDisponibilite(lesDates, lesPeriodes,request);
|
||||
//System.out.println("lesVentilInit : " + lesVentilInit);
|
||||
maSession.setAttribute("lesVentilInit", lesVentilInit);
|
||||
|
||||
// GardeMySQL dg = new GardeMySQL();
|
||||
// ArrayList<Gardes> lesgardes = dg.();
|
||||
// //System.out.println("lesVentilInit : " + lesVentilInit);
|
||||
// maSession.setAttribute("lesVentilInit", lesVentilInit);
|
||||
|
||||
/* Initialisation des couleurs */
|
||||
String[] lesCouleurs = {"blanc", "gris", "jaune"};
|
||||
maSession.setAttribute("lesCouleurs", lesCouleurs);
|
||||
}
|
||||
/* Affichage de la page de ventilation */
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/ventilJSP.jsp").forward(request, response);
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/feuilleGardes.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +118,11 @@ public class GardesServlet extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
// processRequest(request, response);
|
||||
DispoForm vf = new DispoForm();
|
||||
vf.verifDispo(request);
|
||||
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -36,7 +36,7 @@ public class PompierServlet extends HttpServlet {
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
try ( PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
@@ -74,7 +74,7 @@ public class PompierServlet extends HttpServlet {
|
||||
boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString);
|
||||
if (isNumeric) {
|
||||
pageDemandee = Integer.parseInt(pageEnString);
|
||||
if (pageDemandee != 2 && pageDemandee != 3) { // erreur
|
||||
if (pageDemandee != 2 && pageDemandee != 3 && pageDemandee != 5) { // erreur
|
||||
erreur = true;
|
||||
}
|
||||
} else {
|
||||
@@ -101,12 +101,13 @@ public class PompierServlet extends HttpServlet {
|
||||
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);
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/" + jsp).forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,16 +127,16 @@ public class PompierServlet extends HttpServlet {
|
||||
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<String> valeursBt = new ArrayList<String>() ;
|
||||
valeursBt.add("Afficher") ;
|
||||
valeursBt.add("Ajouter") ;
|
||||
valeursBt.add("ValiderMaj") ;
|
||||
|
||||
ArrayList<String> valeursBt = new ArrayList<String>();
|
||||
valeursBt.add("Afficher");
|
||||
valeursBt.add("Ajouter");
|
||||
valeursBt.add("ValiderMaj");
|
||||
|
||||
// Test du bouton btAfficherPompier
|
||||
if (request.getParameter("btAfficherPompier")==null) {
|
||||
if (request.getParameter("btAfficherPompier") == null) {
|
||||
erreur = 1;
|
||||
} else {
|
||||
btValue = request.getParameter("btAfficherPompier");
|
||||
@@ -148,7 +149,7 @@ public class PompierServlet extends HttpServlet {
|
||||
//response.sendRedirect("/sdis29M1/authentification");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HttpSession maSession = request.getSession();
|
||||
ArrayList<Pompier> lesPompiers = (ArrayList<Pompier>) maSession.getAttribute("lesPompiers");
|
||||
if (request.getParameter("btAfficherPompier").equals("Afficher")
|
||||
@@ -158,12 +159,12 @@ public class PompierServlet extends HttpServlet {
|
||||
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")) {
|
||||
|
||||
if (request.getParameter("btAfficherPompier").equals("ValiderMaj")) {
|
||||
PompierForm pf = new PompierForm(request);
|
||||
boolean valid = pf.ctrlPompier();
|
||||
// if (maSession.getAttribute("lePompier")==null) {
|
||||
@@ -178,8 +179,8 @@ public class PompierServlet extends HttpServlet {
|
||||
// }
|
||||
// }
|
||||
pf.majBDD();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/pompierJSP.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
|
@@ -1,129 +1,129 @@
|
||||
package com.sdis29a.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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -3,52 +3,121 @@
|
||||
Created on : 6 déc. 2021, 15:07:45
|
||||
Author : funcha.ahamadi
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<legend>
|
||||
Feuille de gardes
|
||||
</legend>
|
||||
<form action="gardes" method="POST">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2">N° de BIP</th>
|
||||
<th rowspan="2">Nom Prenom</th>
|
||||
<c:forEach items='${sessionScope.lesDatesEnString}' var="uneDate" varStatus="status">
|
||||
<th colspan="2" class="text-center"> ${uneDate}</th>
|
||||
</c:forEach>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<c:forEach var="i" begin="0" end="4" step="1">
|
||||
<c:forEach items='${sessionScope.lesPeriodes}' var="unePeriode" varStatus="status">
|
||||
<td class="text-center">${unePeriode}</td>
|
||||
</c:forEach>
|
||||
</c:forEach>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:set var="oldId" value="-1" scope="page"/>
|
||||
<tr>
|
||||
<c:forEach items='${sessionScope.lesVentilInit}' var="uneVentil" varStatus="status">
|
||||
<c:set var="newId" value='${uneVentil.getPompier().getId()}' scope="page"/>
|
||||
<c:if test='${oldId != newId}' var="test" scope="page">
|
||||
</tr><tr>
|
||||
<td>${uneVentil.getPompier().getId()}</td>
|
||||
<td>${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()}</td>
|
||||
|
||||
<c:set var="oldId" value='${newId}' scope="page"/>
|
||||
</c:if>
|
||||
<c:set var="activite" value='${uneVentil.getActivite()}' scope="page"/>
|
||||
<td>
|
||||
<input readonly type="text" value='${activite}' name="lesActivites"class="ztVentil ${sessionScope.lesCouleurs[activite]}"/>
|
||||
</td>
|
||||
</c:forEach>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<%@include file= "jspf/debutJSP.jspf" %>
|
||||
<body>
|
||||
<%@include file= "jspf/header.jspf" %>
|
||||
<div class="container">
|
||||
<section id="contenuAffiche" class="row">
|
||||
|
||||
|
||||
|
||||
<fieldset class="row mt-1 mb-10">
|
||||
|
||||
<legend>
|
||||
Feuille de gardes
|
||||
</legend>
|
||||
<form action="gardes" method="POST">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th rowspan="2">No</th>
|
||||
<th rowspan="2">Nom Prenom</th>
|
||||
<c:forEach items='${sessionScope.lesDatesEnString}' var="uneDate" varStatus="status">
|
||||
<th colspan="4" class="text-center"> ${uneDate}</th>
|
||||
</c:forEach>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<c:forEach var="i" begin="0" end="6" step="1">
|
||||
<c:forEach items='${sessionScope.lesPeriodes}' var="unePeriode" varStatus="status">
|
||||
|
||||
<td class="text-center">${unePeriode.getCode()}</td>
|
||||
</c:forEach>
|
||||
</c:forEach>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<c:set var="oldId" value="-1" scope="page"/>
|
||||
<tr>
|
||||
|
||||
<c:forEach items='${sessionScope.lesVentilInit}' var="uneVentil" varStatus="status">
|
||||
<c:set var="newId" value='${uneVentil.getPompier().getId()}' scope="page"/>
|
||||
<c:if test='${oldId != newId}' var="test" scope="page">
|
||||
</tr><tr>
|
||||
<td>${uneVentil.getPompier().getId()}</td>
|
||||
<td>${uneVentil.getPompier().getNom()} ${uneVentil.getPompier().getPrenom()}</td>
|
||||
|
||||
<c:set var="oldId" value='${newId}' scope="page"/>
|
||||
</c:if>
|
||||
|
||||
<c:set var="activite" value='${uneVentil.getDisponibilite()}' scope="page"/>
|
||||
<c:set var="check" value="" scope="page"/>
|
||||
<c:if test="${uneVentil.isDeGarde() == true}" var="test" scope="page">
|
||||
<c:set var="check" value="checked" scope="page"/>
|
||||
</c:if>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${sessionScope.lePompierConnecte.getLeStatut().getCode() eq 2}">
|
||||
<td>
|
||||
<input readonly type="text" value='${activite}' name="lesActivites" class="ztVentil ${sessionScope.lesCouleurs[activite]}"/>
|
||||
<input type="checkbox" ${check} name="cbGarde" value="${status.count +1}">
|
||||
</td>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<td>
|
||||
<input readonly type="text" value='${activite}' name="lesActivites" class="ztVentil ${sessionScope.lesCouleurs[activite]}"/>
|
||||
<input type="checkbox" ${check} name="cbGarde" value="${status.count +1}" onclick="return false">
|
||||
</td>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
|
||||
</c:forEach>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="legendCouleur">
|
||||
|
||||
<span style="background-color: white">Dispo</span>
|
||||
<span style="background-color: gray">Indispo</span>
|
||||
<span style="background-color: yellow">Au travail</span>
|
||||
<span>De garde : ☑</span>
|
||||
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button type="submit" value="Valider" class="btn btn-danger"><i class="bi bi-check2"></i> Valider</button>
|
||||
</div>
|
||||
</form>
|
||||
</fieldset>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
var st = (document.getElementById("statut").textContent).trim();
|
||||
if (st != "chef de centre") {
|
||||
|
||||
|
||||
var couleurs = ["blanc", "gris", "jaune"];
|
||||
var lesAct = document.getElementsByClassName("ztVentil");
|
||||
for (var uneAct of lesAct) {
|
||||
uneAct.onclick = function () {
|
||||
var act = this.value;
|
||||
var newAct = (act + 1) % 3;
|
||||
var coul = couleurs[newAct];
|
||||
this.classList.remove(couleurs[act]);
|
||||
this.classList.add(coul);
|
||||
this.value = newAct;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</form><!-- comment -->
|
@@ -126,7 +126,8 @@
|
||||
value="${lePompier.getCommentaire()}" />
|
||||
</div><!-- fin ligne observation -->
|
||||
</div> <!-- fin observation -->
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="danger mt-3">${message} </div>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
@@ -134,10 +135,26 @@
|
||||
<i class="bi bi-check2"></i> Valider
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<p><em>* zone obligatoire</em></p>
|
||||
|
||||
|
||||
</section>
|
||||
<script>
|
||||
var couleurs = ["blanc", "gris", "jaune"];
|
||||
var lesAct = document.getElementsByClassName("ztVentil");
|
||||
for (var uneAct of lesAct) {
|
||||
uneAct.onclick = function () {
|
||||
var act = this.value;
|
||||
var newAct = (act + 1) % 3;
|
||||
var coul = couleurs[newAct];
|
||||
this.classList.remove(couleurs[act]);
|
||||
this.classList.add(coul);
|
||||
this.value = newAct;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div> <!-- fin div contenant aside et section -->
|
||||
</form>
|
||||
|
||||
|
@@ -14,9 +14,12 @@
|
||||
<c:otherwise>
|
||||
<h4>Bienvenue ${sessionScope.lePompierConnecte.getPrenom()}
|
||||
${sessionScope.lePompierConnecte.getNom()} (
|
||||
${sessionScope.lePompierConnecte.getLeStatut().getValeur()})
|
||||
<span id="statut">
|
||||
${sessionScope.lePompierConnecte.getLeStatut().getValeur()}
|
||||
</span>
|
||||
)
|
||||
</h4>
|
||||
|
||||
|
||||
<button type="button" class="btn btn-warning fs-4" title="Déconnexion">
|
||||
<a href="authentification">
|
||||
<i class="bi bi-box-arrow-right heading" width="32" height="32" fill="currentColor"></i> Déconnexion
|
||||
@@ -89,10 +92,20 @@
|
||||
|
||||
</c:choose>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
||||
|
||||
|
||||
<a class="nav-link" href="gardes">Gardes</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
</div> <!-- fin id=identie -->
|
||||
</div> <!-- fin class=container -->
|
||||
</header>
|
||||
</header>
|
||||
|
@@ -20,6 +20,11 @@
|
||||
<servlet-name>feuilleGardes</servlet-name>
|
||||
<servlet-class>servlet.GardesServlet</servlet-class>
|
||||
</servlet>
|
||||
<servlet>
|
||||
<servlet-name>GPServlet</servlet-name>
|
||||
<servlet-class>servlet.GPServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>AuthentifServlet</servlet-name>
|
||||
<url-pattern>/authentification</url-pattern>
|
||||
@@ -32,6 +37,11 @@
|
||||
<servlet-name>feuilleGardes</servlet-name>
|
||||
<url-pattern>/gardes</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>GPServlet</servlet-name>
|
||||
<url-pattern>/PompierGarde</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
|
@@ -18,7 +18,7 @@ body {
|
||||
}
|
||||
fieldset {
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
padding: 3px;
|
||||
border: 1px solid #DB0005;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -84,3 +84,31 @@ aside, #btAfficherPompier {
|
||||
select[readonly] {
|
||||
pointer-events: none;
|
||||
}
|
||||
.blanc {
|
||||
background-color: white;
|
||||
color: white;
|
||||
border-color : white;
|
||||
}
|
||||
|
||||
.gris {
|
||||
background-color: gray;
|
||||
color: gray;
|
||||
border-color: gray;
|
||||
}
|
||||
|
||||
.jaune {
|
||||
background-color: yellow;
|
||||
color: yellow;
|
||||
border-color: yellow;
|
||||
}
|
||||
|
||||
.ztVentil {
|
||||
height: 20px;
|
||||
width : 18px;
|
||||
border-color: black;
|
||||
|
||||
}
|
||||
|
||||
.ztVentil:hover {
|
||||
border-color: grey;
|
||||
}
|
||||
|
Reference in New Issue
Block a user