Skip to content

Commit

Permalink
Merge pull request #49 from pastore99/46-fix-correction-of-the-links-…
Browse files Browse the repository at this point in the history
…of-the-user-pages-with-the-exercise-pages-and-addition-of-the-new-report-page

46 fix correction of the links of the user pages with the exercise pages and addition of the new report page
  • Loading branch information
panuozzo77 authored Jan 8, 2024
2 parents 9225f26 + 18b9ac8 commit ba24b2e
Show file tree
Hide file tree
Showing 50 changed files with 1,151 additions and 874 deletions.
229 changes: 0 additions & 229 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,229 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>TalkAID</artifactId>
<version>1.0-SNAPSHOT</version>
<name>TalkAID</name>
<packaging>war</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<junit.version>5.10.0</junit.version>
<sonar.organization>panuozzo77</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>


<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
</dependency>

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.5</version>
</dependency>

<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.1.4</version>
</dependency>

<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>

<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner-servlet</artifactId>
<version>2.0.7</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner-struts</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.3</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>

<dependency>
<groupId>com.microsoft.cognitiveservices.speech</groupId>
<artifactId>client-sdk</artifactId>
<version>1.34.0</version>
</dependency>


<dependency>
<groupId>info.debatty</groupId>
<artifactId>java-string-similarity</artifactId>
<version>RELEASE</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.2.1</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>
-Xmx1024M ${argLine}
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.10</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
<append>false</append>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.0</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
19 changes: 14 additions & 5 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import model.service.schedule.ScheduleManager;
import model.service.email.EmailManager;
import model.service.encryption.Encryption;
import model.DAO.DAOUser;
Expand All @@ -8,11 +9,19 @@

public class Main {
public static void main(String[] args) {
Authenticator auth = new Authenticator();
Registration r = new Registration();
//Authenticator auth = new Authenticator();
//Registration r = new Registration();

System.out.println(auth.authenticate("[email protected]", "pwd"));
System.out.println(auth.authenticate("[email protected]", "pwd"));
r.invitePatient(9, "[email protected]", "Raffaele", "Monti");
//System.out.println(auth.authenticate("[email protected]", "pwd"));
//System.out.println(auth.authenticate("[email protected]", "pwd"));
//r.invitePatient(9, "[email protected]", "Raffaele", "Monti");

ScheduleManager manager = new ScheduleManager();
String date = "2024-02-10";
String time = "10:00-11:00";
if(manager.checkData(9, date, time)) {
System.out.println("inif");
manager.createNewSchedule(9, date, time); //funziona
}
}
}
1 change: 0 additions & 1 deletion src/main/java/controller/AddRemovePatientCondition.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import model.service.condition.ConditionManager;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/controller/ChangeUserInfo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller;

import model.service.user.UserRegistry;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
Expand All @@ -22,7 +23,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
} else {
risultato = "Dati personali non aggiornati, email gia' utilizzata";
}
response.sendRedirect("/TalkAID_war_exploded/JSP/Cambio_dati.jsp?risultato=" + risultato);
response.sendRedirect("JSP/userInfoChange.jsp?risultato=" + risultato);
}

private boolean updatePersonalInfo(HttpServletRequest request, int userId, UserRegistry userRegistry) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/controller/ExerciseController.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class ExerciseController extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
ExerciseManager em = new ExerciseManager();
String id = request.getParameter("exerciseID");
String insertiondate = request.getParameter("insertionDate");
request.getSession().setAttribute("insertionDate", insertiondate);
request.getSession().setAttribute("exerciseId", id);

ExerciseGlossary ex = em.getExercise(Integer.parseInt(id));
request.getSession().setAttribute("exercise", ex);
response.sendRedirect(request.getContextPath() + "/JSP/exercise.jsp");
Expand Down
76 changes: 0 additions & 76 deletions src/main/java/controller/ExerciseLogger.java
Original file line number Diff line number Diff line change
@@ -1,76 +0,0 @@
package controller;

import model.service.exercise.ExerciseManager;
import org.apache.commons.io.IOUtils;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import javax.sql.rowset.serial.SerialBlob;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.sql.Blob;
import java.sql.Date;
import java.sql.SQLException;

@WebServlet("/exerciseLogger")
@MultipartConfig
public class ExerciseLogger extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
String contentType = request.getContentType();

if ("application/json".equals(contentType)) {
handleNoAudioExercise(request);
} else {
handleAudioExercise(request);
}
RequestDispatcher d = request.getRequestDispatcher("/exerciseEvaluator");
d.forward(request, response);
}

private void handleNoAudioExercise(HttpServletRequest request) throws IOException {
BufferedReader reader = request.getReader();
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
}
String execution = stringBuilder.toString();

try {
byte[] bytes = execution.getBytes(StandardCharsets.UTF_8);
Blob executionBlob = new SerialBlob(bytes);
saveInDB(request, executionBlob);

} catch (SQLException e) {
e.printStackTrace();
}
}

private void handleAudioExercise(HttpServletRequest request) throws ServletException, IOException {

try {
Part audioPart = request.getPart("audioFile");
try (InputStream audioInputStream = audioPart.getInputStream()) {
Blob audioBlob = new SerialBlob(IOUtils.toByteArray(audioInputStream));
saveInDB(request, audioBlob);
}
} catch (SQLException e) {
throw new RuntimeException(e);
}
}

private boolean saveInDB(HttpServletRequest request, Blob execution){
ExerciseManager em = new ExerciseManager();
HttpSession session = request.getSession();
int userId = (int) session.getAttribute("id");
int exerciseId = (int) session.getAttribute("exerciseID");
Date insertDate = (Date) session.getAttribute("insertDate");

return em.saveExecution(userId, exerciseId, insertDate, execution);
}
}
Loading

0 comments on commit ba24b2e

Please sign in to comment.