Compare commits
4 Commits
68bf428f4f
...
03780acc84
Author | SHA1 | Date | |
---|---|---|---|
|
03780acc84 | ||
|
8c53a38e4b | ||
|
785442caf6 | ||
|
5729a4a7eb |
142
build.xml
142
build.xml
@ -1,71 +1,71 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
<!-- some examples of how to customize the build. -->
|
<!-- some examples of how to customize the build. -->
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
<!-- 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 -->
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
<project name="sdis29M1" default="default" basedir=".">
|
<project name="sdis29M1" default="default" basedir=".">
|
||||||
<description>Builds, tests, and runs the project sdis29M1.</description>
|
<description>Builds, tests, and runs the project sdis29M1.</description>
|
||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml"/>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
There exist several targets which are by default empty and which can be
|
||||||
used for execution of your tasks. These targets are usually executed
|
used for execution of your tasks. These targets are usually executed
|
||||||
before and after some main targets. They are:
|
before and after some main targets. They are:
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
-pre-init: called before initialization of project properties
|
||||||
-post-init: called after initialization of project properties
|
-post-init: called after initialization of project properties
|
||||||
-pre-compile: called before javac compilation
|
-pre-compile: called before javac compilation
|
||||||
-post-compile: called after javac compilation
|
-post-compile: called after javac compilation
|
||||||
-pre-compile-single: called before javac compilation of single file
|
-pre-compile-single: called before javac compilation of single file
|
||||||
-post-compile-single: called after 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
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
-post-compile-test: called after 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
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
-pre-dist: called before archive building
|
-pre-dist: called before archive building
|
||||||
-post-dist: called after archive building
|
-post-dist: called after archive building
|
||||||
-post-clean: called after cleaning build products
|
-post-clean: called after cleaning build products
|
||||||
-pre-run-deploy: called before deploying
|
-pre-run-deploy: called before deploying
|
||||||
-post-run-deploy: called after deploying
|
-post-run-deploy: called after deploying
|
||||||
|
|
||||||
Example of pluging an obfuscator after the compilation could look like
|
Example of pluging an obfuscator after the compilation could look like
|
||||||
|
|
||||||
<target name="-post-compile">
|
<target name="-post-compile">
|
||||||
<obfuscate>
|
<obfuscate>
|
||||||
<fileset dir="${build.classes.dir}"/>
|
<fileset dir="${build.classes.dir}"/>
|
||||||
</obfuscate>
|
</obfuscate>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
For list of available properties check the imported
|
For list of available properties check the imported
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
Other way how to customize the build is by overriding existing main targets.
|
Other way how to customize the build is by overriding existing main targets.
|
||||||
The target of interest are:
|
The target of interest are:
|
||||||
|
|
||||||
init-macrodef-javac: defines macro for javac compilation
|
init-macrodef-javac: defines macro for javac compilation
|
||||||
init-macrodef-junit: defines macro for junit execution
|
init-macrodef-junit: defines macro for junit execution
|
||||||
init-macrodef-debug: defines macro for class debugging
|
init-macrodef-debug: defines macro for class debugging
|
||||||
do-dist: archive building
|
do-dist: archive building
|
||||||
run: execution of project
|
run: execution of project
|
||||||
javadoc-build: javadoc generation
|
javadoc-build: javadoc generation
|
||||||
|
|
||||||
Example of overriding the target for project execution could look like
|
Example of overriding the target for project execution could look like
|
||||||
|
|
||||||
<target name="run" depends="<PROJNAME>-impl.jar">
|
<target name="run" depends="<PROJNAME>-impl.jar">
|
||||||
<exec dir="bin" executable="launcher.exe">
|
<exec dir="bin" executable="launcher.exe">
|
||||||
<arg file="${dist.jar}"/>
|
<arg file="${dist.jar}"/>
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
Notice that overridden target depends on jar target and not only on
|
Notice that overridden target depends on jar target and not only on
|
||||||
compile target as regular run target does. Again, for list of available
|
compile target as regular run target does. Again, for list of available
|
||||||
properties which you can use check the target you are overriding in
|
properties which you can use check the target you are overriding in
|
||||||
nbproject/build-impl.xml file.
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
-->
|
-->
|
||||||
</project>
|
</project>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=b54f128f
|
build.xml.data.CRC32=b54f128f
|
||||||
build.xml.script.CRC32=111e10f7
|
build.xml.script.CRC32=111e10f7
|
||||||
build.xml.stylesheet.CRC32=1707db4f@1.87.0.1
|
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.
|
# 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.
|
# 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.data.CRC32=b54f128f
|
||||||
nbproject/build-impl.xml.script.CRC32=bc2b5756
|
nbproject/build-impl.xml.script.CRC32=bc2b5756
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=334708a0@1.87.0.1
|
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.copy.static.files.on.save=true
|
||||||
j2ee.deploy.on.save=true
|
j2ee.deploy.on.save=true
|
||||||
j2ee.platform=1.7-web
|
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
|
j2ee.server.type=Tomcat
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
<type>org.netbeans.modules.web.project</type>
|
<type>org.netbeans.modules.web.project</type>
|
||||||
<configuration>
|
<configuration>
|
||||||
<data xmlns="http://www.netbeans.org/ns/web-project/3">
|
<data xmlns="http://www.netbeans.org/ns/web-project/3">
|
||||||
<name>sdis29M1</name>
|
<name>sdis29M1</name>
|
||||||
<minimum-ant-version>1.6.5</minimum-ant-version>
|
<minimum-ant-version>1.6.5</minimum-ant-version>
|
||||||
<web-module-libraries>
|
<web-module-libraries>
|
||||||
<library dirs="200">
|
<library dirs="200">
|
||||||
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
|
<file>${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}</file>
|
||||||
<path-in-war>WEB-INF/lib</path-in-war>
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
</library>
|
</library>
|
||||||
<library dirs="200">
|
<library dirs="200">
|
||||||
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
|
<file>${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}</file>
|
||||||
<path-in-war>WEB-INF/lib</path-in-war>
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
</library>
|
</library>
|
||||||
<library dirs="200">
|
<library dirs="200">
|
||||||
<file>${file.reference.mysql-connector-java-8.0.26.jar}</file>
|
<file>${file.reference.mysql-connector-java-8.0.26.jar}</file>
|
||||||
<path-in-war>WEB-INF/lib</path-in-war>
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
</library>
|
</library>
|
||||||
</web-module-libraries>
|
</web-module-libraries>
|
||||||
<web-module-additional-libraries/>
|
<web-module-additional-libraries/>
|
||||||
<source-roots>
|
<source-roots>
|
||||||
<root id="src.dir"/>
|
<root id="src.dir"/>
|
||||||
</source-roots>
|
</source-roots>
|
||||||
<test-roots>
|
<test-roots>
|
||||||
<root id="test.src.dir"/>
|
<root id="test.src.dir"/>
|
||||||
</test-roots>
|
</test-roots>
|
||||||
</data>
|
</data>
|
||||||
</configuration>
|
</configuration>
|
||||||
</project>
|
</project>
|
||||||
|
@ -7,13 +7,15 @@ package bdd;
|
|||||||
|
|
||||||
import bean.Gardes;
|
import bean.Gardes;
|
||||||
import bean.Pompier;
|
import bean.Pompier;
|
||||||
import com.sdis29a.util.TrmtDate;
|
import util.TrmtDate;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -64,18 +66,21 @@ public class gardeMySQL {
|
|||||||
ResultSet resultat = prepStmt.executeQuery();
|
ResultSet resultat = prepStmt.executeQuery();
|
||||||
while (resultat.next())
|
while (resultat.next())
|
||||||
// public Pompier(Caserne laCaserne, int id, String nom, String prenom) {
|
// public Pompier(Caserne laCaserne, int id, String nom, String prenom) {
|
||||||
lePompier = new Pompier(resultat.getCaserne("laCaserne"),
|
lePompier = new Pompier(
|
||||||
|
resultat.getCaserne("laCaserne"),
|
||||||
|
resultat.getInt("id"),
|
||||||
resultat.getString("nom"),
|
resultat.getString("nom"),
|
||||||
resultat.getString("prenom");
|
resultat.getString("prenom")
|
||||||
|
);
|
||||||
uneDispo = new Gardes(TrmtDate.getCalDate(resultat.getDate("jourGarde")),
|
uneDispo = new Gardes(TrmtDate.getCalDate(resultat.getDate("jourGarde")),
|
||||||
resultat.getInt("periode")
|
resultat.getInt("periode"),
|
||||||
,lePompier);
|
lePompier);
|
||||||
// Recherche si uneDispo existe dans les Dispos
|
// Recherche si uneDispo existe dans les Dispos
|
||||||
int indice = lesDispo.indexOf(uneDispo);
|
int indice = lesDispo.indexOf(uneDispo);
|
||||||
if (indice > -1) {
|
if (indice > -1) {
|
||||||
laDispoTrouvee = lesDispo.get(indice);
|
laDispoTrouvee = lesDispo.get(indice);
|
||||||
laDispoTrouvee.setActivite(resultat.getInt("disponibilite"));
|
laDispoTrouvee.setDisponibilite(resultat.getInt("disponibilite"));
|
||||||
laDispoTrouvee.setIsInDB(true);
|
laDispoTrouvee.setIsInBDD(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
prepStmt.close();
|
prepStmt.close();
|
||||||
@ -86,7 +91,87 @@ public class gardeMySQL {
|
|||||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Suppression de la ventilation passé en param
|
||||||
|
* @param v : ventilation
|
||||||
|
* @return : nb lignes supprimées
|
||||||
|
*/
|
||||||
|
public int delete(Gardes v) {
|
||||||
|
int nbMaj = -1;
|
||||||
|
String sql = "DELETE FROM gardes "
|
||||||
|
+ "WHERE idPompier = ? AND"
|
||||||
|
+ "periode = ? AND"
|
||||||
|
+ "jourGarde = ?;";
|
||||||
|
try {
|
||||||
|
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||||
|
prepStmt.setInt(1, v.getPompier().getId());
|
||||||
|
prepStmt.setInt(2, v.getPeriode());
|
||||||
|
prepStmt.setDate(3, TrmtDate.getSQLDate(v.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int update(Gardes v) {
|
||||||
|
|
||||||
|
int nbMAJ = -1;
|
||||||
|
String sql = "UPDATE gardes "
|
||||||
|
+ "SET ventil = ? "
|
||||||
|
+ "WHERE idPompier= ? "
|
||||||
|
+ "AND jourGarde = ? "
|
||||||
|
+ "AND periode = ?";
|
||||||
|
try {
|
||||||
|
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||||
|
prepStmt.setInt(1, v.getDisponibilite());
|
||||||
|
prepStmt.setInt(2, v.getPompier().getId());
|
||||||
|
prepStmt.setDate(3, TrmtDate.getSQLDate(v.getJourGarde()));
|
||||||
|
prepStmt.setInt(4, v.getPeriode());
|
||||||
|
System.out.println("update : " + prepStmt);
|
||||||
|
nbMAJ = prepStmt.executeUpdate();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
Logger.getLogger(gardeMySQL.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
return nbMAJ;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Création d'un ventil
|
||||||
|
* @param v : ventil à créer
|
||||||
|
* @return : id du ventil
|
||||||
|
*/
|
||||||
|
public int create(Gardes v) {
|
||||||
|
int nbCre = -1;
|
||||||
|
String sql = "INSERT INTO gardes "
|
||||||
|
+ "(jourGarde, periode, idPompier, ventil)"
|
||||||
|
+ "VALUES (?, ?, ?, ?);";
|
||||||
|
try {
|
||||||
|
PreparedStatement prepStmt = theConnection.prepareStatement(sql);
|
||||||
|
prepStmt.setDate(1, TrmtDate.getSQLDate(v.getJourGarde()));
|
||||||
|
prepStmt.setInt(2, v.getPeriode());
|
||||||
|
prepStmt.setInt(3, v.getPompier().getId());
|
||||||
|
prepStmt.setInt(4, v.getDisponibilite());
|
||||||
|
int nbLigne= prepStmt.executeUpdate();
|
||||||
|
if (nbLigne > 0) {
|
||||||
|
ResultSet result = prepStmt.getGeneratedKeys();
|
||||||
|
if (result.next()) {
|
||||||
|
nbCre = result.getInt(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.out.println("SQLExeption : " + ex.getMessage());
|
||||||
|
System.out.println("SQLState : " + ex.getSQLState());
|
||||||
|
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return nbCre;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@ import java.util.Objects;
|
|||||||
* @author funcha.ahamadi
|
* @author funcha.ahamadi
|
||||||
*/
|
*/
|
||||||
public class Gardes {
|
public class Gardes {
|
||||||
private Calendar jourGarde;
|
Calendar jourGarde;
|
||||||
private int periode;
|
int periode;
|
||||||
private Pompier pompier;
|
Pompier pompier;
|
||||||
private int disponibilite;
|
int disponibilite;
|
||||||
private boolean isInBDD;
|
boolean isInBDD;
|
||||||
|
|
||||||
public Gardes(Calendar jourGarde, int periode, Pompier pompier, int disponibilite, boolean isInBDD) {
|
public Gardes(Calendar jourGarde, int periode, Pompier pompier, int disponibilite, boolean isInBDD) {
|
||||||
this.jourGarde = jourGarde;
|
this.jourGarde = jourGarde;
|
||||||
|
@ -59,7 +59,6 @@ public class Pompier {
|
|||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
this.prenom = prenom;
|
this.prenom = prenom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
|
51
src/java/form/DispoForm.java
Normal file
51
src/java/form/DispoForm.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @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("lesAct");
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
uneGarde.setDisponibilite(newAct);
|
||||||
|
vm.update(uneGarde);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
uneGarde.setDisponibilite(newAct);
|
||||||
|
vm.create(uneGarde);
|
||||||
|
uneGarde.setIsInBDD(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,8 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
package servlet;
|
package servlet;
|
||||||
|
|
||||||
|
import bdd.gardeMySQL;
|
||||||
|
import bean.Gardes;
|
||||||
import bean.Pompier;
|
import bean.Pompier;
|
||||||
import com.sdis29a.util.TrmtDate;
|
import form.DispoForm;
|
||||||
|
import util.TrmtDate;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@ -68,6 +71,7 @@ public class GardesServlet extends HttpServlet {
|
|||||||
String[] lesDatesEnString = new String[7];
|
String[] lesDatesEnString = new String[7];
|
||||||
lesDates[0] = TrmtDate.getDateDebutSemaine();
|
lesDates[0] = TrmtDate.getDateDebutSemaine();
|
||||||
lesDatesEnString[0] = TrmtDate.getDateAAfficher(lesDates[0]);
|
lesDatesEnString[0] = TrmtDate.getDateAAfficher(lesDates[0]);
|
||||||
|
|
||||||
for (int i = 1; i < lesDates.length; i++) {
|
for (int i = 1; i < lesDates.length; i++) {
|
||||||
lesDates[i] = TrmtDate.addDays(lesDates[0], i);
|
lesDates[i] = TrmtDate.addDays(lesDates[0], i);
|
||||||
lesDatesEnString[i] = TrmtDate.getDateAAfficher(lesDates[i]);
|
lesDatesEnString[i] = TrmtDate.getDateAAfficher(lesDates[i]);
|
||||||
@ -77,11 +81,17 @@ public class GardesServlet extends HttpServlet {
|
|||||||
/*Initialisation des periodes */
|
/*Initialisation des periodes */
|
||||||
int[] lesPeriodes = {1,2,3,4};
|
int[] lesPeriodes = {1,2,3,4};
|
||||||
maSession.setAttribute("lesPeriodes", lesPeriodes);
|
maSession.setAttribute("lesPeriodes", lesPeriodes);
|
||||||
|
/* Recherche des ventilations */
|
||||||
|
gardeMySQL vm = new gardeMySQL();
|
||||||
|
ArrayList<Gardes> lesVentilInit = vm.getLesDisponibilite(lesDates, lesPeriodes);
|
||||||
|
//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 */
|
/* Affichage de la page de ventilation */
|
||||||
getServletContext().getRequestDispatcher("/WEB-INF/ventilJSP.jsp").forward(request, response);
|
getServletContext().getRequestDispatcher("/WEB-INF/feuilleGardesJSP.jsp").forward(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +105,10 @@ public class GardesServlet extends HttpServlet {
|
|||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,7 +74,7 @@ public class PompierServlet extends HttpServlet {
|
|||||||
boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString);
|
boolean isNumeric = StringUtils.isStrictlyNumeric(pageEnString);
|
||||||
if (isNumeric) {
|
if (isNumeric) {
|
||||||
pageDemandee = Integer.parseInt(pageEnString);
|
pageDemandee = Integer.parseInt(pageEnString);
|
||||||
if (pageDemandee != 2 && pageDemandee != 3) { // erreur
|
if (pageDemandee != 2 && pageDemandee != 3 && pageDemandee !=5) { // erreur
|
||||||
erreur = true;
|
erreur = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -100,6 +100,10 @@ public class PompierServlet extends HttpServlet {
|
|||||||
lePompier = lesPompiers.get(0);
|
lePompier = lesPompiers.get(0);
|
||||||
page = 3;
|
page = 3;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if(erreur==false && pageDemandee==5){ //page gardes
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (erreur) {
|
if (erreur) {
|
||||||
request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet
|
request.getRequestDispatcher("/authentification").forward(request, response); // redirection servlet
|
||||||
|
@ -1,129 +1,129 @@
|
|||||||
package com.sdis29a.util;
|
package util;
|
||||||
/*
|
/*
|
||||||
* Classe abstraite facilitant le traitement des dates
|
* Classe abstraite facilitant le traitement des dates
|
||||||
* Toutes les méthodes sont statiques, appel : TrmtDate.nomMéthode
|
* Toutes les méthodes sont statiques, appel : TrmtDate.nomMéthode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Dominique_2
|
* @author Dominique_2
|
||||||
*/
|
*/
|
||||||
public abstract class TrmtDate {
|
public abstract class TrmtDate {
|
||||||
static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
|
static Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recherche de la date du début de la semaine courante
|
* Recherche de la date du début de la semaine courante
|
||||||
* @return date du lundi de la semaine, format Calendar
|
* @return date du lundi de la semaine, format Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar getDateDebutSemaine() {
|
public static Calendar getDateDebutSemaine() {
|
||||||
return getDateDebutSemaine(getDateDuJour());
|
return getDateDebutSemaine(getDateDuJour());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recherche de la date du début de semaine à partir de la date passée en paramètre
|
* Recherche de la date du début de semaine à partir de la date passée en paramètre
|
||||||
* @param c Calendar, date de recherche
|
* @param c Calendar, date de recherche
|
||||||
* @return Calendar, début semaine à partir de c
|
* @return Calendar, début semaine à partir de c
|
||||||
*/
|
*/
|
||||||
public static Calendar getDateDebutSemaine(Calendar c) {
|
public static Calendar getDateDebutSemaine(Calendar c) {
|
||||||
Calendar leCal = getClone(c);
|
Calendar leCal = getClone(c);
|
||||||
leCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
leCal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
|
||||||
//System.out.println("Date du lundi correspondant : " + nvCal.getTime());
|
//System.out.println("Date du lundi correspondant : " + nvCal.getTime());
|
||||||
return leCal;
|
return leCal;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retourne la date passée en paramètre sous la forme : lun.05/10 par exemple
|
* Retourne la date passée en paramètre sous la forme : lun.05/10 par exemple
|
||||||
* @param d date à transformer
|
* @param d date à transformer
|
||||||
* @return chaine de car., forme lun.05/10 par exemple
|
* @return chaine de car., forme lun.05/10 par exemple
|
||||||
*/
|
*/
|
||||||
public static String getDateAAfficher(Calendar d) {
|
public static String getDateAAfficher(Calendar d) {
|
||||||
Locale locale = Locale.getDefault();
|
Locale locale = Locale.getDefault();
|
||||||
String dateAAfficher = d.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);
|
String dateAAfficher = d.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM");
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM");
|
||||||
String jrMois = sdf.format(d.getTime());
|
String jrMois = sdf.format(d.getTime());
|
||||||
dateAAfficher += jrMois;
|
dateAAfficher += jrMois;
|
||||||
return dateAAfficher;
|
return dateAAfficher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une date égale à la date passée en paramètre plus le nb jours indiqués
|
* Retourne une date égale à la date passée en paramètre plus le nb jours indiqués
|
||||||
* @param dateInit date initiale, format Calendar
|
* @param dateInit date initiale, format Calendar
|
||||||
* @param days nb jours à ajouter
|
* @param days nb jours à ajouter
|
||||||
* @return dateInit + days, format Calendar
|
* @return dateInit + days, format Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar addDays(Calendar dateInit, int days) {
|
public static Calendar addDays(Calendar dateInit, int days) {
|
||||||
Calendar leCal = getClone(dateInit);
|
Calendar leCal = getClone(dateInit);
|
||||||
leCal.setTime(dateInit.getTime());
|
leCal.setTime(dateInit.getTime());
|
||||||
leCal.add(Calendar.DAY_OF_MONTH, days);
|
leCal.add(Calendar.DAY_OF_MONTH, days);
|
||||||
return leCal;
|
return leCal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une instance de Calendar correspondant à la date au format SQl
|
* Retourne une instance de Calendar correspondant à la date au format SQl
|
||||||
* passée en paramètre
|
* passée en paramètre
|
||||||
* @param sqlDate : date au format java.sql.Date
|
* @param sqlDate : date au format java.sql.Date
|
||||||
* @return instance de Calendar
|
* @return instance de Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar getCalDate(java.sql.Date sqlDate) {
|
public static Calendar getCalDate(java.sql.Date sqlDate) {
|
||||||
cal.setTime(new java.util.Date(sqlDate.getTime()));
|
cal.setTime(new java.util.Date(sqlDate.getTime()));
|
||||||
return cal;
|
return cal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une date sql à partir d'une instance de Calendar
|
* Retourne une date sql à partir d'une instance de Calendar
|
||||||
* @param unCal
|
* @param unCal
|
||||||
* @return date sql
|
* @return date sql
|
||||||
*/
|
*/
|
||||||
public static java.sql.Date getSQLDate(Calendar unCal) {
|
public static java.sql.Date getSQLDate(Calendar unCal) {
|
||||||
return new java.sql.Date(unCal.getTimeInMillis());
|
return new java.sql.Date(unCal.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne une instance de Calendar correspondant à la date
|
* Retourne une instance de Calendar correspondant à la date
|
||||||
* passée en paramètre
|
* passée en paramètre
|
||||||
* @param utilDate : date au format java.util.Date
|
* @param utilDate : date au format java.util.Date
|
||||||
* @return instance de Calendar
|
* @return instance de Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar getCalDate(java.util.Date utilDate) {
|
public static Calendar getCalDate(java.util.Date utilDate) {
|
||||||
cal.setTime(utilDate);
|
cal.setTime(utilDate);
|
||||||
return cal;
|
return cal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne la date du jour au format SQL
|
* Retourne la date du jour au format SQL
|
||||||
* @return Date au format sql
|
* @return Date au format sql
|
||||||
*/
|
*/
|
||||||
public static java.sql.Date getSQLDateDuJour() {
|
public static java.sql.Date getSQLDateDuJour() {
|
||||||
return java.sql.Date.valueOf(java.time.LocalDate.now());
|
return java.sql.Date.valueOf(java.time.LocalDate.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne la date du jour au format Calendar
|
* Retourne la date du jour au format Calendar
|
||||||
* @return Calendar
|
* @return Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar getDateDuJour() {
|
public static Calendar getDateDuJour() {
|
||||||
Calendar nvCal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
|
Calendar nvCal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
|
||||||
nvCal.set(Calendar.HOUR_OF_DAY, 0);
|
nvCal.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
nvCal.set(Calendar.MINUTE, 0);
|
nvCal.set(Calendar.MINUTE, 0);
|
||||||
nvCal.set(Calendar.SECOND, 0);
|
nvCal.set(Calendar.SECOND, 0);
|
||||||
nvCal.set(Calendar.MILLISECOND, 0);
|
nvCal.set(Calendar.MILLISECOND, 0);
|
||||||
//System.out.println("Date du jour : " + nvCal.getTime());
|
//System.out.println("Date du jour : " + nvCal.getTime());
|
||||||
return nvCal;
|
return nvCal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permet d'obtenir une autre instance de Calendar identique à celle passée en paramètre
|
* Permet d'obtenir une autre instance de Calendar identique à celle passée en paramètre
|
||||||
* @param c Calendar à cloner
|
* @param c Calendar à cloner
|
||||||
* @return nouvelle instance de Calendar
|
* @return nouvelle instance de Calendar
|
||||||
*/
|
*/
|
||||||
public static Calendar getClone(Calendar c) {
|
public static Calendar getClone(Calendar c) {
|
||||||
Calendar leCal = Calendar.getInstance();
|
Calendar leCal = Calendar.getInstance();
|
||||||
leCal.setTime(c.getTime());
|
leCal.setTime(c.getTime());
|
||||||
return leCal;
|
return leCal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,53 @@
|
|||||||
value="${lePompier.getCommentaire()}" />
|
value="${lePompier.getCommentaire()}" />
|
||||||
</div><!-- fin ligne observation -->
|
</div><!-- fin ligne observation -->
|
||||||
</div> <!-- fin observation -->
|
</div> <!-- fin observation -->
|
||||||
|
<br/>
|
||||||
|
<!-- tab disp -->
|
||||||
|
<div>
|
||||||
|
<label for="tDisp">Disponibilitées</label>
|
||||||
|
<table border="1" cellspacing="3" cellpadding="1" class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<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="uneP" varStatus="status">
|
||||||
|
<td class="text-center">${uneP}</td>
|
||||||
|
</c:forEach>
|
||||||
|
</c:forEach>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:set var="oldId" value="-1" scope="page"/>
|
||||||
|
<tr>
|
||||||
|
<c:forEach items="${sessionScope.lesVentilInit}" var="ventil" varStatus="status">
|
||||||
|
<c:set var="newId" value="${gardes.getPompier().getId()}" scope="page"/>
|
||||||
|
<c:if test="${oldId != newId}" var="test" scope="page">
|
||||||
|
</tr> <tr>
|
||||||
|
<td>${ventil.getSalarie().getId()}</td>
|
||||||
|
<td>${ventil.getSalarie().getNom()} ${ventil.getSalarie().getPrenom()}</td>
|
||||||
|
<c:set var="oldId" value="${newId}" scope="page"/>
|
||||||
|
</c:if>
|
||||||
|
<c:set var="act" value="${gardes.getDisponibilite()}" scope="page"/>
|
||||||
|
<td><input type="text" value="${act}" name="lesAct" class="ztVentil ${sessionScope.lesCouleurs[act]}" readonly/></td>
|
||||||
|
|
||||||
|
</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>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- fin tab disp -->
|
||||||
<div class="danger mt-3">${message} </div>
|
<div class="danger mt-3">${message} </div>
|
||||||
|
|
||||||
<div class="text-center mt-3">
|
<div class="text-center mt-3">
|
||||||
@ -134,10 +180,26 @@
|
|||||||
<i class="bi bi-check2"></i> Valider
|
<i class="bi bi-check2"></i> Valider
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><em>* zone obligatoire</em></p>
|
<p><em>* zone obligatoire</em></p>
|
||||||
|
|
||||||
</section>
|
</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 -->
|
</div> <!-- fin div contenant aside et section -->
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
@ -89,10 +89,24 @@
|
|||||||
|
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${page eq 5}">
|
||||||
|
<a class="nav-link active" href="pompier?pageDemandee=5">Gardes</a>
|
||||||
|
</c:when>
|
||||||
|
<c:when test="${sessionScope.lePompierConnecte.getLeStatut().getCode() eq 2}">
|
||||||
|
<a class="nav-link" href="pompier?pageDemandee=5">Gardes</a>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
|
||||||
|
</c:otherwise>
|
||||||
|
|
||||||
|
</c:choose>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div> <!-- fin id=identie -->
|
</div> <!-- fin id=identie -->
|
||||||
</div> <!-- fin class=container -->
|
</div> <!-- fin class=container -->
|
||||||
</header>
|
</header>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user