-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
e.elhjoujy
committed
Oct 23, 2023
1 parent
77df404
commit d53681a
Showing
27 changed files
with
464 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ma.yc.airafraik.entities; | ||
|
||
import jakarta.persistence.*; | ||
|
||
@Entity | ||
@Table(name = "bagage") | ||
public class BagageEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private int id ; | ||
|
||
private double poids ; | ||
@ManyToOne | ||
private ReservationEntity reservation ; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
package ma.yc.airafraik.service; | ||
|
||
import ma.yc.airafraik.entities.ReservationEntity; | ||
import ma.yc.airafraik.enums.ReservationStatus; | ||
|
||
import java.util.HashMap; | ||
|
||
public interface ReservationService { | ||
public double confirmationReservation(ReservationEntity reservationEntity); | ||
public double annulationReservation(ReservationEntity reservationEntity); | ||
public ReservationEntity annulationReservation(ReservationEntity reservationEntity); | ||
public boolean annulationReservation(String numeroReservation); | ||
public boolean envoyerEmail(ReservationEntity reservationEntity); | ||
|
||
int statisticsReservation(ReservationStatus reservationStatus, HashMap<String, String> conditions); | ||
} |
5 changes: 3 additions & 2 deletions
5
.../airafraik/service/SearchVolsService.java → .../ma/yc/airafraik/service/VolsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
package ma.yc.airafraik.service; | ||
|
||
import ma.yc.airafraik.entities.ReservationEntity; | ||
import ma.yc.airafraik.entities.VolEntity; | ||
|
||
import java.util.Collection; | ||
|
||
public interface SearchVolsService { | ||
public interface VolsService { | ||
|
||
|
||
public Collection<VolEntity> searchVols(String villeDepart, String villeArrivee, String dateDepart, String dateArrivee, String nombrePassagers); | ||
|
||
VolEntity searchVolParId(String id); | ||
|
||
Collection<VolEntity> consulterVols(); | ||
|
||
boolean deleteVol(String idVol); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
package ma.yc.airafraik.service.impl; | ||
|
||
import ma.yc.airafraik.FunctionalTest.Client.ConfirmationReservationEtEnvoyeEmail; | ||
import ma.yc.airafraik.core.EmailProvider; | ||
import ma.yc.airafraik.core.Print; | ||
import ma.yc.airafraik.core.Util; | ||
import ma.yc.airafraik.dao.Impl.ReservationDaoImpl; | ||
import ma.yc.airafraik.dao.ReservationDao; | ||
import ma.yc.airafraik.entities.ReservationEntity; | ||
import ma.yc.airafraik.entities.VolEntity; | ||
import ma.yc.airafraik.enums.ReservationStatus; | ||
import ma.yc.airafraik.enums.ReserveType; | ||
import ma.yc.airafraik.service.PaiementService; | ||
import ma.yc.airafraik.service.ReservationService; | ||
|
||
import java.awt.font.TextHitInfo; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
|
||
public class ReservationServiceImpl implements ReservationService { | ||
|
||
private PaiementService paiementService ; | ||
|
@@ -59,24 +68,105 @@ public double confirmationReservation(ReservationEntity reservationEntity) { | |
return 0; | ||
}else { | ||
//TODO : SEEND EMAIL TO CLIENT WITH HIS RESERVATION CODE AND PDF FILE | ||
this.envoyerEmail(reservationEntity); | ||
if (this.envoyerEmail(reservationEntity)) | ||
{ | ||
Print.log("Email sent successfully"); | ||
}else { | ||
Print.log("Email not sent"); | ||
throw new RuntimeException("Email not sent"); | ||
} | ||
|
||
} | ||
|
||
return totalCost; | ||
} | ||
|
||
@Override | ||
public double annulationReservation(ReservationEntity reservationEntity) { | ||
public ReservationEntity annulationReservation(ReservationEntity reservationEntity) { | ||
//TODO : annuler sa réservation après la confirmation de son vol dans le cas d'annulation: | ||
// 8% des frais est retenue pour la société AirAfrika > 24h avant le vol | ||
|
||
return 1; | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean envoyerEmail(ReservationEntity reservationEntity) { | ||
public boolean annulationReservation(String numeroReservation) { | ||
|
||
if (numeroReservation == null){ | ||
return false; | ||
} | ||
//TODO : annuler sa réservation après la confirmation de son vol dans le cas d'annulation: | ||
// 8% des frais est retenue pour la société AirAfrika > 24h avant le vol | ||
|
||
Collection<ReservationEntity> reservationEntities = this.reservationDao.consulterReservations(numeroReservation); | ||
if (reservationEntities == null){ | ||
return false; | ||
} | ||
for (ReservationEntity reservationEntity : reservationEntities){ | ||
if (reservationEntity == null){ | ||
return false; | ||
} | ||
if (reservationEntity.getStatus() == ReservationStatus.CONFIRMER || reservationEntity.getStatus() == ReservationStatus.EN_ATTENTE){ | ||
//TODO : THE CLIENT CAN'T CANCEL HIS RESERVATION AFTER 24H BEFORE THE FLIGHT | ||
reservationEntity.setStatus(ReservationStatus.ANNULER); | ||
|
||
for (VolEntity vol : reservationEntity.getVolEntities()){ | ||
if (vol == null){ | ||
return false; | ||
} | ||
if (vol.getDateDepart().before(Util.addHours(24))){ | ||
return false; | ||
}else { | ||
//TODO : THE CLIENT WILL PAY 8% OF THE TOTAL COST OF THE FLIGHT | ||
double totalCost = reservationEntity.getPrixTotal(); | ||
double cost = totalCost * 0.08; | ||
reservationEntity.setPrixTotal(totalCost - cost); | ||
return this.reservationDao.annulerReservation(reservationEntity); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public boolean envoyerEmail(ReservationEntity reservationEntity) { | ||
if (reservationEntity == null){ | ||
return false; | ||
} | ||
String email = "[email protected]"; | ||
String subject = "Confirmation de votre réservation"; | ||
String message = "Bonjour Mr/Mme "+reservationEntity.getClient().getNom()+" "+reservationEntity.getClient().getPrenom()+"\n" + | ||
"Nous vous confirmons votre réservation de vol avec la compagnie Air Afraik\n" + | ||
"Votre code de réservation est : "+reservationEntity.getCode()+"\n" + | ||
"Merci de votre confiance\n" + | ||
"Cordialement\n" + | ||
"Air Afraik"; | ||
|
||
|
||
return EmailProvider.sendMail(message,subject,email); | ||
|
||
} | ||
|
||
@Override | ||
public int statisticsReservation(ReservationStatus reservationStatus,HashMap<String, String> conditions) { | ||
|
||
|
||
//TODO : THE CLIENT WIL CHOOSE TWO DATE CALLED DATE_1 AND DATE_2 FROM THE CALENDER | ||
|
||
|
||
if (reservationStatus == null || conditions == null){ | ||
return 0; | ||
} | ||
|
||
ArrayList<ReservationEntity> reservationEntities = | ||
reservationDao.AfficheLesStatistiques(conditions, reservationStatus); | ||
|
||
|
||
return reservationEntities.size(); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.