diff --git a/src/main/java/controller/AddRemovePatientCondition.java b/src/main/java/controller/AddRemovePatientCondition.java new file mode 100644 index 0000000..0bdf98b --- /dev/null +++ b/src/main/java/controller/AddRemovePatientCondition.java @@ -0,0 +1,38 @@ +package controller; + +import model.service.condition.ConditionManager; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + + +@WebServlet("/AddRemovePatientCondition") +public class AddRemovePatientCondition extends HttpServlet { + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { + String referer = request.getHeader("Referer"); + ConditionManager conditionService= new ConditionManager(); + + int idPatient = Integer.parseInt(request.getParameter("idPatient")); + int idCondition = Integer.parseInt(request.getParameter("idCondition")); + + String operation= request.getParameter("operation"); + if (operation.equals("Rimuovi")) //REMOVE + { + conditionService.RemoveConditionPatient(idCondition,idPatient); + } + if (operation.equals("Aggiungi")) //ADD + { + int severity= Integer.parseInt(request.getParameter("severity")); + conditionService.AddConditionPatient(idCondition,idPatient,severity); + } + + response.sendRedirect(referer); + + } + +} diff --git a/src/main/java/controller/Login.java b/src/main/java/controller/Login.java index a32856d..b082292 100644 --- a/src/main/java/controller/Login.java +++ b/src/main/java/controller/Login.java @@ -2,6 +2,7 @@ import model.entity.PersonalInfo; import model.entity.User; +import model.entity.UserInfo; import model.service.login.Authenticator; import model.service.user.UserData; import model.service.user.UserRegistry; @@ -12,6 +13,7 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import java.io.IOException; +import java.util.ArrayList; @WebServlet("/login") public class Login extends HttpServlet { @@ -35,16 +37,15 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) int result = authService.authenticate(email, password); if (result > 0) { - // Login success, defining its Session attributes - setSessionAttributes(result,request); - response.sendRedirect("JSP/welcome.jsp"); + // Login success, defining its Session attributes and the redirect page + response.sendRedirect(setSessionAttributes(result, request)); } else { // Login failed, redirect back to the login page response.sendRedirect("JSP/login.jsp?error=1"); } } - private void setSessionAttributes(int id, HttpServletRequest request){ + private String setSessionAttributes(int id, HttpServletRequest request){ HttpSession session = request.getSession(); userData = new UserData(); @@ -57,12 +58,25 @@ private void setSessionAttributes(int id, HttpServletRequest request){ session.setAttribute("name", personalInfo.getFirstname()); if(!userData.isTherapist(user)) { + session.setAttribute("type", "patient"); session.setAttribute("therapist", user.getIdTherapist()); + return "JSP/homePatient.jsp"; } else { + setPatientsInfo(session); session.setAttribute("type", "therapist"); + return "JSP/homeTherapist.jsp"; } } + private void setPatientsInfo(HttpSession session){ + + UserRegistry registry = new UserRegistry(); + + PersonalInfo infoLogged = registry.getPersonalInfo(((Integer) session.getAttribute("id"))); + + session.setAttribute("NameSurnameLogged", infoLogged != null ? infoLogged.getFirstname() + " " + infoLogged.getLastname() : null); + + } +} -} \ No newline at end of file diff --git a/src/main/java/model/DAO/DAOCondition.java b/src/main/java/model/DAO/DAOCondition.java new file mode 100644 index 0000000..83cb60a --- /dev/null +++ b/src/main/java/model/DAO/DAOCondition.java @@ -0,0 +1,224 @@ +package model.DAO; + +import model.entity.Condition; +import model.entity.PatientCondition; +import model.entity.User; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; + +public class DAOCondition { + private Connection connection; + public DAOCondition(Connection connection) {this.connection=connection;} + + public DAOCondition() { + try{ + this.connection=DAOConnection.getConnection(); + }catch (SQLException e) { + e.printStackTrace(); + } + } + + private Condition getConditionFromResultSet(ResultSet resultSet) throws SQLException { + Condition c = new Condition(); + + c.setIdCondition(resultSet.getInt("ID_condition")); + c.setDisorderDescription(resultSet.getString("DisorderDescription")); + c.setDisorderName(resultSet.getString("DisorderName")); + c.setSeverity(-1); + + return c; + } + + private Condition getPeronalConditionFromResultSet(ResultSet resultSet) throws SQLException { + Condition c = new Condition(); + + c.setIdCondition(resultSet.getInt("ID_condition")); + c.setDisorderDescription(resultSet.getString("DisorderDescription")); + c.setDisorderName(resultSet.getString("DisorderName")); + c.setSeverity(resultSet.getInt("Severity")); + + return c; + } + + private PatientCondition getPatientConditionFromResultSet(ResultSet resultSet) throws SQLException { + PatientCondition pc = new PatientCondition(); + + pc.setIdCondition(resultSet.getInt("ID_condition")); + pc.setIdPatient(resultSet.getInt("ID_patient")); + pc.setSeverity(resultSet.getInt("Severity")); + + return pc; + } + + public ArrayList getConditionsOfPatient(int id_patient) { + + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + ArrayList list_PersonalCondition=new ArrayList<>(); + try { + + connection = connection.isClosed() ? DAOConnection.getConnection():connection; + String query = null; + + query = "SELECT c.ID_Condition,c.DisorderName, c.DisorderDescription, pc.Severity\n" + + "FROM `condition` c\n" + + "JOIN PatientCondition pc ON c.ID_condition = pc.ID_condition\n" + + "WHERE pc.ID_patient = ?;"; + + preparedStatement = connection.prepareStatement(query); + preparedStatement.setObject(1, id_patient); + + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) { + list_PersonalCondition.add(getPeronalConditionFromResultSet(resultSet)); + } + + return list_PersonalCondition; + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } finally { + try { + if (resultSet != null) resultSet.close(); + if (preparedStatement != null) preparedStatement.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + return null; // or you may throw an exception here + } + + public ArrayList getConditionsNOTOfPatient(int id_patient) { + + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + ArrayList list_PersonalCondition=new ArrayList<>(); + try { + + connection = connection.isClosed() ? DAOConnection.getConnection():connection; + String query = null; + + query = "SELECT c.*\n" + + "FROM `condition` c\n" + + "LEFT JOIN PatientCondition pc ON c.ID_condition = pc.ID_condition AND pc.ID_patient = ?\n" + + "WHERE pc.ID_patient IS NULL\n" + + "ORDER BY c.DisorderName;"; + + preparedStatement = connection.prepareStatement(query); + preparedStatement.setObject(1, id_patient); + + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) { + list_PersonalCondition.add(getConditionFromResultSet(resultSet)); + } + return list_PersonalCondition; + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } finally { + try { + if (resultSet != null) resultSet.close(); + if (preparedStatement != null) preparedStatement.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + return null; // or you may throw an exception here + } + + + public boolean AddConditionPatient(int ID_condition, int ID_patient, int Severity) { + + PreparedStatement preparedStatementPersonalInfo = null; + + try { + connection = connection.isClosed() ? DAOConnection.getConnection():connection; + connection.setAutoCommit(false); // Start a transaction + + // Insert user data into personal_info table + String queryAnagrafica = "INSERT INTO PatientCondition (ID_condition, ID_patient, Severity)\n" + + "VALUES (?, ?, ?)"; + preparedStatementPersonalInfo = connection.prepareStatement(queryAnagrafica); + preparedStatementPersonalInfo.setInt(1, ID_condition); + preparedStatementPersonalInfo.setInt(2, ID_patient); + preparedStatementPersonalInfo.setInt(3, Severity); + preparedStatementPersonalInfo.executeUpdate(); + + connection.commit(); // Commit the transaction + return true; // User created successfully + + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + try { + if (connection != null) { + connection.rollback(); // Rollback the transaction in case of an exception + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } finally { + try { + if (preparedStatementPersonalInfo != null) preparedStatementPersonalInfo.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + + return false; // Default to false if an exception occurs + } + + public boolean RemoveConditionPatient(int ID_condition, int ID_patient) { + + PreparedStatement preparedStatementPersonalInfo = null; + + try { + connection = connection.isClosed() ? DAOConnection.getConnection():connection; + connection.setAutoCommit(false); // Start a transaction + + // Insert user data into personal_info table + String queryAnagrafica = "DELETE FROM PatientCondition\n" + + "WHERE ID_condition = ? AND ID_patient = ?;"; + preparedStatementPersonalInfo = connection.prepareStatement(queryAnagrafica); + preparedStatementPersonalInfo.setInt(1, ID_condition); + preparedStatementPersonalInfo.setInt(2, ID_patient); + preparedStatementPersonalInfo.executeUpdate(); + + connection.commit(); // Commit the transaction + return true; // User created successfully + + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + try { + if (connection != null) { + connection.rollback(); // Rollback the transaction in case of an exception + } + } catch (SQLException ex) { + ex.printStackTrace(); + } + } finally { + try { + if (preparedStatementPersonalInfo != null) preparedStatementPersonalInfo.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + + return false; // Default to false if an exception occurs + } +} diff --git a/src/main/java/model/DAO/DAOExercise.java b/src/main/java/model/DAO/DAOExercise.java index 014bdb1..727782e 100644 --- a/src/main/java/model/DAO/DAOExercise.java +++ b/src/main/java/model/DAO/DAOExercise.java @@ -8,6 +8,20 @@ * The DAOExercise class provides methods for retrieving Exercise information from a database. */ public class DAOExercise { + + private Connection connection; + + public DAOExercise(Connection connection) { + this.connection = connection; + } + + public DAOExercise() { + try { + this.connection = DAOConnection.getConnection(); + } catch (SQLException e) { + e.printStackTrace(); + } + } /** * This method extracts Exercise object data from a ResultSet * @@ -39,12 +53,11 @@ private static Exercise extractExerciseFromResultSet(ResultSet resultSet) throws */ public Exercise getExerciseByPk(int userID, int exerciseID, Date insertDate) { String query = "SELECT * FROM exercise WHERE ID_user = ? AND ID_exercise = ? AND InsertionDate = ?"; - Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { - connection = DAOConnection.getConnection(); + connection = connection.isClosed() ? DAOConnection.getConnection() : connection; preparedStatement = connection.prepareStatement(query); preparedStatement.setInt(1, userID); preparedStatement.setInt(2, exerciseID); @@ -73,11 +86,10 @@ public Exercise getExerciseByPk(int userID, int exerciseID, Date insertDate) { public boolean setExerciseExecution(int userID, int exerciseID, Date insertDate, Blob execution) { String query = "UPDATE exercise SET Execution = ? WHERE ID_user = ? AND ID_exercise = ? AND InsertionDate = ?;"; - Connection connection = null; PreparedStatement preparedStatement = null; try { - connection = DAOConnection.getConnection(); + connection = connection.isClosed() ? DAOConnection.getConnection() : connection; preparedStatement = connection.prepareStatement(query); preparedStatement.setBlob(1, execution); preparedStatement.setInt(2, userID); @@ -101,11 +113,10 @@ public boolean setExerciseExecution(int userID, int exerciseID, Date insertDate, public boolean setExerciseEvaluation(int userID, int exerciseID, Date insertDate, int evaluation) { String query = "UPDATE exercise SET Evaluation = ? WHERE ID_user = ? AND ID_exercise = ? AND InsertionDate = ?;"; - Connection connection = null; PreparedStatement preparedStatement = null; try { - connection = DAOConnection.getConnection(); + connection = connection.isClosed() ? DAOConnection.getConnection() : connection; preparedStatement = connection.prepareStatement(query); preparedStatement.setInt(1, evaluation); preparedStatement.setInt(2, userID); @@ -129,11 +140,10 @@ public boolean setExerciseEvaluation(int userID, int exerciseID, Date insertDate public boolean setExerciseCompletionDate(int userID, int exerciseID, Date insertDate, Date completion) { String query = "UPDATE exercise SET CompletionDate = ? WHERE ID_user = ? AND ID_exercise = ? AND InsertionDate = ?;"; - Connection connection = null; PreparedStatement preparedStatement = null; try { - connection = DAOConnection.getConnection(); + connection = connection.isClosed() ? DAOConnection.getConnection() : connection; preparedStatement = connection.prepareStatement(query); preparedStatement.setDate(1, completion); preparedStatement.setInt(2, userID); diff --git a/src/main/java/model/DAO/DAOExerciseGlossary.java b/src/main/java/model/DAO/DAOExerciseGlossary.java index 6fa9e73..9f3b64b 100644 --- a/src/main/java/model/DAO/DAOExerciseGlossary.java +++ b/src/main/java/model/DAO/DAOExerciseGlossary.java @@ -12,6 +12,20 @@ * The DAOExerciseGlossary class provides methods for retrieving ExerciseGlossary information from a database. */ public class DAOExerciseGlossary { + + private Connection connection; + + public DAOExerciseGlossary(Connection connection) { + this.connection = connection; + } + + public DAOExerciseGlossary() { + try { + this.connection = DAOConnection.getConnection(); + } catch (SQLException e) { + e.printStackTrace(); + } + } /** * This method extracts Exercise object data from a ResultSet * @@ -41,12 +55,11 @@ private static ExerciseGlossary extractExerciseFromResultSet(ResultSet resultSet */ public ExerciseGlossary getExerciseByCode(int code) { String query = "SELECT * FROM exercise_glossary WHERE ID_exercise = ?"; - Connection connection = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { - connection = DAOConnection.getConnection(); + connection = connection.isClosed() ? DAOConnection.getConnection() : connection; preparedStatement = connection.prepareStatement(query); preparedStatement.setInt(1, code); resultSet = preparedStatement.executeQuery(); diff --git a/src/main/java/model/DAO/DAOPersonalInfo.java b/src/main/java/model/DAO/DAOPersonalInfo.java index 1ff703b..23c2e2e 100644 --- a/src/main/java/model/DAO/DAOPersonalInfo.java +++ b/src/main/java/model/DAO/DAOPersonalInfo.java @@ -1,6 +1,7 @@ package model.DAO; import model.entity.PersonalInfo; +import model.entity.User; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/src/main/java/model/DAO/DAOUser.java b/src/main/java/model/DAO/DAOUser.java index f3f9c19..f3d9251 100644 --- a/src/main/java/model/DAO/DAOUser.java +++ b/src/main/java/model/DAO/DAOUser.java @@ -1,11 +1,13 @@ package model.DAO; import model.entity.User; +import model.entity.UserInfo; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.ArrayList; /** * DAOUser is a class that provides methods for accessing the User table in the database. @@ -431,4 +433,91 @@ public boolean deleteUserByIdOrEmail(Object idOrEmail) { // Default to false if an exception occurs return false; } + + public ArrayList getUsersByIdTherapist(int id) { + Connection connection = null; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + ArrayList list_user=new ArrayList<>(); + try { + + connection = DAOConnection.getConnection(); + String query = null; + + query = "SELECT * FROM user WHERE ID_Therapist = ?"; + + preparedStatement = connection.prepareStatement(query); + preparedStatement.setObject(1, id); + + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) { + list_user.add(getUserFromResultSet(resultSet)); + } + return list_user; + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } finally { + try { + if (resultSet != null) resultSet.close(); + if (preparedStatement != null) preparedStatement.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + return null; // or you may throw an exception here + } + + public ArrayList getUsersAndPersonalInfoByIdTherapist(int idTherapist) { + Connection connection = null; + PreparedStatement preparedStatement = null; + ResultSet resultSet = null; + ArrayList list_user=new ArrayList<>(); + + try { + connection = DAOConnection.getConnection(); + String query = null; + + query = "SELECT ID,Email,ActivationDate,Firstname,Lastname,DateOfBirth,Gender,Address,SSN,Phone FROM user,personal_info WHERE ID_Therapist = ? AND user.ID= personal_info.ID_USER;"; + + preparedStatement = connection.prepareStatement(query); + preparedStatement.setObject(1, idTherapist); + + resultSet = preparedStatement.executeQuery(); + + while (resultSet.next()) { + UserInfo u=new UserInfo(); + u.setId(resultSet.getInt("ID")); + u.setEmail(resultSet.getString("Email")); + u.setActivationDate(resultSet.getTimestamp("ActivationDate")); + u.setFirstname(resultSet.getString("Firstname")); + u.setLastname(resultSet.getString("Lastname")); + u.setDateOfBirth(resultSet.getDate("DateOfBirth")); + u.setGender(resultSet.getString("Gender")); + u.setAddress(resultSet.getString("Address")); + u.setSsn(resultSet.getString("SSN")); + u.setPhone(resultSet.getString("Phone")); + + list_user.add(u); + } + return list_user; + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } finally { + try { + if (resultSet != null) resultSet.close(); + if (preparedStatement != null) preparedStatement.close(); + DAOConnection.releaseConnection(connection); + } catch (SQLException e) { + // Handle the exception (e.g., log or throw) + e.printStackTrace(); + } + } + + return null; // or you may throw an exception here + } } diff --git a/src/main/java/model/entity/Condition.java b/src/main/java/model/entity/Condition.java index 5a9b62c..54fc8c2 100644 --- a/src/main/java/model/entity/Condition.java +++ b/src/main/java/model/entity/Condition.java @@ -5,8 +5,18 @@ public class Condition { private String disorderDescription; private String disorderName; + private int severity; + // Getter and Setter methods + public int getSeverity() { + return severity; + } + + public void setSeverity(int severity) { + this.severity = severity; + } + public int getIdCondition() { return idCondition; } diff --git a/src/main/java/model/entity/UserInfo.java b/src/main/java/model/entity/UserInfo.java new file mode 100644 index 0000000..7365fcb --- /dev/null +++ b/src/main/java/model/entity/UserInfo.java @@ -0,0 +1,113 @@ +package model.entity; + +import java.sql.Date; +import java.sql.Timestamp; + +public class UserInfo { + private int id; + private String email; + private Timestamp activationDate; + private String firstname; + private String lastname; + private Date dateOfBirth; + private String gender; + private String address; + private String ssn; + private String phone; + + public UserInfo() { + } + + public UserInfo(int id, String email, Timestamp activationDate, String firstname, String lastname, Date dateOfBirth, String gender, String address, String ssn, String phone) { + this.id = id; + this.email = email; + this.activationDate = activationDate; + this.firstname = firstname; + this.lastname = lastname; + this.dateOfBirth = dateOfBirth; + this.gender = gender; + this.address = address; + this.ssn = ssn; + this.phone = phone; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Timestamp getActivationDate() { + return activationDate; + } + + public void setActivationDate(Timestamp activationDate) { + this.activationDate = activationDate; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public Date getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(Date dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + public String getGender() { + return gender; + } + + public void setGender(String gender) { + this.gender = gender; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } +} diff --git a/src/main/java/model/service/condition/ConditionInterface.java b/src/main/java/model/service/condition/ConditionInterface.java new file mode 100644 index 0000000..3c516e3 --- /dev/null +++ b/src/main/java/model/service/condition/ConditionInterface.java @@ -0,0 +1,12 @@ +package model.service.condition; + +import model.entity.Condition; + +import java.util.ArrayList; + +public interface ConditionInterface { + ArrayList getConditionsOfPatient(int id_patient); + ArrayList getConditionsNOTOfPatient(int id_patient); + boolean AddConditionPatient(int ID_condition, int ID_patient, int Severity); + boolean RemoveConditionPatient(int ID_condition, int ID_patient); +} diff --git a/src/main/java/model/service/condition/ConditionManager.java b/src/main/java/model/service/condition/ConditionManager.java new file mode 100644 index 0000000..55ddd56 --- /dev/null +++ b/src/main/java/model/service/condition/ConditionManager.java @@ -0,0 +1,19 @@ +package model.service.condition; + +import model.DAO.DAOCondition; + +import java.util.ArrayList; +import java.util.concurrent.locks.Condition; + +public class ConditionManager implements ConditionInterface { + + DAOCondition c=new DAOCondition(); + + public ArrayList getConditionsOfPatient(int id_patient) { return c.getConditionsOfPatient(id_patient);} + + public ArrayList getConditionsNOTOfPatient(int id_patient) { return c.getConditionsNOTOfPatient(id_patient);} + + public boolean AddConditionPatient(int ID_condition, int ID_patient, int Severity) {return c.AddConditionPatient(ID_condition, ID_patient,Severity);} + + public boolean RemoveConditionPatient(int ID_condition, int ID_patient) {return c.RemoveConditionPatient(ID_condition,ID_patient);} +} diff --git a/src/main/java/model/service/user/UserData.java b/src/main/java/model/service/user/UserData.java index 12f772d..8ac170a 100644 --- a/src/main/java/model/service/user/UserData.java +++ b/src/main/java/model/service/user/UserData.java @@ -2,6 +2,10 @@ import model.DAO.DAOUser; import model.entity.User; +import model.entity.UserInfo; + +import java.util.ArrayList; +import model.entity.User; import java.sql.Connection; @@ -42,5 +46,6 @@ public String updateUser(int idUser, String Email, String address) { return db.updateUser(idUser, Email, address); } - + public ArrayList getUsersByIdTherapist(int ID_Therapist ){return db.getUsersByIdTherapist(ID_Therapist);} + public ArrayList getUsersAndPersonalInfoByIdTherapist(int ID_Therapist) {return db.getUsersAndPersonalInfoByIdTherapist(ID_Therapist);} } diff --git a/src/main/webapp/CSS/homeTherapist.css b/src/main/webapp/CSS/homeTherapist.css new file mode 100644 index 0000000..e683320 --- /dev/null +++ b/src/main/webapp/CSS/homeTherapist.css @@ -0,0 +1,526 @@ +.hoverable-row:hover { + background-color: #e6f7ff; /* Cambia il colore di sfondo quando il mouse passa sopra */ + cursor: pointer; /* Cambia il cursore quando il mouse passa sopra */ +} + +#searchInput { + padding: 8px; + border: 0px; + position: absolute; + width: 70%; + top: 10px; + left: 50px; + outline: none; +} + + +.table-container { + max-height: 500px; + overflow-y: auto; +} + +table { + width: 100%; + border-collapse: separate; + border-spacing: 0 10px; /* Imposta uno spazio vuoto tra le righe */ +} + +tr { + + text-align: center; /* Centra il testo orizzontalmente */ + vertical-align: middle; /* Centra verticalmente */ +} + +td { + + text-align: center; /* Centra il testo orizzontalmente */ + vertical-align: middle; /* Centra verticalmente */ +} + + +html { + margin: 0px; + height: 100%; +} + +body{ + margin: 0px; + height: 100%; + background-color: #52d1c6bd; + font-family: "Poppins", Helvetica, serif; +} + +a { + text-decoration: none; +} + +.element-home-logopedista { + + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 90%; + margin: 0 auto; +} + +.element-home-logopedista .div { + + width: 100vw; + height: 100vh; + position: relative; +} + +.element-home-logopedista .overlap { + position: absolute; + width: 124px; + height: 48px; + top: 36px; + left: 72vw; + background-image: url(../images/homeTherapist/rectangle-359.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .button-only-text { + display: inline-flex; + align-items: center; + justify-content: center; + font-size: 14px; + gap: 4px; + padding: 0px 4px; + position: relative; + top: 12px; + left: 12px; + border-radius: 9999px; +} + +.element-home-logopedista .button { + position: relative; + width: fit-content; + margin-top: -1px; + font-family: "Poppins", Helvetica; + font-weight: 500; + color: #199a8e; + font-size: 10px; + letter-spacing: 0; + line-height: 16px; + white-space: nowrap; + all: unset; + box-sizing: border-box; +} + +.element-home-logopedista .pop-up { + position: absolute; + width: 50vw; + height: 80vh; + top: 15vh; + left: 30vw; + background-color: #ffffff; + border-radius: 24px; +} + +.element-home-logopedista .text-wrapper-2 { + position: absolute; + width: 10vw; + top: 2vh; + left: 23vw; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 14px; + letter-spacing: 0; + line-height: normal; + white-space: nowrap; +} + +.element-home-logopedista .overlap-group { + position: absolute; + width: 600px; + height: 61px; + top: 54px; + left: 76px; +} + +.element-home-logopedista .doctor { + width: 499px; + height: 61px; + top: 0; + position: absolute; + left: 0; +} + +.element-home-logopedista .group { + height: 61px; + background-color: #ffffff; + border-radius: 6px; + border: 1px solid; + border-color: #221f1f1a; +} + +.element-home-logopedista .overlap-group-wrapper { + position: relative; + width: 282px; + height: 16px; + top: 20px; + left: 118px; +} + +.element-home-logopedista .overlap-group-2 { + position: relative; + width: 278px; + height: 16px; +} + +.element-home-logopedista .inizio-terapia-gg-mm { + position: absolute; + width: 164px; + top: 3px; + left: 114px; + text-shadow: 0px 4px 4px #00000040; + font-family: "Poppins", Helvetica; + font-weight: 500; + color: #221f1f66; + font-size: 7px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.element-home-logopedista .text-wrapper { + position: absolute; + width: 228px; + top: 0; + left: 0; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 10px; + letter-spacing: 0; + line-height: normal; +} + +.element-home-logopedista .others-progress { + position: absolute; + width: 43px; + height: 41px; + top: 9px; + left: 427px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .element-wrapper { + position: relative; + height: 41px; + background-image: url(../images/homeTherapist/ellipse-2.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .element { + position: relative; + top: 8px; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #199a8e; + font-size: 11px; + text-align: center; + letter-spacing: 0; + line-height: 24px; +} + +.element-home-logopedista .image { + position: absolute; + width: 47px; + height: 48px; + top: 6px; + left: 20px; + background-image: url(../images/homeTherapist/ellipse-28.png); + background-size: cover; + background-position: 50% 50%; +} + +.element-home-logopedista .overlap-2 { + position: absolute; + width: 507px; + height: 312px; + top: 136px; + left: 68px; +} + +.element-home-logopedista .doctor-2 { + width: 507px; + height: 312px; + top: 0; + position: absolute; + left: 0; +} + +.element-home-logopedista .group-wrapper { + position: absolute; + width: 499px; + height: 61px; + top: 0; + left: 8px; + background-color: #ffffff; + border-radius: 6px; + border: 1px solid; + border-color: #221f1f1a; +} + +.element-home-logopedista .div-wrapper { + position: absolute; + width: 499px; + height: 61px; + top: 87px; + left: 8px; +} + +.element-home-logopedista .doctor-3 { + position: absolute; + width: 499px; + height: 61px; + top: 174px; + left: 0; +} + +.element-home-logopedista .doctor-4 { + width: 499px; + height: 61px; + top: 251px; + position: absolute; + left: 0; +} + +.element-home-logopedista .overlap-wrapper { + top: 94px; + left: 435px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-2 { + top: 11px; + left: 436px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-3 { + top: 185px; + left: 435px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-4 { + top: 261px; + left: 437px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .image-2 { + position: absolute; + width: 47px; + height: 299px; + top: 8px; + left: 28px; +} + +.element-home-logopedista .ellipse { + position: absolute; + width: 47px; + height: 48px; + top: 0; + left: 0; + object-fit: cover; +} + +.element-home-logopedista .image-3 { + position: absolute; + width: 47px; + height: 213px; + top: 86px; + left: 0; +} + +.element-home-logopedista .image-4 { + position: absolute; + width: 47px; + height: 125px; + top: 88px; + left: 0; +} + +.element-home-logopedista .image-5 { + position: absolute; + width: 47px; + height: 48px; + top: 77px; + left: 0; + background-image: url(../images/homeTherapist/ellipse-28.png); + background-size: cover; + background-position: 50% 50%; +} + +.element-home-logopedista .overlap-3 { + position: absolute; + width: 116px; + height: 530px; + top: 40px; + left: 65px; +} + +.element-home-logopedista .rectangle-2 { + width: 98px; + height: 530px; + top: 0; + left: 0; + background-color: #ffffff; + position: absolute; + border-radius: 30px; +} + +.element-home-logopedista .group-2 { + position: absolute; + width: 24px; + height: 174px; + top: 161px; + left: 37px; +} + +.element-home-logopedista .iconly-light-outline { + position: absolute; + width: 24px; + height: 24px; + top: 0; + left: 0; +} + +.element-home-logopedista .home { + position: absolute; + width: 20px; + height: 22px; + top: 1px; + left: 2px; +} + +.element-home-logopedista .iconly-bold-calendar { + position: absolute; + width: 24px; + height: 24px; + top: 98px; + left: 0; +} + +.element-home-logopedista .iconly-light-message { + top: 49px; + position: absolute; + width: 24px; + height: 24px; + left: 0; +} + +.element-home-logopedista .iconly-light-profile { + top: 150px; + position: absolute; + width: 24px; + height: 24px; + left: 0; +} + +.element-home-logopedista .img { + position: absolute; + width: 47%; + height: 55px; + top: 400px; + left: 22px; +} + +.element-home-logopedista .logovettoriale { + position: absolute; + width: 63px; + height: 75px; + top: 39px; + left: 17px; + object-fit: cover; +} + +.element-home-logopedista .line { + position: absolute; + width: 75px; + height: 1px; + top: 132px; + left: 11px; + object-fit: cover; +} + +.element-home-logopedista .text-wrapper-3 { + position: absolute; + width: 102px; + top: 467px; + left: 0px; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 10px; + letter-spacing: 0; + text-align: center; /* Allinea il testo al centro orizzontalmente */ + line-height: normal; +} + +.element-home-logopedista .ellipse-2 { + position: absolute; + width: 10px; + height: 10px; + top: 450px; + left: 65px; +} + +.element-home-logopedista .material-symbols-wrapper { + position: absolute; + width: 340px; + height: 50px; + top: 35px; + left: 30vw; + background-image: url(../images/homeTherapist/rectangle-32.png); + background-size: 100% 100%; +} + +.element-home-logopedista .material-symbols { + position: absolute; + width: 24px; + height: 24px; + top: 13px; + left: 15px; +} + +.element-home-logopedista .img-wrapper { + position: absolute; + width: 175px; + height: 48px; + top: 36px; + left: 57vw; + background-color: #ffffff; + border-radius: 50px; +} + +.element-home-logopedista .material-symbols-2 { + position: absolute; + width: 17px; + height: 14px; + top: 11px; + left: 17px; +} diff --git a/src/main/webapp/CSS/homeTherapistGuide.css b/src/main/webapp/CSS/homeTherapistGuide.css new file mode 100644 index 0000000..034cc0c --- /dev/null +++ b/src/main/webapp/CSS/homeTherapistGuide.css @@ -0,0 +1,77 @@ +:root { + --x-8a-36-5e: rgba(178, 34, 34, 1); + --fuschia-100: rgba(178, 34, 34, 1); + --fuschia-80: rgba(232, 29, 29, 1); + --fuschia-60: rgba(252, 221, 236, 1); + --iris-100: rgba(93, 95, 239, 1); + --iris-80: rgba(120, 121, 241, 1); + --iris-60: rgba(165, 166, 246, 1); + --primary-2: rgba(58, 148, 231, 1); + --neutral-1: rgba(37, 37, 38, 1); + --header-1-font-family: "WorkSans-Bold", Helvetica; + --header-1-font-weight: 700; + --header-1-font-size: 34px; + --header-1-letter-spacing: -0.68px; + --header-1-line-height: normal; + --header-1-font-style: normal; + --header-2-font-family: "WorkSans-Bold", Helvetica; + --header-2-font-weight: 700; + --header-2-font-size: 20px; + --header-2-letter-spacing: -0.4px; + --header-2-line-height: normal; + --header-2-font-style: normal; + --body-font-family: "WorkSans-Regular", Helvetica; + --body-font-weight: 400; + --body-font-size: 13px; + --body-letter-spacing: -0.26px; + --body-line-height: normal; + --body-font-style: normal; + --jhjgjghj-font-family: "DroidSans-Regular", Helvetica; + --jhjgjghj-font-weight: 400; + --jhjgjghj-font-size: 14px; + --jhjgjghj-letter-spacing: 0px; + --jhjgjghj-line-height: 16px; + --jhjgjghj-font-style: normal; + --button-large-font-family: "Poppins-Medium", Helvetica; + --button-large-font-weight: 500; + --button-large-font-size: 18px; + --button-large-letter-spacing: 0px; + --button-large-line-height: 24px; + --button-large-font-style: normal; + --button-medium-font-family: "Poppins-SemiBold", Helvetica; + --button-medium-font-weight: 600; + --button-medium-font-size: 16px; + --button-medium-letter-spacing: 0px; + --button-medium-line-height: 20px; + --button-medium-font-style: normal; + --caption-12px-medium-font-family: "Poppins-Medium", Helvetica; + --caption-12px-medium-font-weight: 500; + --caption-12px-medium-font-size: 12px; + --caption-12px-medium-letter-spacing: 0px; + --caption-12px-medium-line-height: 16px; + --caption-12px-medium-font-style: normal; + --title-18px-semibold-font-family: "Poppins-SemiBold", Helvetica; + --title-18px-semibold-font-weight: 600; + --title-18px-semibold-font-size: 18px; + --title-18px-semibold-letter-spacing: 0px; + --title-18px-semibold-line-height: 24px; + --title-18px-semibold-font-style: normal; + --title-28px-semibold-font-family: "Poppins-SemiBold", Helvetica; + --title-28px-semibold-font-weight: 600; + --title-28px-semibold-font-size: 28px; + --title-28px-semibold-letter-spacing: 0px; + --title-28px-semibold-line-height: 36px; + --title-28px-semibold-font-style: normal; + --body-16px-medium-font-family: "Poppins-Medium", Helvetica; + --body-16px-medium-font-weight: 500; + --body-16px-medium-font-size: 16px; + --body-16px-medium-letter-spacing: 0px; + --body-16px-medium-line-height: 20px; + --body-16px-medium-font-style: normal; + --caption-10px-medium-font-family: "Poppins-Medium", Helvetica; + --caption-10px-medium-font-weight: 500; + --caption-10px-medium-font-size: 10px; + --caption-10px-medium-letter-spacing: 0px; + --caption-10px-medium-line-height: 16px; + --caption-10px-medium-font-style: normal; +} diff --git a/src/main/webapp/CSS/view_patient.css b/src/main/webapp/CSS/view_patient.css new file mode 100644 index 0000000..d386a03 --- /dev/null +++ b/src/main/webapp/CSS/view_patient.css @@ -0,0 +1,784 @@ +/*---ONE PATIENT----*/ +.singolo-paziente { + background-color: #52d1c6bd; + display: flex; + flex-direction: row; + justify-content: center; + width: 100%; +} + +.singolo-paziente .group-5 { + position: absolute; + width: 145px; + height: 38px; + top: 185px; + left: 68px; +} + +.singolo-paziente .overlap-3 { + position: relative; + width: 175px; + height: 38px; + top: 10vh; + left: 37vw; + background-image: url(../images/homeTherapist/rectangle-351.svg); + background-size: 100% 100%; +} + +.singolo-paziente .text-wrapper-2 { + position: absolute; + width: 107px; + top: 11px; + left: 36px; + font-family: "Poppins", Helvetica; + font-weight: 700; + color: #ffffff; + font-size: 11px; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .group-6 { + position: absolute; + width: 174px; + height: 39px; + top: 183px; + left: 415px; +} + +.singolo-paziente .overlap-4 { + position: relative; + width: 172px; + height: 39px; + top: 10vh; + left: 39vw; + background-image: url(../images/homeTherapist/rectangle-351.svg); + background-size: 100% 100%; +} + +.singolo-paziente .text-wrapper-3 { + position: absolute; + width: 144px; + top: 12px; + left: 14px; + font-family: "Poppins", Helvetica; + font-weight: 700; + color: #ffffff; + font-size: 11px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .button-chat { + position: absolute; + width: 46px; + height: 44px; + top: 35vh; + left: 58vw; + background-color: #e8f3f1; + border-radius: 15px; +} + +.singolo-paziente .iconly-light-chat { + position: absolute; + width: 22px; + height: 21px; + top: 11px; + left: 12px; +} + +.singolo-paziente .line { + position: absolute; + width: 592px; + height: 1px; + top: 244px; + left: 31px; + object-fit: cover; +} + +.singolo-paziente .overlap-5 { + position: absolute; + width: 310px; + height: 200px; + top: 51vh; + left: 49vw; + background-color: #f7f5f5; + border-radius: 29px; +} + +.singolo-paziente .img { + position: absolute; + width: 239px; + height: 144px; + top: 20px; + left: 43px; +} + +.singolo-paziente .vector { + position: absolute; + width: 216px; + height: 37px; + top: 67px; + left: 49px; +} + +.singolo-paziente .text-wrapper-4 { + position: absolute; + top: 157px; + left: 275px; + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 10px; + letter-spacing: 0; + line-height: 20px; + white-space: nowrap; +} + +.singolo-paziente .text-wrapper-5 { + position: absolute; + width: 38px; + top: 25px; + left: 19px; + transform: rotate(-90deg); + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 10px; + letter-spacing: 0; + line-height: 10px; + white-space: nowrap; +} + +.singolo-paziente .line-2 { + position: absolute; + width: 1px; + height: 70px; + top: 88px; + left: 92px; +} + +.singolo-paziente .line-3 { + position: absolute; + width: 1px; + height: 84px; + top: 75px; + left: 205px; +} + +.singolo-paziente .line-4 { + position: absolute; + width: 1px; + height: 89px; + top: 69px; + left: 265px; +} + +.singolo-paziente .line-5 { + position: absolute; + width: 1px; + height: 70px; + top: 89px; + left: 148px; +} + +.singolo-paziente .ellipse-2 { + position: absolute; + width: 4px; + height: 4px; + top: 65px; + left: 263px; + background-color: #199a8e; + border-radius: 2px; +} + +.singolo-paziente .ellipse-3 { + position: absolute; + width: 4px; + height: 4px; + top: 72px; + left: 203px; + background-color: #199a8e; + border-radius: 2px; +} + +.singolo-paziente .ellipse-4 { + position: absolute; + width: 4px; + height: 4px; + top: 86px; + left: 146px; + background-color: #199a8e; + border-radius: 2px; +} + +.singolo-paziente .ellipse-5 { + position: absolute; + width: 4px; + height: 4px; + top: 87px; + left: 90px; + background-color: #199a8e; + border-radius: 2px; +} + +.singolo-paziente .text-wrapper-6 { + top: 161px; + left: 80px; + position: absolute; + width: 25px; + transform: rotate(-29.62deg); + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 6px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .text-wrapper-7 { + top: 161px; + left: 136px; + position: absolute; + width: 25px; + transform: rotate(-29.62deg); + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 6px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .text-wrapper-8 { + top: 161px; + left: 193px; + position: absolute; + width: 25px; + transform: rotate(-29.62deg); + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 6px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .text-wrapper-9 { + top: 162px; + left: 253px; + position: absolute; + width: 25px; + transform: rotate(-29.62deg); + font-family: "Inter", Helvetica; + font-weight: 700; + color: #000000; + font-size: 6px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.singolo-paziente .text-wrapper-10 { + position: absolute; + top: 44vh; + left: 55vw; + font-family: "Inter", Helvetica; + font-weight: 700; + color: #101522; + font-size: 24px; + letter-spacing: 0; + line-height: 32.4px; + white-space: nowrap; +} + +/*---INFO TABLE---*/ +.table { + width: 100%; + border-collapse: collapse; +} + +td { + padding: 15px; + text-align: left; + border-bottom: 1px solid #ddd; +} + +img { + width: 50px; + height: 50px; +} +/*--HOME LAYOUT--*/ + +html { + margin: 0px; + height: 100%; +} + +body{ + margin: 0px; + height: 100%; + background-color: #52d1c6bd; + font-family: "Poppins", Helvetica, serif; +} + +a { + text-decoration: none; +} + +.element-home-logopedista { + + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 90%; + margin: 0 auto; +} + +.element-home-logopedista .div { + + width: 100vw; + height: 100vh; + position: relative; +} + +.element-home-logopedista .overlap { + position: absolute; + width: 124px; + height: 48px; + top: 36px; + left: 72vw; + background-image: url(../images/homeTherapist/rectangle-359.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .button-only-text { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 4px; + padding: 0px 4px; + position: relative; + top: 12px; + left: 11px; + border-radius: 9999px; +} + +.element-home-logopedista .button { + position: relative; + width: fit-content; + margin-top: -1px; + font-family: "Poppins", Helvetica; + font-weight: 500; + color: #199a8e; + font-size: 10px; + letter-spacing: 0; + line-height: 16px; + white-space: nowrap; + all: unset; + box-sizing: border-box; +} + +.element-home-logopedista .pop-up { + position: absolute; + width: 50vw; + height: 85vh; + top: 6vh; + left: 30vw; + background-color: #ffffff; + border-radius: 24px; +} + +.element-home-logopedista .text-wrapper-2 { + position: absolute; + width: 10vw; + top: 2vh; + left: 23vw; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 14px; + letter-spacing: 0; + line-height: normal; + white-space: nowrap; +} + +.element-home-logopedista .overlap-group { + position: absolute; + width: 600px; + height: 61px; + top: 80px; + left: 76px; + display: flex; + justify-content: center; + align-items: center; +} + +.element-home-logopedista .doctor { + width: 499px; + height: 61px; + top: 0; + position: absolute; + left: 0; +} + +.element-home-logopedista .group { + height: 61px; + background-color: #ffffff; + border-radius: 6px; + border: 1px solid; + border-color: #221f1f1a; +} + +.element-home-logopedista .overlap-group-wrapper { + position: relative; + width: 282px; + height: 16px; + top: 20px; + left: 118px; +} + +.element-home-logopedista .overlap-group-2 { + position: relative; + width: 278px; + height: 16px; +} + +.element-home-logopedista .inizio-terapia-gg-mm { + position: absolute; + width: 164px; + top: 3px; + left: 114px; + text-shadow: 0px 4px 4px #00000040; + font-family: "Poppins", Helvetica; + font-weight: 500; + color: #221f1f66; + font-size: 7px; + text-align: center; + letter-spacing: 0; + line-height: normal; +} + +.element-home-logopedista .text-wrapper { + position: absolute; + width: 228px; + top: 0; + left: 0; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 10px; + letter-spacing: 0; + line-height: normal; +} + +.element-home-logopedista .others-progress { + position: absolute; + width: 43px; + height: 41px; + top: 9px; + left: 427px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .element-wrapper { + position: relative; + height: 41px; + background-image: url(../images/homeTherapist/ellipse-2.svg); + background-size: 100% 100%; +} + +.element-home-logopedista .element { + position: relative; + top: 8px; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #199a8e; + font-size: 11px; + text-align: center; + letter-spacing: 0; + line-height: 24px; +} + + +.element-home-logopedista .overlap-2 { + position: absolute; + width: 507px; + height: 312px; + top: 136px; + left: 68px; +} + +.element-home-logopedista .doctor-2 { + width: 507px; + height: 312px; + top: 0; + position: absolute; + left: 0; +} + +.element-home-logopedista .group-wrapper { + position: absolute; + width: 499px; + height: 61px; + top: 0; + left: 8px; + background-color: #ffffff; + border-radius: 6px; + border: 1px solid; + border-color: #221f1f1a; +} + +.element-home-logopedista .div-wrapper { + position: absolute; + width: 499px; + height: 61px; + top: 87px; + left: 8px; +} + +.element-home-logopedista .doctor-3 { + position: absolute; + width: 499px; + height: 61px; + top: 174px; + left: 0; +} + +.element-home-logopedista .doctor-4 { + width: 499px; + height: 61px; + top: 251px; + position: absolute; + left: 0; +} + +.element-home-logopedista .overlap-wrapper { + top: 94px; + left: 435px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-2 { + top: 11px; + left: 436px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-3 { + top: 185px; + left: 435px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .others-progress-4 { + top: 261px; + left: 437px; + background-image: url(../images/homeTherapist/ellipse-1-1.svg); + position: absolute; + width: 43px; + height: 41px; + background-size: 100% 100%; +} + +.element-home-logopedista .image-2 { + position: absolute; + width: 47px; + height: 299px; + top: 8px; + left: 28px; +} + +.element-home-logopedista .ellipse { + position: absolute; + width: 47px; + height: 48px; + top: 0; + left: 0; + object-fit: cover; +} + +.element-home-logopedista .image-3 { + position: absolute; + width: 47px; + height: 213px; + top: 86px; + left: 0; +} + +.element-home-logopedista .image-4 { + position: absolute; + width: 47px; + height: 125px; + top: 88px; + left: 0; +} + + +.element-home-logopedista .overlap-3 { + position: absolute; + width: 116px; + height: 530px; + top: 40px; + left: 65px; +} + +.element-home-logopedista .rectangle-2 { + width: 98px; + height: 530px; + top: 0; + left: 0; + background-color: #ffffff; + position: absolute; + border-radius: 30px; +} + +.element-home-logopedista .group-2 { + position: absolute; + width: 24px; + height: 174px; + top: 161px; + left: 37px; +} + +.element-home-logopedista .iconly-light-outline { + position: absolute; + width: 24px; + height: 24px; + top: 0; + left: 0; +} + +.element-home-logopedista .home { + position: absolute; + width: 20px; + height: 22px; + top: 1px; + left: 2px; +} + +.element-home-logopedista .iconly-bold-calendar { + position: absolute; + width: 24px; + height: 24px; + top: 98px; + left: 0; +} + +.element-home-logopedista .iconly-light-message { + top: 49px; + position: absolute; + width: 24px; + height: 24px; + left: 0; +} + +.element-home-logopedista .iconly-light-profile { + top: 150px; + position: absolute; + width: 24px; + height: 24px; + left: 0; +} + +.element-home-logopedista .img { + position: absolute; + width: 47%; + height: 55px; + top: 400px; + left: 22px; +} + +.element-home-logopedista .logovettoriale { + position: absolute; + width: 63px; + height: 75px; + top: 39px; + left: 17px; + object-fit: cover; +} + +.element-home-logopedista .line { + position: absolute; + width: 75px; + height: 1px; + top: 132px; + left: 11px; + object-fit: cover; +} + +.element-home-logopedista .text-wrapper-3 { + position: absolute; + width: 102px; + top: 467px; + left: 0px; + font-family: "Poppins", Helvetica; + font-weight: 600; + color: #221f1f; + font-size: 10px; + letter-spacing: 0; + text-align: center; /* Allinea il testo al centro orizzontalmente */ + line-height: normal; +} + +.element-home-logopedista .ellipse-2 { + position: absolute; + width: 10px; + height: 10px; + top: 450px; + left: 65px; +} + +.element-home-logopedista .material-symbols-wrapper { + position: absolute; + width: 340px; + height: 50px; + top: 35px; + left: 30vw; + background-image: url(../images/homeTherapist/rectangle-32.png); + background-size: 100% 100%; +} + +.element-home-logopedista .material-symbols { + position: absolute; + width: 24px; + height: 24px; + top: 13px; + left: 15px; +} + +.element-home-logopedista .img-wrapper { + position: absolute; + width: 175px; + height: 48px; + top: 36px; + left: 57vw; + background-color: #ffffff; + border-radius: 50px; +} + +.element-home-logopedista .material-symbols-2 { + position: absolute; + width: 17px; + height: 14px; + top: 11px; + left: 17px; +} diff --git a/src/main/webapp/JS/searchBar.js b/src/main/webapp/JS/searchBar.js new file mode 100644 index 0000000..9219285 --- /dev/null +++ b/src/main/webapp/JS/searchBar.js @@ -0,0 +1,24 @@ +//search bar for name and surname +$(document).ready(function () { + var tableContainer = document.getElementById('tableContainer'); + + // Aggiungi un gestore di eventi all'input di ricerca + $('#searchInput').on('input', function () { + var searchText = $(this).val().toLowerCase(); + + // Nascondi tutte le righe + tableContainer.getElementsByTagName('tbody')[0].style.marginTop = '0'; + + // Filtra e mostra solo le righe che corrispondono alla ricerca + $('tbody tr').each(function () { + var name = $(this).find('td:eq(1)').text().toLowerCase(); + var lastName = $(this).find('td:eq(2)').text().toLowerCase(); + + if (name.includes(searchText) || lastName.includes(searchText)) { + $(this).show(); + } else { + $(this).hide(); + } + }); + }); +}); \ No newline at end of file diff --git a/src/main/webapp/JSP/PatientConditionManager.jsp b/src/main/webapp/JSP/PatientConditionManager.jsp new file mode 100644 index 0000000..571c088 --- /dev/null +++ b/src/main/webapp/JSP/PatientConditionManager.jsp @@ -0,0 +1,97 @@ +<%@ page import="java.util.ArrayList" %> +<%@ page import="model.entity.Condition" %> +<%@ page import="model.service.condition.ConditionManager" %> +<%@ page import="model.entity.Schedule" %> +<%@ page import="model.entity.UserInfo" %> +<%@ page import="model.entity.User" %> +<%@ page import="model.service.user.UserData" %> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Condition + + +<% + int userId = 0; + if(session.getAttribute("type")!=null && !session.getAttribute("type").equals("therapist") || request.getParameter("userId")==null) { + response.sendRedirect("../errorPage/403.html"); + }else { + userId = Integer.parseInt((request.getParameter("userId"))); + + int userTherapist = new UserData().getUser(userId).getIdTherapist(); + if (userTherapist != (Integer) session.getAttribute("id")) { + response.sendRedirect("../errorPage/403.html"); + } + } + + + ConditionManager ConditionService= new ConditionManager(); + + ArrayList list_PatientCondition = ConditionService.getConditionsOfPatient(userId); + ArrayList list_NOTPatientCondition = ConditionService.getConditionsNOTOfPatient(userId); +%> +Home + + + + + + + + + + + + + <% for (Condition condition : list_PatientCondition) { %> + + + + + + + + <% } %> + +
Condition of patient
IDDisorder DescriptionDisorder NameSeverityOperazione
<%= condition.getIdCondition() %><%= condition.getDisorderDescription() %><%= condition.getDisorderName() %><%= condition.getSeverity() %> +
+ + + +
+
+
+ + + + + + + + + + + + + <% for (Condition condition : list_NOTPatientCondition) { %> + + + + + + + + + + <% } %> + +
Add new condition to patient
IDDisorder DescriptionDisorder NameSeverityOperazione
<%= condition.getIdCondition() %><%= condition.getDisorderDescription() %><%= condition.getDisorderName() %>
+ + + +
+ + + + + diff --git a/src/main/webapp/JSP/homeTherapist.jsp b/src/main/webapp/JSP/homeTherapist.jsp new file mode 100644 index 0000000..d28943c --- /dev/null +++ b/src/main/webapp/JSP/homeTherapist.jsp @@ -0,0 +1,98 @@ +<%@ page import="model.entity.*"%> +<%@ page import="model.service.user.UserData"%> +<%@ page import="java.util.ArrayList"%> +<%@ page import="java.text.SimpleDateFormat" %> + + + + + + + + Home + + +
+
+
+
PAZIENTI
+
+
+ + + + + + + + + + + + <% + if(session.getAttribute("type")!=null && session.getAttribute("type").equals("therapist")){ + @SuppressWarnings("unchecked") + ArrayList list_user= new UserData().getUsersAndPersonalInfoByIdTherapist((Integer) session.getAttribute("id")); + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + + for(UserInfo u: list_user){ + %> + + + + + + + + + + <% + } + } else { + response.sendRedirect("../errorPage/403.html"); + } + %> + +
Inizio Terapia Progressi
<%=u.getFirstname()%> <%=u.getLastname()%><%= sdf.format(u.getActivationDate()) %> +
72%
+
+ + + Visualizza +
+
+ +
+
+ +
+
+
+
+ + + +
+ + + +
Dr.
<%=session.getAttribute("NameSurnameLogged")%>
+ +
+
+ + +
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/webapp/JSP/view_patient.jsp b/src/main/webapp/JSP/view_patient.jsp new file mode 100644 index 0000000..6c552b7 --- /dev/null +++ b/src/main/webapp/JSP/view_patient.jsp @@ -0,0 +1,107 @@ +<%@ page import="model.entity.*"%> +<%@ page import="java.util.ArrayList" %> +<%@ page import="model.service.user.UserRegistry" %> +<%@ page import="model.service.user.UserData" %> + + + + + + + Paziente Selezionato + + + +
+
+ +
+
+ <% + + if(session.getAttribute("type")==null || !session.getAttribute("type").equals("therapist") || request.getParameter("patientID") == null) { + response.sendRedirect("../errorPage/403.html"); + }else { + int patientId = Integer.parseInt(request.getParameter("patientID")); + + PersonalInfo user_selected = new UserRegistry().getPersonalInfo(patientId); + User user = new UserData().getUser(patientId); + if (user.getIdTherapist() != (Integer) session.getAttribute("id")) { + response.sendRedirect("../errorPage/403.html"); + } + String email = user.getEmail(); + + %> + + + + + + +
+

Nome: <%=user_selected.getFirstname()%>

+

Indirizzo: <%=user_selected.getAddress()%>

+

Email: <%=email%>

+
+

Cognome: <%=user_selected.getLastname()%>

+

Data di nascita: <%=user_selected.getDateOfBirth()%>

+

Tel: <%=user_selected.getPhone()%>

+
+
+
+ +
+
+
+
+ + + +
+ + + +
Dr.
<%=session.getAttribute("NameSurnameLogged")%>
+ +
+
+
+ +
+
+
Modifica patologie
+
+
+
Raccomanda Esercizio
+
+
+
+ + +
Days
+
Points
+ + + + +
+
+
+
+
10/9
+
11/9
+
12/9
+
13/9
+
+
Andamento
+
+ + + + <%} %> + + diff --git a/src/main/webapp/errorPage/403.html b/src/main/webapp/errorPage/403.html index 2786d01..d41dc1f 100644 --- a/src/main/webapp/errorPage/403.html +++ b/src/main/webapp/errorPage/403.html @@ -17,12 +17,13 @@

Forse devi eseguire l'accesso?

🚫🚫🚫🚫

error code: 403 forbidden
- +
diff --git a/src/main/webapp/images/homeTherapist/doctor.png b/src/main/webapp/images/homeTherapist/doctor.png new file mode 100644 index 0000000..84dcda8 Binary files /dev/null and b/src/main/webapp/images/homeTherapist/doctor.png differ diff --git a/src/main/webapp/images/homeTherapist/ellipse-1-1.svg b/src/main/webapp/images/homeTherapist/ellipse-1-1.svg new file mode 100644 index 0000000..e1ec5e2 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/ellipse-1-1.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/ellipse-2.svg b/src/main/webapp/images/homeTherapist/ellipse-2.svg new file mode 100644 index 0000000..6cb02a0 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/ellipse-2.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/ellipse-94.svg b/src/main/webapp/images/homeTherapist/ellipse-94.svg new file mode 100644 index 0000000..bf7d71e --- /dev/null +++ b/src/main/webapp/images/homeTherapist/ellipse-94.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/group-181.png b/src/main/webapp/images/homeTherapist/group-181.png new file mode 100644 index 0000000..aa628ab Binary files /dev/null and b/src/main/webapp/images/homeTherapist/group-181.png differ diff --git a/src/main/webapp/images/homeTherapist/home.png b/src/main/webapp/images/homeTherapist/home.png new file mode 100644 index 0000000..040a57f Binary files /dev/null and b/src/main/webapp/images/homeTherapist/home.png differ diff --git a/src/main/webapp/images/homeTherapist/iconly-bold-calendar.svg b/src/main/webapp/images/homeTherapist/iconly-bold-calendar.svg new file mode 100644 index 0000000..7d3020f --- /dev/null +++ b/src/main/webapp/images/homeTherapist/iconly-bold-calendar.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/iconly-light-chat.svg b/src/main/webapp/images/homeTherapist/iconly-light-chat.svg new file mode 100644 index 0000000..597a0d0 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/iconly-light-chat.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/main/webapp/images/homeTherapist/iconly-light-message.svg b/src/main/webapp/images/homeTherapist/iconly-light-message.svg new file mode 100644 index 0000000..359c2ff --- /dev/null +++ b/src/main/webapp/images/homeTherapist/iconly-light-message.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/main/webapp/images/homeTherapist/iconly-light-profile.svg b/src/main/webapp/images/homeTherapist/iconly-light-profile.svg new file mode 100644 index 0000000..b43895c --- /dev/null +++ b/src/main/webapp/images/homeTherapist/iconly-light-profile.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/main/webapp/images/homeTherapist/line-6.svg b/src/main/webapp/images/homeTherapist/line-6.svg new file mode 100644 index 0000000..cbccc5a --- /dev/null +++ b/src/main/webapp/images/homeTherapist/line-6.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/line-7.svg b/src/main/webapp/images/homeTherapist/line-7.svg new file mode 100644 index 0000000..e4efc64 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/line-7.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/line-8.svg b/src/main/webapp/images/homeTherapist/line-8.svg new file mode 100644 index 0000000..fd78803 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/line-8.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/line-9.svg b/src/main/webapp/images/homeTherapist/line-9.svg new file mode 100644 index 0000000..4937af3 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/line-9.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/logovettoriale-1.png b/src/main/webapp/images/homeTherapist/logovettoriale-1.png new file mode 100644 index 0000000..f90dfa8 Binary files /dev/null and b/src/main/webapp/images/homeTherapist/logovettoriale-1.png differ diff --git a/src/main/webapp/images/homeTherapist/material-symbols-search-rounded.svg b/src/main/webapp/images/homeTherapist/material-symbols-search-rounded.svg new file mode 100644 index 0000000..7dc8223 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/material-symbols-search-rounded.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/material-symbols-sort.svg b/src/main/webapp/images/homeTherapist/material-symbols-sort.svg new file mode 100644 index 0000000..785e4e4 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/material-symbols-sort.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/rectangle-32.png b/src/main/webapp/images/homeTherapist/rectangle-32.png new file mode 100644 index 0000000..c44410d Binary files /dev/null and b/src/main/webapp/images/homeTherapist/rectangle-32.png differ diff --git a/src/main/webapp/images/homeTherapist/rectangle-351.svg b/src/main/webapp/images/homeTherapist/rectangle-351.svg new file mode 100644 index 0000000..e8e9ce3 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/rectangle-351.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/rectangle-359.svg b/src/main/webapp/images/homeTherapist/rectangle-359.svg new file mode 100644 index 0000000..8e6b813 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/rectangle-359.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/images/homeTherapist/vector-5.svg b/src/main/webapp/images/homeTherapist/vector-5.svg new file mode 100644 index 0000000..8b33122 --- /dev/null +++ b/src/main/webapp/images/homeTherapist/vector-5.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp index 3d6d7b9..32cb6ec 100644 --- a/src/main/webapp/index.jsp +++ b/src/main/webapp/index.jsp @@ -7,6 +7,6 @@

<%= "Hello World!" %>


-Hello Servlet +Login \ No newline at end of file diff --git a/src/test/java/model/DAO/DAOExerciseGlossaryTest.java b/src/test/java/model/DAO/DAOExerciseGlossaryTest.java new file mode 100644 index 0000000..e5708ea --- /dev/null +++ b/src/test/java/model/DAO/DAOExerciseGlossaryTest.java @@ -0,0 +1,54 @@ +package model.DAO; + +import model.entity.ExerciseGlossary; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.sql.*; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +class DAOExerciseGlossaryTest { + private DAOExerciseGlossary daoExerciseGlossary; + private Connection connectionMock; + private PreparedStatement preparedStatementMock; + private ResultSet resultSetMock; + + @BeforeEach + void setUp() throws SQLException { + // Mock all SQL objects + connectionMock = mock(Connection.class); + preparedStatementMock = mock(PreparedStatement.class); + resultSetMock = mock(ResultSet.class); + + // When a new prepared statement is created, return the mock + when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock); + + // Create a new DAOExerciseGlossary instance with the mock connection + daoExerciseGlossary = new DAOExerciseGlossary(connectionMock); + } + + @Test + void testGetExerciseByCode() throws SQLException { + int code = 1; + when(connectionMock.isClosed()).thenReturn(false); + when(connectionMock.prepareStatement(any())).thenReturn(preparedStatementMock); + when(preparedStatementMock.executeQuery()).thenReturn(resultSetMock); + when(resultSetMock.next()).thenReturn(true); + when(resultSetMock.getInt("ID_exercise")).thenReturn(code); + when(resultSetMock.getString("ExerciseName")).thenReturn("Example Exercise"); + // Mock other columns as necessary... + + ExerciseGlossary exerciseGlossary = daoExerciseGlossary.getExerciseByCode(code); + + assertNotNull(exerciseGlossary); + assertEquals(code, exerciseGlossary.getIdExercise()); + assertEquals("Example Exercise", exerciseGlossary.getExerciseName()); + // Assert other columns as necessary... + + verify(connectionMock, times(1)).prepareStatement(any()); + verify(preparedStatementMock, times(1)).setInt(1, code); + verify(preparedStatementMock, times(1)).executeQuery(); + } +} diff --git a/src/test/java/model/DAO/DAOExerciseTest.java b/src/test/java/model/DAO/DAOExerciseTest.java new file mode 100644 index 0000000..8975317 --- /dev/null +++ b/src/test/java/model/DAO/DAOExerciseTest.java @@ -0,0 +1,133 @@ +package model.DAO; + +import model.entity.Exercise; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.sql.*; +import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.*; + +class DAOExerciseTest { + private DAOExercise daoExercise; + private Connection connectionMock; + private PreparedStatement preparedStatementMock; + private ResultSet resultSetMock; + + @BeforeEach + void setUp() throws SQLException { + connectionMock = mock(Connection.class); + preparedStatementMock = mock(PreparedStatement.class); + resultSetMock = mock(ResultSet.class); + daoExercise = new DAOExercise(connectionMock); + + when(connectionMock.prepareStatement(anyString())).thenReturn(preparedStatementMock); + when(connectionMock.isClosed()).thenReturn(false); + } + + @Test + void testGetExerciseByPk() throws SQLException { + int userId = 1; + int exerciseId = 1; + Date insertDate = java.sql.Date.valueOf("2023-12-01"); + + when(preparedStatementMock.executeQuery()).thenReturn(resultSetMock); + when(resultSetMock.next()).thenReturn(true); + when(resultSetMock.getInt("ID_user")).thenReturn(userId); + when(resultSetMock.getInt("ID_exercise")).thenReturn(exerciseId); + when(resultSetMock.getDate("InsertionDate")).thenReturn(insertDate); + // Add other mock configurations for the remaining columns in the resultSet + + Exercise exercise = daoExercise.getExerciseByPk(userId, exerciseId, insertDate); + + assertNotNull(exercise); + assertEquals(userId, exercise.getIdUser()); + assertEquals(exerciseId, exercise.getIdExercise()); + assertEquals(insertDate, exercise.getInsertionDate()); + // Add other assertions for the remaining columns + + verify(preparedStatementMock, times(1)).setInt(1, userId); + verify(preparedStatementMock, times(1)).setInt(2, exerciseId); + verify(preparedStatementMock, times(1)).setDate(3, insertDate); + verify(preparedStatementMock, times(1)).executeQuery(); + } + + @Test + void testSetExerciseExecution() throws SQLException { + int userId = 1; + int exerciseId = 1; + Date insertDate = java.sql.Date.valueOf("2023-12-01"); + Blob blob = mock(Blob.class); + + when(preparedStatementMock.executeUpdate()).thenReturn(1); + + boolean result = daoExercise.setExerciseExecution(userId, exerciseId, insertDate, blob); + + assertTrue(result); + + verify(preparedStatementMock, times(1)).setBlob(1, blob); + verify(preparedStatementMock, times(1)).setInt(2, userId); + verify(preparedStatementMock, times(1)).setInt(3, exerciseId); + verify(preparedStatementMock, times(1)).setDate(4, insertDate); + verify(preparedStatementMock, times(1)).executeUpdate(); + } + + @Test + void testSetExerciseEvaluation() throws SQLException { + int userId = 1; + int exerciseId = 1; + Date insertDate = java.sql.Date.valueOf("2023-12-01"); + int evaluation = 5; + + when(preparedStatementMock.executeUpdate()).thenReturn(1); + + boolean result = daoExercise.setExerciseEvaluation(userId, exerciseId, insertDate, evaluation); + + assertTrue(result); + + verify(preparedStatementMock, times(1)).setInt(1, evaluation); + verify(preparedStatementMock, times(1)).setInt(2, userId); + verify(preparedStatementMock, times(1)).setInt(3, exerciseId); + verify(preparedStatementMock, times(1)).setDate(4, insertDate); + verify(preparedStatementMock, times(1)).executeUpdate(); + } + + @Test + void testSetExerciseCompletionDate() throws SQLException { + int userId = 1; + int exerciseId = 1; + Date insertDate = java.sql.Date.valueOf("2023-12-01"); + Date completionDate = java.sql.Date.valueOf("2023-12-31"); + + when(preparedStatementMock.executeUpdate()).thenReturn(1); + + boolean result = daoExercise.setExerciseCompletionDate(userId, exerciseId, insertDate, completionDate); + + assertTrue(result); + + verify(preparedStatementMock, times(1)).setDate(1, completionDate); + verify(preparedStatementMock, times(1)).setInt(2, userId); + verify(preparedStatementMock, times(1)).setInt(3, exerciseId); + verify(preparedStatementMock, times(1)).setDate(4, insertDate); + verify(preparedStatementMock, times(1)).executeUpdate(); + } + + @Test + void testSetExerciseFeedback() throws SQLException { + int userId = 1; + int exerciseId = 1; + Date insertDate = java.sql.Date.valueOf("2023-12-01"); + int feedback = 5; + + when(preparedStatementMock.executeUpdate()).thenReturn(1); + + boolean result = daoExercise.setExerciseFeedback(userId, exerciseId, insertDate, feedback); + + assertTrue(result); + verify(preparedStatementMock, times(1)).setInt(1, feedback); + verify(preparedStatementMock, times(1)).setInt(2, userId); + verify(preparedStatementMock, times(1)).setInt(3, exerciseId); + verify(preparedStatementMock, times(1)).setDate(4, insertDate); + verify(preparedStatementMock, times(1)).executeUpdate(); + } +} diff --git a/src/test/java/model/entity/ExerciseGlossaryTest.java b/src/test/java/model/entity/ExerciseGlossaryTest.java new file mode 100644 index 0000000..5fc0eda --- /dev/null +++ b/src/test/java/model/entity/ExerciseGlossaryTest.java @@ -0,0 +1,40 @@ +package model.entity; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ExerciseGlossaryTest { + + @Test + public void testExerciseGlossary() { + ExerciseGlossary exerciseGlossary = new ExerciseGlossary(); + + int id = 1; + String name = "Test Exercise"; + String description = "Test Description"; + String type = "Type 1"; + int difficulty = 3; + String initialState = "Initial"; + String solution = "Solution"; + String target = "Target"; + + exerciseGlossary.setIdExercise(id); + exerciseGlossary.setExerciseName(name); + exerciseGlossary.setExerciseDescription(description); + exerciseGlossary.setType(type); + exerciseGlossary.setDifficulty(difficulty); + exerciseGlossary.setInitialState(initialState); + exerciseGlossary.setSolution(solution); + exerciseGlossary.setTarget(target); + + assertEquals(id, exerciseGlossary.getIdExercise()); + assertEquals(name, exerciseGlossary.getExerciseName()); + assertEquals(description, exerciseGlossary.getExerciseDescription()); + assertEquals(type, exerciseGlossary.getType()); + assertEquals(difficulty, exerciseGlossary.getDifficulty()); + assertEquals(initialState, exerciseGlossary.getInitialState()); + assertEquals(solution, exerciseGlossary.getSolution()); + assertEquals(target, exerciseGlossary.getTarget()); + } +} diff --git a/src/test/java/model/entity/ExerciseTest.java b/src/test/java/model/entity/ExerciseTest.java new file mode 100644 index 0000000..150c378 --- /dev/null +++ b/src/test/java/model/entity/ExerciseTest.java @@ -0,0 +1,43 @@ +package model.entity; + + +import org.junit.jupiter.api.Test; +import java.sql.Blob; +import java.sql.Date; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ExerciseTest { + + @Test + public void testExercise(){ + Exercise exercise = new Exercise(); + + int idUser = 1; + int idExercise = 2; + Date dateInsertion = new Date(2024, 1, 1); + Date dateCompletion = new Date(2024, 1, 1); + Blob blob = null; // Assuming blob as null for this unit test + int evaluation = 10; + int recommended = 1; + int feedback = -1; + + exercise.setIdUser(idUser); + exercise.setIdExercise(idExercise); + exercise.setInsertionDate(dateInsertion); + exercise.setCompletionDate(dateCompletion); + exercise.setExecution(blob); + exercise.setEvaluation(evaluation); + exercise.setRecommended(recommended); + exercise.setFeedback(feedback); + + assertEquals(idUser, exercise.getIdUser()); + assertEquals(idExercise, exercise.getIdExercise()); + assertEquals(dateInsertion, exercise.getInsertionDate()); + assertEquals(dateCompletion, exercise.getCompletionDate()); + assertEquals(blob, exercise.getExecution()); + assertEquals(evaluation, exercise.getEvaluation()); + assertEquals(recommended, exercise.getRecommended()); + assertEquals(feedback, exercise.getFeedback()); + } +}