Skip to content

Commit

Permalink
Rimozione metodi inutili
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody2806 committed Jan 17, 2024
1 parent 69038ee commit e2646cb
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 103 deletions.
33 changes: 0 additions & 33 deletions src/main/java/model/DAO/DAOExercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,39 +154,6 @@ public List<SlimmerExercise> retrieveDoneExercises(int patientId) {
return exercises;
}

public List<Exercise> retrieveAllPatientExerciseDone(int userID) {
String query = "SELECT * FROM exercise WHERE ID_user = ? AND CompletionDate IS NOT NULL ORDER BY InsertionDate DESC;";
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
List<Exercise> exercises = new ArrayList<>();

try {
connection = connection.isClosed() ? DAOConnection.getConnection() : connection;
preparedStatement = connection.prepareStatement(query);
preparedStatement.setInt(1, userID);

resultSet = preparedStatement.executeQuery();

while (resultSet.next()) {
Exercise exercise = extractExerciseFromResultSet(resultSet);
exercises.add(exercise);
}

} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
DAOConnection.releaseConnection(connection);
} catch (SQLException e) {
e.printStackTrace();
}
}

return exercises;
}

public List<Exercise> retrievePatientExerciseDone(int patientID) {
String query = "SELECT *\n" +
"FROM exercise\n" +
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/model/DAO/DAOExerciseGlossary.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,50 +85,4 @@ public ExerciseGlossary getExerciseByCode(int code) {

return null;
}



public List<ExerciseGlossary> getExerciseByCode(List<Exercise> esercizi) {
String query = "SELECT * FROM exercise_glossary WHERE ";
PreparedStatement preparedStatement = null;
List<ExerciseGlossary> result= new ArrayList<>();
ResultSet resultSet = null;
try {
for (Exercise esercizio : esercizi)
{
query+="ID_exercise=? OR ";
}
String query_corretta=query.substring(0, query.length() - 4);
query_corretta+=";";

connection = connection.isClosed() ? DAOConnection.getConnection() : connection;
preparedStatement = connection.prepareStatement(query_corretta);
int i=1;
for(Exercise esercizio : esercizi)
{
preparedStatement.setInt(i, esercizio.getIdExercise());
i++;
}

resultSet = preparedStatement.executeQuery();

while (resultSet.next()) {
result.add(extractExerciseFromResultSet(resultSet));
}
return result;

} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
DAOConnection.releaseConnection(connection);
} catch (SQLException e) {
e.printStackTrace();
}
}

return null;
}
}
6 changes: 0 additions & 6 deletions src/main/java/model/service/exercise/ExerciseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ public ExerciseGlossary getExercise(int exerciseID) {
return daoEG.getExerciseByCode(exerciseID);
}

public List<ExerciseGlossary> getExercise(List<Exercise> esercizi){ return daoEG.getExerciseByCode(esercizi);}

public Blob getExecution(int exerciseID, int userID, Date insertionDate) {
return daoE.getExerciseExecution(userID, exerciseID, insertionDate);
}
Expand All @@ -34,10 +32,6 @@ public boolean saveEvaluation(int userID, int exerciseId, Date insertDate, int e
return daoE.setExerciseEvaluation(userID, exerciseId, insertDate, evaluation);
}

public List<Exercise> retrieveAllPatientExerciseDone(int userID){
return daoE.retrieveAllPatientExerciseDone(userID);
}

public List<Exercise> retrievePatientExerciseDone(int patientID) {
return daoE.retrievePatientExerciseDone(patientID);
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/model/service/exercise/ExerciseManagerInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ public interface ExerciseManagerInterface {
*/
public boolean saveEvaluation(int userID, int exerciseId, Date insertDate, int evaluation);

/**
* Recupera una lista di tutti gli esercizi fatti da un paziente specifico.
*
* @param userID L'ID del paziente.
* @return Una lista di oggetti Exercise che rappresentano gli esercizi fatti dal paziente.
*/
public List<Exercise> retrieveAllPatientExerciseDone(int userID);

/**
* Recupera una lista di esercizi che un paziente ha già fatto.
Expand All @@ -73,11 +66,4 @@ public interface ExerciseManagerInterface {
*/
public List<SlimmerExercise> retrieveNotDoneExercises(int patientId);

/**
* Recupera una lista di esercizi che il paziente ha fatto.
*
* @param esercizi la lista degli eseercizi per recuperare l'id.
* @return restituisce una list di ExerciseGlossary rappresentanti del risultato degli esercizi fatti.
*/
public List<ExerciseGlossary> getExercise(List<Exercise> esercizi);
}
8 changes: 4 additions & 4 deletions src/main/webapp/JSP/patientReport.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<%@ page import="model.entity.Exercise" %>
<%@ page import="java.util.List" %>
<%@ page import="model.entity.ExerciseGlossary" %>
<%@ page import="model.entity.SlimmerExercise" %>
<!DOCTYPE html>
<html lang="it" style="background-color: #f7fcff; ">
<%
Expand Down Expand Up @@ -33,11 +34,10 @@

<%
ExerciseManager exerciseManager = new ExerciseManager();
List<Exercise> list = exerciseManager.retrieveAllPatientExerciseDone(userId);
List<SlimmerExercise> list = exerciseManager.retrieveDoneExercises(userId);
if(!list.isEmpty()){
int Counter = 0;
List<ExerciseGlossary> esercizio_glos = exerciseManager.getExercise(list);
for(ExerciseGlossary exerciseGlossary : esercizio_glos) {
for(SlimmerExercise exerciseGlossary : list) {
%>
<div class="margin20">
<div class="card">
Expand All @@ -54,7 +54,7 @@
</svg>

</div></div>
<div class="discovering-english"><%=exerciseGlossary.getExerciseName()%></div>
<div class="discovering-english"><%=exerciseGlossary.getName()%></div>
</div></div></div>
<button class="button-2">Aggiungi Feedback</button>
</div>
Expand Down

0 comments on commit e2646cb

Please sign in to comment.