Skip to content

Commit 3b99aec

Browse files
🔀 Merge pull request #30 from DevLab-umontp/interface-API
✨ Ajout de nouvelles Features
2 parents e1f4586 + ddab8e9 commit 3b99aec

22 files changed

+1263
-243
lines changed

.github/workflows/maven-package.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,37 @@ jobs:
1919
id: get_version
2020
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}
2121

22-
- name: Set up JDK 11 for deploy to OSSRH
22+
- name: Set up JDK 11 for deploy to github packages
2323
uses: actions/setup-java@v1
2424
with:
2525
java-version: 11
26-
server-id: ossrh
27-
server-username: MAVEN_USERNAME
28-
server-password: MAVEN_CENTRAL_TOKEN
29-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
30-
gpg-passphrase: MAVEN_GPG_PASSPHRASE
26+
server-id: github
3127

3228
- name: Build with Maven
3329
run: mvn -B package --file pom.xml
3430

3531
- name: Update package version
3632
run: mvn versions:set -DnewVersion=${{ steps.get_version.outputs.VERSION }}
3733

38-
- name: Publish to Apache Maven Central
39-
run: mvn deploy -PossrhDeploy
34+
- name: Publish to GitHub Packages Apache Maven
35+
run: mvn deploy -PgithubDeploy
4036
env:
41-
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
42-
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }}
43-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4438

45-
- name: Set up JDK 11 for deploy to github packages
39+
- name: Set up JDK 11 for deploy to OSSRH
4640
uses: actions/setup-java@v1
4741
with:
4842
java-version: 11
49-
server-id: github
43+
server-id: ossrh
44+
server-username: MAVEN_USERNAME
45+
server-password: MAVEN_CENTRAL_TOKEN
46+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
47+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
5048

51-
- name: Publish to GitHub Packages Apache Maven
52-
run: mvn deploy -PgithubDeploy
49+
- name: Publish to Apache Maven Central
50+
run: mvn deploy -PossrhDeploy
5351
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
53+
MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }}
54+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
55+

.github/workflows/maven.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ jobs:
2222
java-version: 11
2323
- name: Build with Maven
2424
run: mvn -B package --file pom.xml
25+
- name: Javadoc with Maven
26+
run: mvn -PossrhDeploy javadoc:javadoc

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Compiled class file
22
*.class
33

4-
Test.java
54

65
#VSCode
76
.project

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
[![Maven Central](https://img.shields.io/maven-central/v/com.github.devlab-umontp/edt-iut-umontp.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.devlab-umontp%22%20AND%20a:%22edt-iut-umontp%22)
12
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=DevLab-umontp_API-JAVA-EDT&metric=alert_status)](https://sonarcloud.io/dashboard?id=DevLab-umontp_API-JAVA-EDT)
23
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=DevLab-umontp_API-JAVA-EDT&metric=coverage)](https://sonarcloud.io/dashboard?id=DevLab-umontp_API-JAVA-EDT)
34
![GitHub Actions](https://github.com/DevLab-umontp/API-JAVA-EDT/workflows/Java%20CI%20with%20Maven/badge.svg)
45
[![Javadoc](https://img.shields.io/badge/JavaDoc-Online-green)](https://mathieusoysal.github.io/stats/api-java-edt)
56
[![Gitmoji.dev](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat-square)](https://gitmoji.dev)
6-
[![GitHub](https://img.shields.io/github/license/DevLab-umontp/API-JAVA-EDT)](https://github.com/DevLab-umontp/API-JAVA-EDT/blob/master/LICENSE)
7-
# ![](ressources/devicon.png) Librairie Java : EDT IUT Montpellier
7+
8+
# ![](ressources/devicon.png) Librairie Java : EDT IUT Montpellier [![GitHub](https://img.shields.io/github/license/DevLab-umontp/API-JAVA-EDT)](https://github.com/DevLab-umontp/API-JAVA-EDT/blob/master/LICENSE)
89

910
### IUT Montpellier-Sète – Département Informatique
1011
* **Colaborateurs:** [étudiants du département informatique](https://iut-montpellier-sete.edu.umontpellier.fr/dut-informatique/)
@@ -64,6 +65,7 @@ class ExempleDeCode {
6465
}
6566
}
6667
```
68+
>*Voir plus d'[exemples de code](ressources/ExempleDeCode.java)*
6769
## Contribution
6870
Les suggestions et contributions sont toujours les bienvenues! Veuillez discuter des modifications plus importantes via un [issue](https://github.com/DevLab-umontp/Librarie-Java-EDT/issues) avant de soumettre une demande.
6971

ressources/ExempleDeCode.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import java.time.LocalDate;
2+
3+
import fr.umontp.edt.*;
4+
5+
class ExempleDeCode {
6+
public static void main(String[] args) {
7+
8+
// Récupérer l'emploi du temps de l'ent
9+
EmploiDuTempsProxy emploiDuTempsProxy = EmploiDuTempsProxy.getInstance();
10+
11+
// Récupérer le planning d'aujourd'hui
12+
Planning planningDate = emploiDuTempsProxy.getPlanningOf(LocalDate.now());
13+
14+
// Récupérer le planning du groupe S3
15+
Planning planningGroupe = emploiDuTempsProxy.getPlanningOf(Groupe.S3);
16+
17+
// Récupérer le planning d'aujourd'hui du groupe S2
18+
Planning planningDateGroupe = emploiDuTempsProxy.getPlanningOf(LocalDate.now(), Groupe.S2);
19+
20+
// Parcourir les cours d'un planning
21+
for (Cours cours : planningGroupe) {
22+
System.out.println(cours.getIntitule());
23+
}
24+
25+
// Actualiser votre emploi du temps local avec celui de l'ent
26+
emploiDuTempsProxy.actualiser();
27+
28+
// Récupérer le planning d'un professeur
29+
Planning planningProfesseur = emploiDuTempsProxy.getPlanningOf(RepertoireProfesseur.get("Dupuis", "Jacques"));
30+
31+
// Récupérer le planning de plusieurs groupes
32+
Planning planningGroupes = emploiDuTempsProxy.getPlanningOf(Groupe.S3, Groupe.S4);
33+
34+
// Récupérer le planning de plusieurs dates
35+
Planning planningDates = emploiDuTempsProxy.getPlanningOf(LocalDate.now(), LocalDate.now().plusDays(1));
36+
37+
// Récupérer le planning de plusieurs professeurs
38+
Professeur prof1 = RepertoireProfesseur.get("Dupuis", "Jacques");
39+
Professeur prof2 = RepertoireProfesseur.get("Dupuis", "Jacqueline");
40+
Planning planningProfesseurs = emploiDuTempsProxy.getPlanningOf(prof1, prof2);
41+
42+
// Récupérer un planning via le PlanningFiltreur pour faire des combinaisons entre professeur, groupe et date
43+
PlanningFiltreur plusieursGroupesDatesEtProfesseurs = PlanningFiltreur.filtrer()
44+
.par(Groupe.S2, Groupe.S3)
45+
.par(LocalDate.now(), LocalDate.now().plusDays(1))
46+
.par(prof1, prof2);
47+
Planning planningAvecFiltreur = emploiDuTempsProxy.getPlanningOf(plusieursGroupesDatesEtProfesseurs);
48+
}
49+
}

src/main/java/fr/umontp/edt/Cours.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
import java.time.Duration;
55
import java.time.LocalDate;
66
import java.time.LocalTime;
7-
import java.util.ArrayList;
87
import java.util.Arrays;
9-
import java.util.List;
108
import java.util.Locale;
11-
import java.util.regex.Matcher;
12-
import java.util.regex.Pattern;
139

1410
import net.fortuna.ical4j.model.Component;
1511
import net.fortuna.ical4j.model.DateTime;
@@ -33,22 +29,22 @@
3329
*
3430
* @author emerick-biron
3531
* @author MathieuSoysal
36-
* @version 1.0.0
32+
* @version 1.1.0
3733
*/
3834
public class Cours implements Comparable<Cours> {
3935
private LocalDate date;
40-
private String[] prof;
36+
private Professeur[] professeurs;
4137
private LocalTime heureDebut;
4238
private LocalTime heureFin;
4339
private String lieu;
4440
private int duree;
4541
private Groupe[] groupes;
4642
private String intitule;
4743

48-
public Cours(LocalDate date, String[] prof, LocalTime heureDebut, LocalTime heureFin, String lieu, Groupe[] groupe,
49-
String intitule) {
44+
public Cours(LocalDate date, Professeur[] professeurs, LocalTime heureDebut, LocalTime heureFin, String lieu,
45+
Groupe[] groupe, String intitule) {
5046
this.date = date;
51-
this.prof = prof;
47+
this.professeurs = professeurs;
5248
this.heureDebut = heureDebut;
5349
this.heureFin = heureFin;
5450
this.lieu = lieu;
@@ -90,27 +86,27 @@ public Cours(LocalDate date, String[] prof, LocalTime heureDebut, LocalTime heur
9086
heureFin = LocalTime.of(dateFin.getHours(), dateFin.getMinutes());
9187
lieu = location.getValue();
9288
intitule = summary.getValue();
93-
prof = getProfFromDesc(description.getValue());
89+
professeurs = RepertoireProfesseur.getProfesseurDepuisDescriptionEtAjouterSiNonPresent(description.getValue());
9490
groupes = Groupe.getGroupeDepuisTexte(description.getValue());
9591
duree = (int) Duration.between(heureDebut, heureFin).toMinutes();
9692
}
9793

9894
/**
99-
* Permet d'obtenir le(s) professeur(s) d'un VENVENT a partir de la description
100-
* de ce dernier
101-
*
102-
* @param desc description du VENVENT
103-
* @return {@code String[]} le(s) professeur(s) du present dans la description
104-
* @since 1.0
95+
* Permet de vérfier si un professeur est assigné à ce cours.
96+
*
97+
* @param professeur dont on veut vérier s'il est assigné au cour.
98+
* @return {@code true} si le professeur est assigne à ce cours, sinon
99+
* {@code false}.
100+
*
101+
* @see Cours#professeurs
102+
*
103+
* @since 1.1.0
105104
*/
106-
static String[] getProfFromDesc(String desc) {
107-
String regex = "(?<=\\n)[- A-Z]* [- A-Z]*(?=\\n)";
108-
Matcher m = Pattern.compile(regex).matcher(desc);
109-
final List<String> matches = new ArrayList<>();
110-
while (m.find()) {
111-
matches.add(m.group(0));
112-
}
113-
return matches.toArray(new String[matches.size()]);
105+
public boolean estEnseignePar(Professeur professeur) {
106+
for (Professeur professeurAssigne : professeurs)
107+
if (professeurAssigne == professeur)
108+
return true;
109+
return false;
114110
}
115111

116112
@Override
@@ -124,12 +120,16 @@ public int compareTo(Cours o) {
124120
result = Integer.compare(duree, o.duree);
125121
if (result != 0)
126122
return result;
127-
for (Groupe groupe : groupes)
128-
for (Groupe autreGroupe : o.groupes) {
129-
result = groupe.getIntitule().compareTo(autreGroupe.getIntitule());
123+
result = Integer.compare(groupes.length, o.groupes.length);
124+
if (result != 0)
125+
return result;
126+
for (int i = 0; i < groupes.length; i++) {
127+
if (groupes[i] != o.groupes[i]) {
128+
result = groupes[i].getIntitule().compareTo(o.groupes[i].getIntitule());
130129
if (result != 0)
131130
return result;
132131
}
132+
}
133133
return intitule.compareTo(o.intitule);
134134
}
135135

@@ -143,8 +143,8 @@ public LocalDate getDate() {
143143
/**
144144
* @return {@code String[]} les professeurs organisant le cours
145145
*/
146-
public String[] getProf() {
147-
return prof;
146+
public Professeur[] getProfesseurs() {
147+
return professeurs;
148148
}
149149

150150
/**
@@ -194,8 +194,8 @@ public String getIntitule() {
194194
@Override
195195
public String toString() {
196196
return intitule.toUpperCase(Locale.ROOT) + " :\n Date : " + date + "\n Commence à " + heureDebut + ", finit à "
197-
+ heureFin + "\n Enseignant :" + Arrays.toString(prof) + " \n Localisation : " + lieu + " \n Groupe : "
198-
+ Arrays.toString(groupes);
197+
+ heureFin + "\n Enseignant :" + Arrays.toString(professeurs) + " \n Localisation : " + lieu
198+
+ " \n Groupe : " + Arrays.toString(groupes);
199199
}
200200

201201
/*

src/main/java/fr/umontp/edt/EmploiDuTemps.java

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @author emerick-biron
3636
* @author MathieuSoysal
37-
* @version 1.0.0
37+
* @version 1.2.0
3838
*/
3939
@Deprecated(forRemoval = false)
4040
public final class EmploiDuTemps implements InterfaceEmploiDuTemps {
@@ -134,17 +134,16 @@ public void actualiser() {
134134
}
135135

136136
/**
137-
* Permet d'obtenir le planning correspondant à une date
137+
* Permet d'obtenir le planning correspondant à une date ou plusieurs dates.
138138
*
139-
* @param date date pour laquelle on veut obtenir le planning
139+
* @param dates dates pour lesquelles on veut obtenir le planning.
140140
* @return {@code Planning} correspondant
141-
* @since 1.0
142-
*
143141
* @see Planning
142+
* @see Planning#getPlanningOf(LocalDate...)
144143
*/
145144
@Override
146-
public Planning getPlanningOf(LocalDate date) {
147-
return planningEmploisDuTemps.getPlanningOf(date);
145+
public Planning getPlanningOf(LocalDate... dates) {
146+
return planningEmploisDuTemps.getPlanningOf(dates);
148147
}
149148

150149
/**
@@ -164,17 +163,48 @@ public Planning getPlanningOf(LocalDate date, Groupe groupe) {
164163
}
165164

166165
/**
167-
* Permet d'obtenir le planning correspondant à un groupe
166+
* Permet d'obtenir le planning correspondant à un groupe ou plusieurs groupe.
168167
*
169-
* @param groupe groupe dont on veut obtenir le planning
168+
* @param groupes groupes dont on veut obtenir le planning
170169
* @return planning correspondant
171-
* @since 1.0
172-
*
173170
* @see Groupe
174171
* @see Planning
172+
* @see Planning#getPlanningOf(Groupe...)
173+
*/
174+
@Override
175+
public Planning getPlanningOf(Groupe... groupes) {
176+
return planningEmploisDuTemps.getPlanningOf(groupes);
177+
}
178+
179+
/**
180+
* Permet d'obtenir le planning correspondant à un professeur ou plusieurs
181+
* professeurs
182+
*
183+
* @param professeurs professeurs dont on veut obtenir le planning
184+
* @return planning correspondant
185+
* @since 1.1
186+
*
187+
* @see Professeur
188+
* @see Planning
189+
* @see Planning#getPlanningOf(Professeur...)
190+
*/
191+
@Override
192+
public Planning getPlanningOf(Professeur... professeurs) {
193+
return planningEmploisDuTemps.getPlanningOf(professeurs);
194+
}
195+
196+
/**
197+
* Permet d'obtenir le planning correspondant au {@link PlanningFiltreur}
198+
*
199+
* @param planningFiltreur filtrant le planning
200+
* @return planning correspondant au filtre
201+
* @since 1.2.0
202+
*
203+
* @see PlanningFiltreur
204+
* @see Planning
175205
*/
176206
@Override
177-
public Planning getPlanningOf(Groupe groupe) {
178-
return planningEmploisDuTemps.getPlanningOf(groupe);
207+
public Planning getPlanningOf(PlanningFiltreur planningFiltreur) {
208+
return planningEmploisDuTemps.getPlanningOf(planningFiltreur);
179209
}
180210
}

0 commit comments

Comments
 (0)