Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/main/java/edt/umontp/fr/Cours.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cours> {
private final ZoneId ZONE_ID = ZoneId.of("Europe/Paris");
private LocalDate date;
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -161,7 +182,7 @@ public String toString() {

/*
* (non-Javadoc)
*
*
* @see java.lang.Object#hashCode()
*/

Expand All @@ -179,7 +200,7 @@ public int hashCode() {

/*
* (non-Javadoc)
*
*
* @see java.lang.Object#equals(java.lang.Object)
*/

Expand Down
29 changes: 28 additions & 1 deletion src/main/java/edt/umontp/fr/EmploiDuTemps.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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)) {
Expand All @@ -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()) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edt/umontp/fr/EmploiDuTempsProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +61,9 @@ public void actualiser() {
emploiDuTemps.actualiser();
}

/**
* Cette classe représente une combinaison de clefs
*/
private class MultiKey<K1, K2> {
private K1 key1;
private K2 key2;
Expand Down
38 changes: 33 additions & 5 deletions src/main/java/edt/umontp/fr/Groupe.java
Original file line number Diff line number Diff line change
Expand Up @@ -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), //
Expand All @@ -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];
Expand Down Expand Up @@ -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<Groupe> result = new ArrayList<>();
Expand All @@ -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));
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edt/umontp/fr/InterfaceEmploiDuTemps.java
Original file line number Diff line number Diff line change
@@ -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();
}
28 changes: 28 additions & 0 deletions src/main/java/edt/umontp/fr/Planifiable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
14 changes: 14 additions & 0 deletions src/main/java/edt/umontp/fr/Planning.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Cours>, Planifiable {
private SortedSet<Cours> 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> cours) {
this.cours = new TreeSet(cours);
}
Expand Down
Loading