diff --git a/src/main/java/edt/umontp/fr/Cours.java b/src/main/java/edt/umontp/fr/Cours.java index 554f8fe..e2e09ef 100644 --- a/src/main/java/edt/umontp/fr/Cours.java +++ b/src/main/java/edt/umontp/fr/Cours.java @@ -16,6 +16,13 @@ import net.fortuna.ical4j.model.DateTime; import net.fortuna.ical4j.model.Property; +/** + * Cours est la classe qui gère les cours d'un planning + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + * @see Comparable + */ public class Cours implements Comparable { private final ZoneId ZONE_ID = ZoneId.of("Europe/Paris"); private LocalDate date; @@ -39,6 +46,12 @@ public Cours(LocalDate date, String[] prof, LocalTime heureDebut, LocalTime heur duree = (int) Duration.between(heureDebut, heureFin).toMinutes(); } + /** + * Permet de créer un objet cours a partir d'un VEVENT + * + * @param vEvent event d'un objet Calendar + * @since 1.0 + */ public Cours(Component vEvent) { Property summary = vEvent.getProperty(Property.SUMMARY); Property description = vEvent.getProperty(Property.DESCRIPTION); @@ -65,6 +78,14 @@ public Cours(Component vEvent) { duree = (int) Duration.between(heureDebut, heureFin).toMinutes(); } + /** + * Permet d'obtenir le(s) professeur(s) d'un VENVENT a partir de la description + * de ce dernier + * + * @param desc description du VENVENT + * @return le(s) professeur(s) du present dans la description + * @since 1.0 + */ public static String[] getProfFromDesc(String desc) { String regex = "(?<=\\n)[- A-Z]* [- A-Z]*(?=\\n)"; Matcher m = Pattern.compile(regex).matcher(desc); @@ -161,7 +182,7 @@ public String toString() { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ @@ -179,7 +200,7 @@ public int hashCode() { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ diff --git a/src/main/java/edt/umontp/fr/EmploiDuTemps.java b/src/main/java/edt/umontp/fr/EmploiDuTemps.java index 194e6a9..065b84d 100644 --- a/src/main/java/edt/umontp/fr/EmploiDuTemps.java +++ b/src/main/java/edt/umontp/fr/EmploiDuTemps.java @@ -16,11 +16,25 @@ import net.fortuna.ical4j.model.Calendar; import net.fortuna.ical4j.model.Component; +/** + * EmploisDuTemps est la classe qui permet de gérer un emploi du temps + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + * @see InterfaceEmploiDuTemps + */ public class EmploiDuTemps implements InterfaceEmploiDuTemps { - private final String LIEN_ICAL = "https://proseconsult.umontpellier.fr/jsp/custom/modules/plannings/direct_cal.jsp?data=58c99062bab31d256bee14356aca3f2423c0f022cb9660eba051b2653be722c431b66c493702208e664667048bc04373dc5c094f7d1a811b903031bde802c7f59b21846d3c6254443d7b6e956d3145c6e0d5bac87b70fdd185b8b86771d71211a02411e8351020815cfb0dcc54c667187353dbcfc377b44753a4f433d4e51f753c2b0fc0eafdcbc1cbb6ef4e715ebea9d495758b595b12cb294e70e715876fbaa3c654023c76f43cd51442775ff171e0a5f21b50c55a5b52d94df3e7977af823a1e78ee86c6497b1cf8732d52143eeffacc27449fc13ec1f0b04d23e09712df15579474e1aa0cd65f50f33a1dd766301,1"; private static EmploiDuTemps singleton = null; + private final String LIEN_ICAL = + "https://proseconsult.umontpellier.fr/jsp/custom/modules/plannings/direct_cal" + ".jsp?data" + + "=58c99062bab31d256bee14356aca3f2423c0f022cb9660eba051b2653be722c431b66c493702208e664667048bc04373dc5c094f7d1a811b903031bde802c7f59b21846d3c6254443d7b6e956d3145c6e0d5bac87b70fdd185b8b86771d71211a02411e8351020815cfb0dcc54c667187353dbcfc377b44753a4f433d4e51f753c2b0fc0eafdcbc1cbb6ef4e715ebea9d495758b595b12cb294e70e715876fbaa3c654023c76f43cd51442775ff171e0a5f21b50c55a5b52d94df3e7977af823a1e78ee86c6497b1cf8732d52143eeffacc27449fc13ec1f0b04d23e09712df15579474e1aa0cd65f50f33a1dd766301,1"; private Planning planningEmploisDuTemps; + /** + * Permet mettre a jour l'emploi du temps + * + * @since 1.0 + */ private EmploiDuTemps() { actualiser(); } @@ -38,6 +52,13 @@ public static EmploiDuTemps getInstance() { return localInstance; } + /** + * Permet d'obtenir un objet calendar a parti d'un fichier ics + * + * @param fichierIcs fichier ics source + * @return objet calendar corespondant + * @since 1.0 + */ private Calendar convertieFichierIcsEnCalendar(File fichierIcs) { Calendar calendar = null; try (FileInputStream fileICS = new FileInputStream(fichierIcs)) { @@ -53,6 +74,12 @@ private Calendar convertieFichierIcsEnCalendar(File fichierIcs) { return calendar; } + /** + * Permet d'obtenir un fichier ics correspondant a un lien iCal (ici lien iCal = {@link #LIEN_ICAL} + * + * @return fichier ics correspondant + * @since 1.0 + */ private File getFichierIcsDepuisLienIcal() { File fichierIcs = new File("fichier.ics"); if (fichierIcs.isFile()) { diff --git a/src/main/java/edt/umontp/fr/EmploiDuTempsProxy.java b/src/main/java/edt/umontp/fr/EmploiDuTempsProxy.java index baa735d..67c82bf 100644 --- a/src/main/java/edt/umontp/fr/EmploiDuTempsProxy.java +++ b/src/main/java/edt/umontp/fr/EmploiDuTempsProxy.java @@ -4,6 +4,14 @@ import java.util.EnumMap; import java.util.HashMap; +/** + * EmploiDuTempsProxy est un classe qui permet de proposer un proxy pour + * l'emploi du temps + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + * @see InterfaceEmploiDuTemps + */ public class EmploiDuTempsProxy implements InterfaceEmploiDuTemps { private static EmploiDuTempsProxy singleton = null; private EmploiDuTemps emploiDuTemps; @@ -53,6 +61,9 @@ public void actualiser() { emploiDuTemps.actualiser(); } + /** + * Cette classe représente une combinaison de clefs + */ private class MultiKey { private K1 key1; private K2 key2; diff --git a/src/main/java/edt/umontp/fr/Groupe.java b/src/main/java/edt/umontp/fr/Groupe.java index 82f570d..074f0b9 100644 --- a/src/main/java/edt/umontp/fr/Groupe.java +++ b/src/main/java/edt/umontp/fr/Groupe.java @@ -5,6 +5,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +/** + * Groupe est une enumeration qui permet de recenser les différents groupes + * d'enseignements pour lesquelles l'API est proposée + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + */ public enum Groupe { A1("A1"), // première année dep info S1("S1", A1), // @@ -24,6 +31,7 @@ public enum Groupe { G4("G4", A2); private static final String REGEX; + static { Groupe[] groupes = values(); String[] strings = new String[groupes.length]; @@ -53,12 +61,13 @@ private Groupe(String intitule, Groupe groupeParent) { } /** - * @return the intitule + * Permet d'obtenir le(s) groupe(s) d'enseignement a partir d'un texte (dans le + * cadre de cette API a partir de la description d'un VEVENT) + * + * @param texte texte source (ici description) + * @return groupe(s) correspondant + * @since 1.0 */ - public String getIntitule() { - return intitule; - } - public static Groupe[] getGroupeDepuisTexte(String texte) { final Matcher m = Pattern.compile(REGEX).matcher(texte); Collection result = new ArrayList<>(); @@ -67,10 +76,29 @@ public static Groupe[] getGroupeDepuisTexte(String texte) { return result.toArray(Groupe[]::new); } + /** + * @return the intitule + */ + public String getIntitule() { + return intitule; + } + + /** + * Permet de savoir si ce groupe appartient a un autre groupe + * + * @return {@code boolean} + * @since 1.0 + */ private boolean possedeGroupeParent() { return groupeParent != null; } + /** + * Permet de savoir si ce groupe est contenu dans un autre groupe + * + * @return {@code boolean} + * @since 1.0 + */ public boolean estContenuDans(Groupe autreGroupe) { return autreGroupe == this || (possedeGroupeParent() && groupeParent.estContenuDans(autreGroupe)); } diff --git a/src/main/java/edt/umontp/fr/InterfaceEmploiDuTemps.java b/src/main/java/edt/umontp/fr/InterfaceEmploiDuTemps.java index 3f36f8b..3b3166e 100644 --- a/src/main/java/edt/umontp/fr/InterfaceEmploiDuTemps.java +++ b/src/main/java/edt/umontp/fr/InterfaceEmploiDuTemps.java @@ -1,5 +1,16 @@ package edt.umontp.fr; +/** + * InterfaceEmploisDuTemps est un interface proposant des méthodes pour un emploi du temps + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + * @see Planifiable + */ interface InterfaceEmploiDuTemps extends Planifiable { + + /** + * Permet d'actualiser l'emploi du temps + */ public void actualiser(); } diff --git a/src/main/java/edt/umontp/fr/Planifiable.java b/src/main/java/edt/umontp/fr/Planifiable.java index 15fe713..09ef4a3 100644 --- a/src/main/java/edt/umontp/fr/Planifiable.java +++ b/src/main/java/edt/umontp/fr/Planifiable.java @@ -2,11 +2,39 @@ import java.time.LocalDate; +/** + * Planifiable est une interface proposant des méthodes pour gérer un emploi du temps + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + */ interface Planifiable { + /** + * Permet d'obtenir le planning correspondant a une date + * + * @param date date pour laquelle on veut obtenir le planning + * @return planning corresspndant + * @since 1.0 + */ public Planning getPlanningOf(LocalDate date); + /** + * Permet d'obtenir le planning correspondant a une date et un groupe + * + * @param date date dont on veut obtenir le planning + * @param groupe groupe dont on veut obtenir le planning + * @return planning correspondant + * @since 1.0 + */ public Planning getPlanningOf(LocalDate date, Groupe groupe); + /** + * Permet d'obtenir le planning correspondant a un groupe + * + * @param groupe groupe dont on veut obtenir le planning + * @return planning correspondant + * @since 1.0 + */ public Planning getPlanningOf(Groupe groupe); } diff --git a/src/main/java/edt/umontp/fr/Planning.java b/src/main/java/edt/umontp/fr/Planning.java index f417525..40ffa7e 100644 --- a/src/main/java/edt/umontp/fr/Planning.java +++ b/src/main/java/edt/umontp/fr/Planning.java @@ -11,9 +11,23 @@ import edu.emory.mathcs.backport.java.util.TreeSet; +/** + * Planning est un classe permettant de gérer un planning + * + * @author emerick-biron, MathieuSoysal + * @version 1.0 + * @see Planifiable + * @see Iterable + */ public class Planning implements Iterable, Planifiable { private SortedSet cours; + /** + * Permet de créer un objet Planning a partir d'une collection de cours + * + * @param cours collection de cours + * @since 1.0 + */ public Planning(Collection cours) { this.cours = new TreeSet(cours); } diff --git a/src/test/java/edt/umontp/fr/EmploiDuTempsProxyTest.java b/src/test/java/edt/umontp/fr/EmploiDuTempsProxyTest.java index d9f36db..2af4ed6 100644 --- a/src/test/java/edt/umontp/fr/EmploiDuTempsProxyTest.java +++ b/src/test/java/edt/umontp/fr/EmploiDuTempsProxyTest.java @@ -10,21 +10,22 @@ class EmploiDuTempsProxyTest { - private EmploiDuTempsProxy emploiDuTempsProxyTest; + private EmploiDuTempsProxy emploiDuTempsProxy; @AfterEach void init() { - emploiDuTempsProxyTest.actualiser(); + emploiDuTempsProxy.actualiser(); } @Test void test_getInstance_retourneAucuneErreur() { - assertAll(() -> EmploiDuTempsProxy.getInstance()); + assertAll(() -> emploiDuTempsProxy = EmploiDuTempsProxy.getInstance()); } @Test void test_getPlanningOf_date_plusRapide() { - emploiDuTempsProxyTest = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy.actualiser(); long tempsExecution1 = rapiditeGetPlanningOfDate(); long tempsExecution2 = rapiditeGetPlanningOfDate(); @@ -34,23 +35,24 @@ void test_getPlanningOf_date_plusRapide() { private long rapiditeGetPlanningOfDate() { long startTime = System.currentTimeMillis(); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now()); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(1)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(2)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(3)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(4)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(5)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(6)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(7)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(8)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(9)); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(10)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now()); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(1)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(2)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(3)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(4)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(5)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(6)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(7)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(8)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(9)); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(10)); return System.currentTimeMillis() - startTime; } @Test void test_getPlanningOf_Groupe_plusRapide() { - emploiDuTempsProxyTest = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy.actualiser(); long tempsExecution1 = rapiditeGetPlanningOfGroupe(); long tempsExecution2 = rapiditeGetPlanningOfGroupe(); @@ -60,22 +62,24 @@ void test_getPlanningOf_Groupe_plusRapide() { private long rapiditeGetPlanningOfGroupe() { long startTime = System.currentTimeMillis(); - emploiDuTempsProxyTest.getPlanningOf(Groupe.A1); - emploiDuTempsProxyTest.getPlanningOf(Groupe.Q1); - emploiDuTempsProxyTest.getPlanningOf(Groupe.Q2); - emploiDuTempsProxyTest.getPlanningOf(Groupe.Q3); - emploiDuTempsProxyTest.getPlanningOf(Groupe.Q4); - emploiDuTempsProxyTest.getPlanningOf(Groupe.G1); - emploiDuTempsProxyTest.getPlanningOf(Groupe.G2); - emploiDuTempsProxyTest.getPlanningOf(Groupe.G3); - emploiDuTempsProxyTest.getPlanningOf(Groupe.G4); - emploiDuTempsProxyTest.getPlanningOf(Groupe.A2); + emploiDuTempsProxy.getPlanningOf(Groupe.A1); + emploiDuTempsProxy.getPlanningOf(Groupe.Q1); + emploiDuTempsProxy.getPlanningOf(Groupe.Q2); + emploiDuTempsProxy.getPlanningOf(Groupe.Q3); + emploiDuTempsProxy.getPlanningOf(Groupe.Q4); + emploiDuTempsProxy.getPlanningOf(Groupe.G1); + emploiDuTempsProxy.getPlanningOf(Groupe.G2); + emploiDuTempsProxy.getPlanningOf(Groupe.G3); + emploiDuTempsProxy.getPlanningOf(Groupe.G4); + emploiDuTempsProxy.getPlanningOf(Groupe.A2); return System.currentTimeMillis() - startTime; } @Test void test_getPlanningOf_DateGroupe_plusRapide() { - emploiDuTempsProxyTest = EmploiDuTempsProxy.getInstance(); + + emploiDuTempsProxy = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy.actualiser(); long tempsExecution1 = rapiditeGetPlanningOfDateGroupe(); long tempsExecution2 = rapiditeGetPlanningOfDateGroupe(); @@ -85,22 +89,23 @@ void test_getPlanningOf_DateGroupe_plusRapide() { private long rapiditeGetPlanningOfDateGroupe() { long startTime = System.currentTimeMillis(); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(1), Groupe.A1); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(2), Groupe.Q1); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(3), Groupe.Q2); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(4), Groupe.Q3); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(5), Groupe.Q4); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(6), Groupe.G1); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(7), Groupe.G2); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(8), Groupe.G3); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(9), Groupe.G4); - emploiDuTempsProxyTest.getPlanningOf(LocalDate.now().plusDays(10), Groupe.A2); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(1), Groupe.A1); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(2), Groupe.Q1); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(3), Groupe.Q2); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(4), Groupe.Q3); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(5), Groupe.Q4); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(6), Groupe.G1); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(7), Groupe.G2); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(8), Groupe.G3); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(9), Groupe.G4); + emploiDuTempsProxy.getPlanningOf(LocalDate.now().plusDays(10), Groupe.A2); return System.currentTimeMillis() - startTime; } @Test void test_getPlanningOf_DateGroupe_plusRapideInteligent() { - emploiDuTempsProxyTest = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy = EmploiDuTempsProxy.getInstance(); + emploiDuTempsProxy.actualiser(); long tempsExecution1 = rapiditeGetPlanningOfDate(); long tempsExecution2 = rapiditeGetPlanningOfDateGroupe();