Compare commits
No commits in common. "307c7e700bf3c888789132743ca0c3a5ec11cad3" and "653f9236937769c93e6ba96ca0330ced98ab5651" have entirely different histories.
307c7e700b
...
653f923693
@ -27,7 +27,6 @@ dependencies {
|
|||||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.+'
|
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.+'
|
||||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+'
|
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.+'
|
||||||
implementation 'org.postgresql:postgresql'
|
implementation 'org.postgresql:postgresql'
|
||||||
implementation group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13.3'
|
|
||||||
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testImplementation 'com.h2database:h2'
|
testImplementation 'com.h2database:h2'
|
||||||
|
@ -81,7 +81,7 @@ public class AdminApi {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/admin/appoitements/report/{appointmentId}")
|
@PostMapping("/admin/appoitements/report/{appointmentId}")
|
||||||
public void createAppointmentReport(
|
public void createAppointmentReport(
|
||||||
@PathVariable long appointmentId,
|
@PathVariable String appointmentId,
|
||||||
@RequestBody Report report,
|
@RequestBody Report report,
|
||||||
@AuthenticationPrincipal Jwt principal) {
|
@AuthenticationPrincipal Jwt principal) {
|
||||||
adminApiService.createAppointmentReport(
|
adminApiService.createAppointmentReport(
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package enseirb.myinpulse.controller;
|
package enseirb.myinpulse.controller;
|
||||||
|
|
||||||
import com.itextpdf.text.DocumentException;
|
|
||||||
import enseirb.myinpulse.model.*;
|
import enseirb.myinpulse.model.*;
|
||||||
import enseirb.myinpulse.service.SharedApiService;
|
import enseirb.myinpulse.service.SharedApiService;
|
||||||
|
|
||||||
@ -10,9 +9,6 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|||||||
import org.springframework.security.oauth2.jwt.Jwt;
|
import org.springframework.security.oauth2.jwt.Jwt;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RestController
|
@RestController
|
||||||
public class SharedApi {
|
public class SharedApi {
|
||||||
@ -82,11 +78,7 @@ public class SharedApi {
|
|||||||
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
|
@GetMapping("/shared/projects/appointments/report/{appointmentId}")
|
||||||
public void getPDFReport(
|
public void getPDFReport(
|
||||||
@PathVariable int appointmentId, @AuthenticationPrincipal Jwt principal) {
|
@PathVariable int appointmentId, @AuthenticationPrincipal Jwt principal) {
|
||||||
try {
|
sharedApiService.getPDFReport(appointmentId, principal.getClaimAsString("email"));
|
||||||
sharedApiService.getPDFReport(appointmentId, principal.getClaimAsString("email"));
|
|
||||||
} catch (FileNotFoundException | DocumentException e) {
|
|
||||||
System.out.println(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,8 +115,4 @@ public class Appointment {
|
|||||||
public Report getAppointmentReport() {
|
public Report getAppointmentReport() {
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAppointmentReport(Report report) {
|
|
||||||
this.report = report;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,4 @@ public class Report {
|
|||||||
public void setReportContent(String reportContent) {
|
public void setReportContent(String reportContent) {
|
||||||
this.reportContent = reportContent;
|
this.reportContent = reportContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Appointment getAppointmentReport() {
|
|
||||||
return appointmentReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppointmentReport(Appointment appointmentReport) {
|
|
||||||
this.appointmentReport = appointmentReport;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,6 @@ import enseirb.myinpulse.model.*;
|
|||||||
import enseirb.myinpulse.service.database.AdministratorService;
|
import enseirb.myinpulse.service.database.AdministratorService;
|
||||||
import enseirb.myinpulse.service.database.ProjectService;
|
import enseirb.myinpulse.service.database.ProjectService;
|
||||||
import enseirb.myinpulse.service.database.UserService;
|
import enseirb.myinpulse.service.database.UserService;
|
||||||
import enseirb.myinpulse.service.database.AppointmentService;
|
|
||||||
import enseirb.myinpulse.service.database.ReportService;
|
|
||||||
import enseirb.myinpulse.service.UtilsService;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -22,41 +16,29 @@ import org.springframework.web.server.ResponseStatusException;
|
|||||||
@Service
|
@Service
|
||||||
public class AdminApiService {
|
public class AdminApiService {
|
||||||
|
|
||||||
protected static final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final AdministratorService administratorService;
|
private final AdministratorService administratorService;
|
||||||
private final UtilsService utilsService;
|
|
||||||
private final AppointmentService appointmentService;
|
|
||||||
private final ReportService reportService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AdminApiService(
|
AdminApiService(
|
||||||
ProjectService projectService,
|
ProjectService projectService,
|
||||||
UserService userService,
|
UserService userService,
|
||||||
AdministratorService administratorService,
|
AdministratorService administratorService) {
|
||||||
UtilsService utilsService,
|
|
||||||
AppointmentService appointmentService,
|
|
||||||
ReportService reportService) {
|
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.administratorService = administratorService;
|
this.administratorService = administratorService;
|
||||||
this.utilsService = utilsService;
|
|
||||||
this.appointmentService = appointmentService;
|
|
||||||
this.reportService = reportService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: check if tests are sufficients - peer verification required
|
// TODO: check if tests are sufficients - peer verification required
|
||||||
public Iterable<Project> getProjectsOfAdmin(String mail) {
|
public Iterable<Project> getProjectsOfAdmin(String email) {
|
||||||
return projectService.getProjectsByAdminId(
|
return projectService.getProjectsByAdminId(
|
||||||
administratorService.getAdministratorById(
|
administratorService.getAdministratorById(
|
||||||
this.userService.getUserByEmail(mail).getIdUser()));
|
this.userService.getUserByEmail(email).getIdUser()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public Iterable<Appointment> getUpcomingAppointments(String mail) {
|
public Iterable<Appointment> getUpcomingAppointments(String email) {
|
||||||
logger.info("User {} check their upcoming appointments", mail);
|
|
||||||
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,26 +73,9 @@ public class AdminApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAppointmentReport(long appointmentId, Report report, String mail) {
|
// TODO
|
||||||
long projectId =
|
public void createAppointmentReport(String appointmentId, Report report, String email) {
|
||||||
this.appointmentService
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||||
.getAppointmentById(appointmentId)
|
|
||||||
.getAppointmentListSectionCell()
|
|
||||||
.getFirst()
|
|
||||||
.getProjectSectionCell()
|
|
||||||
.getIdProject();
|
|
||||||
if (!utilsService.isAllowedToCheckProject(mail, projectId)) {
|
|
||||||
logger.warn(
|
|
||||||
"User {} tried to add an report for appointment {} but is not allowed to.",
|
|
||||||
mail,
|
|
||||||
projectId);
|
|
||||||
throw new ResponseStatusException(
|
|
||||||
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
|
|
||||||
}
|
|
||||||
logger.info("User {} added a report for appointment {}", mail, projectId);
|
|
||||||
Report addedReport = this.reportService.addNewReport(report);
|
|
||||||
addedReport.setAppointmentReport(this.appointmentService.getAppointmentById(appointmentId));
|
|
||||||
this.appointmentService.getAppointmentById(appointmentId).setAppointmentReport(addedReport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test
|
// TODO: test
|
||||||
|
@ -10,11 +10,6 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.server.ResponseStatusException;
|
import org.springframework.web.server.ResponseStatusException;
|
||||||
|
|
||||||
import com.itextpdf.text.*;
|
|
||||||
import com.itextpdf.text.pdf.PdfWriter;
|
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -123,9 +118,8 @@ public class SharedApiService {
|
|||||||
return appointments;
|
return appointments;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// TODO
|
||||||
public void getPDFReport(long appointmentId, String mail)
|
public void getPDFReport(long appointmentId, String mail) {
|
||||||
throws FileNotFoundException, DocumentException {
|
|
||||||
long projectId =
|
long projectId =
|
||||||
this.appointmentService
|
this.appointmentService
|
||||||
.getAppointmentById(appointmentId)
|
.getAppointmentById(appointmentId)
|
||||||
@ -145,82 +139,15 @@ public class SharedApiService {
|
|||||||
throw new ResponseStatusException(
|
throw new ResponseStatusException(
|
||||||
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
|
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
|
||||||
}
|
}
|
||||||
logger.info(
|
/* return this.appointmentService
|
||||||
"User {} generated the PDF report related to appointment {}", mail, appointmentId);
|
.getAppointmentById(appointmentId)
|
||||||
|
.getAppointmentReport().getReportContent(); */
|
||||||
String reportContent =
|
// generate pdf from this string, and format it to be decent looking
|
||||||
this.appointmentService
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||||
.getAppointmentById(appointmentId)
|
|
||||||
.getAppointmentReport()
|
|
||||||
.getReportContent();
|
|
||||||
|
|
||||||
// PDF generation
|
|
||||||
Document document = new Document();
|
|
||||||
PdfWriter.getInstance(document, new FileOutputStream("Report" + appointmentId + ".pdf"));
|
|
||||||
document.open();
|
|
||||||
|
|
||||||
Paragraph title =
|
|
||||||
new Paragraph(
|
|
||||||
new Phrase(
|
|
||||||
"Compte Rendu - Réunion du "
|
|
||||||
+ this.appointmentService
|
|
||||||
.getAppointmentById(appointmentId)
|
|
||||||
.getAppointmentDate()
|
|
||||||
.toString(),
|
|
||||||
FontFactory.getFont(
|
|
||||||
FontFactory.HELVETICA,
|
|
||||||
20,
|
|
||||||
Font.BOLDITALIC,
|
|
||||||
BaseColor.BLACK)));
|
|
||||||
title.setAlignment(Element.ALIGN_CENTER);
|
|
||||||
document.add(title);
|
|
||||||
|
|
||||||
Font subsection =
|
|
||||||
FontFactory.getFont(FontFactory.HELVETICA, 14, Font.UNDERLINE, BaseColor.DARK_GRAY);
|
|
||||||
Font body = FontFactory.getFont(FontFactory.COURIER, 12, BaseColor.BLACK);
|
|
||||||
|
|
||||||
String[] split = reportContent.split(" ");
|
|
||||||
|
|
||||||
String tmp = "";
|
|
||||||
int counter = 1;
|
|
||||||
for (String s : split) {
|
|
||||||
if (s.equals("//")) {
|
|
||||||
Chunk chunk = new Chunk(tmp, body);
|
|
||||||
document.add(chunk);
|
|
||||||
document.add(new Paragraph("\n"));
|
|
||||||
tmp = "";
|
|
||||||
Paragraph paragraph = new Paragraph("Point n°" + counter + " : ", subsection);
|
|
||||||
document.add(paragraph);
|
|
||||||
document.add(new Paragraph("\n"));
|
|
||||||
counter++;
|
|
||||||
} else {
|
|
||||||
tmp = tmp.concat(s + " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Chunk chunk = new Chunk(tmp, body);
|
|
||||||
document.add(chunk);
|
|
||||||
document.add(new Paragraph("\n"));
|
|
||||||
|
|
||||||
document.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public void createAppointmentRequest(Appointment appointment, String mail) {
|
public void createAppointmentRequest(Appointment appointment, String mail) {
|
||||||
long projectId =
|
throw new ResponseStatusException(HttpStatus.NOT_IMPLEMENTED, "Not implemented yet");
|
||||||
appointment
|
|
||||||
.getAppointmentListSectionCell()
|
|
||||||
.getFirst()
|
|
||||||
.getProjectSectionCell()
|
|
||||||
.getIdProject();
|
|
||||||
if (!utilsService.isAllowedToCheckProject(mail, projectId)) {
|
|
||||||
logger.warn(
|
|
||||||
"User {} tried to create for the project {} but is not allowed to.",
|
|
||||||
mail,
|
|
||||||
projectId);
|
|
||||||
throw new ResponseStatusException(
|
|
||||||
HttpStatus.UNAUTHORIZED, "You're not allowed to check this project");
|
|
||||||
}
|
|
||||||
logger.info("User {} tried to create an appointment for project {}", mail, projectId);
|
|
||||||
this.appointmentService.addNewAppointment(appointment);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
Format des comptes rendus de réunion :
|
|
||||||
Texte organisé par bullet point, chaque bullet point est séparé par "//" pour pouvoir être correctement généré.
|
|
||||||
|
|
||||||
Exemple :
|
|
||||||
Le texte "// blablabla // oui bonjour"
|
|
||||||
donne le résultat
|
|
||||||
|
|
||||||
Point n°1 :
|
|
||||||
blablabla
|
|
||||||
|
|
||||||
Point n°2 :
|
|
||||||
oui bonjour
|
|
Loading…
x
Reference in New Issue
Block a user