Skip to content

Commit

Permalink
commit : javadoc done and generated
Browse files Browse the repository at this point in the history
  • Loading branch information
fishe authored and fishe committed Jul 25, 2021
1 parent 8ea8a28 commit e0bafd6
Show file tree
Hide file tree
Showing 25 changed files with 735 additions and 161 deletions.
4 changes: 4 additions & 0 deletions src/Controleur/CarListAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
*/
public class CarListAccess {

/**
* connection with the database
* @return null
*/
public static Connection getConnection(){
Connection conn;
try {
Expand Down
24 changes: 12 additions & 12 deletions src/Controleur/CustomerDBQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
*/
public class CustomerDBQuery {

// Database URL Constant
// Database URL Constant
public final String url = "jdbc:mysql://localhost:3306/project"; //DB_URL is the database url to connect to. projet is the name of our project
public final String user = "root"; //user is your username to connect to the database
public final String password = ""; //password is your password to connect to the database
private Connection conn;

public CustomerDBQuery() {

}

/*
* Execute the query.
*/
public CustomerDBQuery() {}

/**
* Execute the query
* @param query
*/
public void run (String query){
getDatabaseConnection(); // assure connection to the database
try
Expand All @@ -47,10 +46,11 @@ public void run (String query){
}
}

/*
* Connection to the database
*/
private void getDatabaseConnection() //Create the connection to the database.

/**
* Connection to the database
*/
public void getDatabaseConnection() //Create the connection to the database.
{
try
{
Expand Down
75 changes: 55 additions & 20 deletions src/Controleur/DBGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import java.sql.*;

/**
*
* savig
* this class has various methods to get values from a table
* by havig in input a table data
* author : Savinien Godineau
*/
public class DBGetter {

Expand All @@ -20,14 +21,20 @@ public class DBGetter {
private Connection conn;

public DBGetter(){}

//The role of this method is to retrieve data from the vehicule table. It is necessary to define several parameters :
//the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
//the number of the line we are interested in (the number of the line corresponds to the ID of the vehicle, we can know it by looking at the database for example)
//the name of the column which is finally the name of the data we are trying to obtain.
//For example, if we want to know the name of the vehicle with ID 5, we can use the following command: GetString("vehicles", 5, "vehicle_name")+ " car")
//The method will return the name of the vehicle as a String.


/**
*The role of this method is to retrieve data from the vehicule table It is necessary to define several parameters :
*the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
*the number of the line we are interested in (the number of the line corresponds to the ID of the vehicle, we can know it by looking at the database for example)
*the name of the column which is finally the name of the data we are trying to obtain
*For example, if we want to know the name of the vehicle with ID 5, we can use the following command: GetString("vehicles", 5, "vehicle_name")+ " car")
*The method will return the name of the vehicle as a String
* @param table_name
* @param line_number
* @param column_name
* @return vehicule name
*/
public String GetString (String table_name, int line_number, String column_name){
getDatabaseConnection();
String data = "xxx";
Expand All @@ -54,6 +61,15 @@ public String GetString (String table_name, int line_number, String column_name)
return data;
}

/**
* This method will get the value of the
* primary key, in this example the primary
* key is the vehicule id (int)
* @param table_name
* @param carname
* @param column_name
* @return
*/
public int GetPrimaryID (String table_name, String carname, String column_name){
getDatabaseConnection();
String data = "xxx";
Expand All @@ -76,8 +92,18 @@ public int GetPrimaryID (String table_name, String carname, String column_name){
return Integer.parseInt(data);
}

//This method has exactly the same role and use as the previous one except that it will return an int and not a string, which is more convenient for processing.
public int GetInt (String table_name, int line_number, String column_name){
//

/**
* this method has exactly the same role and use as the previous
* one except that it will return an int and not a string,
* which is more convenient for processing.
* @param table_name
* @param line_number
* @param column_name
* @return
*/
public int GetInt (String table_name, int line_number, String column_name){
getDatabaseConnection();
String data = "xxx";
try
Expand Down Expand Up @@ -105,13 +131,19 @@ public int GetInt (String table_name, int line_number, String column_name){
return Integer.parseInt(data);
}

//The role of this method is to retrieve data from the person table. It is necessary to define several parameters :
//the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
//the Username value of the user we are interested in
//the name of the column which is finally the name of the data we are trying to obtain.
//For example, if we want to know the firstname of the User called Sav, we can use the following command : GetStringUser("person", "Sav", "firstname")
//The method will return the firstname of the User called Sav as a String.
public String GetStringUser (String table_name, String username, String column_name){
/**
*The role of this method is to retrieve data from the person table It is necessary to define several parameters :
*the name of the table in which the data to be acquired is located, we could do without this parameter but it allows a better readability
*the Username value of the user we are interested in
*the name of the column which is finally the name of the data we are trying to obtain
*For example, if we want to know the firstname of the User called Sav, we can use the following command : GetStringUser("person", "Sav", "firstname")
*The method will return the firstname of the User called Sav as a String
*@param table_name
* @param username
* @param column_name
* @return primary key value
*/
public String GetStringUser (String table_name, String username, String column_name){
getDatabaseConnection();
String data = "xxx";
try
Expand All @@ -137,7 +169,10 @@ public String GetStringUser (String table_name, String username, String column_n
return data;
}

public void getDatabaseConnection() //Create the connection to the database.
/**
*Create the connection to the database.
*/
public void getDatabaseConnection()
{
try
{
Expand All @@ -151,7 +186,7 @@ public void getDatabaseConnection() //Create the connection to the database.
}

//This method is not important, it just allows a better readability.
private int mineone(int a){
private int mineone(int a){
return a-1;
}
}
2 changes: 1 addition & 1 deletion src/Controleur/ExceptionAcceptConditions.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import javax.swing.JOptionPane;

/**
This personalized exception will be excecuted if
*This personalized exception will be excecuted if
* the customer has not accepted the general conditions
* of the application
* author Paul Fisher
Expand Down
5 changes: 3 additions & 2 deletions src/Controleur/ExceptionCarNameWrong.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import javax.swing.JOptionPane;

/**
*
* @author fishe
* this personalized exception will be excecuted
* if the car name entered by the customer is wrong
* author Paul fisher
*/
public class ExceptionCarNameWrong extends Exception {

Expand Down
5 changes: 3 additions & 2 deletions src/Controleur/ExceptionCarNotChoosen.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import javax.swing.JOptionPane;

/**
*
* @author fishe
* this personalized exception will be excecuted
* if no car has been entered
* Paul fisher
*/
public class ExceptionCarNotChoosen extends Exception {

Expand Down
6 changes: 4 additions & 2 deletions src/Controleur/FXMLAccountCheckCustomerController.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class FXMLAccountCheckCustomerController {
@FXML
private Button m_closeAccountCheck;



@FXML
void onClickedChoice(ActionEvent event) throws IOException {
if(event.getSource() == m_buttonYes){ // if the customer has already a account
Expand All @@ -49,14 +51,14 @@ void onClickedChoice(ActionEvent event) throws IOException {
window.setScene(tableViewScene);
window.centerOnScreen();
window.show();
} else if(event.getSource() == m_backAccountCheck){
} else if(event.getSource() == m_backAccountCheck){ // go back to person selection
Parent tableViewParent = FXMLLoader.load(getClass().getResource("/View/FXMLSelectionPersonType.fxml"));
Scene tableViewScene = new Scene(tableViewParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.centerOnScreen();
window.show();
} else if(event.getSource() == m_closeAccountCheck){
} else if(event.getSource() == m_closeAccountCheck){ // close app
JOptionPane.showMessageDialog(null, "The application is about to close","information", JOptionPane.INFORMATION_MESSAGE);
exit();
}
Expand Down
105 changes: 53 additions & 52 deletions src/Controleur/FXMLAddCarToListController.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,70 +60,71 @@ public class FXMLAddCarToListController {
void ActionAddCar(ActionEvent event) throws IOException {

// optimization
if(event.getSource() == m_backAddCar){
if(event.getSource() == m_backAddCar){ // go back
Parent tableViewParent = FXMLLoader.load(getClass().getResource("/View/FXMLChoiceActionEmployee.fxml"));
Scene tableViewScene = new Scene(tableViewParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.centerOnScreen();
window.show();
} else if(event.getSource() == m_exitAddCar){
} else if(event.getSource() == m_exitAddCar){ // exit the app
exit();
}

try{
if(event.getSource() == m_addCar){

LocalDate first = m_firstDate.getValue(); // gets the first date
LocalDate last = m_lastDate.getValue(); // gets the last day
LocalDate current = LocalDate.now();
// exception handling
if(m_vehiculeID.getText().isEmpty()){
throw new ExceptionVehiculeIDEmpty();
} else if(m_vehiculeName.getText().isEmpty()){
throw new ExceptionVehiculeNameEmpty();
} else if(m_discount.getText().isEmpty()){
throw new ExceptionVehiculeDiscountEmpty();
} else if(m_rentalPrice.getText().isEmpty()){
throw new ExceptionVehiculePriceEmpty();
} else if(first == null && last == null){
throw new ExceptionDatesEmpty();
} else if(first == null){
throw new ExceptionDateStartEmpty();
} else if(last == null){
throw new ExceptionDateEndEmpty();
} else if(last.isBefore(first)){
throw new ExceptionDateLastBeforeFirst();
} else if(first.isBefore(current)){
throw new ExceptionDateStartBeforeCurrent();
}
else{ // if no error has exception has been thrown..
String id = m_vehiculeID.getText();
String name = m_vehiculeName.getText();
String discount = m_discount.getText();
String rental = m_rentalPrice.getText();

// convertion to int before adding on vehicule table
int idToInt = Integer.parseInt(id);
int discountToInt = Integer.parseInt(discount);
int rentalToInt = Integer.parseInt(rental);


// adds the new information in the table
CustomerDBQuery dataEnter = new CustomerDBQuery();
dataEnter.run("INSERT INTO `vehicules` (`Vehicule_id`, `vehicule_name`, `first_date`, `last_date`, `discount`, `rental_price`) VALUES ('"+idToInt+"', '"+name+"' , '"+first+"' , '"+last+"' , '"+discountToInt+"', '"+rentalToInt+"')");

JOptionPane.showMessageDialog(null, "the car has been added","info employee", JOptionPane.INFORMATION_MESSAGE);


Parent tableViewParent = FXMLLoader.load(getClass().getResource("/View/FXMLChoiceActionEmployee.fxml"));
Scene tableViewScene = new Scene(tableViewParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.centerOnScreen();
}

LocalDate first = m_firstDate.getValue(); // gets the first date
LocalDate last = m_lastDate.getValue(); // gets the last day
LocalDate current = LocalDate.now();
// exception handling
if(m_vehiculeID.getText().isEmpty()){
throw new ExceptionVehiculeIDEmpty();
} else if(m_vehiculeName.getText().isEmpty()){
throw new ExceptionVehiculeNameEmpty();
} else if(m_discount.getText().isEmpty()){
throw new ExceptionVehiculeDiscountEmpty();
} else if(m_rentalPrice.getText().isEmpty()){
throw new ExceptionVehiculePriceEmpty();
} else if(first == null && last == null){
throw new ExceptionDatesEmpty();
} else if(first == null){
throw new ExceptionDateStartEmpty();
} else if(last == null){
throw new ExceptionDateEndEmpty();
} else if(last.isBefore(first)){
throw new ExceptionDateLastBeforeFirst();
} else if(first.isBefore(current)){
throw new ExceptionDateStartBeforeCurrent();
}
else{ // if no error has exception has been thrown..
String id = m_vehiculeID.getText();
String name = m_vehiculeName.getText();
String discount = m_discount.getText();
String rental = m_rentalPrice.getText();

// convertion to int before adding on vehicule table
int idToInt = Integer.parseInt(id);
int discountToInt = Integer.parseInt(discount);
int rentalToInt = Integer.parseInt(rental);


// adds the new information in the table
CustomerDBQuery dataEnter = new CustomerDBQuery();
dataEnter.run("INSERT INTO `vehicules` (`Vehicule_id`, `vehicule_name`, `first_date`, `last_date`, `discount`, `rental_price`) VALUES ('"+idToInt+"', '"+name+"' , '"+first+"' , '"+last+"' , '"+discountToInt+"', '"+rentalToInt+"')");

JOptionPane.showMessageDialog(null, "the car has been added","info employee", JOptionPane.INFORMATION_MESSAGE);

Parent tableViewParent = FXMLLoader.load(getClass().getResource("/View/FXMLChoiceActionEmployee.fxml"));
Scene tableViewScene = new Scene(tableViewParent);
Stage window = (Stage) ((Node)event.getSource()).getScene().getWindow();
window.setScene(tableViewScene);
window.centerOnScreen();
}

} // exception code excecuted..
} catch (ExceptionDatesEmpty ex) {
}
} catch (ExceptionDatesEmpty ex) { // exception code excecuted..
ex.getMessage();
} catch (ExceptionDateStartEmpty ex) {
ex.getMessage();
Expand Down
Loading

0 comments on commit e0bafd6

Please sign in to comment.